/** * Does not handle non-standard Calendars * @deprecated use getCalendarDate() */ public java.util.Date getTimeDate (int idx) { return getCalendarDate(idx).toDate(); }
/** * Does not handle non-standard Calendars * @deprecated use getCalendarDate() */ public java.util.Date getTimeDate (int idx) { return getCalendarDate(idx).toDate(); }
/** * Does not handle non-standard Calendars * @deprecated use getCalendarDate() */ public java.util.Date getTimeDate (int idx) { return getCalendarDate(idx).toDate(); }
private Range makeTimeRange(CalendarDateRange dateRange, CoordinateAxis1DTime timeAxis, int stride_time) throws InvalidRangeException { Range timeRange = null; if ((dateRange != null) && (timeAxis != null)) { int startIndex = timeAxis.findTimeIndexFromCalendarDate(dateRange.getStart()); int endIndex = timeAxis.findTimeIndexFromCalendarDate(dateRange.getEnd()); if (startIndex < 0) throw new InvalidRangeException("start time=" + dateRange.getStart() + " must be >= " + timeAxis.getCalendarDate(0)); if (endIndex < 0) throw new InvalidRangeException("end time=" + dateRange.getEnd() + " must be >= " + timeAxis.getCalendarDate(0)); if (stride_time <= 1) stride_time = 1; timeRange = new Range(startIndex, endIndex, stride_time); } return timeRange; }
private Range makeTimeRange(CalendarDateRange dateRange, CoordinateAxis1DTime timeAxis, int stride_time) throws InvalidRangeException { Range timeRange = null; if ((dateRange != null) && (timeAxis != null)) { int startIndex = timeAxis.findTimeIndexFromCalendarDate(dateRange.getStart()); int endIndex = timeAxis.findTimeIndexFromCalendarDate(dateRange.getEnd()); if (startIndex < 0) throw new InvalidRangeException("start time=" + dateRange.getStart() + " must be >= " + timeAxis.getCalendarDate(0)); if (endIndex < 0) throw new InvalidRangeException("end time=" + dateRange.getEnd() + " must be >= " + timeAxis.getCalendarDate(0)); if (stride_time <= 1) stride_time = 1; timeRange = new Range(startIndex, endIndex, stride_time); } return timeRange; }
private Range makeTimeRange(CalendarDateRange dateRange, CoordinateAxis1DTime timeAxis, int stride_time) throws InvalidRangeException { Range timeRange = null; if ((dateRange != null) && (timeAxis != null)) { int startIndex = timeAxis.findTimeIndexFromCalendarDate(dateRange.getStart()); int endIndex = timeAxis.findTimeIndexFromCalendarDate(dateRange.getEnd()); if (startIndex < 0) throw new InvalidRangeException("start time=" + dateRange.getStart() + " must be >= " + timeAxis.getCalendarDate(0)); if (endIndex < 0) throw new InvalidRangeException("end time=" + dateRange.getEnd() + " must be >= " + timeAxis.getCalendarDate(0)); if (stride_time <= 1) stride_time = 1; timeRange = new Range(startIndex, endIndex, stride_time); } return timeRange; }
private Range makeTimeRange(CalendarDateRange dateRange, CoordinateAxis1DTime timeAxis, int stride_time) throws InvalidRangeException { Range timeRange = null; if ((dateRange != null) && (timeAxis != null)) { int startIndex = timeAxis.findTimeIndexFromCalendarDate(dateRange.getStart()); int endIndex = timeAxis.findTimeIndexFromCalendarDate(dateRange.getEnd()); if (startIndex < 0) throw new InvalidRangeException("start time=" + dateRange.getStart() + " must be >= " + timeAxis.getCalendarDate(0)); if (endIndex < 0) throw new InvalidRangeException("end time=" + dateRange.getEnd() + " must be >= " + timeAxis.getCalendarDate(0)); if (stride_time <= 1) stride_time = 1; timeRange = new Range(startIndex, endIndex, stride_time); } return timeRange; }
private Range makeTimeRange(CalendarDateRange dateRange, CoordinateAxis1DTime timeAxis, int stride_time) throws InvalidRangeException { Range timeRange = null; if ((dateRange != null) && (timeAxis != null)) { int startIndex = timeAxis.findTimeIndexFromCalendarDate(dateRange.getStart()); int endIndex = timeAxis.findTimeIndexFromCalendarDate(dateRange.getEnd()); if (startIndex < 0) throw new InvalidRangeException("start time=" + dateRange.getStart() + " must be >= " + timeAxis.getCalendarDate(0)); if (endIndex < 0) throw new InvalidRangeException("end time=" + dateRange.getEnd() + " must be >= " + timeAxis.getCalendarDate(0)); if (stride_time <= 1) stride_time = 1; timeRange = new Range(startIndex, endIndex, stride_time); } return timeRange; }
static void readAllTimes1D(Coverage cover, GridDatatype dt, CalendarDate rt_val, int rt_idx, CoordinateAxis1DTime timeAxis, CoordinateAxis1D ensAxis, CoordinateAxis1D vertAxis) { if (timeAxis == null) readAllEnsembles(cover, dt, rt_val, rt_idx, null, -1, ensAxis, vertAxis); else { for (int i = 0; i < timeAxis.getSize(); i++) { CalendarDate timeDate = timeAxis.isInterval() ? timeAxis.getCoordBoundsMidpointDate(i) : timeAxis.getCalendarDate(i); readAllEnsembles(cover, dt, rt_val, rt_idx, timeDate, i, ensAxis, vertAxis); } } }
@Test public void testCOARDSdefaultCalendar() throws IOException { try (GridDataset ds = GridDataset.open(TestDir.cdmUnitTestDir + "conventions/coards/olr.day.mean.nc")) { GeoGrid grid = ds.findGridByName("olr"); assert grid != null; GridCoordSystem gcs = grid.getCoordinateSystem(); CoordinateAxis1DTime time = gcs.getTimeAxis1D(); assert time != null; CalendarDate first = time.getCalendarDate(0); CalendarDate cd = CalendarDateFormatter.isoStringToCalendarDate(Calendar.gregorian, "2002-01-01T00:00:00Z"); assert first.equals(cd) : first + " != " + cd; CalendarDate last = time.getCalendarDate((int) time.getSize() - 1); CalendarDate cd2 = CalendarDateFormatter.isoStringToCalendarDate(Calendar.gregorian, "2012-12-02T00:00:00Z"); assert last.equals(cd2) : last + " != " + cd2; } }
static void readAllRuntimes(Coverage cover, GridDatatype dt, CoordinateAxis1DTime runtimeAxis, CoordinateAxis1D ensAxis, CoordinateAxis1D vertAxis) { GridCoordSystem csys = dt.getCoordinateSystem(); CoordinateAxis1DTime timeAxis1D = csys.getTimeAxis1D(); CoordinateAxis timeAxis = csys.getTimeAxis(); CoordinateAxis2D timeAxis2D = (timeAxis instanceof CoordinateAxis2D) ? (CoordinateAxis2D) timeAxis : null; if (runtimeAxis == null) readAllTimes1D(cover, dt, null, -1, timeAxis1D, ensAxis, vertAxis); else if (timeAxis2D == null) { // 1D time or no time for (int i = 0; i < runtimeAxis.getSize(); i++) readAllTimes1D(cover, dt, runtimeAxis.getCalendarDate(i), i, timeAxis1D, ensAxis, vertAxis); } else { // 2D time TimeHelper helper = TimeHelper.factory(timeAxis.getUnitsString(), timeAxis.getAttributeContainer()); if (timeAxis2D.isInterval()) { ArrayDouble.D3 bounds = timeAxis2D.getCoordBoundsArray(); for (int i = 0; i < runtimeAxis.getSize(); i++) readAllTimes2D(cover, dt, runtimeAxis.getCalendarDate(i), i, helper, bounds.slice(0, i), ensAxis, vertAxis); } else { ArrayDouble.D2 coords = timeAxis2D.getCoordValuesArray(); for (int i = 0; i < runtimeAxis.getSize(); i++) readAllTimes2D(cover, dt, runtimeAxis.getCalendarDate(i), i, helper, coords.slice(0, i), ensAxis, vertAxis); } } }
/** * Test GridCoordSystem.findXYindexFromLatLonBounded() * @throws IOException */ @Test public void checkGridCoordSystem_findXYindexFromLatLonBounded() throws IOException { GridDataset gd = GridDataset.open( datasetLocation ); GridDatatype hsGrid = gd.findGridDatatype( "hs" ); GridCoordSystem coordSys = hsGrid.getCoordinateSystem(); CalendarDate date = coordSys.getTimeAxis1D().getCalendarDate(0); int[] xy = coordSys.findXYindexFromLatLonBounded( lat, lon, null ); assertEquals( i, xy[0] ); assertEquals( j, xy[1] ); GridAsPointDataset hsGridAsPoint = new GridAsPointDataset( Collections.singletonList( hsGrid )); GridAsPointDataset.Point point = hsGridAsPoint.readData( hsGrid, date, lat, lon ); assertEquals( lat, point.lat, 0.001 ); assertEquals( lon, point.lon, 0.001 ); } }
dtCoords.setRunTime(rtcoord.getCalendarDate(rt)); readTime(gdt, rt, tDim, zDim);
dtCoords.setTimeOffsetIntv(tcoord1D.getCoordBounds(t)); } else { dtCoords.setTime(tcoord1D.getCalendarDate(t));