Re: [Fwd: 20010402: Java DODS error]

Hi Donald, Ethan forwarded your message to me:




From: Donald Denbo <dwd@xxxxxxxxxxxxx>
Subject: Java DODS error
Organization: NOAA/PMEL
Keywords: 200104022223.f32MNsL22463 DODS netCDF Java


I have created a test version of ncBrowse that uses the netcdf2.jar file (with minor modifications). I have successfully used this version to read both files and via http/1.1 Web access (not DODS). However, when I tried to access

http://www.cdc.noaa.gov/cgi-bin/nph-nc/Datasets/kaplan_sst/sst.mean.anom.nc

with DODS (java) I got the following error...

      [java] java.lang.ClassCastException: dods.dap.DGrid
[java] at ucar.nc2.dods.DODSVariable.createVectorArray(DODSVariable.java:273)
      [java]     at ucar.nc2.dods.DODSVariable.read(DODSVariable.java:250)
[java] at ncBrowse.SelectionRange.getDoubleArray(SelectionRange.java:907) [java] at ncBrowse.SelectionRange.makeSimpleGrid(SelectionRange.java:720) [java] at ncBrowse.SelectionRange.getDataModel(SelectionRange.java:563)

      [java]     at ncBrowse.VariableGraph.run(VariableGraph.java:145)

This file reads fine using ncBrowse and HTTPClient. It also read just fine as a local file.

Do you have dods.jar file in your classpath? If not, that's the problem. Be sure to get the latest version, eg at

  ftp://ftp.unidata.ucar.edu/pub/netcdf-java/dods.jar

We decided not to include the dods stuff directly in netcdf2 so that package could evolve seperately if needed. But perhaps we should make a jar that has both for convenience.


Don Denbo

P.S. The in-memory ucar.ma2.Array class appears to be about 33 times faster when I need to transpose an axes on a fairly large local file.

nice to hear.

any other comments are welcome, not many have started to use this package yet. Id be interestedin hearing what mods were needed to make this work. Also you might be interested in a new (not yet released) class called VariableStandardized (if so i can give you a pre-release):

/**
 * A "standardized" read-only Variable which implements the semantics of
 *   1) scaled data using <code> scale_factor and add_offset </code>, and
* 2) missing data using <code> valid_min, valid_max, valid_range, missing_data or _FillValue </code> * if those "standard attributes" are present. If they are not present, it acts just like
 * the original Variable.
 *
 * <p> Implementation ruules for scale/offset:
* 1) If scale_factor and/or add_offset variable attributes are present, then
 *    hasScaledData() is true.
* 2) If hasScaledData(), then the Variable element type is converted to float,
 *    (unless it is already type double)
* and the data is converted when read. Otherwise it is left as its original element type.
 *
 * <p> Implementation rules for missing data:
 * 1) _FillValue must have the same type as the data.
 * 2) missing_value should have the same type as the data.
 * 3) _FillValue and missing_data values are in the units of the external
 *    data, which is the packed data if using scale/offset.
 * 4) if valid_range is present, valid_min and valid_max attributes are
* ignored. Otherwise, the valid_min and/or valid_max is used to construct
 *    a valid range.
 * 5) if valid_range has a wider type than the data, and there is a
 *    scale/offset, then it is interpreted as using the same units as the
 *    unpacked data. Otherwise valid_range is interpreted as using the same
 *    units as the external (packed if applicable) data.
 *
* <p> if hasMissingData(), then isMissingData( double val) should be called to * determine if the data is missing. Note that the data is converted to double (if not
 * already) and compared as a double.
 *
 * <p> Uses the Decorator design pattern.
 *
 * @author caron
 * @version $Revision: 1.2 $ $Date: 2001/03/09 19:30:54 $
 */

public class VariableStandardized extends Variable {



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