/** * Create a subset of an existing VerticalTransform * @param original make a subset of this * @param t_range subset the time dimension, or null if you want all of it * @param z_range subset the vertical dimension, or null if you want all of it * @param y_range subset the y dimension, or null if you want all of it * @param x_range subset the x dimension, or null if you want all of it */ public VerticalTransformSubset(VerticalTransform original, Range t_range, Range z_range, Range y_range, Range x_range) { super(null); // timeDim not used in this class this.original = original; this.t_range = t_range; subsetList.add(z_range); subsetList.add(y_range); subsetList.add(x_range); units = original.getUnitString(); }
/** * Create a subset of an existing VerticalTransform * @param original make a subset of this * @param t_range subset the time dimension, or null if you want all of it * @param z_range subset the vertical dimension, or null if you want all of it * @param y_range subset the y dimension, or null if you want all of it * @param x_range subset the x dimension, or null if you want all of it */ public VerticalTransformSubset(VerticalTransform original, Range t_range, Range z_range, Range y_range, Range x_range) { super(null); // timeDim not used in this class this.original = original; this.t_range = t_range; subsetList.add(z_range); subsetList.add(y_range); subsetList.add(x_range); units = original.getUnitString(); }
/** * Create a subset of an existing VerticalTransform * @param original make a subset of this * @param t_range subset the time dimension, or null if you want all of it * @param z_range subset the vertical dimension, or null if you want all of it * @param y_range subset the y dimension, or null if you want all of it * @param x_range subset the x dimension, or null if you want all of it */ public VerticalTransformSubset(VerticalTransform original, Range t_range, Range z_range, Range y_range, Range x_range) { super(null); // timeDim not used in this class this.original = original; this.t_range = t_range; subsetList.add(z_range); subsetList.add(y_range); subsetList.add(x_range); units = original.getUnitString(); }
@Test @Category(NeedsCdmUnitTest.class) public void testWRF() throws Exception { try(GridDataset dataset = GridDataset.open(TestDir.cdmUnitTestDir + "conventions/wrf/wrfout_v2_Lambert.nc")) { GeoGrid grid = dataset.findGridByName("T"); assert null != grid; GridCoordSystem gcs = grid.getCoordinateSystem(); assert null != gcs; assert grid.getRank() == 4; CoordinateAxis zaxis = gcs.getVerticalAxis(); assert zaxis.getSize() == 27; VerticalTransform vt = gcs.getVerticalTransform(); assert vt != null; assert vt.getUnitString().equals("Pa"); GeoGrid grid_section = grid.subset(null, null, null, 3, 3, 3); Array data = grid_section.readDataSlice(-1, -1, -1, -1); assert data.getShape()[0] == 13 : data.getShape()[0]; assert data.getShape()[1] == 9 : data.getShape()[1]; assert data.getShape()[2] == 20 : data.getShape()[2]; assert data.getShape()[3] == 25 : data.getShape()[3]; GridCoordSystem gcs_section = grid_section.getCoordinateSystem(); CoordinateAxis zaxis2 = gcs_section.getVerticalAxis(); assert zaxis2.getSize() == 9 : zaxis2.getSize(); assert zaxis2.getUnitsString().equals(zaxis.getUnitsString()); assert gcs_section.getTimeAxis().equals(gcs.getTimeAxis()); VerticalTransform vt_section = gcs_section.getVerticalTransform(); assert vt_section != null; assert vt_section.getUnitString().equals(vt.getUnitString()); } }
String vertCoordUnit = vt.getUnitString(); assert vunit.isCompatible(vertCoordUnit) : vertCoordUnit + " not udunits compatible with " + vunit.getUnitString();
private void testGrid( GeoGrid grid) throws IOException, InvalidRangeException { assert null != grid; GridCoordSystem gcs = grid.getCoordinateSystem(); assert null != gcs; assert grid.getRank() == 4; Array data = grid.readDataSlice(0, -1, -1, -1); assert data.getRank() == 3; CoordinateAxis zaxis = gcs.getVerticalAxis(); assert data.getShape()[0] == zaxis.getSize() : zaxis.getSize(); CoordinateAxis yaxis = gcs.getYHorizAxis(); assert data.getShape()[1] == yaxis.getSize() : yaxis.getSize(); CoordinateAxis xaxis = gcs.getXHorizAxis(); assert data.getShape()[2] == xaxis.getSize() : xaxis.getSize(); VerticalTransform vt = gcs.getVerticalTransform(); assert vt != null; assert vt.getUnitString() != null; ucar.ma2.ArrayDouble.D3 vcoord = vt.getCoordinateArray(0); assert vcoord.getShape()[0] == zaxis.getSize() : vcoord.getShape()[0]; assert vcoord.getShape()[1] == yaxis.getSize() : vcoord.getShape()[1]; assert vcoord.getShape()[2] == xaxis.getSize() : vcoord.getShape()[2]; }