NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.

To learn about what's going on, see About the Archive Site.

Re: [netcdfgroup] API for removing data variables?

ncdf4.pdf (formatted by me)
>>> to WRITE data to a new netCDF file, the procedure is to

>>> 1 define the dimensions your data array has

>>> 2 define the [data] variable

>>> 3 create the file.

Tom Roche Sun, 05 Feb 2012 20:41:37 -0500
>> plus copy the data to the variable, plus copy additional
>> attributes. Which a priori feels more difficult than

>> 1 copy the file using system tools (e.g., `cp`)
>> 2 remove undesired data variables from the copy

Charlie Zender Sun, 05 Feb 2012 12:23:03 -0800
> ncks -O -v var_name in.nc out.nc

> puts only var_name (and associated coordinates) in the output file

*and* attributes!

http://nco.sourceforge.net/nco.html#ncks-netCDF-Kitchen-Sink
>>>> all global attributes and any attribute associated with an
>>>> extracted variable are copied to the [...] output

That should simplify my R script: I can just

system('ncks -O -v var_name foo bar')
bar.file <- nc_open(...)
datavar <- ncvar_get(...)
fiddle(datavar)

thanks again, Tom Roche <Tom_Roche@xxxxxxxxx>



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