ucar.ma2.ArrayDouble.D3 coordVals = vt.getCoordinateArray(i); assert (null != coordVals); Section cSection = new Section(coordVals.getShape()); if (show) System.out.printf("%s: varSection shape = %s %n", v.getFullName(), varSection); if (show) System.out.printf("%s: coordVal shape = %s %n", v.getFullName(), cSection);
public void testErie() throws IOException, InvalidRangeException { String uri = TestDir.cdmUnitTestDir + "transforms/erie_test.ncml"; String var = "temp"; GridDataset ds = GridDataset.open(uri); GeoGrid grid = ds.findGridByName(var); Section s = new Section(grid.getShape()); System.out.printf("var = %s %n", s); GridCoordSystem gcs = grid.getCoordinateSystem(); VerticalTransform vt = gcs.getVerticalTransform(); ArrayDouble.D3 z = vt.getCoordinateArray(0); Section sv = new Section(z.getShape()); System.out.printf("3dcoord = %s %n", sv); s = s.removeRange(0); assert s.equals(sv); }
int[] shape = array.getShape(); int[] newShape = new int[3]; System.arraycopy(shape, 0, newShape, 0, 3);
int[] shape = array.getShape(); int[] newShape = new int[3]; System.arraycopy(shape, 0, newShape, 0, 3);
origin[2]=xIndex; shape[0] = data.getShape()[0]; shape[1] =1; shape[2] =1;
/** * Get the 1D vertical coordinate array for this time step and point * * @param timeIndex the time index. Ignored if !isTimeDependent(). * @param xIndex the x index * @param yIndex the y index * @return vertical coordinate array * @throws java.io.IOException problem reading data * @throws ucar.ma2.InvalidRangeException _more_ */ public D1 getCoordinateArray1D(int timeIndex, int xIndex, int yIndex) throws IOException, InvalidRangeException { ArrayDouble.D3 data = getCoordinateArray(timeIndex); int[] origin = new int[3]; int[] shape = new int[3]; origin[0]=0; origin[1]=yIndex; origin[2]=xIndex; shape[0] = data.getShape()[0]; shape[1] =1; shape[2] =1; Array tmp = data.section(origin, shape); return (ArrayDouble.D1)tmp.reduce(); }
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]; }
/** * Get the 1D vertical coordinate array for this time step and point * * @param timeIndex the time index. Ignored if !isTimeDependent(). * @param xIndex the x index * @param yIndex the y index * @return vertical coordinate array * @throws java.io.IOException problem reading data * @throws ucar.ma2.InvalidRangeException _more_ */ public D1 getCoordinateArray1D(int timeIndex, int xIndex, int yIndex) throws IOException, InvalidRangeException { ArrayDouble.D3 data = getCoordinateArray(timeIndex); int[] origin = new int[3]; int[] shape = new int[3]; origin[0]=0; origin[1]=yIndex; origin[2]=xIndex; shape[0] = data.getShape()[0]; shape[1] =1; shape[2] =1; Array tmp = data.section(origin, shape); return (ArrayDouble.D1)tmp.reduce(); }
public void testStride() throws java.io.IOException, InvalidRangeException { String filename= TestDir.cdmUnitTestDir + "/conventions/wrf/wrfout_d01_2006-03-08_21-00-00"; GridDataset gds = ucar.nc2.dt.grid.GridDataset.open( filename); GridDatatype grid = gds.findGridDatatype("T"); assert grid != null; grid = grid.makeSubset(null,null,null,1,2,4); GridCoordSystem gcs = grid.getCoordinateSystem(); assert gcs != null; VerticalTransform vt = gcs.getVerticalTransform(); assert vt != null; ArrayDouble.D3 ca = vt.getCoordinateArray(0); assert ca != null; assert ca.getRank() == 3 : ca.getRank(); int[] shape = ca.getShape(); for (int i = 0; i < 3; i++) System.out.println(" shape " + i + " = " + shape[i]); assert shape[0] == 44; assert shape[1] == 399/2 + 1; assert shape[2] == 399/4 + 1; gds.close(); } }
public void testOceanSigma() throws java.io.IOException, InvalidRangeException { GridDataset gds = ucar.nc2.dt.grid.GridDataset.open( TestDir.cdmUnitTestDir + "conventions/cf/gomoos_cf.nc"); GridDatatype grid = gds.findGridDatatype("temp"); assert grid != null; GridCoordSystem gcs = grid.getCoordinateSystem(); assert gcs != null; VerticalCT vct = gcs.getVerticalCT(); assert vct != null; assert vct.getVerticalTransformType() == VerticalCT.Type.OceanSigma; VerticalTransform vt = gcs.getVerticalTransform(); assert vt != null; CoordinateAxis1DTime taxis = gcs.getTimeAxis1D(); for (int t=0; t<taxis.getSize(); t++) { System.out.printf("vert coord for time = %s%n", taxis.getTimeDate(t)); ArrayDouble.D3 ca = vt.getCoordinateArray(t); assert ca != null; assert ca.getRank() == 3 : ca.getRank(); int[] shape = ca.getShape(); for (int i = 0; i < 3; i++) System.out.println(" shape " + i + " = " + shape[i]); } gds.close(); }
private void testGrid(String uri, String var) throws IOException, InvalidRangeException { GridDataset ds = null; try { ds = GridDataset.open(uri); GeoGrid grid = ds.findGridByName(var); Section s = new Section(grid.getShape()); System.out.printf("var = %s %n", s); GridCoordSystem GridCoordS = grid.getCoordinateSystem(); VerticalTransform vt = GridCoordS.getVerticalTransform(); ArrayDouble.D3 z = vt.getCoordinateArray(0); Section sv = new Section(z.getShape()); System.out.printf("3dcoord = %s %n", sv); if (vt.isTimeDependent()) s = s.removeRange(0); assert s.equals(sv); } finally { if (ds != null) ds.close(); } }
public void testAtmHybrid() throws java.io.IOException, InvalidRangeException { GridDataset gds = ucar.nc2.dt.grid.GridDataset.open( TestDir.cdmUnitTestDir + "conventions/cf/ccsm2.nc"); GridDatatype grid = gds.findGridDatatype("T"); assert grid != null; GridCoordSystem gcs = grid.getCoordinateSystem(); assert gcs != null; VerticalCT vct = gcs.getVerticalCT(); assert vct != null; assert vct.getVerticalTransformType() == VerticalCT.Type.HybridSigmaPressure : vct.getVerticalTransformType(); VerticalTransform vt = gcs.getVerticalTransform(); assert vt != null; ArrayDouble.D3 ca = vt.getCoordinateArray(0); assert ca != null; assert ca.getRank() == 3 : ca.getRank(); int[] shape = ca.getShape(); for (int i = 0; i < 3; i++) System.out.println(" shape " + i + " = " + shape[i]); gds.close(); }
public void testAtmSigma() throws java.io.IOException, InvalidRangeException { GridDataset gds = ucar.nc2.dt.grid.GridDataset.open( TestDir.cdmUnitTestDir + "transforms/temperature.nc"); GridDatatype grid = gds.findGridDatatype("Temperature"); assert grid != null; GridCoordSystem gcs = grid.getCoordinateSystem(); assert gcs != null; VerticalCT vct = gcs.getVerticalCT(); assert vct != null; assert vct.getVerticalTransformType() == VerticalCT.Type.Sigma; VerticalTransform vt = gcs.getVerticalTransform(); assert vt != null; ArrayDouble.D3 ca = vt.getCoordinateArray(0); assert ca != null; assert ca.getRank() == 3 : ca.getRank(); int[] shape = ca.getShape(); for (int i = 0; i < 3; i++) System.out.println(" shape " + i + " = " + shape[i]); gds.close(); }
/** * Get the 1D vertical coordinate array for this time step and point * * @param timeIndex the time index. Ignored if !isTimeDependent(). * @param xIndex the x index * @param yIndex the y index * @return vertical coordinate array * @throws java.io.IOException problem reading data * @throws ucar.ma2.InvalidRangeException _more_ */ public D1 getCoordinateArray1D(int timeIndex, int xIndex, int yIndex) throws IOException, InvalidRangeException { ArrayDouble.D3 ddata = getCoordinateArray(timeIndex); int[] origin = new int[]{0, yIndex, xIndex }; int[] shape = new int[]{ ddata.getShape()[0] , 1, 1 }; return (ArrayDouble.D1)ddata.section(origin, shape).reduce(); }
public void testWrfEta() throws java.io.IOException, InvalidRangeException { GridDataset gds = ucar.nc2.dt.grid.GridDataset.open( TestDir.cdmUnitTestDir + "conventions/wrf/wrfout_v2_Lambert.nc"); GridDatatype grid = gds.findGridDatatype("T"); assert grid != null; GridCoordSystem gcs = grid.getCoordinateSystem(); assert gcs != null; VerticalCT vct = gcs.getVerticalCT(); assert vct != null; assert vct.getVerticalTransformType() == VerticalCT.Type.WRFEta : vct.getVerticalTransformType(); VerticalTransform vt = gcs.getVerticalTransform(); assert vt != null; ArrayDouble.D3 ca = vt.getCoordinateArray(0); assert ca != null; assert ca.getRank() == 3 : ca.getRank(); int[] shape = ca.getShape(); for (int i = 0; i < 3; i++) System.out.println(" shape " + i + " = " + shape[i]); gds.close(); }
public void testOceanS() throws java.io.IOException, InvalidRangeException { GridDataset gds = ucar.nc2.dt.grid.GridDataset.open(TestDir.cdmUnitTestDir + "transforms/roms_ocean_s_coordinate.nc"); GridDatatype grid = gds.findGridDatatype("temp"); assert grid != null; GridCoordSystem gcs = grid.getCoordinateSystem(); assert gcs != null; VerticalCT vct = gcs.getVerticalCT(); assert vct != null; assert vct.getVerticalTransformType() == VerticalCT.Type.OceanS; VerticalTransform vt = gcs.getVerticalTransform(); assert vt != null; ArrayDouble.D3 ca = vt.getCoordinateArray(0); assert ca != null; assert ca.getRank() == 3 : ca.getRank(); int[] shape = ca.getShape(); for (int i = 0; i < 3; i++) System.out.println(" shape " + i + " = " + shape[i]); gds.close(); }
/** * Get the 1D vertical coordinate array for this time step and point * * @param timeIndex the time index. Ignored if !isTimeDependent(). * @param xIndex the x index * @param yIndex the y index * @return vertical coordinate array * @throws java.io.IOException problem reading data * @throws ucar.ma2.InvalidRangeException _more_ */ public D1 getCoordinateArray1D(int timeIndex, int xIndex, int yIndex) throws IOException, InvalidRangeException { ArrayDouble.D3 ddata = (ArrayDouble.D3) getCoordinateArray(timeIndex); int[] origin = new int[]{0, yIndex, xIndex }; int[] shape = new int[]{ ddata.getShape()[0] , 1, 1 }; return (ArrayDouble.D1)ddata.section(origin, shape).reduce(); }
/** * Get the 1D vertical coordinate array for this time step and point * * @param timeIndex the time index. Ignored if !isTimeDependent(). * @param xIndex the x index * @param yIndex the y index * @return vertical coordinate array * @throws java.io.IOException problem reading data * @throws ucar.ma2.InvalidRangeException _more_ */ public D1 getCoordinateArray1D(int timeIndex, int xIndex, int yIndex) throws IOException, InvalidRangeException { ArrayDouble.D3 ddata = getCoordinateArray(timeIndex); int[] origin = new int[]{0, yIndex, xIndex }; int[] shape = new int[]{ ddata.getShape()[0] , 1, 1 }; return (ArrayDouble.D1)ddata.section(origin, shape).reduce(); }
@Test public void testHybridSigmaPressure2() throws IOException, InvalidRangeException { String filename = testDir + "climo.cam2.h0.0000-09.nc"; NetcdfDataset ncd = ucar.nc2.dataset.NetcdfDataset.openDataset(filename); VerticalTransform vt = test(ncd, "lev", "T", "time", VerticalCT.Type.HybridSigmaPressure, HybridSigmaPressure.class, SimpleUnit.pressureUnit, true); Dimension timeDim = ncd.findDimension("time"); for (int i = 0; i < timeDim.getLength(); i++) { ucar.ma2.ArrayDouble.D3 coordVals = vt.getCoordinateArray(i); int[] shape = coordVals.getShape(); assert shape[0] == ncd.findDimension("lev").getLength(); assert shape[1] == ncd.findDimension("lat").getLength(); assert shape[2] == ncd.findDimension("lon").getLength(); } ncd.close(); }
@Test public void testHybridSigmaPressure3() throws IOException, InvalidRangeException { String filename = testDir + "HIRLAMhybrid.ncml"; NetcdfDataset ncd = ucar.nc2.dataset.NetcdfDataset.openDataset(filename); VerticalTransform vt = test(ncd, "hybrid", "Relative_humidity_hybrid", "time", VerticalCT.Type.HybridSigmaPressure, HybridSigmaPressure.class, SimpleUnit.pressureUnit, true); Dimension timeDim = ncd.findDimension("time"); for (int i = 0; i < timeDim.getLength(); i++) { ucar.ma2.ArrayDouble.D3 coordVals = vt.getCoordinateArray(i); int[] shape = coordVals.getShape(); assert shape[0] == ncd.findDimension("hybrid").getLength(); assert shape[1] == ncd.findDimension("y").getLength(); assert shape[2] == ncd.findDimension("x").getLength(); } ncd.close(); }