Java Code Examples for ucar.nc2.dataset.NetcdfDataset#findDimension()

The following examples show how to use ucar.nc2.dataset.NetcdfDataset#findDimension() . 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: CFpointObsExt.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
protected boolean identifyEncodingProfile(NetcdfDataset ds, EncodingInfo info, Formatter errlog) {
  Evaluator.VarAtt varatt = Evaluator.findVariableWithAttribute(ds, CF.SAMPLE_DIMENSION);
  if (varatt == null)
    return false;
  String dimName = varatt.att.getStringValue();
  Dimension obsDim = ds.findDimension(dimName);

  Structure profile = info.lat.getParentStructure();
  if (profile.getRank() == 0) { // could be scalar
    info.set(Encoding.single, null, obsDim);
  }
  Dimension profileDim = profile.getDimension(0);

  // now find the child structure
  info.childStruct = Evaluator.findStructureWithDimensions(ds, obsDim, null);

  // the raggeds
  if (identifyRaggeds(ds, info, profileDim, obsDim, errlog))
    return true;

  errlog.format("CFpointObsExt: %s only supports ragged array representation%n", CF.FeatureType.profile);
  return false;
}
 
Example 2
Source File: MadisAcars.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public boolean isMine(FeatureType wantFeatureType, NetcdfDataset ds) {
  if ((wantFeatureType != FeatureType.ANY_POINT) && (wantFeatureType != FeatureType.TRAJECTORY))
    return false;

  String title = ds.getRootGroup().findAttributeString("title", null);
  if (!"MADIS ACARS data".equals(title))
    return false;

  if (!ds.hasUnlimitedDimension())
    return false;
  if (ds.findDimension("recNum") == null)
    return false;

  VNames vn = getVariableNames(ds, null);
  if (ds.findVariable(vn.lat) == null)
    return false;
  if (ds.findVariable(vn.lon) == null)
    return false;
  if (ds.findVariable(vn.obsTime) == null)
    return false;
  return ds.findVariable(TRAJ_ID) != null;

}
 
Example 3
Source File: SequenceObsDataset.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private Dimension findDimension(NetcdfDataset ds, String name) {
  Dimension result = ds.findDimension(name);
  if (result == null) {
    String aname = ds.findAttValueIgnoreCase(null, name + "Dimension", null);
    if (aname != null)
      result = ds.findDimension(aname);
  }
  return result;
}
 
Example 4
Source File: Evaluator.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Find the dimension pointed to by key
 *
 * @param ds in this dataset
 * @param key may be dimension name or ":gatt" where gatt is local attribute whose value is the dimension name
 * @param errlog error messages here
 * @return dimension or null if not exist
 */
public static Dimension getDimension(NetcdfDataset ds, String key, Formatter errlog) {
  Dimension d = null;
  String s = getLiteral(ds, key, errlog);
  if (s != null) {
    d = ds.findDimension(s); // LOOK use group
    if ((d == null) && (errlog != null))
      errlog.format(" Cant find Variable %s from %s%n", s, key);
  }
  return d;
}
 
Example 5
Source File: FslWindProfiler.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void makeMultidimInner(NetcdfDataset ds, TableConfig parentTable, TableConfig childTable, String outerDin,
    String innerDim) {
  Dimension parentDim = ds.findDimension(outerDin);
  Dimension childDim = ds.findDimension(innerDim);

  // divide up the variables between the parent and the child
  List<String> obsVars;
  List<Variable> vars = ds.getVariables();
  List<String> parentVars = new ArrayList<>(vars.size());
  obsVars = new ArrayList<>(vars.size());
  for (Variable orgV : vars) {
    if (orgV instanceof Structure)
      continue;

    Dimension dim0 = orgV.getDimension(0);
    if ((dim0 != null) && dim0.equals(parentDim)) {
      if ((orgV.getRank() == 1) || ((orgV.getRank() == 2) && orgV.getDataType() == DataType.CHAR)) {
        parentVars.add(orgV.getShortName());
      } else {
        Dimension dim1 = orgV.getDimension(1);
        if ((dim1 != null) && dim1.equals(childDim))
          obsVars.add(orgV.getShortName());
      }
    }
  }
  parentTable.vars = parentVars;
  childTable.vars = obsVars;
}
 
