ucar.nc2.dataset.CoordinateAxis Java Examples

The following examples show how to use ucar.nc2.dataset.CoordinateAxis. 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: HdfEosModisConvention.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private boolean addTimeCoordinate() {
  // add time coordinate by parsing the filename, of course.
  CalendarDate cd = parseFilenameForDate(datasetBuilder.orgFile.getLocation());
  if (cd == null) {
    return false;
  }

  rootGroup.addAttribute(new Attribute("_MODIS_Date", cd.toString()));

  // add the time dimension
  rootGroup.addDimension(new Dimension(TIME_NAME, 1));

  // add the coordinate variable
  String units = "seconds since " + cd;
  CoordinateAxis.Builder timeCoord = CoordinateAxis1D.builder().setName(TIME_NAME).setDataType(DataType.DOUBLE)
      .setParentGroupBuilder(rootGroup).setDimensionsByName("").setUnits(units).setDesc("time coordinate");
  timeCoord.setAutoGen(0, 0);
  timeCoord.addAttribute(new Attribute(_Coordinate.AxisType, AxisType.Time.toString()));
  datasetBuilder.replaceCoordinateAxis(rootGroup, timeCoord);

  return true;
}
 
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 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 #3
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 #4
Source File: AWIPSConvention.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private CoordinateAxis.Builder makeLatCoordAxis(int n, String name) {
  double min = findAttributeDouble("yMin");
  double max = findAttributeDouble("yMax");
  double d = findAttributeDouble("dy");
  if (Double.isNaN(min) || Double.isNaN(max) || Double.isNaN(d))
    return null;

  CoordinateAxis1D.Builder v = CoordinateAxis1D.builder().setName(name).setDataType(DataType.DOUBLE)
      .setParentGroupBuilder(rootGroup).setDimensionsByName(name).setUnits(CDM.LAT_UNITS).setDesc("latitude");
  v.addAttribute(new Attribute(_Coordinate.AxisType, AxisType.Lat.toString()));
  v.setAutoGen(min, d);

  double maxCalc = min + d * n;
  parseInfo.format("Created Lat Coordinate Axis (max calc= %f should be = %f)%n", maxCalc, max);
  return v;
}
 
Example #5
Source File: GridRenderer.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * @return x index for given point
 */
public int findSliceFromPoint(ProjectionPoint pp) {
  if ((null == drawProjection) || (null == stridedGrid))
    return -1;

  // convert to dataProjection, where x and y are orthogonal
  if (!sameProjection) {
    LatLonPoint llpt = drawProjection.projToLatLon(pp);
    pp = dataProjection.latLonToProj(llpt);
  }

  // find the grid index
  GridCoordSystem geocs = stridedGrid.getCoordinateSystem();
  CoordinateAxis xaxis = geocs.getXHorizAxis();
  if (!(xaxis instanceof CoordinateAxis1D))
    return -1;
  int[] index = geocs.findXYindexFromCoord(pp.getX(), pp.getY(), null);
  return index[0];
}
 
Example #6
Source File: ADASConvention.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void makeCoordAxis(String axisName) throws IOException {
  String name = axisName + "_stag";
  if (!rootGroup.findVariableLocal(name).isPresent()) {
    return;
  }
  VariableDS.Builder stagV = (VariableDS.Builder) rootGroup.findVariableLocal(name).get();
  Array data_stag = stagV.orgVar.read();
  int n = (int) data_stag.getSize() - 1;
  DataType dt = DataType.getType(data_stag);
  Array data = Array.factory(dt, new int[] {n});
  Index stagIndex = data_stag.getIndex();
  Index dataIndex = data.getIndex();
  for (int i = 0; i < n; i++) {
    double val = data_stag.getDouble(stagIndex.set(i)) + data_stag.getDouble(stagIndex.set(i + 1));
    data.setDouble(dataIndex.set(i), 0.5 * val);
  }

  DataType dtype = DataType.getType(data);
  String units = stagV.getAttributeContainer().findAttributeString(CDM.UNITS, "m");
  CoordinateAxis.Builder cb = CoordinateAxis1D.builder().setName(axisName).setDataType(dtype)
      .setParentGroupBuilder(rootGroup).setDimensionsByName(axisName).setUnits(units)
      .setDesc("synthesized non-staggered " + axisName + " coordinate");
  cb.setCachedData(data, true);
  datasetBuilder.replaceCoordinateAxis(rootGroup, cb);
}
 
