private void makeMidpoints() { int size = (int) getSize(); midpoint = new double[size]; for (int i = 0; i < size; i++) midpoint[i] = (edge[i] + edge[i + 1]) / 2; }
private void makeEdges() { int size = (int) getSize(); edge = new double[size + 1]; if (size < 1) return; for (int i = 1; i < size; i++) edge[i] = (midpoint[i - 1] + midpoint[i]) / 2; edge[0] = midpoint[0] - (edge[1] - midpoint[0]); edge[size] = midpoint[size - 1] + (midpoint[size - 1] - edge[size - 1]); }
private void makeEdges() { int size = (int) getSize(); edge = new double[size + 1]; if (size < 1) return; for (int i = 1; i < size; i++) edge[i] = (coords[i - 1] + coords[i]) / 2; edge[0] = coords[0] - (edge[1] - coords[0]); edge[size] = coords[size - 1] + (coords[size - 1] - edge[size - 1]); isContiguous = true; }
private void makeEdges() { int size = (int) getSize(); edge = new double[size + 1]; if (size < 1) return; for (int i = 1; i < size; i++) edge[i] = (coords[i - 1] + coords[i]) / 2; edge[0] = coords[0] - (edge[1] - coords[0]); edge[size] = coords[size - 1] + (coords[size - 1] - edge[size - 1]); isContiguous = true; }
private Range makeVerticalRange(Range zRange, CoordinateAxis1D vertAxis) throws InvalidRangeException { return (zRange != null) && (vertAxis != null) && (vertAxis.getSize() > 1) ? zRange : null; }
/** * Get the String name for the ith level(z) coordinate. * * @param index which level coordinate * @return level name */ public String getLevelName(int index) { if ((vertZaxis == null) || (index < 0) || (index >= vertZaxis.getSize())) throw new IllegalArgumentException("getLevelName = " + index); return vertZaxis.getCoordName(index).trim(); }
/** * Get the String name for the ith level(z) coordinate. * * @param index which level coordinate * @return level name */ public String getLevelName(int index) { if ((vertZaxis == null) || (index < 0) || (index >= vertZaxis.getSize())) throw new IllegalArgumentException("getLevelName = " + index); return vertZaxis.getCoordName(index).trim(); }
/** * Get the index corresponding to the level name. * * @param name level name * @return level index, or -1 if not found */ public int getLevelIndex(String name) { if ((vertZaxis == null) || (name == null)) return -1; for (int i = 0; i < vertZaxis.getSize(); i++) { if (vertZaxis.getCoordName(i).trim().equals(name)) return i; } return -1; }
/** * Get the String name for the ith level(z) coordinate. * * @param index which level coordinate * @return level name */ public String getLevelName(int index) { if ((vertZaxis == null) || (index < 0) || (index >= vertZaxis.getSize())) throw new IllegalArgumentException("getLevelName = " + index); return vertZaxis.getCoordName(index).trim(); }
@Override public double getMinValue() { if (!isNumeric()) throw new UnsupportedOperationException("CoordinateAxis1D.getCoordValue() on non-numeric"); if (!wasRead) doRead(); return Math.min(coords[0], coords[(int) getSize() - 1]); }
@Override public double getMaxValue() { if (!isNumeric()) throw new UnsupportedOperationException("CoordinateAxis1D.getCoordValue() on non-numeric"); if (!wasRead) doRead(); return Math.max(coords[0], coords[(int) getSize() - 1]); }
@Override public double getMaxValue() { if (!isNumeric()) throw new UnsupportedOperationException("CoordinateAxis1D.getCoordValue() on non-numeric"); if (!wasRead) doRead(); return Math.max(midpoint[0], midpoint[(int) getSize() - 1]); }
@Override public double getMinValue() { if (!isNumeric()) throw new UnsupportedOperationException("CoordinateAxis1D.getCoordValue() on non-numeric"); if (!wasRead) doRead(); return Math.min(midpoint[0], midpoint[(int) getSize() - 1]); }
public Axis( CoordinateAxis1D coordAxis) { this.coordAxis = coordAxis; this.name = this.coordAxis.getFullName(); this.label = this.coordAxis.getFullName(); this.description = this.coordAxis.getDescription(); this.isNumeric = this.coordAxis.isNumeric(); this.values = new ArrayList<String>(); for ( int i = 0; i < this.coordAxis.getSize(); i++ ) this.values.add( this.coordAxis.getCoordName( i ).trim() ); }
VertCoord(CoordinateAxis1D axis) { this.axis = axis; this.name = axis.getFullName(); this.units = axis.getUnitsString(); int n = (int) axis.getSize(); if (axis.isInterval()) { values1 = axis.getBound1(); values2 = axis.getBound2(); } else { values1 = new double[n]; for (int i = 0; i < axis.getSize(); i++) values1[i] = axis.getCoordValue(i); } }
static void readAllEnsembles(Coverage cover, GridDatatype dt, CalendarDate rt_val, int rt_idx, CalendarDate time_val, int time_idx, CoordinateAxis1D ensAxis, CoordinateAxis1D vertAxis) { if (ensAxis == null) readAllVertLevels(cover, dt, rt_val, rt_idx, time_val, time_idx, 0, -1, vertAxis); else { for (int i = 0; i < ensAxis.getSize(); i++) readAllVertLevels(cover, dt, rt_val, rt_idx, time_val, time_idx, ensAxis.getCoordValue(i), i, vertAxis); } }
public void setVertical(CoordinateAxis1D vaxis) { int n = (int) vaxis.getSize(); double size = vaxis.getCoordValue(n - 1) - vaxis.getCoordValue(0); double resolution = vaxis.getIncrement(); String units = vaxis.getUnitsString(); this.updown = new Range(vaxis.getCoordValue(0), size, resolution, units); if (units != null) { setZPositiveUp(SimpleUnit.isCompatible("m", units)); } }
public void setVertical(CoordinateAxis1D vaxis) { int n = (int) vaxis.getSize(); double size = vaxis.getCoordValue(n - 1) - vaxis.getCoordValue(0); double resolution = vaxis.getIncrement(); String units = vaxis.getUnitsString(); this.updown = new Range(vaxis.getCoordValue(0), size, resolution, units); if (units != null) { setZPositiveUp(SimpleUnit.isCompatible("m", units)); } }
public void setVertical(CoordinateAxis1D vaxis) { int n = (int) vaxis.getSize(); double size = vaxis.getCoordValue(n - 1) - vaxis.getCoordValue(0); double resolution = vaxis.getIncrement(); String units = vaxis.getUnitsString(); this.updown = new Range(vaxis.getCoordValue(0), size, resolution, units); if (units != null) { setZPositiveUp(SimpleUnit.isCompatible("m", units)); } }
static void readAllVertLevels(Coverage cover, GridDatatype dt, CalendarDate rt_val, int rt_idx, CalendarDate time_val, int time_idx, double ens_val, int ens_idx, CoordinateAxis1D vertAxis) { if (vertAxis == null) readOneSlice(cover, dt, rt_val, rt_idx, time_val, time_idx, ens_val, ens_idx, 0, -1); else { for (int i = 0; i < vertAxis.getSize(); i++) { double levVal = vertAxis.isInterval() ? vertAxis.getCoordBoundsMidpoint(i) : vertAxis.getCoordValue(i); readOneSlice(cover, dt, rt_val, rt_idx, time_val, time_idx, ens_val, ens_idx, levVal, i); } } }