Example 6
Source File: Madis.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public boolean isMine(FeatureType wantFeatureType, NetcdfDataset ds) {
  if ((wantFeatureType != FeatureType.ANY_POINT) && (wantFeatureType != FeatureType.STATION)
      && (wantFeatureType != FeatureType.POINT) && (wantFeatureType != FeatureType.STATION_PROFILE))
    return false;

  if (!ds.hasUnlimitedDimension())
    return false;
  if (ds.findDimension("recNum") == null)
    return false;

  if (ds.findVariable("staticIds") == null)
    return false;
  if (ds.findVariable("nStaticIds") == null)
    return false;
  if (ds.findVariable("lastRecord") == null)
    return false;
  if (ds.findVariable("prevRecord") == null)
    return false;

  VNames vn = getVariableNames(ds, null);
  if (ds.findVariable(vn.lat) == null)
    return false;
  if (ds.findVariable(vn.lon) == null)
    return false;
  return ds.findVariable(vn.obsTime) != null;

}
 
Example 7
Source File: FslRaob.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void makeMultidimInner(NetcdfDataset ds, TableConfig parentTable, TableConfig childTable, String outerDin,
    String innerDim) {
  Dimension parentDim = ds.findDimension(outerDin);
  Dimension childDim = ds.findDimension(innerDim);

  // divide up the variables between the parent and the child
  List<String> obsVars;
  List<Variable> vars = ds.getVariables();
  List<String> parentVars = new ArrayList<>(vars.size());
  obsVars = new ArrayList<>(vars.size());
  for (Variable orgV : vars) {
    if (orgV instanceof Structure)
      continue;

    Dimension dim0 = orgV.getDimension(0);
    if ((dim0 != null) && dim0.equals(parentDim)) {
      if ((orgV.getRank() == 1) || ((orgV.getRank() == 2) && orgV.getDataType() == DataType.CHAR)) {
        parentVars.add(orgV.getShortName());
      } else {
        Dimension dim1 = orgV.getDimension(1);
        if ((dim1 != null) && dim1.equals(childDim))
          obsVars.add(orgV.getShortName());
      }
    }
  }
  parentTable.vars = parentVars;
  childTable.vars = obsVars;
}
 
Example 8
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;
}
 
Example 9
Source File: PointConfigXML.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void makeMultidimInner(NetcdfDataset ds, TableConfig parentTable, TableConfig childTable) {
  Dimension parentDim = ds.findDimension(parentTable.dimName);
  Dimension childDim = ds.findDimension(childTable.innerName);

  // divide up the variables between the parent and the child
  List<String> obsVars;
  List<Variable> vars = ds.getVariables();
  List<String> parentVars = new ArrayList<>(vars.size());
  obsVars = new ArrayList<>(vars.size());
  for (Variable orgV : vars) {
    if (orgV instanceof Structure)
      continue;

    Dimension dim0 = orgV.getDimension(0);
    if ((dim0 != null) && dim0.equals(parentDim)) {
      if ((orgV.getRank() == 1) || ((orgV.getRank() == 2) && orgV.getDataType() == DataType.CHAR)) {
        parentVars.add(orgV.getShortName());
      } else {
        Dimension dim1 = orgV.getDimension(1);
        if ((dim1 != null) && dim1.equals(childDim))
          obsVars.add(orgV.getShortName());
      }
    }
  }
  parentTable.vars = parentVars;
  childTable.vars = obsVars;
}
 
