Re: netcdf structure (?) question (fwd)

Hi Tom:

First, I would highly reccomend that you switch over to using Netcdf-Java,
version 2, at http://www.unidata.ucar.edu/packages/netcdf-java/

users manual at

http://www.unidata.ucar.edu/packages/netcdf-java/manual.pdf

It has some important optimizations, and is the API we will continue to
develop.

The variable.getDouble(index) was removed from this version, because it is
so easy to use, but is so inefficient for retrieving a lot of data.

In version 2, you explicitly read the data into a memory-based MultiArray,
eg:

  MultiArray ma;
  try {
    ma = variable.read();
  } catch (IOException ioe) {
  }

  // use an index
  Index index = ma.getIndex();
  int[] shape = ma.getShape();
  for (int i=0; i<shape[0]; i++)
    x[i] = ma.getDouble(index.set(i));

  // or use an iterator
  int count = 0;
  IndexIterator iter = ma.getIndexIterator();
  while (iter.hasNext())
    x[count++] = iter.getDoubleNext();

  // or extract using subclass cast
  MultiArrayDouble.1D mad1 = (MultiArrayDouble.1D) ma;
  int[] shape = ma.getShape();
  for (int i=0; i<shape[0]; i++)
    x[i] = mad1.getDouble(i);

  // or, extract entire java array
  double [] x = (double []) ma.copyTo1DJavaArray();

Each read is typically a disk access. So its more obvious to read a
reasonable chunk at a time.

If you really need to use version 1, let me know, and I'll track down the
equivalent calls.


----- Original Message -----
From: "Russ Rew" <russ@xxxxxxxxxxxxxxxx>
To: <caron@xxxxxxxx>
Sent: Wednesday, March 06, 2002 2:31 PM
Subject: netcdf structure (?) question (fwd)


