PeriodType getPeriodType() { return getField().p; }
PeriodType getPeriodType() { return getField().p; }
PeriodType getPeriodType() { return getField().p; }
public String getUnits() { if (units != null) return units; CalendarPeriod.Field cf = calendarPeriod.getField(); if (cf == CalendarPeriod.Field.Month || cf == CalendarPeriod.Field.Year) return "calendar "+ cf.toString() + " since " + runDate; else return calendarPeriod.getField().toString() + " since " + runDate; }
DurationFieldType getDurationFieldType() { return getField().p.getFieldType(0); }
DurationFieldType getDurationFieldType() { return getField().p.getFieldType(0); }
DurationFieldType getDurationFieldType() { return getField().p.getFieldType(0); }
public CoordinateRuntime(List<Long> runtimeSorted, CalendarPeriod timeUnit) { this.runtimes = new long[runtimeSorted.size()]; int idx = 0; for (long val : runtimeSorted) this.runtimes[idx++] = val; this.firstDate = CalendarDate.of(runtimeSorted.get(0)); this.timeUnit = timeUnit == null ? CalendarPeriod.Hour : timeUnit; CalendarPeriod.Field cf = this.timeUnit.getField(); if (cf == CalendarPeriod.Field.Month || cf == CalendarPeriod.Field.Year) this.periodName = "calendar "+ cf.toString(); else this.periodName = cf.toString(); }
CoordinateTimeAbstract(int code, CalendarPeriod timeUnit, CalendarDate refDate, int[] time2runtime) { this.code = code; this.timeUnit = timeUnit; this.refDate = (cdf == null) ? refDate : cdf.get(refDate); this.time2runtime = time2runtime; CalendarPeriod.Field cf = timeUnit.getField(); if (cf == CalendarPeriod.Field.Month || cf == CalendarPeriod.Field.Year) this.periodName = "calendar "+ cf.toString(); else this.periodName = cf.toString(); }
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(); }
static public CalendarDateFormatter factory(CalendarPeriod period) { switch (period.getField()) { case Year: return new CalendarDateFormatter("yyyy"); case Month: return new CalendarDateFormatter("yyyy-MM"); case Day: return new CalendarDateFormatter("yyyy-MM-dd"); case Hour: return new CalendarDateFormatter("yyyy-MM-ddTHH"); default: return new CalendarDateFormatter("yyyy-MM-ddTHH:mm:ss"); } }
/** * 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); }
@Override public TimeCoord.TinvDate getForecastTimeInterval(Grib2Record gr) { Grib2Pds pds = gr.getPDS(); if (!pds.isTimeInterval()) return null; int[] intv = getForecastTimeIntervalOffset(gr); assert intv != null; int intvLen = intv[1]-intv[0]; int timeUnitOrg = pds.getTimeUnit(); int timeUnitConvert = convertTimeUnit(timeUnitOrg); CalendarPeriod unitPeriod = Grib2Utils.getCalendarPeriod(timeUnitConvert); if (unitPeriod == null) throw new IllegalArgumentException("unknown CalendarPeriod "+timeUnitConvert+ " org="+timeUnitOrg); CalendarPeriod.Field fld = unitPeriod.getField(); CalendarDate start = gr.getReferenceDate().add(intv[0], fld); CalendarPeriod period = CalendarPeriod.of(intvLen, fld); return new TimeCoord.TinvDate(start, 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 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); }
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])}; }