next up previous contents
Next: and Finally ... Up: NetCDF Previous: NetCDF   Contents

Reading NetCDF

Here is a general sequence of events for opening a netCDF file in idl.
;Open the netcdf file,  ncid is an idl string
ncid = NCDF_OPEN('filename')

;get a variable out of the data
NCDF_VARGET, ncid,  varid, var_name

;Close the netcdf file
NCDF_CLOSE, ncid

However, by far the simplest method, that will suffice for most peoples needs is the use of 'cdf2idl.pro' routine. This can be downloaded from

http://www-c4.ucsd.edu/~cids/software/visual.html
Its use is described at,
http://www.nodc.noaa.gov/woce_V2/disk02/netcdf/netcdf_primer.htm
The cdf2idl.pro routine is one of a suite of similar routines available for Fortran, c and matlab which may also be useful.

Basically it reads a netCDF file and then generates each of the above commands in sequence for each variable in the netcdf file. It also gets global attributes.

For instance, if you have a netcdf file 'test.nc', you have a command line cdf2idl,file,outfile='/path/to/outfile',/verbose

You then type @/path/to/outfile (i.e. cdf2idl generates a batch script)



John Marsham 2005-04-22