private CoordinateAxis makeXCoordAxis(NetcdfDataset ds, int nx, String xname) { CoordinateAxis v = new CoordinateAxis1D(ds, null, xname, DataType.DOUBLE, xname, "km", "x on projection"); ds.setValues(v, nx, startx, dx); parseInfo.format("Created X Coordinate Axis = "); v.getNameAndDimensions(parseInfo, true, false); parseInfo.format("\n"); if (debugProj) parseInfo.format(" makeXCoordAxis ending x %f nx= %d dx= %f\n",startx + nx * dx, nx, dx); return v; }
private CoordinateAxis makeYCoordAxis( NetcdfDataset ds, int ny, String yname) { CoordinateAxis v = new CoordinateAxis1D( ds, null, yname, DataType.DOUBLE, yname, "km", "y on projection"); ds.setValues( v, ny, starty, dy); parseInfo.format("Created Y Coordinate Axis = "); v.getNameAndDimensions(parseInfo, true, false); parseInfo.format("\n"); if (debugProj) parseInfo.format(" makeYCoordAxis ending y %f ny= %d dy= %f\n",starty + ny * dy, ny, dy); return v; }
private CoordinateAxis makeXCoordAxis(NetcdfDataset ds, int nx, String xname) { double dx = findAttributeDouble(ds, "dxKm"); CoordinateAxis v = new CoordinateAxis1D(ds, null, xname, DataType.DOUBLE, xname, "km", "x on projection"); ds.setValues(v, nx, startx, dx); parseInfo.format("Created X Coordinate Axis = "); v.getNameAndDimensions(parseInfo, true, false); parseInfo.format("\n"); return v; }
private CoordinateAxis makeYCoordAxis(NetcdfDataset ds, int ny, String yname) { double dy = findAttributeDouble(ds, "dyKm"); CoordinateAxis v = new CoordinateAxis1D(ds, null, yname, DataType.DOUBLE, yname, "km", "y on projection"); ds.setValues(v, ny, starty, dy); parseInfo.format("Created Y Coordinate Axis = "); v.getNameAndDimensions(parseInfo, true, false); parseInfo.format("\n"); return v; }
private CoordinateAxis makeLonCoordAxis(NetcdfDataset ds, int n, String xname) { double min = findAttributeDouble(ds, "xMin"); double max = findAttributeDouble(ds, "xMax"); double d = findAttributeDouble(ds, "dx"); if (Double.isNaN(min) || Double.isNaN(max) || Double.isNaN(d)) return null; CoordinateAxis v = new CoordinateAxis1D(ds, null, xname, DataType.DOUBLE, xname, CDM.LON_UNITS, "longitude"); ds.setValues(v, n, min, d); v.addAttribute(new Attribute(_Coordinate.AxisType, AxisType.Lon.toString())); double maxCalc = min + d * n; parseInfo.format("Created Lon Coordinate Axis (max calc= %f shoule be = %f)\n", maxCalc, max); v.getNameAndDimensions(parseInfo, true, false); parseInfo.format("\n"); return v; }
private CoordinateAxis makeLatCoordAxis(NetcdfDataset ds, int n, String xname) { double min = findAttributeDouble(ds, "yMin"); double max = findAttributeDouble(ds, "yMax"); double d = findAttributeDouble(ds, "dy"); if (Double.isNaN(min) || Double.isNaN(max) || Double.isNaN(d)) return null; CoordinateAxis v = new CoordinateAxis1D(ds, null, xname, DataType.DOUBLE, xname, CDM.LAT_UNITS, "latitude"); ds.setValues(v, n, min, d); v.addAttribute(new Attribute(_Coordinate.AxisType, AxisType.Lat.toString())); double maxCalc = min + d * n; parseInfo.format("Created Lat Coordinate Axis (max calc= %f should be = %f)\n", maxCalc, max); v.getNameAndDimensions(parseInfo, true, false); parseInfo.format("\n"); return v; }
CoordinateAxis makeXCoordAxis( NetcdfDataset ds, String xname) { CoordinateAxis v = new CoordinateAxis1D( ds, null, xname, DataType.DOUBLE, xname, (0 == grid_code) ? CDM.LON_UNITS : "km", "synthesized X coord"); v.addAttribute( new Attribute( _Coordinate.AxisType, (0 == grid_code) ? AxisType.Lon.toString() : AxisType.GeoX.toString())); ds.setValues( v, nx, startx, dx); ds.addCoordinateAxis( v); return v; }
CoordinateAxis makeYCoordAxis( NetcdfDataset ds, String yname) { CoordinateAxis v = new CoordinateAxis1D( ds, null, yname, DataType.DOUBLE, yname, ((0 == grid_code) ? CDM.LAT_UNITS : "km"), "synthesized Y coord"); v.addAttribute( new Attribute( _Coordinate.AxisType, (0 == grid_code) ? AxisType.Lat.toString() : AxisType.GeoY.toString())); ds.setValues( v, ny, starty, dy); ds.addCoordinateAxis( v); return v; }
private CoordinateAxis makeFakeCoordAxis(NetcdfDataset ds, String axisName, Dimension dim) { if (dim == null) return null; CoordinateAxis v = new CoordinateAxis1D(ds, null, axisName, DataType.SHORT, dim.getShortName(), "", "synthesized coordinate: only an index"); v.addAttribute(new Attribute(_Coordinate.AxisType, "GeoZ")); if (!axisName.equals(dim.getShortName())) v.addAttribute(new Attribute(_Coordinate.AliasForDimension, dim.getShortName())); ds.setValues(v, dim.getLength(), 0, 1); return v; }
private CoordinateAxis makeLonCoordAxis(NetcdfDataset ds, String axisName, Dimension dim) { if (dim == null) return null; double dx = 4 * findAttributeDouble(ds, "DX"); int nx = dim.getLength(); double startx = centerX - dx * (nx - 1) / 2; CoordinateAxis v = new CoordinateAxis1D(ds, null, axisName, DataType.DOUBLE, dim.getShortName(), "degrees_east", "synthesized longitude coordinate"); ds.setValues(v, nx, startx, dx); v.addAttribute(new Attribute(_Coordinate.AxisType, "Lon")); if (!axisName.equals(dim.getShortName())) v.addAttribute(new Attribute(_Coordinate.AliasForDimension, dim.getShortName())); return v; }
private CoordinateAxis makeLatCoordAxis(NetcdfDataset ds, String axisName, Dimension dim) { if (dim == null) return null; double dy = findAttributeDouble(ds, "DY"); int ny = dim.getLength(); double starty = centerY - dy * (ny - 1) / 2; CoordinateAxis v = new CoordinateAxis1D(ds, null, axisName, DataType.DOUBLE, dim.getShortName(), "degrees_north", "synthesized latitude coordinate"); ds.setValues(v, ny, starty, dy); v.addAttribute(new Attribute(_Coordinate.AxisType, "Lat")); if (!axisName.equals(dim.getShortName())) v.addAttribute(new Attribute(_Coordinate.AliasForDimension, dim.getShortName())); return v; }
private void makeXCoordAxis( NetcdfDataset ds, String units ) { Dimension dim = ds.findDimension( "COL" ); final String newUnits = units.equals( "m" ) ? "km" : units; String desc = "synthesized x coordinate from XORIG, XCELL global attributes"; CoordinateAxis axis = new CoordinateAxis1D( ds, null, "x", DataType.DOUBLE, dim.getShortName(), newUnits, desc ); final double scale = units.equals("m") ? 0.001 : 1.0;//IDV BUG m->km final double xorig = doubleAttribute( "XORIG" ) * scale; final double xcell = doubleAttribute( "XCELL" ) * scale; ds.setValues(axis, dim.getLength(), xorig, xcell); axis.addAttribute( new Attribute( CDM.UNITS, newUnits ) ); axis.addAttribute( new Attribute( CDM.LONG_NAME, desc ) ); axis.addAttribute( new Attribute( _Coordinate.AxisType, AxisType.GeoX.toString() ) ); ds.addCoordinateAxis( axis ); }
private void makeYCoordAxis( NetcdfDataset ds, String units ) { Dimension dim = ds.findDimension( "ROW" ); final String newUnits = units.equals( "m" ) ? "km" : units; String desc = "synthesized y coordinate from YORIG, YCELL global attributes"; CoordinateAxis axis = new CoordinateAxis1D( ds, null, "y", DataType.DOUBLE, dim.getShortName(), newUnits, desc ); final double scale = units.equals("m") ? 0.001 : 1.0;//IDV BUG m->km final double yorig = doubleAttribute( "YORIG" ) * scale; final double ycell = doubleAttribute( "YCELL" ) * scale; ds.setValues(axis, dim.getLength(), yorig, ycell ); axis.addAttribute( new Attribute( CDM.UNITS, newUnits ) ); axis.addAttribute( new Attribute( CDM.LONG_NAME, desc ) ); axis.addAttribute( new Attribute( _Coordinate.AxisType, AxisType.GeoY.toString() ) ); ds.addCoordinateAxis( axis ); }
private void makeZCoordAxis( NetcdfDataset ds ) { Dimension dim = ds.findDimension( "LAY" ); String desc = "synthesized z coordinate from VGTYP, VGTOP, VGLVLS global attributes"; CoordinateAxis axis = new CoordinateAxis1D( ds, null, "z", DataType.DOUBLE, dim.getShortName(), "km", desc ); // IDV? final int vgtyp = intAttribute( "VGTYP" ); final double vgtop = doubleAttribute( "VGTOP" ); final double[] vglvls = doubleArrayAttribute( "VGLVLS" ); double[] vgLevelsInMeters = convertVGLevels_( vgtyp, vgtop, vglvls ); final int count = vgLevelsInMeters.length; List<String> vgArray = new ArrayList<String>( count ); for ( int index = 0; index < count; ++index ) { vgArray.add( Double.toString( vgLevelsInMeters[ index ] * 0.001 ) ); } ds.setValues(axis, vgArray ); axis.addAttribute( new Attribute( CDM.UNITS, "km" ) ); axis.addAttribute( new Attribute( CDM.LONG_NAME, desc ) ); axis.addAttribute( new Attribute( _Coordinate.AxisType, AxisType.Height.toString() ) ); ds.addCoordinateAxis( axis ); }
private void addCoordSystem(NetcdfDataset ds) throws IOException { double lat = ds.findGlobalAttributeIgnoreCase("Latitude").getNumericValue().doubleValue(); double lon = ds.findGlobalAttributeIgnoreCase("Longitude").getNumericValue().doubleValue(); double dlat = ds.findGlobalAttributeIgnoreCase("LatGridSpacing").getNumericValue().doubleValue(); double dlon = ds.findGlobalAttributeIgnoreCase("LonGridSpacing").getNumericValue().doubleValue(); int time = ds.findGlobalAttributeIgnoreCase("Time").getNumericValue().intValue(); if (debug) System.out.println(ds.getLocation() + " Lat/Lon=" + lat + "/" + lon); int nlat = ds.findDimension("Lat").getLength(); int nlon = ds.findDimension("Lon").getLength(); // add lat CoordinateAxis v = new CoordinateAxis1D(ds, null, "Lat", DataType.FLOAT, "Lat", CDM.LAT_UNITS, "latitude coordinate"); ds.setValues(v, nlat, lat, -dlat); v.addAttribute(new Attribute(_Coordinate.AxisType, AxisType.Lat.toString())); ds.addCoordinateAxis( v); // add lon v = new CoordinateAxis1D(ds, null, "Lon", DataType.FLOAT, "Lon", CDM.LON_UNITS, "longitude coordinate"); ds.setValues(v, nlon, lon, dlon); v.addAttribute(new Attribute(_Coordinate.AxisType, AxisType.Lon.toString())); ds.addCoordinateAxis( v); // add time ds.addDimension(null, new Dimension("Time", 1)); v = new CoordinateAxis1D(ds, null, "Time", DataType.INT, "Time", "seconds since 1970-1-1 00:00:00", "time coordinate"); ds.setValues(v, 1, time, 1); v.addAttribute(new Attribute(_Coordinate.AxisType, AxisType.Time.toString())); ds.addCoordinateAxis( v); }
private void calcCenterPoints(NetcdfDataset ds, Projection proj) throws IOException { double lat_check = findAttributeDouble(ds, "CTRLAT", Double.NaN); double lon_check = findAttributeDouble(ds, "CTRLON", Double.NaN); LatLonPointImpl lpt0 = new LatLonPointImpl(lat_check, lon_check); ProjectionPoint ppt0 = proj.latLonToProj(lpt0, new ProjectionPointImpl()); System.out.println("CTR lpt0= " + lpt0 + " ppt0=" + ppt0); Variable xstag = ds.findVariable("x_stag"); int nxpts = (int) xstag.getSize(); ArrayFloat.D1 xstagData = (ArrayFloat.D1) xstag.read(); float center_x = xstagData.get(nxpts - 1); double false_easting = center_x / 2000 - ppt0.getX() * 1000.0; System.out.println("false_easting= " + false_easting); Variable ystag = ds.findVariable("y_stag"); int nypts = (int) ystag.getSize(); ArrayFloat.D1 ystagData = (ArrayFloat.D1) ystag.read(); float center_y = ystagData.get(nypts - 1); double false_northing = center_y / 2000 - ppt0.getY() * 1000.0; System.out.println("false_northing= " + false_northing); double dx = findAttributeDouble(ds, "DX", Double.NaN); double dy = findAttributeDouble(ds, "DY", Double.NaN); double w = dx * (nxpts - 1); double h = dy * (nypts - 1); double startx = ppt0.getX() * 1000.0 - w / 2; double starty = ppt0.getY() * 1000.0 - h / 2; ds.setValues(xstag, nxpts, startx, dx); ds.setValues(ystag, nypts, starty, dy); }
Dimension latDim = ds.findDimension( "row"); Variable latVar = ds.findVariable("latitude"); ds.setValues( latVar, latDim.getLength(), startLat, incrLat); Dimension lonDim = ds.findDimension( "column"); Variable lonVar = ds.findVariable("longitude"); ds.setValues( lonVar, lonDim.getLength(), startLon, incrLon);
String lName = "elevation angle in degres: 0 = parallel to pedestal base, 90 = perpendicular"; CoordinateAxis v = new CoordinateAxis1D(ds, null, "Elevation", DataType.DOUBLE, "Elevation", "degrees", lName); ds.setValues(v, 1, ele, 0); v.addAttribute(new Attribute(_Coordinate.AxisType, AxisType.RadialElevation.toString())); ds.addVariable(null, v);
String lName = "elevation angle in degres: 0 = parallel to pedestal base, 90 = perpendicular"; CoordinateAxis v = new CoordinateAxis1D(ds, null, "Elevation", DataType.DOUBLE, "Elevation", "degrees", lName); ds.setValues(v, 1, ele, 0); v.addAttribute(new Attribute(_Coordinate.AxisType, AxisType.RadialElevation.toString())); ds.addVariable(null, v);
String lName = "elevation angle in degres: 0 = parallel to pedestal base, 90 = perpendicular"; CoordinateAxis v = new CoordinateAxis1D(ds, null, "Elevation", DataType.DOUBLE, "Elevation", "degrees", lName); ds.setValues(v, 1, ele, 0); v.addAttribute(new Attribute(_Coordinate.AxisType, AxisType.RadialElevation.toString())); ds.addVariable(null, v);