Example 10
Source File: AWIPSConvention.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private CoordinateAxis makeTimeCoordAxis(NetcdfDataset ds) {
  Variable timeVar = ds.findVariable("valtimeMINUSreftime");
  Dimension recordDim = ds.findDimension("record");
  Array vals;

  try {
    vals = timeVar.read();
  } catch (IOException ioe) {
    return null;
  }

  // it seems that the record dimension does not always match valtimeMINUSreftime dimension!!
  // HAHAHAHAHAHAHAHA !
  int recLen = recordDim.getLength();
  int valLen = (int) vals.getSize();
  if (recLen != valLen) {
    try {
      vals = vals.sectionNoReduce(new int[] {0}, new int[] {recordDim.getLength()}, null);
      parseInfo.format(" corrected the TimeCoordAxis length%n");
    } catch (InvalidRangeException e) {
      parseInfo.format("makeTimeCoordAxis InvalidRangeException%n");
    }
  }

  // create the units out of the filename if possible
  String units = makeTimeUnitFromFilename(ds.getLocation());
  if (units == null) // ok that didnt work, try something else
    return makeTimeCoordAxisFromReference(ds, timeVar, vals);

  // create the coord axis
  String desc = "synthesized time coordinate from valtimeMINUSreftime and filename YYYYMMDD_HHMM";
  CoordinateAxis1D timeCoord = new CoordinateAxis1D(ds, null, "timeCoord", DataType.INT, "record", units, desc);

  timeCoord.setCachedData(vals, true);

  parseInfo.format("Created Time Coordinate Axis = ");
  timeCoord.getNameAndDimensions(parseInfo, true, false);
  parseInfo.format("%n");

  return timeCoord;
}
 
Example 11
Source File: CFpointObs.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
/**
 * Identify ragged array representations for double nests (timeSeries profile, timeSeries trajectory)
 * <p/>
 * This uses the contiguous ragged array representation for each profile (9.5.43.3), and the indexed ragged array
 * representation to organise the profiles into time series (9.3.54). The canonical use case is when writing real-time
 * data streams that contain profiles from many stations, arriving randomly, with the data for each entire profile
 * written all at once.
 *
 * @param ds in this dataset
 * @param info put info here
 * @param errlog error go here
 * @return EncodingInfo if ragged array representations is found
 */
protected boolean identifyDoubleRaggeds(NetcdfDataset ds, EncodingInfo info, Formatter errlog) {
  // the timeseries are stored as ragged index
  Evaluator.VarAtt varatt = Evaluator.findVariableWithAttribute(ds, CF.INSTANCE_DIMENSION);
  if (varatt == null)
    varatt = Evaluator.findVariableWithAttribute(ds, CF.RAGGED_PARENTINDEX);
  if (varatt == null)
    return false;

  Variable ragged_parentIndex = varatt.var;
  String instanceDimName = varatt.att.getStringValue();
  Dimension stationDim = ds.findDimension(instanceDimName);

  if (stationDim == null) {
    errlog.format(
        "CFpointObs: Indexed ragged array representation: parent_index variable has illegal value for %s = %s%n",
        CF.INSTANCE_DIMENSION, instanceDimName);
    return false;
  }

  if (ragged_parentIndex.getDataType() != DataType.INT) {
    errlog.format("CFpointObs: Indexed ragged array representation: parent_index variable must be of type integer%n");
    return false;
  }

  if (ragged_parentIndex.getRank() != 1 && info.childStruct == null) {
    errlog.format("CFpointObs: Indexed ragged array representation: parent_index variable %s must be 1D %n",
        ragged_parentIndex);
    return false;
  }
  Dimension profileDim = (info.childDim != null) ? info.childDim : ragged_parentIndex.getDimension(0);

  // onto the profiles, stored contiguously
  varatt = Evaluator.findVariableWithAttribute(ds, CF.SAMPLE_DIMENSION);
  if (varatt == null)
    varatt = Evaluator.findVariableWithAttribute(ds, CF.RAGGED_ROWSIZE);
  if (varatt == null)
    return false;

  Variable ragged_rowSize = varatt.var;
  String obsDimName = varatt.att.getStringValue();
  Dimension obsDim = ds.findDimension(obsDimName);

  if (obsDimName == null) {
    errlog.format(
        "CFpointObs: Contiguous ragged array representation: parent_index variable has illegal value for %s = %s%n",
        CF.SAMPLE_DIMENSION, obsDimName);
    return false;
  }

  if (!obsDimName.equals(info.grandChildDim.getShortName())) {
    errlog.format(
        "CFpointObs: Contiguous ragged array representation: row_size variable has obs dimension %s must be %s%n",
        obsDimName, info.childDim);
    return false;
  }

  if (ragged_rowSize.getDataType() != DataType.INT) {
    errlog.format("CFpointObs: Contiguous ragged array representation: row_size variable must be of type integer%n");
    return false;
  }

  if (info.childDim == null) { // nc4 ext
    Dimension profileDim2 = ragged_rowSize.getDimension(0);
    if (profileDim2 != profileDim) {
      errlog.format("CFpointObs: Double ragged array representation dimensions do not agree: %s != %s%n",
          profileDim2.getShortName(), profileDim.getShortName());
      return false;
    }
  }

  info.set(Encoding.raggedIndex, stationDim, profileDim, obsDim);
  info.ragged_parentIndex = ragged_parentIndex;
  info.ragged_rowSize = ragged_rowSize;
  return true;
}
 
