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

The following examples show how to use ucar.nc2.dataset.CoordinateAxis#getDimension() . 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: RafNimbus.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public TableConfig getConfig(FeatureType wantFeatureType, NetcdfDataset ds, Formatter errlog) {
  TableConfig topTable = new TableConfig(Table.Type.Top, "singleTrajectory");

  CoordinateAxis coordAxis = CoordSysEvaluator.findCoordByType(ds, AxisType.Time);
  if (coordAxis == null) {
    errlog.format("Cant find a time coordinate");
    return null;
  }
  Dimension innerDim = coordAxis.getDimension(0);
  boolean obsIsStruct = Evaluator.hasNetcdf3RecordStructure(ds) && innerDim.isUnlimited();

  TableConfig obsTable = new TableConfig(Table.Type.Structure, innerDim.getShortName());
  obsTable.dimName = innerDim.getShortName();
  obsTable.time = coordAxis.getFullName();
  obsTable.structName = obsIsStruct ? "record" : innerDim.getShortName();
  obsTable.structureType =
      obsIsStruct ? TableConfig.StructureType.Structure : TableConfig.StructureType.PsuedoStructure;
  CoordSysEvaluator.findCoords(obsTable, ds, axis -> innerDim.equals(axis.getDimension(0)));

  topTable.addChild(obsTable);
  return topTable;
}
 
Example 2
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 3
Source File: NdbcNetcdf4.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public TableConfig getConfig(FeatureType wantFeatureType, NetcdfDataset ds, Formatter errlog) {
  Dimension obsDim = ds.findDimension("time");
  if (obsDim == null) {
    CoordinateAxis axis = CoordSysEvaluator.findCoordByType(ds, AxisType.Time);
    if ((axis != null) && axis.isScalar())
      obsDim = axis.getDimension(0);
  }

  if (obsDim == null) {
    errlog.format("Must have an Observation dimension: unlimited dimension, or from Time Coordinate");
    return null;
  }
  boolean hasStruct = Evaluator.hasNetcdf3RecordStructure(ds);



  // otherwise, make it a Station
  TableConfig nt = new TableConfig(Table.Type.Top, "station");
  nt.featureType = FeatureType.STATION;

  nt.lat = CoordSysEvaluator.findCoordNameByType(ds, AxisType.Lat);
  nt.lon = CoordSysEvaluator.findCoordNameByType(ds, AxisType.Lon);

  nt.stnId = ds.getRootGroup().findAttributeString("station_name", null);
  nt.stnWmoId = ds.getRootGroup().findAttributeString("wmo_id", null);

  nt.stnDesc = ds.getRootGroup().findAttributeString("description", null);
  if (nt.stnDesc == null)
    nt.stnDesc = ds.getRootGroup().findAttributeString("comment", null);

  TableConfig obs = new TableConfig(Table.Type.Structure, hasStruct ? "record" : obsDim.getShortName());
  obs.structName = "record";
  obs.structureType = hasStruct ? TableConfig.StructureType.Structure : TableConfig.StructureType.PsuedoStructure;
  obs.dimName = obsDim.getShortName();
  obs.time = CoordSysEvaluator.findCoordNameByType(ds, AxisType.Time);
  nt.addChild(obs);

  return nt;
}