Example #7
Source File: CoordSystemBuilder.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Does this axis "fit" this variable. True if all of the dimensions in the axis also appear in
 * the variable. If char variable, last dimension is left out.
 *
 * @param axis check if this axis is ok for the given variable
 * @param vp the given variable
 * @return true if all of the dimensions in the axis also appear in the variable.
 */
protected boolean isCoordinateAxisForVariable(CoordinateAxis.Builder<?> axis, VarProcess vp) {
  ImmutableList<Dimension> varDims = vp.vb.getDimensions();
  ImmutableList<Dimension> axisDims = axis.getDimensions();

  // a CHAR variable must really be a STRING, so leave out the last (string length) dimension
  int checkDims = axisDims.size();
  if (axis.dataType == DataType.CHAR)
    checkDims--;

  for (int i = 0; i < checkDims; i++) {
    Dimension axisDim = axisDims.get(i);
    if (!varDims.contains(axisDim)) {
      return false;
    }
  }
  return true;
}
 
Example #8
Source File: GridDatasetInfo.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public int compare(GridDatatype grid1, GridDatatype grid2) {
  GridCoordSystem gcs1 = grid1.getCoordinateSystem();
  GridCoordSystem gcs2 = grid2.getCoordinateSystem();

  CoordinateAxis time1 = gcs1.getTimeAxis();
  CoordinateAxis time2 = gcs2.getTimeAxis();
  int ret = compareAxis(time1, time2);
  if (ret != 0)
    return ret;

  CoordinateAxis vert1 = gcs1.getVerticalAxis();
  CoordinateAxis vert2 = gcs2.getVerticalAxis();
  ret = compareAxis(vert1, vert2);
  if (ret != 0)
    return ret;

  return grid1.getFullName().compareTo(grid2.getFullName());
}
 
Example #9
Source File: CoordSystemBuilder.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Make implicit CoordinateSystem objects for variables that dont already have one, by using the
 * variables' list of coordinate axes, and any coordinateVariables for it. Must be at least 2
 * axes. All of a variable's _Coordinate Variables_ plus any variables listed in a
 * *__CoordinateAxes_* or *_coordinates_* attribute will be made into an *_implicit_* Coordinate
 * System. If there are at least two axes, and the coordinate system uses all of the variable's
 * dimensions, it will be assigned to the data variable.
 */
protected void makeCoordinateSystemsImplicit() {
  for (VarProcess vp : varList) {
    if (!vp.hasCoordinateSystem() && vp.maybeData()) {
      List<CoordinateAxis.Builder> dataAxesList = vp.findCoordinateAxes(true);
      if (dataAxesList.size() < 2) {
        continue;
      }

      String csName = coords.makeCanonicalName(dataAxesList);
      Optional<CoordinateSystem.Builder> csOpt = coords.findCoordinateSystem(csName);
      if (csOpt.isPresent() && coords.isComplete(csOpt.get(), vp.vb)) {
        vp.vb.addCoordinateSystemName(csName);
        parseInfo.format(" assigned implicit CoordSystem '%s' for var= %s%n", csName, vp);
      } else {
        CoordinateSystem.Builder csnew = CoordinateSystem.builder().setCoordAxesNames(csName).setImplicit(true);
        if (coords.isComplete(csnew, vp.vb)) {
          vp.vb.addCoordinateSystemName(csName);
          coords.addCoordinateSystem(csnew);
          parseInfo.format(" created implicit CoordSystem '%s' for var= %s%n", csName, vp);
        }
      }
    }
  }
}
 
