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

Re: NetCDF-Java NcML bug: Can't read time variable in doubly-aggregated dataset



Hey Christian:

It appears to be a bug in 4.1 and 4.2. Ill get a fix into the next release. thanks much

On 3/29/2010 4:55 PM, Christian Ward-Garrison wrote:
Hi John,

Here's a bug I encountered that has me totally baffled:

<netcdf xmlns="http://www.unidata.ucar.edu/namespaces/netcdf/ncml-2.2";>
<aggregation dimName="ensemble" type="joinNew">

<variableAgg name="P" />
<variableAgg name="T" />
<netcdf coordValue="1">
<aggregation dimName="time" type="joinExisting">
<netcdf location="jan.nc" />
<netcdf location="feb.nc" />
</aggregation>
</netcdf>
</aggregation>
</netcdf>

The files "jan.nc" and "feb.nc" are the same ones from the NcML tutorial. You can load this NcML into NJ and everything seems fine, until you try to read from the "time" variable:

File ncmlFile = new File("C:/Documents and Settings/cwardgar/Desktop/test.ncml"); NetcdfDataset dataset = NetcdfDataset.openDataset(ncmlFile.getAbsolutePath());
System.out.println(dataset.readSection("time"));

Exception in thread "main" java.lang.NullPointerException
at ucar.nc2.ncml.AggregationOuterDimension$CacheVar.read(AggregationOuterDimension.java:885) at ucar.nc2.ncml.AggregationOuterDimension.read(AggregationOuterDimension.java:280)
        at ucar.nc2.dataset.VariableDS._read(VariableDS.java:470)
        at ucar.nc2.dataset.VariableDS._read(VariableDS.java:492)
        at ucar.nc2.Variable.read(Variable.java:809)
        at ucar.nc2.NetcdfFile.readSection(NetcdfFile.java:1887)
        at gov.usgs.shodan.Mlar.aggNcml(Mlar.java:49)
        at gov.usgs.shodan.Mlar.main(Mlar.java:26)

What's so curious about this error is that it only occurs for the "time" variable--all other variables read fine. Also, if you declare "time" as one of the variables to receive the new "ensemble" dimension, you can suddenly read read from it with no problem! Strange, no?

Regards,
Christian Ward-Garrison