public int findTimeIndexFromCalendarDate(int run_idx, CalendarDate want) throws IOException, InvalidRangeException { CoordinateAxisTimeHelper helper = getCoordinateAxisTimeHelper(); double wantOffset = helper.offsetFromRefDate(want); if (isInterval()) { ArrayDouble.D3 bounds = getCoordBoundsArray(); if (bounds == null) throw new IllegalStateException("getCoordBoundsArray returned null for coordinate "+getFullName()); ArrayDouble.D2 boundsForRun = (ArrayDouble.D2) bounds.slice(0,run_idx ); int idx = findSingleHit(boundsForRun, wantOffset); if (idx >= 0) return idx; if (idx == -1) return -1; // multiple hits = choose closest to the midpoint return findClosest(boundsForRun, wantOffset); } else { ArrayDouble.D2 values = getCoordValuesArray(); ArrayDouble.D1 valuesForRun = (ArrayDouble.D1) values.slice(0,run_idx ); for (int i=0; i<valuesForRun.getSize(); i++) { if (Misc.nearlyEquals(valuesForRun.get(i), wantOffset)) return i; } return -1; } }
ArrayDouble.D3 bounds = axis2D.getCoordBoundsArray(); if (bounds == null) throw new IllegalStateException("No bounds array"); int[] shape = bounds.getShape(); ArrayDouble.D3 bounds = axis2D.getCoordBoundsArray(); if (bounds == null) throw new IllegalStateException("No bounds array"); int[] shape = bounds.getShape();
CoordinateAxis2D axis2 = (CoordinateAxis2D) vds; if (axis2.isInterval()) { ArrayDouble.D3 bounds = axis2.getCoordBoundsArray(); for (int i = 0; i < axis2.getShape(0); i++) for (int j = 0; j < axis2.getShape(1); j++) {
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); } } }
CoordinateAxisTimeHelper helper = tcoord2D.getCoordinateAxisTimeHelper(); if (timeCoord2DBoundsArray == null) timeCoord2DBoundsArray = tcoord2D.getCoordBoundsArray(); for (int t = 0; t < timeDim.getLength(); t++) { if (isTimeInterval) {