Example #10
Source File: CoordinatesHelper.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void addAxes(Group group, List<CoordinateAxis> axes) {
  for (Variable v : group.getVariables()) {
    if (v instanceof CoordinateAxis) {
      axes.add((CoordinateAxis) v);
    }
    if (v instanceof Structure) {
      Structure s = (Structure) v;
      for (Variable nested : s.getVariables()) {
        if (nested instanceof CoordinateAxis) {
          axes.add((CoordinateAxis) nested);
        }
      }
    }
  }
  for (Group nestedGroup : group.getGroups()) {
    addAxes(nestedGroup, axes);
  }
}
 
Example #11
Source File: WRFConvention.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Nullable
private CoordinateAxis.Builder makeLonCoordAxis(String axisName, Dimension dim) {
  if (dim == null)
    return null;
  double dx = 4 * findAttributeDouble("DX");
  int nx = dim.getLength();
  double startx = centerX - dx * (nx - 1) / 2;

  CoordinateAxis.Builder v = CoordinateAxis1D.builder().setName(axisName).setDataType(DataType.DOUBLE)
      .setDimensionsByName(dim.getShortName()).setUnits("degrees_east").setDesc("synthesized longitude coordinate");
  v.setAutoGen(startx, dx);
  v.setAxisType(AxisType.Lon);
  v.addAttribute(new Attribute(_Coordinate.AxisType, "Lon"));
  if (!axisName.equals(dim.getShortName()))
    v.addAttribute(new Attribute(_Coordinate.AliasForDimension, dim.getShortName()));

  return v;
}
 
Example #12
Source File: WRFConvention.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Nullable
private CoordinateAxis.Builder makeLatCoordAxis(String axisName, Dimension dim) {
  if (dim == null)
    return null;
  double dy = findAttributeDouble("DY");
  int ny = dim.getLength();
  double starty = centerY - dy * (ny - 1) / 2;

  CoordinateAxis.Builder v = CoordinateAxis1D.builder().setName(axisName).setDataType(DataType.DOUBLE)
      .setDimensionsByName(dim.getShortName()).setUnits("degrees_north").setDesc("synthesized latitude coordinate");
  v.setAutoGen(starty, dy);
  v.setAxisType(AxisType.Lat);
  v.addAttribute(new Attribute(_Coordinate.AxisType, "Lat"));
  if (!axisName.equals(dim.getShortName()))
    v.addAttribute(new Attribute(_Coordinate.AliasForDimension, dim.getShortName()));

  return v;
}
 
Example #13
Source File: WRFConvention.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Nullable
private CoordinateAxis.Builder makeXCoordAxis(String axisName, String dimName) {
  Optional<Dimension> dimOpt = rootGroup.findDimension(dimName);
  if (!dimOpt.isPresent()) {
    return null;
  }
  Dimension dim = dimOpt.get();
  double dx = findAttributeDouble("DX") / 1000.0; // km ya just gotta know
  int nx = dim.getLength();
  double startx = centerX - dx * (nx - 1) / 2; // ya just gotta know

  CoordinateAxis.Builder v = CoordinateAxis1D.builder().setName(axisName).setDataType(DataType.DOUBLE)
      .setParentGroupBuilder(rootGroup).setDimensionsByName(dim.getShortName()).setUnits("km")
      .setDesc("synthesized GeoX coordinate from DX attribute");
  v.setAutoGen(startx, dx);
  v.setAxisType(AxisType.GeoX);
  v.addAttribute(new Attribute(_Coordinate.AxisType, "GeoX"));
  if (!axisName.equals(dim.getShortName()))
    v.addAttribute(new Attribute(_Coordinate.AliasForDimension, dim.getShortName()));

  if (gridE)
    v.addAttribute(new Attribute(_Coordinate.Stagger, CDM.ARAKAWA_E));
  return v;
}
 