Example 12
Source File: CFpointObs.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private TableConfig makeMultidimInner(NetcdfDataset ds, TableConfig parentTable, Dimension obsDim, EncodingInfo info,
    Formatter errlog) {
  Dimension parentDim = ds.findDimension(parentTable.dimName);

  Table.Type obsTableType =
      (parentTable.structureType == TableConfig.StructureType.PsuedoStructure) ? Table.Type.MultidimInnerPsuedo
          : Table.Type.MultidimInner;
  // if (info.time.isMemberOfStructure()) obsTableType = Table.Type.Structure;

  TableConfig obsTable = new TableConfig(obsTableType, obsDim.getShortName());

  obsTable.lat = matchAxisTypeAndDimension(ds, AxisType.Lat, parentDim, obsDim);
  obsTable.lon = matchAxisTypeAndDimension(ds, AxisType.Lon, parentDim, obsDim);
  obsTable.elev = matchAxisTypeAndDimension(ds, AxisType.Height, parentDim, obsDim);
  if (obsTable.elev == null)
    obsTable.elev = matchAxisTypeAndDimension(ds, AxisType.Pressure, parentDim, obsDim);
  if (obsTable.elev == null)
    obsTable.elev = matchAxisTypeAndDimension(ds, AxisType.GeoZ, parentDim, obsDim);
  obsTable.time = matchAxisTypeAndDimension(ds, AxisType.Time, parentDim, obsDim);

  // divide up the variables between the parent and the obs
  List<String> obsVars;
  List<Variable> vars = ds.getVariables();
  List<String> parentVars = new ArrayList<>(vars.size());
  obsVars = new ArrayList<>(vars.size());
  for (Variable orgV : vars) {
    if (orgV instanceof Structure)
      continue;

    Dimension dim0 = orgV.getDimension(0);
    if ((dim0 != null) && dim0.equals(parentDim)) {
      if ((orgV.getRank() == 1) || ((orgV.getRank() == 2) && orgV.getDataType() == DataType.CHAR)) {
        parentVars.add(orgV.getShortName());
      } else {
        Dimension dim1 = orgV.getDimension(1);
        if (obsDim.equals(dim1))
          obsVars.add(orgV.getShortName());
      }
    }
  }
  parentTable.vars = parentVars;
  // parentTable.vars = parentTable.isPsuedoStructure ? parentVars : null; // restrict to these if psuedoStruct

  obsTable.structureType = parentTable.structureType;
  obsTable.outerName = parentDim.getShortName();
  obsTable.innerName = obsDim.getShortName();
  obsTable.dimName = (parentTable.structureType == TableConfig.StructureType.PsuedoStructure) ? obsTable.outerName
      : obsTable.innerName;
  obsTable.structName = obsDim.getShortName();
  obsTable.vars = obsVars;

  return obsTable;
}
 
