[ncl-talk] writing netCDF file
Dipti Sharma
sdipti596 at gmail.com
Wed Jun 28 17:55:44 MDT 2017
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170628/fd2eebca/attachment.html
More information about the ncl-talk
mailing list