Example #14
Source File: CoordinatesHelper.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
String makeCanonicalName(VariableDS.Builder<?> vb, String axesNames) {
  Preconditions.checkNotNull(axesNames);
  List<CoordinateAxis.Builder> axes = new ArrayList<>();
  StringTokenizer stoker = new StringTokenizer(axesNames);
  while (stoker.hasMoreTokens()) {
    String vname = stoker.nextToken();
    Optional<CoordinateAxis.Builder> vbOpt = findAxisByFullName(vname);
    if (!vbOpt.isPresent()) {
      vbOpt = findAxisByVerticalSearch(vb, vname);
    }
    if (vbOpt.isPresent()) {
      axes.add(vbOpt.get());
    } else {
      // TODO this should fail, leaving it here to match current behavior.
      log.warn("No axis named {}", vname);
      // throw new IllegalArgumentException("Cant find axis " + vname);
    }
  }
  return makeCanonicalName(axes);
}
 
Example #15
Source File: WRFConvention.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Nullable
private CoordinateAxis.Builder makeYCoordAxis(String axisName, String dimName) {
  Optional<Dimension> dimOpt = rootGroup.findDimension(dimName);
  if (!dimOpt.isPresent()) {
    return null;
  }
  Dimension dim = dimOpt.get();
  double dy = findAttributeDouble("DY") / 1000.0;
  int ny = dim.getLength();
  double starty = centerY - dy * (ny - 1) / 2; // - dy/2; // ya just gotta know

  CoordinateAxis.Builder v = CoordinateAxis1D.builder().setName(axisName).setDataType(DataType.DOUBLE)
      .setParentGroupBuilder(rootGroup).setDimensionsByName(dim.getShortName()).setUnits("km")
      .setDesc("synthesized GeoY coordinate from DY attribute");
  v.setAxisType(AxisType.GeoY);
  v.addAttribute(new Attribute(_Coordinate.AxisType, "GeoY"));
  v.setAutoGen(starty, dy);
  if (!axisName.equals(dim.getShortName()))
    v.addAttribute(new Attribute(_Coordinate.AliasForDimension, dim.getShortName()));

  if (gridE)
    v.addAttribute(new Attribute(_Coordinate.Stagger, CDM.ARAKAWA_E));
  return v;
}
 
Example #16
Source File: DapperDataset.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public static PointObsDataset factory(NetcdfDataset ds) throws IOException {
  Variable latVar = null, timeVar = null;

  // identify key variables
  List axes = ds.getCoordinateAxes();
  for (int i = 0; i < axes.size(); i++) {
    CoordinateAxis axis = (CoordinateAxis) axes.get(i);
    if (axis.getAxisType() == AxisType.Lat)
      latVar = axis;
    if (axis.getAxisType() == AxisType.Time)
      timeVar = axis;
  }

  // lat, lon are always in the outer; gotta use name to fetch wrapping variable
  Structure outerSequence = getWrappingParent(ds, latVar);

  // depth may be in inner or outer
  boolean isProfile = getWrappingParent(ds, timeVar) == outerSequence;
  if (isProfile)
    return new DapperPointDataset(ds);
  else
    return new DapperStationDataset(ds);
}
 
Example #17
Source File: FmrcDataset.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
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<>();
  for (CoordinateAxis axis : protoCs.getCoordinateAxes()) {
    CoordinateAxis ra = result.findCoordinateAxis(axis.getFullNameEscaped());
    axes.add(ra);
  }

  // coord transforms are immutable and can be shared
  CoordinateSystem cs = new CoordinateSystem(result, axes, protoCs.getCoordinateTransforms());
  result.addCoordinateSystem(cs);
  return cs;
}
 
