/** * @param index * @return */ private double handleValues(int index) { double val=coordinateAxis.getCoordValue(index); if(!Double.isNaN(scaleFactor)){ val*=scaleFactor; } if(!Double.isNaN(offsetFactor)){ val+=offsetFactor; } return val; }
private void calcIsRegular() { if (wasCalcRegular) return; if (!wasRead) doRead(); if (!isNumeric()) isRegular = false; else if (getSize() < 2) isRegular = true; else { start = getCoordValue(0); int n = (int) getSize(); increment = (getCoordValue(n - 1) - getCoordValue(0)) / (n - 1); isRegular = true; for (int i = 1; i < getSize(); i++) if (!ucar.nc2.util.Misc.closeEnough(getCoordValue(i) - getCoordValue(i - 1), increment, 5.0e-3)) { isRegular = false; break; } } wasCalcRegular = true; }
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)); } }
public Date buildTime(int timeIndex) { if (epoch != null) { final Calendar cal = new GregorianCalendar(); cal.setTime(epoch); cal.setTimeZone(UnidataTimeUtilities.UTC_TIMEZONE); final double coordValue = axis1D.getCoordValue(timeIndex); long vi = (long) Math.floor(coordValue); double vd = coordValue - vi; UnidataTimeUtilities.addTimeUnit(cal, baseTimeUnits, vi); if (vd != 0.0) { UnidataTimeUtilities.addTimeUnit(cal, UnidataTimeUtilities.getTimeUnits(units, vd), UnidataTimeUtilities.getTimeSubUnitsValue(units, vd)); } return cal.getTime(); } return null; }
/** * The "name" of the ith coordinate. If nominal, this is all there is to a coordinate. * If numeric, this will return a String representation of the coordinate. * * @param index which one ? * @return the ith coordinate value as a String */ public String getCoordName(int index) { if (!wasRead) doRead(); if (isNumeric()) return Format.d(getCoordValue(index), 5, 8); else return names[index]; }
/** * The "name" of the ith coordinate. If nominal, this is all there is to a coordinate. * If numeric, this will return a String representation of the coordinate. * * @param index which one ? * @return the ith coordinate value as a String */ public String getCoordName(int index) { if (!wasRead) doRead(); if (isNumeric()) return Format.d(getCoordValue(index), 5, 8); else return names[index]; }
/** * The "name" of the ith coordinate. If nominal, this is all there is to a coordinate. * If numeric, this will return a String representation of the coordinate. * * @param index which one ? * @return the ith coordinate value as a String */ public String getCoordName(int index) { if (!wasRead) doRead(); if (isNumeric()) return Format.d(getCoordValue(index), 5, 8); else return names[index]; }
private void doRead() { if (isNumeric()) { readValues(); wasRead = true; if (getSize() < 2) isAscending = true; else isAscending = getCoordValue(0) < getCoordValue(1); // calcIsRegular(); */ } else if (getDataType() == DataType.STRING) { readStringValues(); wasRead = true; } else { readCharValues(); wasRead = true; } }
private void doRead() { if (isNumeric()) { readValues(); wasRead = true; if (getSize() < 2) isAscending = true; else isAscending = getCoordValue(0) < getCoordValue(1); // calcIsRegular(); */ } else if (getDataType() == DataType.STRING) { readStringValues(); wasRead = true; } else { readCharValues(); wasRead = true; } }
TimeCoord(Date runDate, CoordinateAxis1D axis) { this.axis = axis; DateUnit unit = null; try { unit = new DateUnit(axis.getUnitsString()); } catch (Exception e) { throw new IllegalArgumentException("Not a unit of time "+axis.getUnitsString()); } int n = (int) axis.getSize(); offset = new double[n]; for (int i = 0; i < axis.getSize(); i++) { Date d = unit.makeDate(axis.getCoordValue(i)); offset[i] = getOffsetInHours(runDate, d); } }
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); } }
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); } }
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); } }
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); } }
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 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); } } }
public Point readData(GridDatatype grid, CalendarDate date, double zCoord, double lat, double lon) throws java.io.IOException { GridCoordSystem gcs = grid.getCoordinateSystem(); //CoordinateAxis1DTime timeAxis = gcs.getTimeAxis1D(); //int tidx = timeAxis.findTimeIndexFromCalendarDate(date); int tidx = -1; //Date may be null if the grid does not have time axis if(date != null) tidx= findTimeIndexForCalendarDate(gcs, date); CoordinateAxis1D zAxis = gcs.getVerticalAxis(); int zidx = zAxis.findCoordElement( zCoord); int[] xy = gcs.findXYindexFromLatLon(lat, lon, null); Array data = grid.readDataSlice(tidx, zidx, xy[1], xy[0]); // use actual grid midpoint LatLonPoint latlon = gcs.getLatLon(xy[0], xy[1]); Point p = new Point(); p.lat = latlon.getLatitude(); p.lon = latlon.getLongitude(); p.z = zAxis.getCoordValue( zidx); p.dataValue = data.getDouble( data.getIndex()); return p; }
private void readVert(GridDatatype gdt, int rtIndex, int tIndex, Dimension zDim) throws IOException { if (zDim != null) { CoordinateAxis1D zcoord = gdc.getVerticalAxis(); boolean isLayer = zcoord.isInterval(); for (int z = 0; z < zDim.getLength(); z++) { if (isLayer) { dtCoords.setVertCoordIntv(zcoord.getCoordBounds(z)); } else { dtCoords.setVertCoord(zcoord.getCoordValue(z)); } readAndTestGrib(gdt, rtIndex, tIndex, z); } } else { readAndTestGrib(gdt, rtIndex, tIndex, -1); } }