> John,
>
> This is a Java netcdf question.  Can you handle it please and CC: me on
> the reply?  Thanks!
>
> --Russ
>
> ------- Forwarded Message
>
> Date:    Wed, 06 Mar 2002 15:28:19 -0600
> From:    Tom Whittaker <tomw@xxxxxxxxxxxxx>
> To:      russ@xxxxxxxxxxxxxxxx
> Subject: netcdf structure (?) question
>
> Russ:
>
> Below is a schema from a Netcdf file that one of our groups is
> producing.  It contains measurements from an instrument onboard an
> aircraft.  I'm just starting on a small project to provide them with a
> specialized viewer for these data.
>
> Right at the start, I try to read the 28113 values of "Latitude",
> "Longitude", and "FOVAngle", looping over statements like:
>
>   index[0] = i;
>   x[i] = variable.getDouble(index);
>
> it is taking a long, long time (300 or more seconds for the 185MB
file...and
> I need to work with 3 files open at once...).
>
> I looked through your example at
> http://www.unidata.ucar.edu/packages/netcdf/java/examples/ReadNetcdf.java
> and then tried to approach it using "variable.copyout(o,e)" to a
> MultiArray, but I never get farther than trying to use MultiArray's
> toArray() method (throws a cast exception).  I thought before I head
> further down that path, I'd ask...
>
> Anyway, if you would have a quick look at this schema and see if there
> is a better structure they should be using...or if I should be reading
> the data differently...I would appreciate any help.
>
> ...and I'll see you next week!
>
> Thanks again,
>
> tom
>
>
>
> netcdf 000827_sci_mw.nc {
> dimensions:
>         wavenumber = 1608 ;
>         sequence = 19 ;
>         time = UNLIMITED ; // (28113 currently)
> variables:
>         int date() ;
>         int base_time() ;
>                 base_time:longname = "Base time in Epoch" ;
>                 base_time:units = "seconds" ;
>                 base_time:format = "seconds since 1970-1-1 00:00:00" ;
>                 base_time:string = "27-AUG-2000,08:06:31 GMT" ;
>         double wavenumber(wavenumber) ;
>                 wavenumber:longname = "Wavenumber in reciprocal
> centimeters" ;
>                 wavenumber:units = "cm-1" ;
>                 wavenumber:precision = 1.0E-6 ;
>                 wavenumber:missing_value = -9999.0 ;
>                 wavenumber:range_of_values = 1025.0449829101562,
> 1799.8555603027
> 344 ;
>         float sequence(sequence) ;
>                 sequence:longname = "Sequence of scene mirror angles
> for one rep
> etitive cycle" ;
>                 sequence:units = "degrees" ;
>                 sequence:precision = 0.1 ;
>                 sequence:missing_value = -9999.0 ;
>                 sequence:range_of_values = 0.0, 359.999 ;
>         double time_offset(time) ;
>                 time_offset:longname = "Time offset from base_time" ;
>                 time_offset:units = "seconds" ;
>         float instrumentLongitude(time) ;
>                 instrumentLongitude:longname = "Longitude of nadir
> point" ;
>                 instrumentLongitude:units = "degrees_east" ;
>                 instrumentLongitude:precision = 0.01 ;
>                 instrumentLongitude:missing_value = -9999.0 ;
>                 instrumentLongitude:range_of_values = -180.0, 180.0 ;
>         float instrumentLatitude(time) ;
>                 instrumentLatitude:longname = "Latitude of nadir
> point" ;
>                 instrumentLatitude:units = "degrees_north" ;
>                 instrumentLatitude:precision = 0.01 ;
>                 instrumentLatitude:missing_value = -9999.0 ;
>                 instrumentLatitude:range_of_values = -90.0, 90.0 ;
>         float FOVangle(time) ;
>                 FOVangle:longname = "Angle from nadir, negative left
> of track" ;
>
>                 FOVangle:units = "degrees" ;
>                 FOVangle:precision = 0.1 ;
>                 FOVangle:missing_value = -9999.0 ;
>                 FOVangle:range_of_values = "start_angle, end_angle" ;
>         float sceneMirrorAngle(time) ;
>                 sceneMirrorAngle:longname = "Scene mirror angle,
> relative to ins
> trument zenith" ;
>                 sceneMirrorAngle:units = "degrees" ;
>                 sceneMirrorAngle:precision = 0.1 ;
>                 sceneMirrorAngle:missing_value = -9999.0 ;
>                 sceneMirrorAngle:range_of_values = "start_angle,
> end_angle" ;
>         float Altitude(time) ;
>                 Altitude:longname = "Observation Altitude" ;
>                 Altitude:units = "meters" ;
>                 Altitude:precision = 1.0 ;
>                 Altitude:missing_value = -9999.0 ;
>                 Altitude:range_of_values = 0.0, 60000.0 ;
>         float Longitude(time) ;
>                 Longitude:longname = "Observation longitude
> (surface-projected)"
>  ;
>                 Longitude:units = "degrees_east" ;
>                 Longitude:precision = 0.01 ;
>                 Longitude:missing_value = -9999.0 ;
>                 Longitude:range_of_values = -180.0, 180.0 ;
>         float Latitude(time) ;
>                 Latitude:longname = "Observation latitude
> (surface-projected)"
> ;
>                 Latitude:units = "degrees_north" ;
>                 Latitude:precision = 0.01 ;
>                 Latitude:missing_value = -9999.0 ;
>                 Latitude:range_of_values = -90.0, 90.0 ;
>         float aircraftRoll(time) ;
>                 aircraftRoll:longname = "Instrument aircraftRoll
> (0=level, posit
> ive clockwise from behind)" ;
>                 aircraftRoll:units = "degrees" ;
>                 aircraftRoll:precision = 0.1 ;
>                 aircraftRoll:missing_value = -9999.0 ;
>                 aircraftRoll:range_of_values = -90.0, 90.0 ;
>         float aircraftPitch(time) ;
>                 aircraftPitch:longname = "Instrument aircraftPitch
> (0=level, pos
> itive upward)" ;
>                 aircraftPitch:units = "degrees" ;
>                 aircraftPitch:precision = 0.1 ;
>                 aircraftPitch:missing_value = -9999.0 ;
>                 aircraftPitch:range_of_values = -90.0, 90.0 ;
>         float aircraftHeading(time) ;
>                 aircraftHeading:longname = "Direction of instrument
> travel (0=No
> rth, 90=East)" ;
>                 aircraftHeading:units = "degrees" ;
>                 aircraftHeading:precision = 0.1 ;
>                 aircraftHeading:missing_value = -9999.0 ;
>                 aircraftHeading:range_of_values = 0.0, 359.99 ;
>         float timeUTC(time) ;
>                 timeUTC:longname = "Time since 0000UTC" ;
>                 timeUTC:units = "hours" ;
>                 timeUTC:precision = 1.0E-6 ;
>                 timeUTC:missing_value = -9999.0 ;
>                 timeUTC:range_of_values = "start, end" ;
>         float timeOfDay(time) ;
>                 timeOfDay:longname = "Time since 0000UTC" ;
>                 timeOfDay:units = " " ;
>                 timeOfDay:precision = 0.1 ;
>                 timeOfDay:missing_value = -9999.0 ;
>                 timeOfDay:range_of_values = "start, end" ;
>                 timeOfDay:format = "hour.minute.second" ;
>         float refTimeYear(time) ;
>                 refTimeYear:longname = "Reference time, integer
> four-digit year"
>  ;
>                 refTimeYear:units = "year" ;
>                 refTimeYear:precision = 1.0 ;
>         float refTimeMonth(time) ;
>                 refTimeMonth:longname = "Reference time, integer
> month" ;
>                 refTimeMonth:units = "month" ;
>                 refTimeMonth:precision = 1.0 ;
>         float refTimeDay(time) ;
>                 refTimeDay:longname = "Reference time, integer
> day-of-month" ;
>                 refTimeDay:units = "day" ;
>                 refTimeDay:precision = 1.0 ;
>         float refTimeSec(time) ;
>                 refTimeSec:longname = "Reference time, seconds from
> 00:00:00, no
> t to exceed 86400" ;
>                 refTimeSec:units = "seconds" ;
>                 refTimeSec:precision = 1.0 ;
>         float refTimeUsec(time) ;
>                 refTimeUsec:longname = "Reference time, microseconds
> and fractio
> ns of microseconds offset" ;
>                 refTimeUsec:units = "microseconds" ;
>                 refTimeUsec:precision = 1.0 ;
>         float radiance(time, wavenumber) ;
>                 radiance:longname = "radiance Spectrum" ;
>                 radiance:units = "mW/(m2.sr.cm-1)" ;
>                 radiance:precision = 1.0E-4 ;
>                 radiance:missing_value = -9999.0 ;
>                 radiance:range_of_values = "min_rad_val, max_rad_val"
> ;
>
> // global attributes:
>                 :Title = "SHIS band 1, unapodized radiance spectra,
resampled to
>  standard wavenumber grid" ;
>                 :CDL_Version = "$Id: shis_sci.cdl,v 1.1 2000/02/10
18:16:49 cvs
> Exp $" ;
>                 :SoftwareVersion = "$Id: wrtncfil.for,v 1.9 2000/09/29
19:53:03
> cvs Exp $" ;
>                 :Comments = "SHIS unapodized earth-view radiance spectra
@1831" ;
>
>                 :FileHistory = "  5922##### begin File
> E:\SH000827\ARC\000827C2.
>
> ......
>
> --
> Tom Whittaker
> University of Wisconsin-Madison
> Space Science and Eng. Center
> ph:  608.262.2759
>
> ------- End of Forwarded Message
>
>


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