/** * Check whether the Y axis need to be flipped. Note that the method is synchronized since it * access the underlying Variable * * @param axis * @return * @throws IOException */ private synchronized boolean needFlipYAxis(CoordinateAxis axis) throws IOException { boolean flipYAxis = false; try { Array yAxisStart = axis.read(new Section().appendRange(2)); float y1 = yAxisStart.getFloat(0); float y2 = yAxisStart.getFloat(1); if (y2 > y1) { flipYAxis = true; } } catch (InvalidRangeException e) { throw new RuntimeException(e); } return flipYAxis; }
/** get the Azimuth axis data. Calling this will force the data to be cached. */ public Array getAzimuthAxisDataCached() throws IOException { if (aziData == null) aziData = aziAxis.read(); return aziData; }
/** get the Radial axis data. Calling this will force the data to be cached. */ public Array getRadialAxisDataCached() throws IOException { if (radialData == null) radialData = radialAxis.read(); return radialData; }
/** get the Elevation axis data. Calling this will force the data to be cached. */ public Array getElevationAxisDataCached() throws IOException { if (elevData == null) elevData = elevAxis.read(); return elevData; }
/** get the Radial axis data. Calling this will force the data to be cached. */ public Array getRadialAxisDataCached() throws IOException { if (radialData == null) radialData = radialAxis.read(); return radialData; }
/** get the Time axis data. Calling this will force the data to be cached. */ public Array getTimeAxisDataCached() throws IOException { if (timeData == null) timeData = timeAxis.read(); return timeData; }
/** get the Azimuth axis data. Calling this will force the data to be cached. */ public Array getAzimuthAxisDataCached() throws IOException { if (aziData == null) aziData = aziAxis.read(); return aziData; }
/** get the Elevation axis data. Calling this will force the data to be cached. */ public Array getElevationAxisDataCached() throws IOException { if (elevData == null) elevData = elevAxis.read(); return elevData; }
/** get the Radial axis data. Calling this will force the data to be cached. */ public Array getRadialAxisDataCached() throws IOException { if (radialData == null) radialData = radialAxis.read(); return radialData; }
/** get the Azimuth axis data. Calling this will force the data to be cached. */ public Array getAzimuthAxisDataCached() throws IOException { if (aziData == null) aziData = aziAxis.read(); return aziData; }
/** get the Elevation axis data. Calling this will force the data to be cached. */ public Array getElevationAxisDataCached() throws IOException { if (elevData == null) elevData = elevAxis.read(); return elevData; }
/** get the Time axis data. Calling this will force the data to be cached. */ public Array getTimeAxisDataCached() throws IOException { if (timeData == null) timeData = timeAxis.read(); return timeData; }
/** get the Time axis data. Calling this will force the data to be cached. */ public Array getTimeAxisDataCached() throws IOException { if (timeData == null) timeData = timeAxis.read(); return timeData; }
private void init() { try { Array data = read(); minmax = MAMath.getMinMax(data); } catch (IOException ioe) { log.error("Error reading coordinate values ", ioe); throw new IllegalStateException(ioe); } }
private void init() { try { Array data = read(); minmax = MAMath.getMinMax(data); } catch (IOException ioe) { log.error("Error reading coordinate values ", ioe); throw new IllegalStateException(ioe); } }
private void init() { try { Array data = read(); minmax = MAMath.getMinMax(data); } catch (IOException ioe) { log.error("Error reading coordinate values ", ioe); throw new IllegalStateException(ioe); } }
/** * testing */ public static void main(String arg[]) throws IOException { String defaultFilename = "C:/data/rap/fmrc.xml"; String filename = (arg.length > 0) ? arg[0] : defaultFilename; GridDataset gds = ucar.nc2.dt.grid.GridDataset.open(filename); GridDatatype gg = gds.findGridDatatype("T"); GridCoordSystem gsys = gg.getCoordinateSystem(); // gsys.getTimeAxisForRun(1); // generate error CoordinateAxis1DTime rtaxis = gsys.getRunTimeAxis(); CoordinateAxis taxis2D = gsys.getTimeAxis(); Array data = taxis2D.read(); NCdump.printArray(data, "2D time array", System.out, null); System.out.println("Run Time, Valid Times"); List<CalendarDate> runtimes = rtaxis.getCalendarDates(); for (int i = 0; i < runtimes.size(); i++) { System.out.println("\n" + runtimes.get(i)); CoordinateAxis1DTime taxis = gsys.getTimeAxisForRun(i); List<CalendarDate> times = taxis.getCalendarDates(); for (int j = 0; j < times.size(); j++) { System.out.println(" " + times.get(j)); } } }
/** * Check whether the Y axis need to be flipped. Note that the method is synchronized since it * access the underlying Variable * * @param axis * @return * @throws IOException */ private synchronized boolean needFlipYAxis(CoordinateAxis axis) throws IOException { boolean flipYAxis = false; try { Array yAxisStart = axis.read(new Section().appendRange(2)); float y1 = yAxisStart.getFloat(0); float y2 = yAxisStart.getFloat(1); if (y2 > y1) { flipYAxis = true; } } catch (InvalidRangeException e) { throw new RuntimeException(e); } return flipYAxis; }
@Test public void testWrfTimeUnderscore() throws IOException { String tstFile = TestDir.cdmLocalTestDataDir +"wrf/WrfTimesStrUnderscore.nc"; System.out.println(tstFile); String wrfConvention = new WRFConvention().getConventionUsed(); NetcdfDataset ncd = NetcdfDataset.openDataset(tstFile); // make sure this file went through the WrfConvention assert ncd.getConventionUsed().equals(wrfConvention); CoordinateAxis tca = ncd.findCoordinateAxis(AxisType.Time); Array times = tca.read(); ncd.close(); // if the date/time string cannot be parsed (in this case, 2008-06-27_00:00:00) // the the time will come back as 0 seconds after going through the WRFConvention // coordinate system builder class. assert times.getInt(0) != 0; // first date in this file is 1214524800 [seconds since 1970-01-01T00:00:00], // which is 2008-06-27 00:00:00 assert times.getInt(0) == 1214524800; }
@Test public void testSingleDataset() throws IOException { Catalog cat = TdsLocalCatalog.open(null); Dataset ds = cat.findDatasetByID("testDataset2"); assert (ds != null) : "cant find dataset 'testDataset'"; assert ds.getFeatureType() == FeatureType.GRID; DataFactory fac = new DataFactory(); try (DataFactory.Result dataResult = fac.openFeatureDataset(ds, null)) { Assert.assertTrue(dataResult.errLog.toString(), !dataResult.fatalError); Assert.assertNotNull(dataResult.featureDataset); Assert.assertEquals( ucar.nc2.dt.grid.GridDataset.class, dataResult.featureDataset.getClass()); ucar.nc2.dt.grid.GridDataset gds = ( ucar.nc2.dt.grid.GridDataset) dataResult.featureDataset; String gridName = "Z_sfc"; VariableSimpleIF vs = gds.getDataVariable(gridName); Assert.assertNotNull(gridName, vs); GeoGrid grid = gds.findGridByShortName(gridName); Assert.assertNotNull(gridName, grid); GridCoordSystem gcs = grid.getCoordinateSystem(); Assert.assertNotNull(gcs); assert null == gcs.getVerticalAxis(); CoordinateAxis time = gcs.getTimeAxis(); Assert.assertNotNull("time axis", time); Assert.assertEquals(1, time.getSize()); Array data = time.read(); Assert2.assertNearlyEquals(102840.0, data.getFloat(0)); } }