void makeTimeAxis() { if ((tAxis != null) && (tAxis instanceof CoordinateAxis1D) && !(tAxis instanceof CoordinateAxis1DTime)) { Formatter err = new Formatter(); try { CoordinateAxis1DTime timeAxis = CoordinateAxis1DTime.factory(ds, tAxis, err); coordAxes.remove(tAxis); coordAxes.add(timeAxis); tAxis = timeAxis; ds.addCoordinateAxis(timeAxis); // will remove old one } catch (Exception e) { log.error(tAxis.getDatasetLocation() + ": Error reading time coord= " + err, e); } } }
void makeTimeAxis() { if ((tAxis != null) && (tAxis instanceof CoordinateAxis1D) && !(tAxis instanceof CoordinateAxis1DTime)) { Formatter err = new Formatter(); try { CoordinateAxis1DTime timeAxis = CoordinateAxis1DTime.factory(ds, tAxis, err); coordAxes.remove(tAxis); coordAxes.add(timeAxis); tAxis = timeAxis; ds.addCoordinateAxis(timeAxis); // will remove old one } catch (Exception e) { log.error(tAxis.getDatasetLocation() + ": Error reading time coord= " + err, e); } } }
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; }
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())); v.setValues(ny, starty, dy); ds.addCoordinateAxis( v); 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())); v.setValues( nx, startx, dx); ds.addCoordinateAxis( v); 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())); v.setValues( 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())); v.setValues(ny, starty, dy); ds.addCoordinateAxis( v); return v; }
private void augmentDataset3(NetcdfDataset ds) throws IOException { Group grids = ds.findGroup("/HDFEOS/GRIDS"); if (grids == null) return; for (Group g2 : grids.getGroups()) { Attribute gctp = g2.findAttribute("GCTPProjectionCode"); if (gctp == null || !gctp.getNumericValue().equals(0)) continue; Attribute nlon = g2.findAttribute("NumberOfLongitudesInGrid"); Attribute nlat = g2.findAttribute("NumberOfLatitudesInGrid"); if (nlon == null || nlon.isString()) continue; if (nlat == null || nlat.isString()) continue; ds.addCoordinateAxis(makeLonCoordAxis(ds, g2, nlon.getNumericValue().intValue(), "XDim")); ds.addCoordinateAxis(makeLatCoordAxis(ds, g2, nlat.getNumericValue().intValue(), "YDim")); for (Group g3 : g2.getGroups()) { for (Variable v : g3.getVariables()) { v.addAttribute(new Attribute(_Coordinate.Axes, "lat lon")); } } } ds.finish(); }
private void augmentDataset3(NetcdfDataset ds) throws IOException { Group grids = ds.findGroup("/HDFEOS/GRIDS"); if (grids == null) return; for (Group g2 : grids.getGroups()) { Attribute gctp = g2.findAttribute("GCTPProjectionCode"); if (gctp == null || !gctp.getNumericValue().equals(0)) continue; Attribute nlon = g2.findAttribute("NumberOfLongitudesInGrid"); Attribute nlat = g2.findAttribute("NumberOfLatitudesInGrid"); if (nlon == null || nlon.isString()) continue; if (nlat == null || nlat.isString()) continue; ds.addCoordinateAxis(makeLonCoordAxis(ds, g2, nlon.getNumericValue().intValue(), "XDim")); ds.addCoordinateAxis(makeLatCoordAxis(ds, g2, nlat.getNumericValue().intValue(), "YDim")); for (Group g3 : g2.getGroups()) { for (Variable v : g3.getVariables()) { v.addAttribute(new Attribute(_Coordinate.Axes, "lat lon")); } } } ds.finish(); }
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 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 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 ); }
/** * Turn the variable into a coordinate axis, if not already. Add to the dataset, replacing variable if needed. * * @return variable as a coordinate axis */ public CoordinateAxis makeIntoCoordinateAxis() { if (axis != null) return axis; // if not a CoordinateAxis, will turn into one v = axis = ds.addCoordinateAxis((VariableDS) v); if (axisType != null) { axis.setAxisType(axisType); axis.addAttribute(new Attribute(_Coordinate.AxisType, axisType.toString())); if (((axisType == AxisType.Height) || (axisType == AxisType.Pressure) || (axisType == AxisType.GeoZ)) && (positive != null)) { axis.setPositive(positive); axis.addAttribute(new Attribute(_Coordinate.ZisPositive, positive)); } } return axis; }
/** * Turn the variable into a coordinate axis, if not already. Add to the dataset, replacing variable if needed. * * @return variable as a coordinate axis */ public CoordinateAxis makeIntoCoordinateAxis() { if (axis != null) return axis; // if not a CoordinateAxis, will turn into one v = axis = ds.addCoordinateAxis((VariableDS) v); if (axisType != null) { axis.setAxisType(axisType); axis.addAttribute(new Attribute(_Coordinate.AxisType, axisType.toString())); if (((axisType == AxisType.Height) || (axisType == AxisType.Pressure) || (axisType == AxisType.GeoZ)) && (positive != null)) { axis.setPositive(positive); axis.addAttribute(new Attribute(_Coordinate.ZisPositive, positive)); } } return axis; }
/** * Turn the variable into a coordinate axis, if not already. Add to the dataset, replacing variable if needed. * * @return variable as a coordinate axis */ public CoordinateAxis makeIntoCoordinateAxis() { if (axis != null) return axis; // if not a CoordinateAxis, will turn into one v = axis = ds.addCoordinateAxis((VariableDS) v); if (axisType != null) { axis.setAxisType(axisType); axis.addAttribute(new Attribute(_Coordinate.AxisType, axisType.toString())); if (((axisType == AxisType.Height) || (axisType == AxisType.Pressure) || (axisType == AxisType.GeoZ)) && (positive != null)) { axis.setPositive(positive); axis.addAttribute(new Attribute(_Coordinate.ZisPositive, positive)); } } return axis; }
private CoordinateSystem findReplacementCs(CoordinateSystem protoCs, String timeDim, NetcdfDataset result) { CoordinateSystem replace = result.findCoordinateSystem(protoCs.getName()); if (replace != null) return replace; List<CoordinateAxis> axes = new ArrayList<CoordinateAxis>(); for (CoordinateAxis axis : protoCs.getCoordinateAxes()) { Variable v = result.findCoordinateAxis(axis.getFullNameEscaped()); CoordinateAxis ra; if (v instanceof CoordinateAxis) ra = (CoordinateAxis) v; else { // if not a CoordinateAxis, will turn into one ra = result.addCoordinateAxis((VariableDS) v); if (axis.getAxisType() != null) { ra.setAxisType(axis.getAxisType()); ra.addAttribute(new Attribute(_Coordinate.AxisType, axis.getAxisType().toString())); } } axes.add(ra); } // coord transforms are immutable and can be shared CoordinateSystem cs = new CoordinateSystem(result, axes, protoCs.getCoordinateTransforms()); result.addCoordinateSystem(cs); return cs; }
private boolean addTimeCoordinate(NetcdfDataset ds) { // add time coordinate CalendarDate cd = parseFilenameForDate(ds.getLocation()); if (cd == null) return false; ds.addAttribute(ds.getRootGroup(), new Attribute("_MODIS_Date", cd.toString())); // add the time dimension int nTimesDim = 1; Dimension newDim = new Dimension(TIME_NAME, nTimesDim); ds.addDimension( null, newDim); // add the coordinate variable String units = "seconds since "+cd.toString(); String desc = "time coordinate"; Array data = Array.makeArray(DataType.DOUBLE, 1, 0.0, 0.0) ; CoordinateAxis1D timeCoord = new CoordinateAxis1D( ds, null, TIME_NAME, DataType.DOUBLE, "", units, desc); timeCoord.setCachedData(data, true); timeCoord.addAttribute(new Attribute(_Coordinate.AxisType, AxisType.Time.toString())); ds.addCoordinateAxis(timeCoord); return true; }
private boolean addTimeCoordinate(NetcdfDataset ds) { // add time coordinate CalendarDate cd = parseFilenameForDate(ds.getLocation()); if (cd == null) return false; ds.addAttribute(ds.getRootGroup(), new Attribute("_MODIS_Date", cd.toString())); // add the time dimension int nTimesDim = 1; Dimension newDim = new Dimension(TIME_NAME, nTimesDim); ds.addDimension( null, newDim); // add the coordinate variable String units = "seconds since "+cd.toString(); String desc = "time coordinate"; Array data = Array.makeArray(DataType.DOUBLE, 1, 0.0, 0.0) ; CoordinateAxis1D timeCoord = new CoordinateAxis1D( ds, null, TIME_NAME, DataType.DOUBLE, "", units, desc); timeCoord.setCachedData(data, true); timeCoord.addAttribute(new Attribute(_Coordinate.AxisType, AxisType.Time.toString())); ds.addCoordinateAxis(timeCoord); return true; }
private boolean addTimeCoordinate(NetcdfDataset ds) { // add time coordinate CalendarDate cd = parseFilenameForDate(ds.getLocation()); if (cd == null) return false; ds.addAttribute(ds.getRootGroup(), new Attribute("_MODIS_Date", cd.toString())); // add the time dimension int nTimesDim = 1; Dimension newDim = new Dimension(TIME_NAME, nTimesDim); ds.addDimension( null, newDim); // add the coordinate variable String units = "seconds since "+cd.toString(); String desc = "time coordinate"; Array data = Array.makeArray(DataType.DOUBLE, 1, 0.0, 0.0) ; CoordinateAxis1D timeCoord = new CoordinateAxis1D( ds, null, TIME_NAME, DataType.DOUBLE, "", units, desc); timeCoord.setCachedData(data, true); timeCoord.addAttribute(new Attribute(_Coordinate.AxisType, AxisType.Time.toString())); ds.addCoordinateAxis(timeCoord); return true; }