public Tinv convertReferenceDate(CalendarDate refDate, CalendarPeriod timeUnit) { if (timeUnit == null) return null; int startOffset = timeUnit.getOffset(refDate, start); // LOOK wrong - not dealing with value ?? int endOffset = timeUnit.getOffset(refDate, end); return new TimeCoord.Tinv(startOffset, endOffset); }
public double getOffsetInTimeUnits(CalendarDate start) { return timeUnit.getOffset(start, getRefDate()); } ////////////////////////////////////////
public double getOffsetInTimeUnits(CalendarDate start, CalendarDate end) { return dateUnit.getCalendarPeriod().getOffset(start, end); }
public double getOffsetInTimeUnits(CalendarDate start) { return timeUnit.getOffset(start, getFirstDate()); }
private int[] makeOffsets(CalendarPeriod period) { CalendarDate firstDate = runtime.getFirstDate(); int[] offsets = new int[nruns]; for (int idx=0; idx<nruns; idx++) { offsets[idx] = period.getOffset(firstDate, runtime.getRuntimeDate(idx)); // LOOK possible loss of precision } return offsets; }
public static void main(String[] args) { CalendarPeriod cp = new CalendarPeriod(1, Field.Day); CalendarDate start = CalendarDate.parseUdunits(null, "3 days since 1970-01-01 12:00"); CalendarDate end = CalendarDate.parseUdunits(null, "6 days since 1970-01-01 12:00"); int offset = cp.getOffset(start, end); System.out.printf("offset=%d%n", offset); } }
private int[] makeOffsets(List<Coordinate> orgTimes) { CalendarDate firstDate = runtime.getFirstDate(); int[] offsets = new int[nruns]; for (int idx=0; idx<nruns; idx++) { CoordinateTimeAbstract coordTime = (CoordinateTimeAbstract) orgTimes.get(idx); CalendarPeriod period = coordTime.getTimeUnit(); // LOOK are we assuming all have same period ?? offsets[idx] = period.getOffset(firstDate, runtime.getRuntimeDate(idx)); // LOOK possible loss of precision } return offsets; }
public static void main(String[] args) { CalendarPeriod cp = new CalendarPeriod(1, Field.Day); CalendarDate start = CalendarDate.parseUdunits(null, "3 days since 1970-01-01 12:00"); CalendarDate end = CalendarDate.parseUdunits(null, "6 days since 1970-01-01 12:00"); int offset = cp.getOffset(start, end); System.out.printf("offset=%d%n", offset); } }
public static void main(String[] args) { CalendarPeriod cp = CalendarPeriod.of(1, Field.Day); CalendarDate start = CalendarDate.parseUdunits(null, "3 days since 1970-01-01 12:00"); CalendarDate end = CalendarDate.parseUdunits(null, "6 days since 1970-01-01 12:00"); int offset = cp.getOffset(start, end); System.out.printf("offset=%d%n", offset); } }
/** * Find the index matching a runtime and time coordinate * @param runIdx which run * @param value time coordinate * @return index in the time coordinate of the value */ public int matchTimeCoordinate(int runIdx, CoordinateTime2D.Time2D value) { CoordinateTimeAbstract time = getTimeCoordinate(runIdx); int offset = timeUnit.getOffset(getRefDate(runIdx), value.getRefDate()); Object valueWithOffset; if (isTimeInterval) { valueWithOffset = value.tinv.offset(offset); } else { valueWithOffset = value.time + offset; } int result = time.getIndex(valueWithOffset); if (Grib.debugRead) System.out.printf(" matchTimeCoordinate value wanted = (%s) valueWithOffset=%s result=%d %n", value, valueWithOffset, result); return result; }