[ncl-talk] writing netCDF file

Mary Haley haley at ucar.edu
Thu Jun 29 09:49:45 MDT 2017


Hi Dipti,

I'm not sure that addfile can recognize Windows type of directory paths
with "C:\....".

Try using UNIX-style paths:

ncdf=addfile("/Users/Downloads/New\ folder/MERRA2_200.inst3_3d_
asm_Nv.19950830.nc <http://merra2_200.inst3_3d_asm_nv.19950830.nc/>","c")

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.

--Mary


On Wed, Jun 28, 2017 at 5:55 PM, Dipti Sharma <sdipti596 at gmail.com> wrote:

> Dear NCL,
>
> 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
>  " fatal:Could not create (C:\Users\Downloads\New folder\
> MERRA2_200.inst3_3d_asm_Nv.19950830.nc)
>
> 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).
>
> Thank you very much in advance for your help.
>
> Regards,
>
> Dipti
>
> Attached is the script that I used to read the data.
>
>
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
>
> ; setfileoption("nc", "FileStructure", "Advanced")
>
> fn = "C:\Users\Downloads\New folder\MERRA2_200.inst3_3d_
> asm_Nv.19950830.nc4"
> fn1 = "C:\Users\Downloads\New folder\MERRA2_200.inst3_3d_
> gas_Nv.19950830.nc4"
>
>  fi = addfile(fn, "r")
> fi1= addfile(fn1, "r")
>
> ; setfileoption("nc", "Format",  "NetCDF4Classic")
>
>  printVarSummary(fi)
> ;print(fi)
>
>  time = fi->time
>  lev = fi->lev
>  lat = fi->lat
>  lon = fi->lon
>  u = fi->U;(:,:,269,101)
>  v = fi->V;(:,:,269,101)
>  w=fi->OMEGA;(:,:,269,101)
>  p=fi->PL;(:,:,269,101)
> den=fi1->AIRDENS;(:,:,269,101)
> uh=u(:,:,269,101)
> uv=v(:,:,269,101)
> wv=w(:,:,269,101)
> pv=PL(:,:,269,101)
> denv=den(:,:,269,101)
> ;printVarSummary(u)
> printVarSummary(denv)
> printVarSummary(wv)
> printMinMax(wv,True)
> ;calculate vertical velocity
> wc=(wv/(-9.8*denv))
> printVarSummary(wc)
> printMinMax(wc,True)
> wc!0="time"
> wc!1="lev"
> ;wc!2="lat"
> ;wc!3="lon"
> datad = wc;(time|:,lev|:)
> printVarSummary(datad)
>
> ;Writeout new netCDF file
>
> wc&time = time
> wc&lev = lev
> ncdf=addfile("C:\Users\Downloads\New folder\MERRA2_200.inst3_3d_
> asm_Nv.19950830.nc","c")
> ncdf->time= (/time/)
> ncdf->lev=  (/lev/)
> ncdf->data=(/datad/)
> return
> end
>
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170629/dee8b68c/attachment.html 


More information about the ncl-talk mailing list