@Override public CalendarDateRange makeCalendarDateRange(ucar.nc2.time.Calendar cal) { CalendarDateUnit cdu = CalendarDateUnit.withCalendar(cal, periodName + " since " + refDate.toString()); CalendarDate start = cdu.makeCalendarDate(timeUnit.getValue() * offsetSorted.get(0)); CalendarDate end = cdu.makeCalendarDate(timeUnit.getValue() * offsetSorted.get(getSize() - 1)); return CalendarDateRange.of(start, end); }
public CalendarDate add(CalendarPeriod period) { switch (period.getField()) { case Millisec: return new CalendarDate(cal, dateTime.plusMillis( period.getValue() )); case Second: return new CalendarDate(cal, dateTime.plusSeconds( period.getValue() )); case Minute: return new CalendarDate(cal, dateTime.plusMinutes(period.getValue())); case Hour: return new CalendarDate(cal, dateTime.plusHours(period.getValue())); case Day: return new CalendarDate(cal, dateTime.plusDays( period.getValue() )); case Month: return new CalendarDate(cal, dateTime.plusMonths( period.getValue() )); case Year: return new CalendarDate(cal, dateTime.plusYears( period.getValue() )); } throw new UnsupportedOperationException("period units = "+period); }
public CalendarDate subtract(CalendarPeriod period) { switch (period.getField()) { case Millisec: return new CalendarDate(cal, dateTime.minusMillis( period.getValue() )); case Second: return new CalendarDate(cal, dateTime.minusSeconds( period.getValue() )); case Minute: return new CalendarDate(cal, dateTime.minusMinutes(period.getValue())); case Hour: return new CalendarDate(cal, dateTime.minusHours(period.getValue())); case Day: return new CalendarDate(cal, dateTime.minusDays( period.getValue() )); case Month: return new CalendarDate(cal, dateTime.minusMonths( period.getValue() )); case Year: return new CalendarDate(cal, dateTime.minusYears( period.getValue() )); } throw new UnsupportedOperationException("period units = "+period); }
public CalendarDate add(CalendarPeriod period) { switch (period.getField()) { case Millisec: return new CalendarDate(cal, dateTime.plusMillis(period.getValue())); case Second: return new CalendarDate(cal, dateTime.plusSeconds(period.getValue())); case Minute: return new CalendarDate(cal, dateTime.plusMinutes(period.getValue())); case Hour: return new CalendarDate(cal, dateTime.plusHours(period.getValue())); case Day: return new CalendarDate(cal, dateTime.plusDays(period.getValue())); case Month: return new CalendarDate(cal, dateTime.plusMonths(period.getValue())); case Year: return new CalendarDate(cal, dateTime.plusYears(period.getValue())); } throw new UnsupportedOperationException("period units = "+period); }
public CalendarDate subtract(CalendarPeriod period) { switch (period.getField()) { case Millisec: return new CalendarDate(cal, dateTime.minusMillis(period.getValue())); case Second: return new CalendarDate(cal, dateTime.minusSeconds(period.getValue())); case Minute: return new CalendarDate(cal, dateTime.minusMinutes(period.getValue())); case Hour: return new CalendarDate(cal, dateTime.minusHours(period.getValue())); case Day: return new CalendarDate(cal, dateTime.minusDays(period.getValue())); case Month: return new CalendarDate(cal, dateTime.minusMonths(period.getValue())); case Year: return new CalendarDate(cal, dateTime.minusYears(period.getValue())); } throw new UnsupportedOperationException("period units = "+period); }
public CalendarDate subtract(CalendarPeriod period) { switch (period.getField()) { case Millisec: return new CalendarDate(cal, dateTime.minusMillis( period.getValue() )); case Second: return new CalendarDate(cal, dateTime.minusSeconds( period.getValue() )); case Minute: return new CalendarDate(cal, dateTime.minusMinutes(period.getValue())); case Hour: return new CalendarDate(cal, dateTime.minusHours(period.getValue())); case Day: return new CalendarDate(cal, dateTime.minusDays( period.getValue() )); case Month: return new CalendarDate(cal, dateTime.minusMonths( period.getValue() )); case Year: return new CalendarDate(cal, dateTime.minusYears( period.getValue() )); } throw new UnsupportedOperationException("period units = "+period); }
public CalendarDate add(CalendarPeriod period) { switch (period.getField()) { case Millisec: return new CalendarDate(cal, dateTime.plusMillis( period.getValue() )); case Second: return new CalendarDate(cal, dateTime.plusSeconds( period.getValue() )); case Minute: return new CalendarDate(cal, dateTime.plusMinutes(period.getValue())); case Hour: return new CalendarDate(cal, dateTime.plusHours(period.getValue())); case Day: return new CalendarDate(cal, dateTime.plusDays( period.getValue() )); case Month: return new CalendarDate(cal, dateTime.plusMonths( period.getValue() )); case Year: return new CalendarDate(cal, dateTime.plusYears( period.getValue() )); } throw new UnsupportedOperationException("period units = "+period); }
/** * Make calendar date range, using the first and last ending bounds * @param cal optional calendar, may be null * @return calendar date range */ @Override public CalendarDateRange makeCalendarDateRange(ucar.nc2.time.Calendar cal) { CalendarDateUnit cdu = CalendarDateUnit.of(cal, timeUnit.getField(), refDate); CalendarDate start = cdu.makeCalendarDate( timeUnit.getValue() * timeIntervals.get(0).getBounds2()); CalendarDate end = cdu.makeCalendarDate(timeUnit.getValue() * timeIntervals.get(getSize()-1).getBounds2()); return CalendarDateRange.of(start, end); }
public String getTimeIntervalName() { if (!isInterval()) return null; // are they the same length ? int firstValue = -1; boolean same = true; for (Tinv tinv : intervals) { int value = (tinv.b2 - tinv.b1); if (firstValue < 0) firstValue = value; else if (value != firstValue) same = false; } if (same) { firstValue = (firstValue * calendarPeriod.getValue()); return firstValue + "_" + calendarPeriod.getField().toString(); } else { return CoordinateTimeAbstract.MIXED_INTERVALS; } }
/** * Check if we all time intervals have the same length. * @return time interval name or MIXED_INTERVALS */ public String getTimeIntervalName() { // are they the same length ? int firstValue = -1; for (TimeCoord.Tinv tinv : timeIntervals) { int value = (tinv.getBounds2() - tinv.getBounds1()); if (firstValue < 0) firstValue = value; else if (value != firstValue) return MIXED_INTERVALS; } firstValue = (firstValue * timeUnit.getValue()); return firstValue + "_" + timeUnit.getField().toString(); }
private String makeTimeCoord(Grib1ParamTime ptime) { CalendarPeriod period = GribUtils.getCalendarPeriod(getTimeUnit()); CalendarDateUnit unit = CalendarDateUnit.of(null, period.getField(), getReferenceDate()); int timeCoord; if (ptime.isInterval()) { int[] intv = ptime.getInterval(); CalendarDate cdate1 = unit.makeCalendarDate(period.getValue() * intv[0]); CalendarDate cdate2 = unit.makeCalendarDate(period.getValue() * intv[1]); return "(" + cdate1.toString() + "," + cdate2.toString() + ")"; } else { timeCoord = ptime.getForecastTime(); CalendarDate cdate = unit.makeCalendarDate(period.getValue() * timeCoord); return cdate.toString(); } }
public CalendarDate[] getForecastInterval(Grib1SectionProductDefinition pds, Grib1ParamTime ptime) { CalendarPeriod period = GribUtils.getCalendarPeriod(pds.getTimeUnit()); CalendarDateUnit unit = CalendarDateUnit.of(null, period.getField(), pds.getReferenceDate()); int[] intv = ptime.getInterval(); return new CalendarDate[]{ unit.makeCalendarDate(period.getValue() * intv[0]), unit.makeCalendarDate(period.getValue() * intv[1])}; }
int timeIdx = 0; for (int val : coordTime.getOffsetSorted()) { data[runIdx * ntimes + timeIdx] = timeUnit.getValue() * val + time2D.getOffset(runIdx); timeIdx++; CoordinateTime coordTime = (CoordinateTime) time2D.getTimeCoordinate(runIdx); for (int val : coordTime.getOffsetSorted()) data[count++] = timeUnit.getValue() * val + time2D.getOffset(runIdx); int timeIdx = 0; for (TimeCoord.Tinv tinv : timeIntv.getTimeIntervals()) { data[runIdx * ntimes + timeIdx] = timeUnit.getValue() * tinv.getBounds2() + time2D.getOffset(runIdx); // use upper bounds for coord value timeIdx++; CoordinateTimeIntv timeIntv = (CoordinateTimeIntv) time2D.getTimeCoordinate(runIdx); for (TimeCoord.Tinv tinv : timeIntv.getTimeIntervals()) { data[count++] = timeUnit.getValue() * tinv.getBounds2() + time2D.getOffset(runIdx); // use upper bounds for coord value int timeIdx = 0; for (TimeCoord.Tinv tinv : timeIntv.getTimeIntervals()) { data[runIdx * ntimes * 2 + timeIdx] = timeUnit.getValue() * tinv.getBounds1() + time2D.getOffset(runIdx); data[runIdx * ntimes * 2 + timeIdx + 1] = timeUnit.getValue() * tinv.getBounds2() + time2D.getOffset(runIdx); timeIdx += 2; CoordinateTimeIntv timeIntv = (CoordinateTimeIntv) time2D.getTimeCoordinate(runIdx); for (TimeCoord.Tinv tinv : timeIntv.getTimeIntervals()) { data[count++] = timeUnit.getValue() * tinv.getBounds1() + time2D.getOffset(runIdx); data[count++] = timeUnit.getValue() * tinv.getBounds2() + time2D.getOffset(runIdx);
public CalendarDate getForecastDate(Grib1SectionProductDefinition pds, Grib1ParamTime ptime) { CalendarPeriod period = GribUtils.getCalendarPeriod(pds.getTimeUnit()); CalendarDateUnit unit = CalendarDateUnit.of(null, period.getField(), pds.getReferenceDate()); int timeCoord = ptime.getForecastTime(); return unit.makeCalendarDate(period.getValue() * timeCoord); }
CoordinateTimeIntv timeIntv = (CoordinateTimeIntv) time2D.getTimeCoordinate(runIdx); for (TimeCoord.Tinv tinv : timeIntv.getTimeIntervals()) { values[count++] = timeUnit.getValue() * tinv.getBounds1() + time2D.getOffset(runIdx); values[count++] = timeUnit.getValue() * tinv.getBounds2() + time2D.getOffset(runIdx); CoordinateTime coordTime = (CoordinateTime) time2D.getTimeCoordinate(runIdx); for (int val : coordTime.getOffsetSorted()) { double b1 = timeUnit.getValue() * val + time2D.getOffset(runIdx); values[count++] = b1;