[ncl-talk] write variable to netCDF in slices

Maria Gehne - NOAA Affiliate maria.gehne at noaa.gov
Mon Mar 23 14:04:09 MDT 2015


Hi Frank,

one way that I have used for large data files is to write out the time
slices in separate netcdf files including a time dimension and then
concatenating those files afterwards using ncrcat. I don't know how many
days you can read in, but one way to go could be by reading each month and
saving monthly files (div_1.nc to div_12.nc). You can then easily
concatenate in the time dimension by calling

ncrcat div_?.nc div_allyear.nc

from the command line.

Hope this helps,
Maria

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/061c3525/attachment.html 


More information about the ncl-talk mailing list