dataset.close();
}
public void utestSubsetCoordEdges() throws Exception {
NetcdfDataset fooDataset = NetcdfDataset.openDataset(TestAll.cdmLocalTestDataDir + "dataset/subsetCoordEdges.ncml");
try {
GridDataset fooGridDataset = new GridDataset(fooDataset);
GridDatatype fooGrid = fooGridDataset.findGridDatatype("foo");
CoordinateAxis1D fooTimeAxis = fooGrid.getCoordinateSystem().getTimeAxis1D();
CoordinateAxis1D fooLatAxis = (CoordinateAxis1D) fooGrid.getCoordinateSystem().getYHorizAxis();
CoordinateAxis1D fooLonAxis = (CoordinateAxis1D) fooGrid.getCoordinateSystem().getXHorizAxis();
// Expected: [0.0, 31.0, 59.0, 90.0, 120.0]
// Actual: [0.0, 31.0, 59.0, 90.0, 120.0]
System.out.println("mid time= " + Arrays.toString(fooTimeAxis.getCoordValues()));
System.out.println("edge time= " + Arrays.toString(fooTimeAxis.getCoordEdges()));
System.out.println();
// Expected: [-90.0, -18.0, 36.0, 72.0, 90.0]
// Actual: [-90.0, -18.0, 36.0, 72.0, 90.0]
System.out.println("mid lat= " + Arrays.toString(fooLatAxis.getCoordValues()));
System.out.println("edge lat= " + Arrays.toString(fooLatAxis.getCoordEdges()));
System.out.println();
// Expected: [0.0, 36.0, 108.0, 216.0, 360.0]
// Actual: [0.0, 36.0, 108.0, 216.0, 360.0]
System.out.println("mid lon= " + Arrays.toString(fooLonAxis.getCoordValues()));
System.out.println("edge lon= " + Arrays.toString(fooLonAxis.getCoordEdges()));
System.out.println();
Range middleRange = new Range(1, 2);
GridDatatype fooSubGrid = fooGrid.makeSubset(null, null, middleRange, null, middleRange, middleRange);
CoordinateAxis1D fooSubTimeAxis = fooSubGrid.getCoordinateSystem().getTimeAxis1D();
CoordinateAxis1D fooSubLatAxis = (CoordinateAxis1D) fooSubGrid.getCoordinateSystem().getYHorizAxis();
CoordinateAxis1D fooSubLonAxis = (CoordinateAxis1D) fooSubGrid.getCoordinateSystem().getXHorizAxis();
// Expected: [31.0, 59.0, 90.0]
// Actual: [30.25, 59.75, 89.25]
System.out.println("mid time= " + Arrays.toString(fooSubTimeAxis.getCoordValues()));
System.out.println("edge time= " + Arrays.toString(fooSubTimeAxis.getCoordEdges()));
compare(fooSubTimeAxis.getCoordEdges(), new double[] {31.0, 59.0, 90.0} );
System.out.println();
// Expected: [-18.0, 36.0, 72.0]
// Actual: [-13.5, 31.5, 76.5]
System.out.println("mid lat= " + Arrays.toString(fooSubLatAxis.getCoordValues()));
System.out.println("edge lat= " + Arrays.toString(fooSubLatAxis.getCoordEdges()));
compare(fooSubLatAxis.getCoordEdges(), new double[] {-18.0, 36.0, 72.0} );
System.out.println();
// Expected: [36.0, 108.0, 216.0]
// Actual: [27.0, 117.0, 207.0]
System.out.println("mid lon= " + Arrays.toString(fooSubLonAxis.getCoordValues()));
System.out.println("edge lon= " + Arrays.toString(fooSubLonAxis.getCoordEdges()));
compare(fooSubLonAxis.getCoordEdges(), new double[] {36.0, 108.0, 216.0} );
System.out.println();
} finally {
fooDataset.close();
}
}