[ncl-talk] write variable to netCDF in slices

Dennis Shea shea at ucar.edu
Mon Mar 23 14:11:33 MDT 2015


For concatenation of netCDF files, the 'record dimension (here, time) must
be unlimited.
You have a few things out-of-place. Also, you can do better than time steps
of 999.

I used 'ncrcat' ... likely the CDO have some equivalent operator.

See attached ... not tested

Good Luck

On Mon, Mar 23, 2015 at 12:40 PM, Frank Rüthrich <frank.ruethrich at posteo.de>
wrote:

> 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
> _______________________________________________
> ncl-talk mailing list
> 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/20150323/281487b9/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: FrankRuthrich.ncl
Type: application/octet-stream
Size: 1954 bytes
Desc: not available
Url : http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150323/281487b9/attachment.obj 


More information about the ncl-talk mailing list