Example #18
Source File: CoordinatesHelper.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private CoordinatesHelper(Builder builder, NetcdfDataset ncd) {
  List<CoordinateAxis> axes = new ArrayList<>();
  addAxes(ncd.getRootGroup(), axes);
  this.coordAxes = ImmutableList.copyOf(axes);

  coordTransforms =
      builder.coordTransforms.stream().map(ct -> ct.build(ncd)).filter(Objects::nonNull).collect(Collectors.toList());

  coordTransforms.addAll(builder.verticalCTBuilders.stream().map(ct -> ct.makeVerticalCT(ncd))
      .filter(Objects::nonNull).collect(Collectors.toList()));

  this.coordSystems = builder.coordSys.stream().map(s -> s.build(ncd, this.coordAxes, this.coordTransforms))
      .collect(Collectors.toList());
}
 
Example #19
Source File: HdfEosModisConvention.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private CoordinateAxis.Builder makeLatLonCoordAxis(Group.Builder dataG, int n, double start, double end,
    boolean isLon) {
  String name = isLon ? AxisType.Lon.toString() : AxisType.Lat.toString();
  String dimName = isLon ? DIMX_NAME : DIMY_NAME;

  CoordinateAxis.Builder v = CoordinateAxis1D.builder().setName(name).setDataType(DataType.DOUBLE)
      .setParentGroupBuilder(dataG).setDimensionsByName(dimName).setUnits(isLon ? "degrees_east" : "degrees_north");

  double incr = (end - start) / n;
  v.setAutoGen(start, incr);
  v.addAttribute(new Attribute(_Coordinate.AxisType, name));
  return v;
}
 
Example #20
Source File: CoordinatesHelper.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private List<CoordinateAxis.Builder<?>> getAxesForSystem(CoordinateSystem.Builder cs) {
  Preconditions.checkNotNull(cs);
  List<CoordinateAxis.Builder<?>> axes = new ArrayList<>();
  StringTokenizer stoker = new StringTokenizer(cs.coordAxesNames);
  while (stoker.hasMoreTokens()) {
    String vname = stoker.nextToken();
    Optional<CoordinateAxis.Builder> vbOpt = findAxisByFullName(vname);
    if (vbOpt.isPresent()) {
      axes.add(vbOpt.get());
    } else {
      throw new IllegalArgumentException("Cant find axis " + vname);
    }
  }
  return axes;
}
 
Example #21
Source File: TableConfigurerImpl.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
protected CoordinateAxis findZAxisNotStationAlt(NetcdfDataset ds) {
  CoordinateAxis z = CoordSysEvaluator.findCoordByType(ds, AxisType.Height, new NotStationAlt());
  if (z != null)
    return z;

  z = CoordSysEvaluator.findCoordByType(ds, AxisType.Pressure, new NotStationAlt());
  if (z != null)
    return z;

  z = CoordSysEvaluator.findCoordByType(ds, AxisType.GeoZ, new NotStationAlt());
  return z;
}
 
Example #22
Source File: CoordinatesHelper.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public Optional<CoordinateAxis.Builder> findAxisByType(CoordinateSystem.Builder csys, AxisType type) {
  for (CoordinateAxis.Builder<?> axis : getAxesForSystem(csys)) {
    if (axis.axisType == type) {
      return Optional.of(axis);
    }
  }
  return Optional.empty();
}
 
Example #23
Source File: CoordinatesHelper.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public Builder addCoordinateAxis(CoordinateAxis.Builder axis) {
  if (axis == null) {
    return this;
  }
  coordAxes.add(axis);
  return this;
}
 
Example #24
Source File: CoordSysEvaluator.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * search for Dimension used by axis of given by Type.
 * 
 * @param ds search in this dataset's "Best" coordinate system.
 * @param atype search for this type of CoordinateAxis. takes the first one it finds.
 * @return the found CoordinateAxis' first Dimension, or null if none or scalar
 */
