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

Re: 970724: extracting multi-dimensional variables



>To: address@hidden
>From: Roy Deal <address@hidden>
>Subject: extracting multi-dimensional variables
>Organization: TASC
>Keywords: 199707241326.HAA01589

Hi Roy,

> I recently received a netCDF file with a set of variables 
> dimensioned like this:  var(time, level, lat, lon), and I'm 
> having trouble extracting them from the file.  When I do 
> an ncdump on the file the values look like this:  var =  
> 25, -30, 30, 15, etc.
> 
> I'm using ncvarget with start[] = {0, 0, 0, 0} and count[] 
> = {4, 1, 1, 1} with the intention of extracting the 4 
> values listed in the previous paragraph, but when I print 
> the values out, only the first number agrees with those
> listed above.  Any idea what might be happening?

Yes, ncdump prints the values in the order they are stored:

 var[0][0][0][0]
 var[0][0][0][1]
 var[0][0][0][2]
  ...
 var[0][0][1][0]
 var[0][0][1][1]
 var[0][0][1][2]
  ...

If you use the "-b C" option to ncdump, it provides brief annotations as
comments identifying which values it is printing.  The "-f C" option
provides full annotations of every value.

If you want to get the values in the same order as ncdump presents them,
with the right-most dimension varying fastest, use count[] = {1, 1, 1,
4}.

--Russ

_____________________________________________________________________

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