wiki:Documentation/UserGuide/StudyNetCDF

Version 7 (modified by jryder, 8 years ago) (diff)

--

How to study the data from netCDF files quickly and easily

The quickest way of all to look at NetCDF files is to use ncview, i.e.:

ncview myJob_20060101_20061231_1M_sechiba_history.nc

Unfortunately the ncview application can be a little unstable (at least on my system anyway).

ncdump is more flexible, and is a great way to look at header information:

ncdump -h myJob_20060101_20061231_1M_sechiba_history.nc

or, for example to extract one column of data in a tabulated text format (here for 'fluxlat', the latent heat flux):

ncdump -v fluxlat -f fortran -n fluxlat myJob_20060101_20061231_1M_sechiba_history.nc > myJob_fluxlat.cdl

But there's a really useful script that can be used in IDL to import all of the data series at once, without having to spend time writing scripts to define input arrays first. First of all, download cdf2idl.pro, compile it within IDL and then input the following:

cdf2idl, '/home/rest_of_the_path/myJob_20060101_20061231_1M_sechiba_history.nc'

@myJob_20060101_20061231_1M_sechiba_history.idl

And then you have all of your variables automatically imported, each into arrays of an appropriate size, and they can be quickly plotted, e.g:

plot, tstep, tair(0,0,0,*)

(remember that IDL by default defines arrays as starting from 0, instead of from 1)

ncks: If you would like to remove a certain time series from a netcdf file (for instance, in this example, all data from 'temp_atmos_pres' in the file jamescdf.nc for which the height dimension is 20) with the output written to jamestest.nc

ncks -H -d height,20 -d temp_atmos_pres,: jamescdf.nc jamestest.nc