/** * Extract an Array (with rank reduced by one) from the Variable * for the given time index. * * @param v variable to extract from * @param timeIndex time index * @return Array of data * @throws IOException problem getting Array */ private Array getTimeSlice(Variable v, int timeIndex) throws IOException { //ADD: this would make a good utility method //ADD: use Array.slice? int[] shape = v.getShape(); int[] origin = new int[v.getRank()]; if (getTimeDimension() != null) { int dimIndex = v.findDimensionIndex(getTimeDimension().getShortName()); if (dimIndex >= 0) { shape[dimIndex] = 1; origin[dimIndex] = timeIndex; } } try { return v.read(origin, shape).reduce(); } catch (InvalidRangeException e) { throw new IOException(e); } }
/** * Extract an Array (with rank reduced by one) from the Variable * for the given time index. * * @param v variable to extract from * @param timeIndex time index * @return Array of data * @throws IOException problem getting Array */ private Array getTimeSlice(Variable v, int timeIndex) throws IOException { //ADD: this would make a good utility method //ADD: use Array.slice? int[] shape = v.getShape(); int[] origin = new int[v.getRank()]; if (getTimeDimension() != null) { int dimIndex = v.findDimensionIndex(getTimeDimension().getShortName()); if (dimIndex >= 0) { shape[dimIndex] = 1; origin[dimIndex] = timeIndex; } } try { return v.read(origin, shape).reduce(); } catch (InvalidRangeException e) { throw new IOException(e); } }
/** * Extract an Array (with rank reduced by one) from the Variable * for the given time index. * * @param v variable to extract from * @param timeIndex time index * @return Array of data * @throws IOException problem getting Array */ private Array getTimeSlice(Variable v, int timeIndex) throws IOException { //ADD: this would make a good utility method //ADD: use Array.slice? int[] shape = v.getShape(); int[] origin = new int[v.getRank()]; if (getTimeDimension() != null) { int dimIndex = v.findDimensionIndex(getTimeDimension().getShortName()); if (dimIndex >= 0) { shape[dimIndex] = 1; origin[dimIndex] = timeIndex; } } try { return v.read(origin, shape).reduce(); } catch (InvalidRangeException e) { return null; } }