Example 13
Source File: CFpointObs.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
private TableConfig makeMultidimInner3D(NetcdfDataset ds, TableConfig outerTable, TableConfig middleTable,
    Dimension innerDim, Formatter errlog) {
  Dimension outerDim = ds.findDimension(outerTable.dimName);
  Dimension middleDim = ds.findDimension(middleTable.innerName);

  Table.Type obsTableType =
      (outerTable.structureType == TableConfig.StructureType.PsuedoStructure) ? Table.Type.MultidimInnerPsuedo3D
          : Table.Type.MultidimInner3D;
  TableConfig obsTable = new TableConfig(obsTableType, innerDim.getShortName());
  obsTable.structureType = TableConfig.StructureType.PsuedoStructure2D;
  obsTable.dimName = outerTable.dimName;
  obsTable.outerName = middleTable.innerName;
  obsTable.innerName = innerDim.getShortName();
  obsTable.structName = innerDim.getShortName();

  obsTable.lat = matchAxisTypeAndDimension(ds, AxisType.Lat, outerDim, middleDim, innerDim);
  obsTable.lon = matchAxisTypeAndDimension(ds, AxisType.Lon, outerDim, middleDim, innerDim);
  obsTable.elev = matchAxisTypeAndDimension(ds, AxisType.Height, outerDim, middleDim, innerDim);
  if (obsTable.elev == null)
    obsTable.elev = matchAxisTypeAndDimension(ds, AxisType.Pressure, middleDim, innerDim);
  if (obsTable.elev == null)
    obsTable.elev = matchAxisTypeAndDimension(ds, AxisType.GeoZ, middleDim, innerDim);
  obsTable.time = matchAxisTypeAndDimension(ds, AxisType.Time, outerDim, middleDim, innerDim);

  // divide up the variables between the 3 tables
  List<Variable> vars = ds.getVariables();
  List<String> outerVars = new ArrayList<>(vars.size());
  List<String> middleVars = new ArrayList<>(vars.size());
  List<String> innerVars = new ArrayList<>(vars.size());
  for (Variable orgV : vars) {
    if (orgV instanceof Structure)
      continue;

    if ((orgV.getRank() == 1) || ((orgV.getRank() == 2) && orgV.getDataType() == DataType.CHAR)) {
      if (outerDim.equals(orgV.getDimension(0)))
        outerVars.add(orgV.getShortName());

    } else if (orgV.getRank() == 2) {
      if (outerDim.equals(orgV.getDimension(0)) && middleDim.equals(orgV.getDimension(1)))
        middleVars.add(orgV.getShortName());

    } else if (orgV.getRank() == 3) {
      if (outerDim.equals(orgV.getDimension(0)) && middleDim.equals(orgV.getDimension(1))
          && innerDim.equals(orgV.getDimension(2)))
        innerVars.add(orgV.getShortName());
    }
  }
  outerTable.vars = outerVars;
  middleTable.vars = middleVars;
  obsTable.vars = innerVars;

  return obsTable;
}
 
Example 14
Source File: CFpointObsExt.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
protected boolean identifyEncodingTimeSeriesProfile(NetcdfDataset ds, EncodingInfo info, CF.FeatureType ftype,
    Formatter errlog) {
  // find the obs structure
  Evaluator.VarAtt varatt = Evaluator.findVariableWithAttribute(ds, CF.SAMPLE_DIMENSION);
  if (varatt == null)
    return false;
  String dimName = varatt.att.getStringValue();
  info.grandChildDim = ds.findDimension(dimName);
  info.grandChildStruct = Evaluator.findStructureWithDimensions(ds, info.grandChildDim, null);

  // find the station structure
  Variable stdId = Evaluator.findVariableWithAttributeValue(ds, CF.CF_ROLE, CF.TIMESERIES_ID);
  Structure stn = stdId.getParentStructure();
  if (stn.getRank() == 0) { // could be scalar
    info.set(Encoding.single, null, info.grandChildDim);
  }
  info.parentDim = stn.getDimension(0);
  info.parentStruct = stn;

  // find the profile structure
  Variable profileId = Evaluator.findVariableWithAttributeValue(ds, CF.CF_ROLE, CF.PROFILE_ID);
  Structure profile = profileId.getParentStructure();
  info.childDim = profile.getDimension(0);
  info.childStruct = profile;

  // find the non-station altitude
  VariableDS z = findZAxisNotStationAlt(ds);
  if (z == null) {
    errlog.format("CFpointObs: timeSeriesProfile must have a z coordinate, not the station altitude%n");
    return false;
  }
  info.alt = z;

  // raggeds
  if (identifyDoubleRaggeds(ds, info, errlog))
    return true;

  errlog.format("CFpointObsExt: %s only supports ragged array representation%n", CF.FeatureType.timeSeriesProfile);
  return false;
}
 
