<div dir="ltr"><div class="gmail_default" style="font-size:small">Dear Dipti,</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">I'm sorry, but I missed that you had a second question imbedded in this email.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">Were you able to get the metadata added to "wc"?</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">The reason it doesn't have metadata like "var" is because when you do a calculation and assign it to a variable that doesn't exist:</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default">wc=(wv/(-9.8*denv))<br></div><div class="gmail_default"><br></div><div class="gmail_default">then "wc" will not inherit any metadata from wv or denv except the _FillValue attribute.</div><div class="gmail_default"><br></div><div class="gmail_default">In order to get metadata, you either need to do a direct variable copy first, so that "wc" gets metadata before doing the calculation:</div><div class="gmail_default"><br></div><div class="gmail_default"><div class="gmail_default">wc=wv ; Trick to copy metadata from wv to wc (values also get copied)<br></div><div><div class="gmail_default">wc=(wc/(-9.8*denv))<br></div></div><div class="gmail_default"><br></div><div class="gmail_default">or you can use copy_VarMeta:</div><div class="gmail_default"><br></div><div class="gmail_default"><div class="gmail_default">wc=(wv/(-9.8*denv))<br></div><div>copy_VarMeta(wv,wc) ; copy wv's metadata to wc</div><div><br></div><div>In either case, you should update the long_name/standard_name and units attributes of wc to correctly reflect what they are.</div><div><br></div><div>--Mary</div><div><br></div></div><div><br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jun 29, 2017 at 5:12 PM, Dipti Sharma <span dir="ltr"><<a href="mailto:sdipti596@gmail.com" target="_blank">sdipti596@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div>Hi Mary,<br><br></div>Thank you. It worked now. I also made file name little shorter then that worked.<br><br><span style="font-size:12.8px">ncdf=addfile("/Users/</span><span style="font-size:12.8px">Downloads<wbr>/New\ folder/</span>MERRA_19950830.nc","c")<br></div><div>but one thing, when I do printVarSummay(var) I get the var info with 2dimensions <br><br>Number of Dimensions: 2<br>Dimensions and sizes: [time | 8] x [lev | 72]<br>Coordinates: <br> time: [0..1260]<br> lev: [ 1.. 72]<br>Number Of Attributes: 13<br> lon : -112.5<br> lat : 42<br> valid_range : ( -1e+15, 1e+15 )<br> vmin : -1e+15<br> vmax : 1e+15<br> standard_name : air_density<br> add_offset : 0<br> scale_factor : 1<br> fmissing_value : 1e+15<br> missing_value : 1e+15<br> _FillValue : 1e+15<br> units : kg m-3<br><br></div><div>But for wc, when I do printVarSummay(wc)<br>Variable: wc<br>Type: float<br>Total Size: 2304 bytes<br> 576 values<br>Number of Dimensions: 2<br>Dimensions and sizes: [8] x [72]; There is different format so how to get this like ' [time | 8] x [lev | 72]'?<br><br>Coordinates: <br>Number Of Attributes: 1<br> _FillValue : 1e+15<br>(0) <br>(0) min=-0.0658635 max=0.0909946<br><br></div><div>ALSO, my necdf file is not looking with correct attributes,<br><br>
<pre>netcdf file:/C:/Users/Downloads/New%<wbr>20folder/MERRA2_19950830.nc {
dimensions:
ncl0 = 8; should be time=8; <br> ncl1 = 72;lev=72; etc.
ncl2 = 8;
ncl3 = 72;
variables:
int time(ncl0=8);
double lev(ncl1=72);
float data2(ncl2=8, ncl3=72);
}
</pre>
<br></div>Thank you so much again.<span class="HOEnZb"><font color="#888888"><br><br></font></span></div><span class="HOEnZb"><font color="#888888">Dipti</font></span><div><div class="h5"><br><div><div><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jun 29, 2017 at 11:49 AM, Mary Haley <span dir="ltr"><<a href="mailto:haley@ucar.edu" target="_blank">haley@ucar.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div style="font-size:small">Hi Dipti,</div><div style="font-size:small"><br></div><div style="font-size:small">I'm not sure that addfile can recognize Windows type of directory paths with "C:\....".</div><div style="font-size:small"><br></div><div style="font-size:small">Try using UNIX-style paths:</div><div style="font-size:small"><br></div><div style="font-size:small"><span style="font-size:12.8px">ncdf=addfile("/Users/</span><span style="font-size:12.8px">Downloads<wbr>/New\ folder/</span><a href="http://merra2_200.inst3_3d_asm_nv.19950830.nc/" style="font-size:12.8px" target="_blank">MERRA2_200.inst3_3d_asm<wbr>_Nv.19950830.nc</a><span style="font-size:12.8px">","c")</span><br style="font-size:12.8px"></div><div style="font-size:small"><br></div><div style="font-size:small">Note that I used forward slashes ('/') instead of backward slashes ('\'). However, since you have a space in one of your directory names----"New folder"---I put a backward slash in front of the space, just in case.</div><div style="font-size:small"><br></div><div style="font-size:small">--Mary</div><div style="font-size:small"><br></div></div><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="m_5583139399802477319h5">On Wed, Jun 28, 2017 at 5:55 PM, Dipti Sharma <span dir="ltr"><<a href="mailto:sdipti596@gmail.com" target="_blank">sdipti596@gmail.com</a>></span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="m_5583139399802477319h5"><div dir="ltr"><div>Dear NCL,<br><br></div><div>I am trying to write netCDF file for selected variable (wc, the vertical velocity here in this example) from MERRA-2 wind data. However, I always get an error message saying that<br> " fatal:Could not create (C:\Users\Downloads\New folder\<a href="http://MERRA2_200.inst3_3d_asm_Nv.19950830.nc" target="_blank">MERRA2_200.inst3_3d_asm<wbr>_Nv.19950830.nc</a>)<br><br></div><div>Could someone please help me how to write the output file in netCDF. I want to have wc (time,lev) 2D data from 4D (time, lev,lat,lon). I just want the data at 1 location (1 lat and 1 lon).<br><br></div><div>Thank you very much in advance for your help.<br><br></div><div>Regards,<br><br></div><div>Dipti<br></div><div><br></div><div>Attached is the script that I used to read the data.<br></div><div><br></div><div><br>load "$NCARG_ROOT/lib/ncarg/nclscri<wbr>pts/csm/gsn_code.ncl"<br>load "$NCARG_ROOT/lib/ncarg/nclscri<wbr>pts/csm/gsn_csm.ncl"<br><br>; setfileoption("nc", "FileStructure", "Advanced")<br><br>fn = "C:\Users\Downloads\New folder\MERRA2_200.inst3_3d_asm<wbr>_Nv.19950830.nc4"<br>fn1 = "C:\Users\Downloads\New folder\MERRA2_200.inst3_3d_gas<wbr>_Nv.19950830.nc4"<br><br> fi = addfile(fn, "r")<br>fi1= addfile(fn1, "r")<br><br>; setfileoption("nc", "Format", "NetCDF4Classic")<br><br> printVarSummary(fi)<br>;print(fi)<br><br> time = fi->time<br> lev = fi->lev<br> lat = fi->lat<br> lon = fi->lon<br> u = fi->U;(:,:,269,101)<br> v = fi->V;(:,:,269,101)<br> w=fi->OMEGA;(:,:,269,101)<br> p=fi->PL;(:,:,269,101)<br>den=fi1->AIRDENS;(:,:,269,101)<br>uh=u(:,:,269,101)<br>uv=v(:,:,269,101)<br>wv=w(:,:,269,101)<br>pv=PL(:,:,269,101)<br>denv=den(:,:,269,101)<br>;printVarSummary(u)<br>printVarSummary(denv)<br>printVarSummary(wv)<br>printMinMax(wv,True) <br></div>;calculate vertical velocity<br><div>wc=(wv/(-9.8*denv))<br>printVarSummary(wc)<br>printMinMax(wc,True)<br>wc!0="time"<br>wc!1="lev"<br>;wc!2="lat"<br>;wc!3="lon"<br>datad = wc;(time|:,lev|:)<br>printVarSummary(datad)<br><br>;Writeout new netCDF file<br><br>wc&time = time<br>wc&lev = lev<br>ncdf=addfile("C:\Users\Downloa<wbr>ds\New folder\<a href="http://MERRA2_200.inst3_3d_asm_Nv.19950830.nc" target="_blank">MERRA2_200.inst3_3d_asm<wbr>_Nv.19950830.nc</a>","c")<br>ncdf->time= (/time/)<br>ncdf->lev= (/lev/)<br>ncdf->data=(/datad/)<br>return<br></div><div>end<br></div><div><div class="gmail_extra"><br><br></div></div></div>
<br></div></div>______________________________<wbr>_________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/mailma<wbr>n/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>
</blockquote></div><br></div></div></div></div></div>
</blockquote></div><br></div>