Java Code Examples for ucar.nc2.dataset.CoordinateAxis#addAttribute()

The following examples show how to use ucar.nc2.dataset.CoordinateAxis#addAttribute() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AWIPSConvention.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
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");
  v.setValues(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;
}
 
Example 2
Source File: AWIPSConvention.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
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");
  v.setValues(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;
}
 
Example 3
Source File: HdfEosOmiConvention.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 *
 */
private CoordinateAxis makeLatCoordAxis(NetcdfDataset ds, Group g, int n, String dimName) {
  double incr = 180.0 / n;
  CoordinateAxis v = new CoordinateAxis1D(ds, g, "lat", DataType.FLOAT, dimName, CDM.LAT_UNITS, "latitude");
  v.setValues(n, -90.0 + 0.5 * incr, incr);
  v.addAttribute(new Attribute(_Coordinate.AxisType, AxisType.Lat.toString()));
  return v;
}
 
Example 4
Source File: HdfEosOmiConvention.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 *
 */
private CoordinateAxis makeLonCoordAxis(NetcdfDataset ds, Group g, int n, String dimName) {
  double incr = 360.0 / n;
  CoordinateAxis v = new CoordinateAxis1D(ds, g, "lon", DataType.FLOAT, dimName, CDM.LON_UNITS, "longitude");
  v.setValues(n, -180.0 + 0.5 * incr, incr);
  v.addAttribute(new Attribute(_Coordinate.AxisType, AxisType.Lon.toString()));
  return v;
}