Example 15
Source File: CFpointObsExt.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
protected boolean identifyEncodingSection(NetcdfDataset ds, EncodingInfo info, CF.FeatureType ftype,
    Formatter errlog) {
  // find the obs structure
  Evaluator.VarAtt varatt = Evaluator.findVariableWithAttribute(ds, CF.SAMPLE_DIMENSION);
  if (varatt == null)
    return false;
  String dimName = varatt.att.getStringValue();
  info.grandChildDim = ds.findDimension(dimName);
  info.grandChildStruct = Evaluator.findStructureWithDimensions(ds, info.grandChildDim, null);

  // find the traj structure
  Variable trajId = Evaluator.findVariableWithAttributeValue(ds, CF.CF_ROLE, CF.TRAJECTORY_ID);
  Structure traj = trajId.getParentStructure();
  if (traj.getRank() == 0) { // could be scalar
    info.set(Encoding.single, null, info.grandChildDim);
  }
  info.parentDim = traj.getDimension(0);
  info.parentStruct = traj;

  // find the profile structure
  Variable profileId = Evaluator.findVariableWithAttributeValue(ds, CF.CF_ROLE, CF.PROFILE_ID);
  Structure profile = profileId.getParentStructure();
  info.childDim = profile.getDimension(0);
  info.childStruct = profile;

  // find the non-station altitude
  VariableDS z = findZAxisNotStationAlt(ds);
  if (z == null) {
    errlog.format("CFpointObs: section must have a z coordinate%n");
    return false;
  }
  if (z.getRank() == 0 && z.getParentStructure() == null) {
    errlog.format("CFpointObs: section cannot have a scalar z coordinate%n");
    return false;
  }
  info.alt = z;

  // raggeds
  if (identifyDoubleRaggeds(ds, info, errlog))
    return true;

  errlog.format("CFpointObsExt: %s only supports ragged array representation%n", CF.FeatureType.trajectoryProfile);
  return false;
}
 
Example 16
Source File: GempakCdm.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
protected TableConfig getStationProfileConfig(NetcdfDataset ds, Formatter errlog) {
  TableConfig stnTable = makeStationTable(ds, errlog);
  if (stnTable == null)
    return null;
  Dimension stationDim = ds.findDimension(stnTable.dimName);
  stnTable.featureType = FeatureType.STATION_PROFILE;

  // obs table
  VariableDS time = CoordSysEvaluator.findCoordByType(ds, AxisType.Time);
  if (time == null) {
    errlog.format("GempakCdm: Must have a Time coordinate");
    return null;
  }
  Dimension obsDim = time.getDimension(time.getRank() - 1); // may be time(time) or time(stn, obs)

  Structure multidimStruct = Evaluator.findStructureWithDimensions(ds, stationDim, obsDim);
  if (multidimStruct == null) {
    errlog.format("GempakCdm: Cannot figure out Station/obs table structure");
    return null;
  }

  TableConfig timeTable = new TableConfig(Table.Type.MultidimStructure, obsDim.getShortName());
  timeTable.missingVar = "_isMissing";
  timeTable.structName = multidimStruct.getFullName();
  timeTable.structureType = TableConfig.StructureType.Structure;
  timeTable.addJoin(new JoinArray(time, JoinArray.Type.level, 1));
  timeTable.time = time.getFullName();
  timeTable.feature_id = time.getFullName();
  stnTable.addChild(timeTable);

  TableConfig obsTable = new TableConfig(Table.Type.NestedStructure, obsDim.getShortName());
  Structure nestedStruct = Evaluator.findNestedStructure(multidimStruct);
  if (nestedStruct == null) {
    errlog.format("GempakCdm: Cannot find nested Structure for profile");
    return null;
  }

  obsTable.structName = nestedStruct.getFullName();
  obsTable.nestedTableName = nestedStruct.getShortName();
  Variable elev = findZAxisNotStationAlt(ds);
  if (elev == null) {
    errlog.format("GempakCdm: Cannot find profile elevation variable");
    return null;
  }
  obsTable.elev = elev.getShortName();
  timeTable.addChild(obsTable);

  return stnTable;
}