Re: nc2

Don Murray wrote:


I have some code that reads a netCDF file using the ucar.netcdf
package.  I wanted to use VariableStandardized from ucar.nc2,
so need to move my code to use ucar.nc2.  I've got lines like:

   ncFile.get("Latitude").getDouble(new int[] {0}));

Variable v = ncFile.findVariable("Latitude");
Array a =;             // does the actual I/O
Index ima = a.getIndex();
double lat = a.getDouble(ima.set0(0));

// looping
IndexIterator ii= a.getIndexIterator();
while (ii.hasNext())
  lat = ii.getDoubleNext();

if you know the type and rank, a convenient variant is:

Variable v = ncFile.findVariable("Latitude");
ArrayDouble.D1 a = (ArrayDouble.D1);
double lat = a.get(0);

// looping
for (int i=0; i<a.size(); i++)
  lat = a.get(i);

I keep a copy of the users manual around as it has a convenient API summary im always refering to:

BTW, im working on a version 2.1 of nc2 that will have some important improvements to dods access.

to get a particular value from a variable.  How would I do
this using ucar.nc2?


Don Murray                               UCAR Unidata Program
dmurray@xxxxxxxxxxxxxxxx                        P.O. Box 3000
(303) 497-8628                              Boulder, CO 80307

  • 2002 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdf-java archives: