/** * only if isRegular() LOOK REDO * * @return time unit * @throws Exception on bad unit string */ public TimeUnit getTimeResolution() throws Exception { String tUnits = getUnitsString(); StringTokenizer stoker = new StringTokenizer(tUnits); double tResolution = getIncrement(); return new TimeUnit(tResolution, stoker.nextToken()); }
/** * only if isRegular() LOOK REDO * * @return time unit * @throws Exception on bad unit string */ public TimeUnit getTimeResolution() throws Exception { String tUnits = getUnitsString(); StringTokenizer stoker = new StringTokenizer(tUnits); double tResolution = getIncrement(); return new TimeUnit(tResolution, stoker.nextToken()); }
/** * only if isRegular() LOOK REDO * * @return time unit * @throws Exception on bad unit string */ public TimeUnit getTimeResolution() throws Exception { String tUnits = getUnitsString(); StringTokenizer stoker = new StringTokenizer(tUnits); double tResolution = getIncrement(); return new TimeUnit(tResolution, stoker.nextToken()); }
TimeCoord(CalendarDate runDate, CoordinateAxis1DTime axis) { this.runDate = runDate; this.axisName = axis.getFullName(); 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(); if (axis.isInterval()) { this.isInterval = true; this.bound1 = new double[n]; this.bound2 = new double[n]; double[] orgBound1 = axis.getBound1(); double[] orgBound2 = axis.getBound2(); this.bound2 = new double[n]; for (int i = 0; i < axis.getSize(); i++) { this.bound1[i] = getValueInHours(unit, orgBound1[i]); this.bound2[i] = getValueInHours(unit, orgBound2[i]); } } else { offset = new double[n]; for (int i = 0; i < axis.getSize(); i++) { offset[i] = getValueInHours(unit, axis.getCoordValue(i)); } } }
unit = new DateUnit(axis.getUnitsString()); atrCal = axis.findAttribute(CF.CALENDAR ); if(atrCal != null) throw new IllegalArgumentException("Not a unit of time " + axis.getUnitsString());
unit = new DateUnit(axis.getUnitsString()); atrCal = axis.findAttribute(CF.CALENDAR ); if(atrCal != null) throw new IllegalArgumentException("Not a unit of time " + axis.getUnitsString());
CalendarDateUnit dateUnit = CalendarDateUnit.withCalendar(calendar, getUnitsString()); // this will throw exception on failure
this.helper= new CoordinateAxisTimeHelper(getCalendarFromAttribute(), getUnitsString());
this.helper= new CoordinateAxisTimeHelper(getCalendarFromAttribute(), getUnitsString());
@Test public void testFloatingPointCompare() throws Exception { String spec = TestDir.cdmUnitTestDir+"ft/fmrc/fp_precision/sediment_thickness_#yyMMddHHmm#.*\\.nc$"; System.out.printf("%n====================FMRC dataset %s%n", spec); Formatter errlog = new Formatter(); Fmrc fmrc = Fmrc.open(spec, errlog); assert (fmrc != null) : errlog; try (ucar.nc2.dt.GridDataset gridDs = fmrc.getDatasetBest()) { GridDatatype v = gridDs.findGridByShortName("thickness_of_sediment"); assert v != null; GridCoordSystem gcs = v.getCoordinateSystem(); CoordinateAxis1DTime time = gcs.getTimeAxis1D(); Assert.assertEquals("hours since 2015-03-08 12:51:00.000 UTC", time.getUnitsString()); Assert.assertEquals(74, time.getSize()); Array data = time.read(); logger.debug("{}", NCdumpW.toString(data)); for (CalendarDate cd : time.getCalendarDates()) { assert cd.getFieldValue(CalendarPeriod.Field.Minute) == 0 : System.out.printf("%s%n", cd); } } } }