public String getUnit(){ return coordinateAxis.getUnitsString(); }
/** * Returns the units as a string. If the axis direction or the time epoch * was appended to the units, then this part of the string is removed. */ private String getUnitsString() { String symbol = axis.getUnitsString(); if (symbol != null) { int i = symbol.lastIndexOf('_'); if (i > 0) { final String direction = getDirection().name(); if (symbol.regionMatches(true, i+1, direction, 0, direction.length())) { symbol = symbol.substring(0, i).trim(); } } i = symbol.indexOf(" since "); if (i > 0) { symbol = symbol.substring(0, i); } symbol = symbol.trim(); } return symbol; }
/** * Get the list of level names, to be used for user selection. * The ith one refers to the ith level coordinate. * * @return List of ucar.nc2.util.NamedObject, or empty list. */ public List<NamedObject> getLevels() { if (vertZaxis == null) return new ArrayList<>(0); int n = (int) vertZaxis.getSize(); List<NamedObject> levels = new ArrayList<>(n); for (int i = 0; i < n; i++) levels.add(new ucar.nc2.util.NamedAnything(vertZaxis.getCoordName(i), vertZaxis.getUnitsString())); return levels; }
/** * Get the list of level names, to be used for user selection. * The ith one refers to the ith level coordinate. * * @return List of ucar.nc2.util.NamedObject, or empty list. */ public List<NamedObject> getLevels() { if (vertZaxis == null) return new ArrayList<>(0); int n = (int) vertZaxis.getSize(); List<NamedObject> levels = new ArrayList<>(n); for (int i = 0; i < n; i++) levels.add(new ucar.nc2.util.NamedAnything(vertZaxis.getCoordName(i), vertZaxis.getUnitsString())); return levels; }
/** * Get the list of level names, to be used for user selection. * The ith one refers to the ith level coordinate. * * @return List of ucar.nc2.util.NamedObject, or empty list. */ public List<NamedObject> getLevels() { if (vertZaxis == null) return new ArrayList<NamedObject>(0); int n = (int) vertZaxis.getSize(); List<NamedObject> levels = new ArrayList<NamedObject>(n); for (int i = 0; i < n; i++) levels.add(new ucar.nc2.util.NamedAnything(vertZaxis.getCoordName(i), vertZaxis.getUnitsString())); return levels; }
/** * Get the list of names, to be used for user selection. * The ith one refers to the ith coordinate. * * @return List of ucar.nc2.util.NamedObject, or empty list. */ public List<NamedObject> getNames() { int n = getDimension(0).getLength(); List<NamedObject> names = new ArrayList<>(n); for (int i = 0; i < n; i++) names.add(new ucar.nc2.util.NamedAnything(getCoordName(i), getUnitsString())); return names; }
/** * Get the list of names, to be used for user selection. * The ith one refers to the ith coordinate. * * @return List of ucar.nc2.util.NamedObject, or empty list. */ public List<NamedObject> getNames() { int n = (int) getDimension(0).getLength(); List<NamedObject> names = new ArrayList<NamedObject>(n); for (int i = 0; i < n; i++) names.add(new ucar.nc2.util.NamedAnything(getCoordName(i), getUnitsString())); return names; }
/** * Get the list of names, to be used for user selection. * The ith one refers to the ith coordinate. * * @return List of ucar.nc2.util.NamedObject, or empty list. */ public List<NamedObject> getNames() { int n = getDimension(0).getLength(); List<NamedObject> names = new ArrayList<>(n); for (int i = 0; i < n; i++) names.add(new ucar.nc2.util.NamedAnything(getCoordName(i), getShortName() + " " + getUnitsString())); return names; }
TimeCoord(Date runDate, CoordinateAxis1D axis) { this.axis = axis; DateUnit unit = null; try { unit = new DateUnit(axis.getUnitsString()); } catch (Exception e) { throw new IllegalArgumentException("Not a unit of time "+axis.getUnitsString()); } int n = (int) axis.getSize(); offset = new double[n]; for (int i = 0; i < axis.getSize(); i++) { Date d = unit.makeDate(axis.getCoordValue(i)); offset[i] = getOffsetInHours(runDate, d); } }
@Override public CoordinateAxis copyNoCache() { CoordinateAxis1D axis = new CoordinateAxis1D(ncd, getParentGroup(), getShortName(), getDataType(), getDimensionsString(), getUnitsString(), getDescription()); // other state axis.axisType = this.axisType; axis.boundaryRef = this.boundaryRef; axis.isContiguous = this.isContiguous; axis.positive = this.positive; axis.cache = new Variable.Cache(); // decouple cache return axis; }
@Override public CoordinateAxis copyNoCache() { CoordinateAxis1D axis = new CoordinateAxis1D(ncd, getParentGroup(), getShortName(), getDataType(), getDimensionsString(), getUnitsString(), getDescription()); // other state axis.axisType = this.axisType; axis.boundaryRef = this.boundaryRef; axis.isContiguous = this.isContiguous; axis.positive = this.positive; axis.cache = new Variable.Cache(); // decouple cache return axis; }
@Override public CoordinateAxis copyNoCache() { CoordinateAxis1D axis = new CoordinateAxis1D(ncd, getParentGroup(), getShortName(), getDataType(), getDimensionsString(), getUnitsString(), getDescription()); // other state axis.axisType = this.axisType; axis.boundaryRef = this.boundaryRef; axis.isContiguous = this.isContiguous; axis.positive = this.positive; axis.cache = new Variable.Cache(); // decouple cache return axis; }
VertCoord(CoordinateAxis1D axis) { // this.axis = axis; this.name = axis.getFullName(); this.units = axis.getUnitsString(); int n = (int) axis.getSize(); if (axis.isInterval()) { values1 = axis.getBound1(); values2 = axis.getBound2(); } else { values1 = new double[n]; for (int i = 0; i < axis.getSize(); i++) values1[i] = axis.getCoordValue(i); } }
VertCoord(CoordinateAxis1D axis) { this.axis = axis; this.name = axis.getFullName(); this.units = axis.getUnitsString(); int n = (int) axis.getSize(); if (axis.isInterval()) { values1 = axis.getBound1(); values2 = axis.getBound2(); } else { values1 = new double[n]; for (int i = 0; i < axis.getSize(); i++) values1[i] = axis.getCoordValue(i); } }
VertCoord(CoordinateAxis1D axis) { // this.axis = axis; this.name = axis.getFullName(); this.units = axis.getUnitsString(); int n = (int) axis.getSize(); if (axis.isInterval()) { values1 = axis.getBound1(); values2 = axis.getBound2(); } else { values1 = new double[n]; for (int i = 0; i < axis.getSize(); i++) values1[i] = axis.getCoordValue(i); } }
public void setVertical(CoordinateAxis1D vaxis) { int n = (int) vaxis.getSize(); double size = vaxis.getCoordValue(n - 1) - vaxis.getCoordValue(0); double resolution = vaxis.getIncrement(); String units = vaxis.getUnitsString(); this.updown = new Range(vaxis.getCoordValue(0), size, resolution, units); if (units != null) { setZPositiveUp(SimpleUnit.isCompatible("m", units)); } }
VertCoord(CoordinateAxis1D axis) { // this.axis = axis; this.name = axis.getFullName(); this.units = axis.getUnitsString(); int n = (int) axis.getSize(); if (axis.isInterval()) { values1 = axis.getBound1(); values2 = axis.getBound2(); } else { values1 = new double[n]; for (int i = 0; i < axis.getSize(); i++) values1[i] = axis.getCoordValue(i); } }
public void setVertical(CoordinateAxis1D vaxis) { int n = (int) vaxis.getSize(); double size = vaxis.getCoordValue(n - 1) - vaxis.getCoordValue(0); double resolution = vaxis.getIncrement(); String units = vaxis.getUnitsString(); this.updown = new Range(vaxis.getCoordValue(0), size, resolution, units); if (units != null) { setZPositiveUp(SimpleUnit.isCompatible("m", units)); } }
public void setVertical(CoordinateAxis1D vaxis) { int n = (int) vaxis.getSize(); double size = vaxis.getCoordValue(n - 1) - vaxis.getCoordValue(0); double resolution = vaxis.getIncrement(); String units = vaxis.getUnitsString(); this.updown = new Range(vaxis.getCoordValue(0), size, resolution, units); if (units != null) { setZPositiveUp(SimpleUnit.isCompatible("m", units)); } }
@Test public void testBestOffsetGE() throws IOException { FeatureCollectionConfig config = new FeatureCollectionConfig("espresso_2013_da_his_fmrc_offset_with_Offset_in_filename", "DavidRobertson", FeatureCollectionType.FMRC, TestDir.cdmUnitTestDir + "ft/fmrc/espresso/.*.nc$", null, "#espresso_his_#yyyyMMdd_HHmm", null, null, null); config.fmrcConfig.regularize=false; config.fmrcConfig.addBestDataset("Best", 26); Formatter errlog = new Formatter(); Fmrc fmrc = Fmrc.open(config, errlog); assert (fmrc != null) : errlog; FeatureCollectionConfig.BestDataset bd = new FeatureCollectionConfig.BestDataset("Best", 26); try (ucar.nc2.dt.GridDataset gridDs = fmrc.getDatasetBest(bd)) { GridDatatype grid = gridDs.findGridByShortName("salt"); GridCoordSystem gcs = grid.getCoordinateSystem(); CoordinateAxis1D timeAxis = gcs.getTimeAxis1D(); logger.debug("timeAxis = {} {}", NCdumpW.toString(timeAxis.read()), timeAxis.getUnitsString()); CoordinateAxis1D runAxis = gcs.getRunTimeAxis(); logger.debug("runAxis = {} {}", NCdumpW.toString( runAxis.read()), runAxis.getUnitsString()); CalendarDate expected = CalendarDate.parseISOformat(null, "2013-05-05T00:00:00"); CalendarDateUnit cdu = CalendarDateUnit.of(null, timeAxis.getUnitsString()); Assert.assertEquals(expected, cdu.getBaseCalendarDate()); CalendarDateUnit cdu2 = CalendarDateUnit.of(null, runAxis.getUnitsString()); Assert.assertEquals(expected, cdu2.getBaseCalendarDate()); for (int i=0; i<runAxis.getSize(); i++) { Assert.assertEquals("run coord", i<12 ? 0 : 24, runAxis.getCoordValue(i), 1.0e-8); } } }