public void test2D() throws Exception {
GridDataset dataset = GridDataset.open(TestAll.cdmUnitTestDir + "conventions/cf/mississippi.nc");
GeoGrid grid = dataset.findGridByName("salt");
assert null != grid;
GridCoordSystem gcs = grid.getCoordinateSystem();
assert null != gcs;
assert grid.getRank() == 4;
GeoGrid grid_section = grid.subset(null, null, null, 5, 5, 5);
Array data = grid_section.readDataSlice(-1, -1, -1, -1);
assert data.getShape()[0] == 1 : data.getShape()[0];
assert data.getShape()[1] == 4 : data.getShape()[1];
assert data.getShape()[2] == 13 : data.getShape()[2];
assert data.getShape()[3] == 26 : data.getShape()[3];
grid_section = grid.subset(null, new Range(0, 0), null, 0, 2, 2);
data = grid_section.readDataSlice(-1, -1, -1, -1);
assert data.getShape()[0] == 1 : data.getShape()[0];
assert data.getShape()[1] == 1 : data.getShape()[1];
assert data.getShape()[2] == 32 : data.getShape()[2];
assert data.getShape()[3] == 64 : data.getShape()[3];
NCdump.printArray(data, "grid_section", System.out, null);
LatLonPoint p0 = new LatLonPointImpl(29.0, -90.0);
LatLonRect bbox = new LatLonRect(p0, 1.0, 2.0);
grid_section = grid.subset(null, null, bbox, 1, 1, 1);
data = grid_section.readDataSlice(-1, -1, -1, -1);
assert data.getShape()[0] == 1 : data.getShape()[0];
assert data.getShape()[1] == 20 : data.getShape()[1];
assert data.getShape()[2] == 63 : data.getShape()[2];
assert data.getShape()[3] == 53 : data.getShape()[3];
gcs = grid_section.getCoordinateSystem();
ProjectionRect rect = gcs.getBoundingBox();
System.out.println(" rect= " + rect);
p0 = new LatLonPointImpl(30.0, -90.0);
bbox = new LatLonRect(p0, 1.0, 2.0);
grid_section = grid.subset(null, null, bbox, 1, 1, 1);
data = grid_section.readDataSlice(-1, -1, -1, -1);
assert data.getShape()[0] == 1 : data.getShape()[0];
assert data.getShape()[1] == 20 : data.getShape()[1];
assert data.getShape()[2] == 18 : data.getShape()[2];
assert data.getShape()[3] == 17 : data.getShape()[3];
gcs = grid_section.getCoordinateSystem();
System.out.println(" rect= " + gcs.getBoundingBox());
dataset.close();
}