NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.

To learn about what's going on, see About the Archive Site.

[netcdf-java] Using netcdf-java from Matlab

Hi All,
I'm trying to use netcdf-java 4.0 from Matlab to access OpenDAP data and am
getting the following error:

>> import ucar.nc2.dataset.*
>> nc = NetcdfDataset.openDataset('
http://dods.mbari.org/cgi-bin/nph-nc/data/ssdsdata/deployments/m1/200810/m1_metsys_20081008_original.nc
')
Loading units database: com/mathworks/uk/units/Unit.xml
Fatal error: Could not open null
java.io.IOException: Could not open null
at
com.mathworks.toolbox.mbc.units.UnitXML.urlToInputSource(UnitXML.java:541)
at com.mathworks.toolbox.mbc.units.UnitXML.toXdoc(UnitXML.java:148)
at com.mathworks.toolbox.mbc.units.UnitXML.getFromXML(UnitXML.java:111)
at ucar.units.StandardUnitDB.addFromXML(StandardUnitDB.java:173)
at ucar.units.StandardUnitDB.<init>(StandardUnitDB.java:115)
at ucar.units.StandardUnitDB.instance(StandardUnitDB.java:137)
at ucar.units.UnitDBManager.instance(UnitDBManager.java:57)
at ucar.units.UnitFormatImpl.parse(UnitFormatImpl.java:57)
at ucar.nc2.units.SimpleUnit.<clinit>(SimpleUnit.java:62)
at
ucar.nc2.dataset.conv.COARDSConvention.getAxisType(COARDSConvention.java:78)
at ucar.nc2.dataset.conv.CSMConvention.getAxisType(CSMConvention.java:101)
at ucar.nc2.dataset.conv.CF1Convention.getAxisType(CF1Convention.java:226)
at
ucar.nc2.dataset.CoordSysBuilder.makeCoordinateAxes(CoordSysBuilder.java:622)
at
ucar.nc2.dataset.CoordSysBuilder.buildCoordinateSystems(CoordSysBuilder.java:482)
at
ucar.nc2.dataset.CoordSysBuilder.addCoordinateSystems(CoordSysBuilder.java:390)
at ucar.nc2.dataset.NetcdfDataset.enhance(NetcdfDataset.java:468)
at ucar.nc2.dataset.NetcdfDataset.<init>(NetcdfDataset.java:1125)
at ucar.nc2.dataset.NetcdfDataset.openDataset(NetcdfDataset.java:436)
at ucar.nc2.dataset.NetcdfDataset.openDataset(NetcdfDataset.java:413)
at ucar.nc2.dataset.NetcdfDataset.openDataset(NetcdfDataset.java:398)
at ucar.nc2.dataset.NetcdfDataset.openDataset(NetcdfDataset.java:385)
Unknown unit: "sec"
SimpleUnit initialization failed java.lang.ClassCastException:
java.lang.String
??? Java exception occurred:
java.lang.ExceptionInInitializerError
at
ucar.nc2.dataset.conv.COARDSConvention.getAxisType(COARDSConvention.java:78)
at ucar.nc2.dataset.conv.CSMConvention.getAxisType(CSMConvention.java:101)
at ucar.nc2.dataset.conv.CF1Convention.getAxisType(CF1Convention.java:226)
at
ucar.nc2.dataset.CoordSysBuilder.makeCoordinateAxes(CoordSysBuilder.java:622)
at
ucar.nc2.dataset.CoordSysBuilder.buildCoordinateSystems(CoordSysBuilder.java:482)
at
ucar.nc2.dataset.CoordSysBuilder.addCoordinateSystems(CoordSysBuilder.java:390)
at ucar.nc2.dataset.NetcdfDataset.enhance(NetcdfDataset.java:468)
at ucar.nc2.dataset.NetcdfDataset.<init>(NetcdfDataset.java:1125)
at ucar.nc2.dataset.NetcdfDataset.openDataset(NetcdfDataset.java:436)
at ucar.nc2.dataset.NetcdfDataset.openDataset(NetcdfDataset.java:413)
at ucar.nc2.dataset.NetcdfDataset.openDataset(NetcdfDataset.java:398)
at ucar.nc2.dataset.NetcdfDataset.openDataset(NetcdfDataset.java:385)
Caused by: java.lang.RuntimeException: SimpleUnit initialization failed
java.lang.ClassCastException:
java.lang.String
at ucar.nc2.units.SimpleUnit.<clinit>(SimpleUnit.java:77)
... 12 more


 I've added the following jars from the netcdf distribution onto the Matlab
classpath:

visadNoDods.jar
stax-api-1.0.1.jar
spring-2.5.jar
slf4j-log4j12-1.5.6.jar
slf4j-jdk14-1.5.6.jar
slf4j-api-1.5.6.jar
resourcesOptional.jar
opendap-2.1.jar
netcdfUI-4.0.jar
netcdf-4.0.jar
lucene.jar
log4j-1.2.15.jar
jpeg2000.jar
jdom.jar
grib-6.0.jar
forms-1.0.7.jar
ehcache-1.6.0-beta3.jar
commons-logging-1.1.jar
commons-httpclient-3.1.jar
commons-codec-1.3.jar
bufrTables-1.5.jar

And I noticed matlab has the following on its java classpath:

/Applications/MATLAB76/java/jarext/mwucarunits.jar

I'm pretty sure that the above jar is short for Mathworks ucar units. jar

Anyone familiar with the ucar units package and/or accessing opendap using
the netcdf libraries? Is there anyway to disable whatever units conversion
that NetcdfDataset.openDataset call seems to be trying? Other workaround
ideas?

Thanks

-- 
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
Brian Schlining
bschlining@xxxxxxxxx
  • 2009 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdf-java archives: