[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[netCDF #YMF-333401]: ncdump



Hi Morgan,

The ncdump utility is not particularly good at generating nice tables of 
values, which is why it's not called "ncreport" or "nclayout" :-).
But it does have some options for annotating the output to help you navigate 
through all those values.  It prints the values in the order of last dimension 
varying fastest, so, for example, if you have a variable whose declaration 
appears in the ncdump output as

  float u(time,lon,lat) ;

then the values will be output with the time dimension varying most slowly, the 
lon dimension next most slowly, and the lat dimension fastest, so the values in 
each row will run up in latitudes before the next longitude, sort of like the 
digits on a car odometer.

Depending on whether you are used to C or Fortran index order for arrays, this 
means the values will be in the order

  u[0][0][0], u[0][0][1], u[0][0][2], ..., u[0][1][0], u[0][1][1], ...
or
  u(1,1,1), u(2,1,1), u(3,1,1), ..., u(1,2,1), u(2,2,1), ...

If you use the ncdump -b or -f option for brief or full annotations and specify 
whether you want C or Fortran indices, you can get comments in the output that 
identify the values.  For example, 

  ncdump -b f foo.nc
might produce ("//" starts a comment to the end of the line):
 u =
  // u(1-5 ,1,1)
    1, 2, 3, 4, 5,
  // u(1-5 ,2,1)
    6, 7, 8, 9, 10,
to show in Fortran order what the values are, whereas 
  ncdump -b c foo.nc
would output the same data as 
 u =
  // u(0,0, 0-4)
    1, 2, 3, 4, 5,
  // u(0,1, 0-4)
    6, 7, 8, 9, 10,
and so on.  Using the full annotation will provide a comment tag for every 
single value, as in
  ncdump -f c
 u =
    1,  // u(0,0,0)
    2,  // u(0,0,1)
    3,  // u(0,0,2)
    4,  // u(0,0,3)
    5,  // u(0,0,4)
    6,  // u(0,1,0)
 ...

If you want a nice table, you might try a different utility, such as the "ncks" 
program from the NCO package, which outputs netcdf data in a tabular format 
intended to be easy to search for the data you want, with all dimension 
subscripts and coordinate values preceding each data value on the same line.  
See:

  http://www.unidata.ucar.edu/software/netcdf/software.html#NCO

There are other utility programs that can produce more readable output as well, 
among the many packages listed in at

  http://www.unidata.ucar.edu/software/netcdf/software.html

--Russ

Russ Rew                                         UCAR Unidata Program
address@hidden                     http://www.unidata.ucar.edu



Ticket Details
===================
Ticket ID: YMF-333401
Department: Support netCDF
Priority: Normal
Status: Closed