public static Dimension findDimensionByType(NetcdfDataset ds, AxisType atype) {
  CoordinateAxis axis = findCoordByType(ds, atype);
  if (axis == null)
    return null;
  if (axis.isScalar())
    return null;
  return axis.getDimension(0);
}
 
Example #25
Source File: HdfEosModisConvention.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private CoordinateAxis.Builder makeCoordAxis(Group.Builder dataG, String name, int n, double start, double end,
    boolean isX) {
  CoordinateAxis.Builder vb =
      CoordinateAxis1D.builder().setName(name).setDataType(DataType.DOUBLE).setParentGroupBuilder(dataG)
          .setDimensionsByName(name).setUnits("km").setDesc(isX ? "x coordinate" : "y coordinate");

  double incr = (end - start) / n;
  vb.setAutoGen(start * .001, incr * .001); // km
  vb.addAttribute(new Attribute(_Coordinate.AxisType, isX ? AxisType.GeoX.name() : AxisType.GeoY.name()));
  return vb;
}
 
Example #26
Source File: AWIPSConvention.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
CoordinateAxis.Builder makeYCoordAxis(String yname) {
  CoordinateAxis1D.Builder v = CoordinateAxis1D.builder().setName(yname).setDataType(DataType.DOUBLE)
      .setParentGroupBuilder(rootGroup).setDimensionsByName(yname).setUnits("km").setDesc("y on projection");
  v.setAutoGen(starty, dy);

  parseInfo.format("Created Y Coordinate Axis = %s%n", yname);
  return v;
}
 
Example #27
Source File: AWIPSConvention.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
CoordinateAxis.Builder makeXCoordAxis(String xname) {
  CoordinateAxis1D.Builder v = CoordinateAxis1D.builder().setName(xname).setDataType(DataType.DOUBLE)
      .setParentGroupBuilder(rootGroup).setDimensionsByName(xname).setUnits("km").setDesc("x on projection");
  v.setAutoGen(startx, dx);

  parseInfo.format("Created X Coordinate Axis = %s%n", xname);
  return v;
}
 
Example #28
Source File: AWIPSConvention.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private String getZisPositive(CoordinateAxis.Builder v) {
  String attValue = v.getAttributeContainer().findAttributeString("positive", null);
  if (null != attValue) {
    return attValue.equalsIgnoreCase("up") ? "up" : "down";
  }

  String unit = v.getUnits();
  if ((unit != null) && SimpleUnit.isCompatible("millibar", unit))
    return "down";
  if ((unit != null) && SimpleUnit.isCompatible("m", unit))
    return "up";

  // dunno
  return null;
}
 
Example #29
Source File: AWIPSSatConvention.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private CoordinateAxis.Builder makeLatCoordAxis(String yname) {
  CoordinateAxis1D.Builder v = CoordinateAxis1D.builder().setName(yname).setDataType(DataType.DOUBLE)
      .setParentGroupBuilder(rootGroup).setDimensionsByName(yname).setUnits(CDM.LAT_UNITS).setDesc("latitude");
  v.addAttribute(new Attribute(_Coordinate.AxisType, AxisType.Lat.toString()));
  v.setAutoGen(starty, dy);
  parseInfo.format("Created Lat Coordinate Axis = %s%n", yname);
  return v;
}
 
Example #30
Source File: AWIPSSatConvention.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private CoordinateAxis.Builder makeLonCoordAxis(String xname) {
  CoordinateAxis1D.Builder v = CoordinateAxis1D.builder().setName(xname).setDataType(DataType.DOUBLE)
      .setParentGroupBuilder(rootGroup).setDimensionsByName(xname).setUnits(CDM.LON_UNITS).setDesc("longitude");
  v.addAttribute(new Attribute(_Coordinate.AxisType, AxisType.Lon.toString()));
  v.setAutoGen(startx, dx);

  parseInfo.format("Created Lon Coordinate Axis = %s%n", xname);
  return v;
}