public void writeRecord(String stnName, double timeCoordValue, CalendarDate obsDate, StructureData sdata) throws IOException { trackBB(null, obsDate); Integer parentIndex = stationMap.get(stnName); if (parentIndex == null) throw new RuntimeException("Cant find station " + stnName); // needs to be wrapped as an ArrayStructure, even though we are only writing one at a time. ArrayStructureW sArray = new ArrayStructureW(sdata.getStructureMembers(), new int[]{1}); sArray.setStructureData(sdata, 0); timeArray.set(0, timeCoordValue); parentArray.set(0, parentIndex); // write the recno record origin[0] = recno; try { writer.write(record, origin, sArray); writer.write(time, origin, timeArray); writer.write(stationIndex, origin, parentArray); } catch (InvalidRangeException e) { e.printStackTrace(); throw new IllegalStateException(e); } recno++; }
public void writeRecord(double timeCoordValue, CalendarDate obsDate, EarthLocation loc, StructureData sdata) throws IOException { trackBB(loc, obsDate); // needs to be wrapped as an ArrayStructure, even though we are only writing one at a time. ArrayStructureW sArray = new ArrayStructureW(sdata.getStructureMembers(), new int[]{1}); sArray.setStructureData(sdata, 0); timeArray.set(0, timeCoordValue); latArray.set(0, loc.getLatitude()); lonArray.set(0, loc.getLongitude()); if (altUnits != null) altArray.set(0, loc.getAltitude()); // write the recno record origin[0] = recno; try { writer.write(record, origin, sArray); writer.write(time, origin, timeArray); writer.write(lat, origin, latArray); writer.write(lon, origin, lonArray); if (altUnits != null) writer.write(alt, origin, altArray); } catch (InvalidRangeException e) { e.printStackTrace(); throw new IllegalStateException(e); } recno++; }
private void makeZCoordAxis(NetcdfDataset ds, String dimName, String levelsName, String unitName) { Dimension dimz = ds.findDimension(dimName); int nz = dimz.getLength(); ArrayDouble.D1 dataLev = new ArrayDouble.D1(nz); ArrayDouble.D1 dataLayers = new ArrayDouble.D1(nz + 1); // layer values are a numeric global attribute array !! Attribute layers = ds.findGlobalAttribute("VGLVLS"); for (int i = 0; i <= nz; i++) dataLayers.set(i, layers.getNumericValue(i).doubleValue()); for (int i = 0; i < nz; i++) { double midpoint = (dataLayers.get(i) + dataLayers.get(i + 1)) / 2; dataLev.set(i, midpoint); } CoordinateAxis v = new CoordinateAxis1D(ds, null, "level", DataType.DOUBLE, dimName, unitName, "synthesized coordinate from " + levelsName + " global attributes"); v.setCachedData(dataLev, true); v.addAttribute(new Attribute("positive", "down")); v.addAttribute(new Attribute(_Coordinate.AxisType, AxisType.GeoZ.toString())); // layer edges String edge_name = "layer"; Dimension lay_edge = new Dimension(edge_name, nz + 1); ds.addDimension(null, lay_edge); CoordinateAxis vedge = new CoordinateAxis1D(ds, null, edge_name, DataType.DOUBLE, edge_name, unitName, "synthesized coordinate from " + levelsName + " global attributes"); vedge.setCachedData(dataLayers, true); v.setBoundaryRef(edge_name); ds.addCoordinateAxis(v); ds.addCoordinateAxis(vedge); }
height.set(z, az + bz * orog);
/** * Make the C array * * @param s s Array * @param a "a" value * @param b "b" value * @return the C array */ private Array makeC(Array s, double a, double b) { int nz = (int) s.getSize(); Index sIndex = s.getIndex(); if (a == 0) return s; // per R. Signell, USGS ArrayDouble.D1 c = new ArrayDouble.D1(nz); double fac1 = 1.0 - b; double denom1 = 1.0 / Math.sinh(a); double denom2 = 1.0 / (2.0 * Math.tanh(0.5 * a)); for (int i = 0; i < nz; i++) { double sz = s.getDouble(sIndex.set(i)); double term1 = fac1 * Math.sinh(a * sz) * denom1; double term2 = b * (Math.tanh(a * (sz + 0.5)) * denom2 - 0.5); c.set(i, term1 + term2); } return c; }
/** * Make the C array * * @param s s Array * @param a "a" value * @param b "b" value * @return the C array */ private Array makeC(Array s, double a, double b) { int nz = (int) s.getSize(); Index sIndex = s.getIndex(); if (a == 0) return s; // per R. Signell, USGS ArrayDouble.D1 c = new ArrayDouble.D1(nz); double fac1 = 1.0 - b; double denom1 = 1.0 / Math.sinh(a); double denom2 = 1.0 / (2.0 * Math.tanh(0.5 * a)); for (int i = 0; i < nz; i++) { double sz = s.getDouble(sIndex.set(i)); double term1 = fac1 * Math.sinh(a * sz) * denom1; double term2 = b * (Math.tanh(a * (sz + 0.5)) * denom2 - 0.5); c.set(i, term1 + term2); } return c; }
/** * Get the 1D vertical coordinate array for this time step and point * * (needds test!!!) * * @param timeIndex the time index. Ignored if !isTimeDependent(). * @param xIndex the x index * @param yIndex the y index * @return vertical coordinate array * @throws java.io.IOException problem reading data * @throws ucar.ma2.InvalidRangeException _more_ */ public D1 getCoordinateArray1D(int timeIndex, int xIndex, int yIndex) throws IOException, InvalidRangeException { Array ps = readArray(psVar, timeIndex); Index psIndex = ps.getIndex(); int nz = sigma.length; ArrayDouble.D1 result = new ArrayDouble.D1(nz); double psVal = ps.getDouble(psIndex.set(yIndex, xIndex)); for (int z = 0; z < nz; z++) { result.set(z, ptop + sigma[z] * (psVal - ptop)); } return result; }
/** * Get the 1D vertical coordinate array for this time step and point * * (needds test!!!) * * @param timeIndex the time index. Ignored if !isTimeDependent(). * @param xIndex the x index * @param yIndex the y index * @return vertical coordinate array * @throws java.io.IOException problem reading data * @throws ucar.ma2.InvalidRangeException _more_ */ public D1 getCoordinateArray1D(int timeIndex, int xIndex, int yIndex) throws IOException, InvalidRangeException { Array ps = readArray(psVar, timeIndex); Index psIndex = ps.getIndex(); int nz = sigma.length; ArrayDouble.D1 result = new ArrayDouble.D1(nz); double psVal = ps.getDouble(psIndex.set(yIndex, xIndex)); for (int z = 0; z < nz; z++) { result.set(z, ptop + sigma[z] * (psVal - ptop)); } return result; }
/** * Get the 1D vertical coordinate array for this time step and point * * @param timeIndex the time index. Ignored if !isTimeDependent(). * @param xIndex the x index * @param yIndex the y index * @return vertical coordinate array * @throws java.io.IOException problem reading data * @throws ucar.ma2.InvalidRangeException _more_ */ public D1 getCoordinateArray1D(int timeIndex, int xIndex, int yIndex) throws IOException, InvalidRangeException { Array eta = readArray(etaVar, timeIndex); Array sigma = readArray(sVar, timeIndex); Array depth = readArray(depthVar, timeIndex); int nz = (int) sigma.getSize(); Index sIndex = sigma.getIndex(); Index etaIndex = eta.getIndex(); Index depthIndex = depth.getIndex(); ArrayDouble.D1 height = new ArrayDouble.D1(nz); for (int z = 0; z < nz; z++) { double sigmaVal = sigma.getDouble(sIndex.set(z)); double etaVal = eta.getDouble(etaIndex.set(yIndex, xIndex)); double depthVal = depth.getDouble(depthIndex.set(yIndex, xIndex)); height.set(z, etaVal + sigmaVal * (depthVal + etaVal)); } return height; }
double hterm = term3 + term4; height.set(z,hterm);
/** * Make the C array * * @param s s Array * @param a "a" value * @param b "b" value * @return the C array */ private Array makeC(Array s, double a, double b) { int nz = (int) s.getSize(); Index sIndex = s.getIndex(); if (a == 0) return s; // per R. Signell, USGS ArrayDouble.D1 c = new ArrayDouble.D1(nz); double fac1 = 1.0 - b; double denom1 = 1.0 / Math.sinh(a); double denom2 = 1.0 / (2.0 * Math.tanh(0.5 * a)); for (int i = 0; i < nz; i++) { double sz = s.getDouble(sIndex.set(i)); double term1 = fac1 * Math.sinh(a * sz) * denom1; double term2 = b * (Math.tanh(a * (sz + 0.5)) * denom2 - 0.5); c.set(i, term1 + term2); } return c; }
double hterm = Sterm + term3 * term4; height.set(z, hterm);
double hterm = Sterm + term3 * term4; height.set(z, hterm);
double hterm = Sterm + term3 * term4; height.set(z, hterm);
double hterm = term3 + term4; height.set(z,hterm);
double hterm = Sterm + term3 * term4; height.set(z,hterm);
/** * Get the 1D vertical coordinate array for this time step and point * * (needds test!!!) * * @param timeIndex the time index. Ignored if !isTimeDependent(). * @param xIndex the x index * @param yIndex the y index * @return vertical coordinate array * @throws java.io.IOException problem reading data * @throws ucar.ma2.InvalidRangeException _more_ */ public D1 getCoordinateArray1D(int timeIndex, int xIndex, int yIndex) throws IOException, InvalidRangeException { Array ps = readArray(psVar, timeIndex); Index psIndex = ps.getIndex(); int nz = sigma.length; ArrayDouble.D1 result = new ArrayDouble.D1(nz); double psVal = ps.getDouble(psIndex.set(yIndex, xIndex)); for (int z = 0; z < nz; z++) { result.set(z, ptop + sigma[z] * (psVal - ptop)); } return result; }
double hterm = term3 + term4; height.set(z,hterm);
double hterm = Sterm + term3 * term4; height.set(z,hterm);
double hterm = Sterm + term3 * term4; height.set(z,hterm);