private VariableDS makeOffsetCoordinate(NetcdfDataset result, Group group, String dimName, CalendarDate base, double[] values) { DataType dtype = DataType.DOUBLE; VariableDS timeVar = new VariableDS(result, group, null, dimName+"_offset", dtype, dimName, null, null); // LOOK could just make a CoordinateAxis1D timeVar.addAttribute(new Attribute(CDM.LONG_NAME, "offset hour from start of run for coordinate = " + dimName)); timeVar.addAttribute(new ucar.nc2.Attribute("standard_name", "forecast_period")); timeVar.addAttribute(new ucar.nc2.Attribute(CDM.UNITS, "hours since " + base)); timeVar.addAttribute(new ucar.nc2.Attribute(CDM.MISSING_VALUE, Double.NaN)); // construct the values int ntimes = values.length; ArrayDouble.D1 timeCoordVals = (ArrayDouble.D1) Array.factory( DataType.DOUBLE, new int[] {ntimes}, values); timeVar.setCachedData(timeCoordVals); group.addVariable(timeVar); return timeVar; }
private VariableDS makeRunTimeCoordinate(NetcdfDataset result, Group group, String dimName, CalendarDate base, double[] values) { DataType dtype = DataType.DOUBLE; VariableDS timeVar = new VariableDS(result, group, null, dimName+"_run", dtype, dimName, null, null); // LOOK could just make a CoordinateAxis1D timeVar.addAttribute(new Attribute(CDM.LONG_NAME, "run times for coordinate = " + dimName)); timeVar.addAttribute(new ucar.nc2.Attribute("standard_name", "forecast_reference_time")); timeVar.addAttribute(new ucar.nc2.Attribute(CDM.UNITS, "hours since " + base)); timeVar.addAttribute(new ucar.nc2.Attribute(CDM.MISSING_VALUE, Double.NaN)); timeVar.addAttribute(new ucar.nc2.Attribute(_Coordinate.AxisType, AxisType.RunTime.toString())); // if theres already a time coord, dont put in coordSys - too complicated // construct the values int ntimes = values.length; ArrayDouble.D1 timeCoordVals = (ArrayDouble.D1) Array.factory( DataType.DOUBLE, new int[] {ntimes}, values); timeVar.setCachedData(timeCoordVals); group.addVariable(timeVar); return timeVar; }
private VariableDS makeOffsetCoordinate(NetcdfDataset result, Group group, String dimName, CalendarDate base, double[] values) { DataType dtype = DataType.DOUBLE; VariableDS timeVar = new VariableDS(result, group, null, dimName+"_offset", dtype, dimName, null, null); // LOOK could just make a CoordinateAxis1D timeVar.addAttribute(new Attribute(CDM.LONG_NAME, "offset hour from start of run for coordinate = " + dimName)); timeVar.addAttribute(new ucar.nc2.Attribute("standard_name", "forecast_period")); timeVar.addAttribute(new ucar.nc2.Attribute(CF.CALENDAR, base.getCalendar().name() )); timeVar.addAttribute(new ucar.nc2.Attribute(CDM.UNITS, "hours since " + base)); timeVar.addAttribute(new ucar.nc2.Attribute(CDM.MISSING_VALUE, Double.NaN)); // construct the values int ntimes = values.length; ArrayDouble.D1 timeCoordVals = (ArrayDouble.D1) Array.factory( DataType.DOUBLE, new int[] {ntimes}, values); timeVar.setCachedData(timeCoordVals); group.addVariable(timeVar); return timeVar; }
private VariableDS makeOffsetCoordinate(NetcdfDataset result, Group group, String dimName, CalendarDate base, double[] values) { DataType dtype = DataType.DOUBLE; VariableDS timeVar = new VariableDS(result, group, null, dimName+"_offset", dtype, dimName, null, null); // LOOK could just make a CoordinateAxis1D timeVar.addAttribute(new Attribute(CDM.LONG_NAME, "offset hour from start of run for coordinate = " + dimName)); timeVar.addAttribute(new ucar.nc2.Attribute("standard_name", "forecast_period")); timeVar.addAttribute(new ucar.nc2.Attribute(CF.CALENDAR, base.getCalendar().name() )); timeVar.addAttribute(new ucar.nc2.Attribute(CDM.UNITS, "hours since " + base)); timeVar.addAttribute(new ucar.nc2.Attribute(CDM.MISSING_VALUE, Double.NaN)); // construct the values int ntimes = values.length; ArrayDouble.D1 timeCoordVals = (ArrayDouble.D1) Array.factory( DataType.DOUBLE, new int[] {ntimes}, values); timeVar.setCachedData(timeCoordVals); group.addVariable(timeVar); return timeVar; }
private VariableDS makeRunTimeCoordinate(NetcdfDataset result, Group group, String dimName, CalendarDate base, double[] values) { DataType dtype = DataType.DOUBLE; VariableDS timeVar = new VariableDS(result, group, null, dimName+"_run", dtype, dimName, null, null); // LOOK could just make a CoordinateAxis1D timeVar.addAttribute(new Attribute(CDM.LONG_NAME, "run times for coordinate = " + dimName)); timeVar.addAttribute(new ucar.nc2.Attribute("standard_name", "forecast_reference_time")); timeVar.addAttribute(new ucar.nc2.Attribute(CF.CALENDAR, base.getCalendar().name() )); //timeVar.addAttribute(new ucar.nc2.Attribute(CDM.UNITS, "hours since " + base)); timeVar.addAttribute(new ucar.nc2.Attribute(CDM.UNITS, "hours since " + base.getTimeUnits() )); timeVar.addAttribute(new ucar.nc2.Attribute(CDM.MISSING_VALUE, Double.NaN)); timeVar.addAttribute(new ucar.nc2.Attribute(_Coordinate.AxisType, AxisType.RunTime.toString())); // if theres already a time coord, dont put in coordSys - too complicated // construct the values int ntimes = values.length; ArrayDouble.D1 timeCoordVals = (ArrayDouble.D1) Array.factory( DataType.DOUBLE, new int[] {ntimes}, values); timeVar.setCachedData(timeCoordVals); group.addVariable(timeVar); return timeVar; }
private VariableDS makeRunTimeCoordinate(NetcdfDataset result, Group group, String dimName, CalendarDate base, double[] values) { DataType dtype = DataType.DOUBLE; VariableDS timeVar = new VariableDS(result, group, null, dimName+"_run", dtype, dimName, null, null); // LOOK could just make a CoordinateAxis1D timeVar.addAttribute(new Attribute(CDM.LONG_NAME, "run times for coordinate = " + dimName)); timeVar.addAttribute(new ucar.nc2.Attribute("standard_name", "forecast_reference_time")); timeVar.addAttribute(new ucar.nc2.Attribute(CF.CALENDAR, base.getCalendar().name() )); //timeVar.addAttribute(new ucar.nc2.Attribute(CDM.UNITS, "hours since " + base)); timeVar.addAttribute(new ucar.nc2.Attribute(CDM.UNITS, "hours since " + base.getTimeUnits() )); timeVar.addAttribute(new ucar.nc2.Attribute(CDM.MISSING_VALUE, Double.NaN)); timeVar.addAttribute(new ucar.nc2.Attribute(_Coordinate.AxisType, AxisType.RunTime.toString())); // if theres already a time coord, dont put in coordSys - too complicated // construct the values int ntimes = values.length; ArrayDouble.D1 timeCoordVals = (ArrayDouble.D1) Array.factory( DataType.DOUBLE, new int[] {ntimes}, values); timeVar.setCachedData(timeCoordVals); group.addVariable(timeVar); return timeVar; }
private VariableDS makeTimeCoordinate(NetcdfDataset result, Group group, String dimName, CalendarDate base, FmrcInvLite.ValueB valueb) { DataType dtype = DataType.DOUBLE; VariableDS timeVar = new VariableDS(result, group, null, dimName, dtype, dimName, null, null); // LOOK could just make a CoordinateAxis1D timeVar.addAttribute(new Attribute(CDM.LONG_NAME, "Forecast time for ForecastModelRunCollection")); timeVar.addAttribute(new ucar.nc2.Attribute("standard_name", "time")); timeVar.addAttribute(new ucar.nc2.Attribute(CDM.UNITS, "hours since " + base)); timeVar.addAttribute(new ucar.nc2.Attribute(CDM.MISSING_VALUE, Double.NaN)); timeVar.addAttribute(new ucar.nc2.Attribute(_Coordinate.AxisType, AxisType.Time.toString())); // construct the values int ntimes = valueb.offset.length; timeVar.setCachedData(Array.factory( DataType.DOUBLE, new int[] {ntimes}, valueb.offset)); group.addVariable(timeVar); if (valueb.bounds != null) { String bname = timeVar.getShortName() + "_bounds"; timeVar.addAttribute(new ucar.nc2.Attribute("bounds", bname)); Dimension bd = ucar.nc2.dataset.DatasetConstructor.getBoundsDimension( result); VariableDS boundsVar = new VariableDS(result, group, null, bname, dtype, dimName+" " + bd.getShortName(), null, null); boundsVar.addAttribute(new Attribute(CDM.LONG_NAME, "bounds for "+ timeVar.getShortName())); boundsVar.setCachedData(Array.factory( DataType.DOUBLE, new int[] {ntimes, 2}, valueb.bounds)); group.addVariable(boundsVar); } return timeVar; }
private VariableDS makeTimeCoordinate(NetcdfDataset result, Group group, String dimName, CalendarDate base, FmrcInvLite.ValueB valueb) { DataType dtype = DataType.DOUBLE; VariableDS timeVar = new VariableDS(result, group, null, dimName, dtype, dimName, null, null); // LOOK could just make a CoordinateAxis1D timeVar.addAttribute(new Attribute(CDM.LONG_NAME, "Forecast time for ForecastModelRunCollection")); timeVar.addAttribute(new ucar.nc2.Attribute("standard_name", "time")); timeVar.addAttribute(new ucar.nc2.Attribute(CF.CALENDAR, base.getCalendar().name() )); //timeVar.addAttribute(new ucar.nc2.Attribute(CDM.UNITS, "hours since " + base)); //Ensure a valid udunit timeVar.addAttribute(new ucar.nc2.Attribute(CDM.UNITS, "hours since " + base.getTimeUnits())); timeVar.addAttribute(new ucar.nc2.Attribute(CDM.MISSING_VALUE, Double.NaN)); timeVar.addAttribute(new ucar.nc2.Attribute(_Coordinate.AxisType, AxisType.Time.toString())); // construct the values int ntimes = valueb.offset.length; timeVar.setCachedData(Array.factory( DataType.DOUBLE, new int[] {ntimes}, valueb.offset)); group.addVariable(timeVar); if (valueb.bounds != null) { String bname = timeVar.getShortName() + "_bounds"; timeVar.addAttribute(new ucar.nc2.Attribute("bounds", bname)); Dimension bd = ucar.nc2.dataset.DatasetConstructor.getBoundsDimension( result); VariableDS boundsVar = new VariableDS(result, group, null, bname, dtype, dimName+" " + bd.getShortName(), null, null); boundsVar.addAttribute(new Attribute(CDM.LONG_NAME, "bounds for "+ timeVar.getShortName())); boundsVar.setCachedData(Array.factory( DataType.DOUBLE, new int[] {ntimes, 2}, valueb.bounds)); group.addVariable(boundsVar); } return timeVar; }
private VariableDS makeTimeCoordinate(NetcdfDataset result, Group group, String dimName, CalendarDate base, FmrcInvLite.ValueB valueb) { DataType dtype = DataType.DOUBLE; VariableDS timeVar = new VariableDS(result, group, null, dimName, dtype, dimName, null, null); // LOOK could just make a CoordinateAxis1D timeVar.addAttribute(new Attribute(CDM.LONG_NAME, "Forecast time for ForecastModelRunCollection")); timeVar.addAttribute(new ucar.nc2.Attribute("standard_name", "time")); timeVar.addAttribute(new ucar.nc2.Attribute(CF.CALENDAR, base.getCalendar().name() )); //timeVar.addAttribute(new ucar.nc2.Attribute(CDM.UNITS, "hours since " + base)); //Ensure a valid udunit timeVar.addAttribute(new ucar.nc2.Attribute(CDM.UNITS, "hours since " + base.getTimeUnits())); timeVar.addAttribute(new ucar.nc2.Attribute(CDM.MISSING_VALUE, Double.NaN)); timeVar.addAttribute(new ucar.nc2.Attribute(_Coordinate.AxisType, AxisType.Time.toString())); // construct the values int ntimes = valueb.offset.length; timeVar.setCachedData(Array.factory( DataType.DOUBLE, new int[] {ntimes}, valueb.offset)); group.addVariable(timeVar); if (valueb.bounds != null) { String bname = timeVar.getShortName() + "_bounds"; timeVar.addAttribute(new ucar.nc2.Attribute("bounds", bname)); Dimension bd = ucar.nc2.dataset.DatasetConstructor.getBoundsDimension( result); VariableDS boundsVar = new VariableDS(result, group, null, bname, dtype, dimName+" " + bd.getShortName(), null, null); boundsVar.addAttribute(new Attribute(CDM.LONG_NAME, "bounds for "+ timeVar.getShortName())); boundsVar.setCachedData(Array.factory( DataType.DOUBLE, new int[] {ntimes, 2}, valueb.bounds)); group.addVariable(boundsVar); } return timeVar; }
private Projection makeLCProjection(NetcdfDataset ds) { Attribute latLonOrigin = projVar.findAttributeIgnoreCase("latLonOrigin"); if (latLonOrigin == null) throw new IllegalStateException(); double centralLon = latLonOrigin.getNumericValue(0).doubleValue(); double centralLat = latLonOrigin.getNumericValue(1).doubleValue(); double par1 = findAttributeDouble( "stdParallelOne"); double par2 = findAttributeDouble( "stdParallelTwo"); LambertConformal lc = new LambertConformal(centralLat, centralLon, par1, par2); // make Coordinate Transform Variable ProjectionCT ct = new ProjectionCT("lambertConformalProjection", "FGDC", lc); VariableDS ctVar = makeCoordinateTransformVariable(ds, ct); ctVar.addAttribute( new Attribute(_Coordinate.Axes, "xCoord yCoord")); ds.addVariable(null, ctVar); return lc; }
private Projection makeLCProjection(NetcdfDataset ds) { Attribute latLonOrigin = projVar.findAttributeIgnoreCase("latLonOrigin"); if (latLonOrigin == null) throw new IllegalStateException(); double centralLon = latLonOrigin.getNumericValue(0).doubleValue(); double centralLat = latLonOrigin.getNumericValue(1).doubleValue(); double par1 = findAttributeDouble( "stdParallelOne"); double par2 = findAttributeDouble( "stdParallelTwo"); LambertConformal lc = new LambertConformal(centralLat, centralLon, par1, par2); // make Coordinate Transform Variable ProjectionCT ct = new ProjectionCT("lambertConformalProjection", "FGDC", lc); VariableDS ctVar = makeCoordinateTransformVariable(ds, ct); ctVar.addAttribute( new Attribute(_Coordinate.Axes, "xCoord yCoord")); ds.addVariable(null, ctVar); return lc; }
private Projection makeLCProjection(NetcdfDataset ds) { Attribute latLonOrigin = projVar.findAttributeIgnoreCase("latLonOrigin"); double centralLon = latLonOrigin.getNumericValue(0).doubleValue(); double centralLat = latLonOrigin.getNumericValue(1).doubleValue(); double par1 = findAttributeDouble( "stdParallelOne"); double par2 = findAttributeDouble( "stdParallelTwo"); LambertConformal lc = new LambertConformal(centralLat, centralLon, par1, par2); // make Coordinate Transform Variable ProjectionCT ct = new ProjectionCT("lambertConformalProjection", "FGDC", lc); VariableDS ctVar = makeCoordinateTransformVariable(ds, ct); ctVar.addAttribute( new Attribute(_Coordinate.Axes, "xCoord yCoord")); ds.addVariable(null, ctVar); return lc; }
public void augmentDataset(NetcdfDataset ds, CancelTask cancelTask) { projCT = makeProjectionCT(ds); if (projCT != null) { VariableDS v = makeCoordinateTransformVariable(ds, projCT); ds.addVariable(null, v); String xname = findCoordinateName(ds, AxisType.GeoX); String yname = findCoordinateName(ds, AxisType.GeoY); if (xname != null && yname != null) v.addAttribute(new Attribute(_Coordinate.Axes, xname + " " + yname)); } ds.finish(); }
public void augmentDataset(NetcdfDataset ds, CancelTask cancelTask) { projCT = makeProjectionCT(ds); if (projCT != null) { VariableDS v = makeCoordinateTransformVariable(ds, projCT); ds.addVariable(null, v); String xname = findCoordinateName(ds, AxisType.GeoX); String yname = findCoordinateName(ds, AxisType.GeoY); if (xname != null && yname != null) v.addAttribute(new Attribute(_Coordinate.Axes, xname + " " + yname)); } ds.finish(); }
public void augmentDataset(NetcdfDataset ds, CancelTask cancelTask) { projCT = makeProjectionCT(ds); if (projCT != null) { VariableDS v = makeCoordinateTransformVariable(ds, projCT); ds.addVariable(null, v); String xname = findCoordinateName(ds, AxisType.GeoX); String yname = findCoordinateName(ds, AxisType.GeoY); if (xname != null && yname != null) v.addAttribute(new Attribute(_Coordinate.Axes, xname + " " + yname)); } ds.finish(); }
public void augmentDataset(NetcdfDataset ds, CancelTask cancelTask) { projCT = makeProjectionCT(ds); if (projCT != null) { VariableDS v = makeCoordinateTransformVariable(ds, projCT); ds.addVariable(null, v); String xname = findCoordinateName(ds, AxisType.GeoX); String yname = findCoordinateName(ds, AxisType.GeoY); if (xname != null && yname != null) v.addAttribute(new Attribute(_Coordinate.Axes, xname + " " + yname)); } ds.finish(); }
public void augmentDataset(NetcdfDataset ds, CancelTask cancelTask) { projCT = makeProjectionCT(ds); if (projCT != null) { VariableDS v = makeCoordinateTransformVariable(ds, projCT); ds.addVariable(null, v); String xname = findCoordinateName(ds, AxisType.GeoX); String yname = findCoordinateName(ds, AxisType.GeoY); if (xname != null && yname != null) v.addAttribute(new Attribute(_Coordinate.Axes, xname + " " + yname)); } ds.finish(); }
public void augmentDataset(NetcdfDataset ds, CancelTask cancelTask) { projCT = makeProjectionCT(ds); if (projCT != null) { VariableDS v = makeCoordinateTransformVariable(ds, projCT); ds.addVariable(null, v); String xname = findCoordinateName(ds, AxisType.GeoX); String yname = findCoordinateName(ds, AxisType.GeoY); if (xname != null && yname != null) v.addAttribute(new Attribute(_Coordinate.Axes, xname + " " + yname)); } ds.finish(); }
/** * Create a "dummy" Coordinate Transform Variable based on the given CoordinateTransform. * This creates a scalar Variable with dummy data, and adds the Parameters of the CoordinateTransform * as attributes. * @param ds for this dataset * @param ct based on the CoordinateTransform * @return the Coordinate Transform Variable. You must add it to the dataset. */ static public VariableDS makeDummyTransformVariable(NetcdfDataset ds, CoordinateTransform ct) { VariableDS v = new VariableDS( ds, null, null, ct.getName(), DataType.CHAR, "", null, null); List<Parameter> params = ct.getParameters(); for (Parameter p : params) { if (p.isString()) v.addAttribute(new Attribute(p.getName(), p.getStringValue())); else { double[] data = p.getNumericValues(); Array dataA = Array.factory(DataType.DOUBLE, new int[]{data.length}, data); v.addAttribute(new Attribute(p.getName(), dataA)); } } v.addAttribute( new Attribute(_Coordinate.TransformType, ct.getTransformType().toString())); // fake data Array data = Array.factory(DataType.CHAR, new int[] {}, new char[] {' '}); v.setCachedData(data, true); return v; }
/** * Create a "dummy" Coordinate Transform Variable based on the given CoordinateTransform. * This creates a scalar Variable with dummy data, and adds the Parameters of the CoordinateTransform * as attributes. * @param ds for this dataset * @param ct based on the CoordinateTransform * @return the Coordinate Transform Variable. You must add it to the dataset. */ static public VariableDS makeDummyTransformVariable(NetcdfDataset ds, CoordinateTransform ct) { VariableDS v = new VariableDS( ds, null, null, ct.getName(), DataType.CHAR, "", null, null); List<Parameter> params = ct.getParameters(); for (Parameter p : params) { if (p.isString()) v.addAttribute(new Attribute(p.getName(), p.getStringValue())); else { double[] data = p.getNumericValues(); Array dataA = Array.factory(double.class, new int[]{data.length}, data); v.addAttribute(new Attribute(p.getName(), dataA)); } } v.addAttribute( new Attribute(_Coordinate.TransformType, ct.getTransformType().toString())); // fake data Array data = Array.factory(DataType.CHAR.getPrimitiveClassType(), new int[] {}, new char[] {' '}); v.setCachedData(data, true); return v; }