[ncl-talk] write variable to netCDF in slices

Frank Rüthrich frank.ruethrich at posteo.de
Mon Mar 23 12:40:54 MDT 2015


Hi there!
I wonder if anybody of you had success with a similar problem:

I want to calculate hourly horizontal divergences on 20 pressure levels 
for one year.
Dimensions are:[ 8784 <time | unlimited>, 20 <pressure>, 180 
<south_north>, 270 <west_east> ]
Unfortunately, reading the entire u and v netCDF-files gives me a memory 
error, so i will have to perform the calculation in slices.
I neither can allocate an array to store the divergences and thus:
I will have to append the divergences of the sliced u and v variables 
directly to the netCDF file.

Reading u and v in timeslices and calculating divergences works fine, 
but I did not succeed in writing them to a netcdf file so far.

I guess need somethin like the "ncdf->div(i:i+999,:,:,:)=DV" in the 
below example:

fu      = addfile (fileu, "r")
fv      = addfile (filev, "r")
ncdf     = addfile(fnameout ,"w")  ; open output netCDF file (already 
existing)
filedimdef(ncdf,"time",-1,True)
TIME   = fu->time
m=dimsizes(TIME)
do while (i.le.m)
       VARu    =  short2flt(fu->u(i:i+999,:,:,:))
       VARv    =  short2flt(fv->v(i:i+999,:,:,:))
       DV    = uv2dvF_Wrap(VARu,VARv)
       ncdf->div(i:i+999,:,:,:)=DV
       i=i+1000
end do

I would very much appreciate every idea!

Cheers,
Frank


More information about the ncl-talk mailing list