7.0 Other methods and examining netCDF files

Obtaining ascii output of a netcdf file is possible.  There are several methods. First is to use ncdump or ncBrowse.  Both ncdump and ncBrowse produce the ascii output in the same format.  However this format is not particularly friendly if you want to import the data to a spreadsheet such as Excel.  The second method is to use Ferret, MATLAB or IDL.  An example is given from Ferret below.  The third method is to use publicly available routines such as cdf2asc or nc2text commands. I have not tested either of these routines.  

7.1 ncdump

This utility is a very useful program for those who do not have Matlab, IDL, Ferret, or ncBrowse and want to check the attributes and obtain the data from a netCDF file. On unix machines the man pages describe this command in detail (and its partner ncgen) or in the netCDF User's Guide for Fortran, (Chapter 10). To obtain the attributes of the current meter data one would

>ncdump -h rcm00683.cdf

Appendix 3 shows the output from this command. To obtain the speed data in this file

>ncdump -v speed rcm00683.cdf

or to obtain the speed and the direction data

>ncdump -v speed,direction rcm00683.cdf

The last command can lead to large files ascii files, but have a relatively simple structure and can be read by programs. However, the value of ncdump is that it allows one to check attributes and structure of netcdf files quickly and easily. A more convenient way to examine netCDF files is too be able to visualize the data using a graphical interface such as ncBrowse or Ferret.

7.2 Using Ferret to create ascii files

Ferret has the capability to read netcdf file directly, and it also has the capability to export variables in ascii format from a netcdf file. For example the ferret commands

USE sst05d19900108.nc
SHADE/X=0.25E:363.25E/Y=89.75S:89.75N SEA_SURFACE_TEMPERATURE[d=sst05d19900108.nc]
LIST/X=0.25E:363.25E/Y=0S/file=sea_surface_temperature SEA_SURFACE_TEMPERATURE[d=sst05d19900108.nc]

will use the sea surface temperature netcdf file  (USE command), plot its contours (SHADE), and list the sea surface temperature field along the equator around the world to the file called  sea_surface_temperature (LIST).

The output of the LIST command in this case is a more friendly format than the output from ncdump, and can be imported into spreadsheet programs like excel, staroffice or gnumeric.

             sea surface temperature (1/100 degree C)
LATITUDE: 0 (interpolated)
DATA SET: ./sst05d19900108.nc
0.25E / 1: 32767.
0.75E / 2: 32767.
1.25E / 3: 17644.
1.75E / 4: 32767.
2.25E / 5: 32767.
2.75E / 6: 17704.
3.25E / 7: 32767.
3.75E / 8: 32767.
4.25E / 9: 32767.
4.75E / 10: 32767.


0.25W / 720: 17711.
0.25E / 721: 32767.
0.75E / 722: 32767.
1.25E / 723: 17644.
1.75E / 724: 32767.
2.25E / 725: 32767.
2.75E / 726: 17704.
3.25E / 727: 32767.

Note that ferret cannot list a large number of columns to a file, and thus the size of two dimensional arrays that are LISTed to a file is limited.