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

[netCDF #MYN-702465]: extracting netCDF data



Hi Amy,

> I have been able to retrieve files from other FTP servers, so not sure
> why this one isn't working for me. But in any case, if it's not
> maintained, then I would rather use something that is, like the ncdump
> utility that you mention. I have read through some of the
> documentation about netCDF files on your website and I am a bit
> confused by it all. I just want to be able to extract temperature and
> precipitation time series for 4 grid points. Are there any simplifying
> instructions you could give me to achieve this using ncdump?

ncdump is a portable command-line utility that can be used to show the
structure and values of netCDF data, but is not particularly
well-suited to extracting a small set of data meeting specified
conditions from a large netCDF dataset.  Nevertheless, it can be used
to "dump" the data in text from for a specified list of variables.
And if you know the corresponding indices of the grid points you are
looking for, it can be used to extract values for just those grid
points as well.  But it doesn't interpret coordinate systems, so
ncdump is not the right tool to use to ask for data within a specified
lat/lon bounding box, unless your data is on a simple rectilinear
lat/lon grid.

If you are familiar with and have access to other scientific software
visualization and analysis packages such as MATLAB, IDL, or IDV, it's
possible to access netCDF data from within those packages and print or
plot it.  Other software packages useful for data visualization and
analysis that support netCDF include NCL, NCO, and CDO.  Short
descriptions and links to all these packages are available here:

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

and any you already have access to may be easier for extracting values
than ncdump.

Another alternative, if you have programming skills, is to look at the
simple example programs for reading netCDF data in various programming
languages, to see how to access and print data from a netCDF file that
way:

  http://www.unidata.ucar.edu/software/netcdf/examples/programs/

which also includes examples for accessing data in MATLAB and IDL.

But if you want to use ncdump for this purpose, there was a discussion
of this on the netcdfgroup mailing list earlier this year:

  
http://www.unidata.ucar.edu/mailing_lists/archives/netcdfgroup/2009/msg00145.html
  
http://www.unidata.ucar.edu/mailing_lists/archives/netcdfgroup/2009/msg00146.html
  
http://www.unidata.ucar.edu/mailing_lists/archives/netcdfgroup/2009/msg00148.html

Here are the steps, assuming you are trying to get the data from a
file named "data.nc", it has variables named "temp" and "precip" (you
can determine what the variables are really named with "ncdump -h
data.nc"), and they are dimensioned as

  temp(time,lon,lat)
  precip(time,lon,lat)

Also assume one of the grid points you want data for is the one
corresponding to the 10th lon and the 20th lat, and that you have the
"grep" utility for matching patterns in strings.

Then use

  ncdump -v temp -f c data.nc | grep "temp([0-9]*,9,19)"

to get the time series of values for temperature, and similarly for
precipitation.  You use "9,19" instead of "10,20" to specify the
lat,lon indexes, because the indexes start at 0 rather than 1.

--Russ

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



Ticket Details
===================
Ticket ID: MYN-702465
Department: Support netCDF
Priority: High
Status: Closed