Re: [netcdfgroup] Appending new data to a variable

Hi,

C. S. Natarajan wrote:
>        I am trying to concatenate reasonably large netcdf files to make a
> large file. I.e I am trying to combine 64 256 MB files to create a 16GB
> file. I'm new to the file format and 'am not entirely sure whats the best
> way to go about this! Each file contains a 3-D matrix of of size
> 2048*2048*32 of type short.

Here are several possibilities:

 - Get and install the NCO (netCDF Operators) package from
   http://nco.sourceforge.net/ and use the ncecat or ncrcat utility to
   combine the input files into one output file from the command line.

 - Get and install the NCL (NCAR Command Language) package from
   http://www.ncl.ucar.edu/ and use a small NCL script to accomplish
   the concatenation.  Examples of how to do this with NCO and NCL are
   discussed in the Follow-Ups to this mailing list posting:
   
http://www.unidata.ucar.edu/mailing_lists/archives/netcdfgroup/2009/msg00194.html

 - Get and install the CDO (Climate Data Operators) package from
   http://www.mpimet.mpg.de/fileadmin/software/cdo/ and use its merge
   operators, if they're suitable for what you need.

 - Write a program using the nc_put_vara_short() interface to append
   each variable to the desired variable, with start and count arguments.

> Naively I tried just creating a new file with the size of the new dataset
> 2048*2048*2048 and tried adding data to it. However everytime I add data
> using nc_put_var_short, only the latest addition remains! for example
> ......
>    if ((retval = nc_put_var_int(ncid, varid, &data_out[0][0][0])))
>       ERR(retval);
> 
>    if ((retval = nc_put_var_int(ncid, varid, &data_out2[0][0][0])))
>       ERR(retval);
> 
>    if ((retval = nc_close(ncid)))
>       ERR(retval);
> ....
> only retains data from out2!   Is there anyway to keep appending 3-D
> matrices at the end of the current variable?

Yes, by incrementing one of the indices in the start array before each
write, so that each slab gets written to the desired section of the
output variable.

--Russ



  • 2009 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdfgroup archives: