ucar.nc2.VariableSimpleIF Java Examples

The following examples show how to use ucar.nc2.VariableSimpleIF. 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: NcMeasureType.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public static MeasureType initValue(MeasureType value, PointFeature pointFeat, VariableSimpleIF dataVar)
    throws IOException {
  // TEXT
  StructureMembers.Member firstDataMember = pointFeat.getDataAll().findMember(dataVar.getShortName());
  assert firstDataMember != null : String
      .format("%s appeared in the list of data variables but not in the StructureData.", dataVar.getShortName());

  Array dataArray = pointFeat.getDataAll().getArray(firstDataMember);
  assert dataArray.getSize() == 1 : String.format("Expected array to be scalar, but its shape was %s.",
      Arrays.toString(dataArray.getShape()));

  double dataVal = dataArray.getDouble(0);
  value.setDoubleValue(dataVal);

  return value;
}
 
Example #2
Source File: WriterCFTrajectoryCollection.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void writeHeader(TrajectoryFeature feature, PointFeature obs) throws IOException {
  // obs data
  List<VariableSimpleIF> coords = new ArrayList<>();
  coords.add(VariableSimpleBuilder.makeScalar(timeName, "time of measurement", timeUnit.getUdUnit(), DataType.DOUBLE)
      .addAttribute(CF.CALENDAR, timeUnit.getCalendar().toString()).build());

  coords.add(
      VariableSimpleBuilder.makeScalar(latName, "latitude of measurement", CDM.LAT_UNITS, DataType.DOUBLE).build());
  coords.add(
      VariableSimpleBuilder.makeScalar(lonName, "longitude of measurement", CDM.LON_UNITS, DataType.DOUBLE).build());
  Formatter coordNames = new Formatter().format("%s %s %s", timeName, latName, lonName);
  if (altUnits != null) {
    coords.add(VariableSimpleBuilder.makeScalar(altName, "altitude of measurement", altUnits, DataType.DOUBLE)
        .addAttribute(CF.POSITIVE, CF1Convention.getZisPositive(altName, altUnits)).build());
    coordNames.format(" %s", altName);
  }

  super.writeHeader(coords, feature.getFeatureData(), null, obs.getFeatureData(), coordNames.toString());
}
 
Example #3
Source File: FeatureDatasetCapabilitiesWriter.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private Element writeVariable(VariableSimpleIF v) {
  NcmlWriter ncMLWriter = new NcmlWriter();
  Element varElem = new Element("variable");
  varElem.setAttribute("name", v.getShortName());

  DataType dt = v.getDataType();
  if (dt != null)
    varElem.setAttribute("type", dt.toString());

  // attributes
  for (Attribute att : v.attributes()) {
    varElem.addContent(ncMLWriter.makeAttributeElement(att));
  }

  return varElem;
}
 
Example #4
Source File: WriterCFStationProfileCollection.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void writeHeader(StationProfileFeature stn, ProfileFeature profile, PointFeature obs) throws IOException {
  StructureData stnData = stn.getFeatureData();
  StructureData profileData = profile.getFeatureData();
  StructureData obsData = obs.getFeatureData();

  List<VariableSimpleIF> obsCoords = new ArrayList<>();
  Formatter coordNames = new Formatter().format("%s %s %s", profileTimeName, latName, lonName);
  obsCoords.add(VariableSimpleBuilder.makeScalar(altitudeCoordinateName, "obs altitude", altUnits, DataType.DOUBLE)
      .addAttribute(CF.STANDARD_NAME, "altitude")
      .addAttribute(CF.POSITIVE, CF1Convention.getZisPositive(altitudeCoordinateName, altUnits)).build());
  coordNames.format(" %s", altitudeCoordinateName);

  super.writeHeader(obsCoords, stnData, profileData, obsData, coordNames.toString());

  // write the stations
  int count = 0;
  stationIndexMap = new HashMap<>(2 * stnList.size());
  for (StationFeature sf : stnList) {
    writeStationData(sf);
    stationIndexMap.put(sf.getName(), count);
    count++;
  }

}
 
Example #5
Source File: FeatureDatasetCapabilitiesWriter.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private Element writeVariable(VariableSimpleIF v) {
  NcmlWriter ncMLWriter = new NcmlWriter();
  Element varElem = new Element("variable");
  varElem.setAttribute("name", v.getShortName());

  ucar.ma2.DataType dt = v.getDataType();
  if (dt != null)
    varElem.setAttribute("type", dt.toString());

  // attributes
  for (Attribute att : v.attributes()) {
    varElem.addContent(ncMLWriter.makeAttributeElement(att));
  }

  return varElem;
}
 
Example #6
Source File: ThreddsMetadataExtractor.java    From tds with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public ThreddsMetadata.VariableGroup extractVariables(FeatureDatasetPoint fd) {
  List<ThreddsMetadata.Variable> vars = new ArrayList<>();

  List<VariableSimpleIF> dataVars = fd.getDataVariables();
  if (dataVars == null)
    return null;

  for (VariableSimpleIF v : dataVars) {
    String name = v.getShortName();
    String desc = v.getDescription();
    String units = v.getUnitsString();
    String vname = null;
    String id = null;

    ucar.nc2.Attribute att = v.attributes().findAttributeIgnoreCase("standard_name");
    if (att != null)
      vname = att.getStringValue();
    vars.add(new ThreddsMetadata.Variable(name, desc, vname, units, id));
  }

  Collections.sort(vars);
  // String vocab, String vocabHref, URI vocabUri, URI mapUri, List<Variable> variables
  return new ThreddsMetadata.VariableGroup("CF-1.0", null, null, vars);
}
 
Example #7
Source File: WriterCFTrajectoryProfileCollection.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
void makeFeatureVariables(StructureData trajData, boolean isExtended) {
  // add the dimensions : extended model can use an unlimited dimension
  Dimension trajDim = writerb.addDimension(trajDimName, ntraj);

  List<VariableSimpleIF> trajVars = new ArrayList<>();

  trajVars.add(VariableSimpleBuilder.makeString(trajIdName, "trajectory identifier", null, traj_strlen)
      .addAttribute(CF.CF_ROLE, CF.TRAJECTORY_ID).build());

  for (StructureMembers.Member m : trajData.getMembers()) {
    if (findDataVar(m.getName()) != null)
      trajVars.add(VariableSimpleBuilder.fromMember(m).build());
  }

  if (isExtended) {
    Structure.Builder structb = writerb.addStructure(trajStructName, trajDimName);
    addCoordinatesExtended(structb, trajVars);
  } else {
    addCoordinatesClassic(trajDim, trajVars, trajVarMap);
  }

}
 
Example #8
Source File: PointDatasetRemote.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public PointDatasetRemote(FeatureType wantFeatureType, String uri, CalendarDateUnit timeUnit, String altUnits,
    List<VariableSimpleIF> vars, LatLonRect bb, CalendarDateRange dr) {

  super(wantFeatureType);
  setBoundingBox(bb);
  setDateRange(dr);
  setLocationURI(CdmrFeatureDataset.SCHEME + uri);

  dataVariables = new ArrayList<>(vars);

  collectionList = new ArrayList<>(1);
  switch (wantFeatureType) {
    case POINT:
      collectionList.add(new PointCollectionStreamRemote(uri, timeUnit, altUnits, null));
      break;
    case STATION:
      collectionList.add(new StationCollectionStream(uri, timeUnit, altUnits));
      break;
    default:
      throw new UnsupportedOperationException("No implementation for " + wantFeatureType);
  }
}
 
Example #9
Source File: WriterCFPointCollection.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
void writeHeader(PointFeature pf) throws IOException {
  List<VariableSimpleIF> coords = new ArrayList<>();
  coords.add(VariableSimpleBuilder.makeScalar(timeName, "time of measurement", timeUnit.getUdUnit(), DataType.DOUBLE)
      .addAttribute(CF.CALENDAR, timeUnit.getCalendar().toString()).build());

  coords.add(
      VariableSimpleBuilder.makeScalar(latName, "latitude of measurement", CDM.LAT_UNITS, DataType.DOUBLE).build());
  coords.add(
      VariableSimpleBuilder.makeScalar(lonName, "longitude of measurement", CDM.LON_UNITS, DataType.DOUBLE).build());
  Formatter coordNames = new Formatter().format("%s %s %s", timeName, latName, lonName);
  if (altUnits != null) {
    coords.add(VariableSimpleBuilder.makeScalar(altName, "altitude of measurement", altUnits, DataType.DOUBLE)
        .addAttribute(CF.POSITIVE, CF1Convention.getZisPositive(altName, altUnits)).build());
    coordNames.format(" %s", altName);
  }

  super.writeHeader(coords, null, null, pf.getDataAll(), coordNames.toString());
}
 
Example #10
Source File: NcMeasurementTimeseriesType.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public static MeasurementTimeseriesType initMeasurementTimeseries(MeasurementTimeseriesType measurementTimeseries,
    StationTimeSeriesFeature stationFeat, VariableSimpleIF dataVar) throws IOException {
  // @gml:id
  String id = MarshallingUtil.createIdForType(MeasurementTimeseriesType.class);
  measurementTimeseries.setId(id);

  // wml2:defaultPointMetadata
  NcTVPDefaultMetadataPropertyType.initDefaultPointMetadata(measurementTimeseries.addNewDefaultPointMetadata(),
      dataVar);

  // wml2:point[0..*]
  for (PointFeature pf : stationFeat) {
    // wml2:point
    Point.initPoint(measurementTimeseries.addNewPoint(), pf, dataVar);
  }

  return measurementTimeseries;
}
 
Example #11
Source File: PointSubsetWriterCSV.java    From tds with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void writePoint(PointFeature pointFeat) throws IOException {
  EarthLocation loc = pointFeat.getLocation();

  writer.print(CalendarDateFormatter.toDateTimeStringISO(pointFeat.getObservationTimeAsCalendarDate()));
  writer.print(',');
  writer.print(Format.dfrac(loc.getLatitude(), 3));
  writer.print(',');
  writer.print(Format.dfrac(loc.getLongitude(), 3));

  StructureData structureData = pointFeat.getDataAll();
  for (VariableSimpleIF wantedVar : wantedVariables) {
    writer.print(',');
    Array dataArray = structureData.getArray(wantedVar.getShortName());
    writer.print(dataArray.toString().trim());
  }
  writer.println();
}
 
Example #12
Source File: StationSubsetWriterCSV.java    From tds with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
protected void writeHeader(StationPointFeature stationPointFeat) throws IOException {
  writer.print("time,station,latitude[unit=\"degrees_north\"],longitude[unit=\"degrees_east\"]");
  for (VariableSimpleIF wantedVar : wantedVariables) {
    writer.print(",");
    writer.print(wantedVar.getShortName());
    if (wantedVar.getUnitsString() != null)
      writer.print("[unit=\"" + wantedVar.getUnitsString() + "\"]");
  }
  writer.println();
}
 
Example #13
Source File: NcOMObservationPropertyType.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static OMObservationPropertyType initObservationMember(OMObservationPropertyType observationMember,
    StationTimeSeriesFeature stationFeat, VariableSimpleIF dataVar) throws IOException {
  // om:OM_Observation
  NcOMObservationType.initOmObservation(observationMember.addNewOMObservation(), stationFeat, dataVar);

  return observationMember;
}
 
Example #14
Source File: FeatureDatasetImpl.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public VariableSimpleIF getDataVariable(String shortName) {
  for (VariableSimpleIF s : getDataVariables()) {
    String ss = s.getShortName();
    if (shortName.equals(ss))
      return s;
  }
  return null;
}
 
Example #15
Source File: WriterCFTrajectoryProfileCollection.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
WriterCFTrajectoryProfileCollection(String fileOut, AttributeContainer globalAtts, List<VariableSimpleIF> dataVars,
    CalendarDateUnit timeUnit, String altUnits, CFPointWriterConfig config) throws IOException {
  super(fileOut, globalAtts, dataVars, timeUnit, altUnits, config);
  writerb.addAttribute(new Attribute(CF.FEATURE_TYPE, CF.FeatureType.trajectoryProfile.name()));
  writerb.addAttribute(
      new Attribute(CF.DSG_REPRESENTATION, "Contiguous ragged array representation of trajectory profile, H.6.3"));
}
 
Example #16
Source File: WriterCFStationProfileCollection.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
WriterCFStationProfileCollection(String fileOut, AttributeContainer globalAtts, List<VariableSimpleIF> dataVars,
    CalendarDateUnit timeUnit, String altUnits, CFPointWriterConfig config) throws IOException {
  super(fileOut, globalAtts, dataVars, timeUnit, altUnits, config);
  writerb.addAttribute(new Attribute(CF.FEATURE_TYPE, CF.FeatureType.timeSeriesProfile.name()));
  writerb.addAttribute(
      new Attribute(CF.DSG_REPRESENTATION, "Ragged array representation of time series profiless, H.5.3"));
}
 
Example #17
Source File: WriterCFStationProfileCollection.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
void makeMiddleVariables(StructureData profileData, boolean isExtended) {
  Dimension profileDim = writerb.addDimension(profileDimName, nfeatures);

  // add the profile Variables using the profile dimension
  List<VariableSimpleIF> profileVars = new ArrayList<>();
  profileVars.add(VariableSimpleBuilder.makeString(profileIdName, "profile identifier", null, id_strlen)
      .addAttribute(CF.CF_ROLE, CF.PROFILE_ID) // profileId:cf_role = "profile_id";
      .addAttribute(CDM.MISSING_VALUE, String.valueOf(idMissingValue)).build());

  profileVars
      .add(VariableSimpleBuilder.makeScalar(numberOfObsName, "number of obs for this profile", null, DataType.INT)
          .addAttribute(CF.SAMPLE_DIMENSION, recordDimName).build()); // rowSize:sample_dimension = "obs"

  profileVars.add(VariableSimpleBuilder
      .makeScalar(profileTimeName, "nominal time of profile", timeUnit.getUdUnit(), DataType.DOUBLE)
      .addAttribute(CF.CALENDAR, timeUnit.getCalendar().toString()).build());

  profileVars
      .add(VariableSimpleBuilder.makeScalar(stationIndexName, "station index for this profile", null, DataType.INT)
          .addAttribute(CF.INSTANCE_DIMENSION, stationDimName).build());

  for (StructureMembers.Member m : profileData.getMembers()) {
    VariableSimpleIF dv = findDataVar(m.getName());
    if (dv != null)
      profileVars.add(dv);
  }

  if (isExtended) {
    Structure.Builder structb = writerb.addStructure(profileStructName, profileDimName);
    addCoordinatesExtended(structb, profileVars);
  } else {
    addCoordinatesClassic(profileDim, profileVars, profileVarMap);
  }
}
 
Example #18
Source File: NcTVPDefaultMetadataPropertyType.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static TVPDefaultMetadataPropertyType initDefaultPointMetadata(
    TVPDefaultMetadataPropertyType defaultPointMetadata, VariableSimpleIF dataVar) {
  // wml2:DefaultTVPMeasurementMetadata
  DefaultTVPMeasurementMetadataDocument defaultTVPMeasurementMetadataDoc =
      DefaultTVPMeasurementMetadataDocument.Factory.newInstance();
  NcTVPMeasurementMetadataType.initDefaultTVPMeasurementMetadata(
      defaultTVPMeasurementMetadataDoc.addNewDefaultTVPMeasurementMetadata(), dataVar);
  defaultPointMetadata.set(defaultTVPMeasurementMetadataDoc);

  return defaultPointMetadata;
}
 
Example #19
Source File: WriterCFStationProfileCollection.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
void makeFeatureVariables(StructureData stnData, boolean isExtended) {
  // add the dimensions : extended model can use an unlimited dimension
  Dimension stationDim = writerb.addDimension(stationDimName, stnList.size());

  List<VariableSimpleIF> stnVars = new ArrayList<>();
  stnVars.add(VariableSimpleBuilder.makeScalar(latName, "station latitude", CDM.LAT_UNITS, DataType.DOUBLE).build());
  stnVars.add(VariableSimpleBuilder.makeScalar(lonName, "station longitude", CDM.LON_UNITS, DataType.DOUBLE).build());

  if (useAlt) {
    stnVars.add(VariableSimpleBuilder.makeScalar(stationAltName, "station altitude", altUnits, DataType.DOUBLE)
        .addAttribute(CF.STANDARD_NAME, CF.SURFACE_ALTITUDE)
        .addAttribute(CF.POSITIVE, CF1Convention.getZisPositive(altName, altUnits)).build());
  }

  stnVars.add(VariableSimpleBuilder.makeString(stationIdName, "station identifier", null, id_strlen)
      .addAttribute(CF.CF_ROLE, CF.TIMESERIES_ID).build()); // station_id:cf_role = "timeseries_id";

  if (useDesc)
    stnVars.add(VariableSimpleBuilder.makeString(descName, "station description", null, desc_strlen)
        .addAttribute(CF.STANDARD_NAME, CF.PLATFORM_NAME).build());

  if (useWmoId)
    stnVars.add(VariableSimpleBuilder.makeString(wmoName, "station WMO id", null, wmo_strlen)
        .addAttribute(CF.STANDARD_NAME, CF.PLATFORM_ID).build());

  for (StructureMembers.Member m : stnData.getMembers()) {
    if (findDataVar(m.getName()) != null)
      stnVars.add(VariableSimpleBuilder.fromMember(m).build());
  }

  if (isExtended) {
    Structure.Builder structb = writerb.addStructure(stationStructName, stationDimName);
    addCoordinatesExtended(structb, stnVars);
  } else {
    addCoordinatesClassic(stationDim, stnVars, stationVarMap);
  }

}
 
Example #20
Source File: WriterCFTrajectoryProfileCollection.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
protected void makeMiddleVariables(StructureData profileData, boolean isExtended) {
  Dimension profileDim = writerb.addDimension(profileDimName, nfeatures);

  // add the profile Variables using the profile dimension
  List<VariableSimpleIF> profileVars = new ArrayList<>();
  profileVars.add(VariableSimpleBuilder.makeString(profileIdName, "profile identifier", null, id_strlen)
      .addAttribute(CF.CF_ROLE, CF.PROFILE_ID) // profileId:cf_role = "profile_id";
      .addAttribute(CDM.MISSING_VALUE, String.valueOf(idMissingValue)).build());

  profileVars
      .add(VariableSimpleBuilder.makeScalar(latName, "profile latitude", CDM.LAT_UNITS, DataType.DOUBLE).build());
  profileVars
      .add(VariableSimpleBuilder.makeScalar(lonName, "profile longitude", CDM.LON_UNITS, DataType.DOUBLE).build());
  profileVars.add(VariableSimpleBuilder
      .makeScalar(profileTimeName, "nominal time of profile", timeUnit.getUdUnit(), DataType.DOUBLE)
      .addAttribute(CF.CALENDAR, timeUnit.getCalendar().toString()).build());

  profileVars.add(
      VariableSimpleBuilder.makeScalar(trajectoryIndexName, "trajectory index for this profile", null, DataType.INT)
          .addAttribute(CF.INSTANCE_DIMENSION, trajDimName).build());

  profileVars
      .add(VariableSimpleBuilder.makeScalar(numberOfObsName, "number of obs for this profile", null, DataType.INT)
          .addAttribute(CF.SAMPLE_DIMENSION, recordDimName).build());

  for (StructureMembers.Member m : profileData.getMembers()) {
    VariableSimpleIF dv = findDataVar(m.getName());
    if (dv != null)
      profileVars.add(dv);
  }

  if (isExtended) {
    Structure.Builder structb = writerb.addStructure(profileStructName, profileDimName);
    addCoordinatesExtended(structb, profileVars);
  } else {
    addCoordinatesClassic(profileDim, profileVars, profileVarMap);
  }
}
 
Example #21
Source File: WriterCFTrajectoryCollection.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
void makeFeatureVariables(StructureData featureData, boolean isExtended) {
  // LOOK why not unlimited here fro extended model ?
  Dimension trajDim = writerb.addDimension(trajDimName, nfeatures);

  // add the profile Variables using the profile dimension
  List<VariableSimpleIF> featureVars = new ArrayList<>();
  featureVars.add(VariableSimpleBuilder.makeString(trajIdName, "trajectory identifier", null, id_strlen)
      .addAttribute(CF.CF_ROLE, CF.TRAJECTORY_ID).build());

  featureVars
      .add(VariableSimpleBuilder.makeScalar(numberOfObsName, "number of obs for this profile", null, DataType.INT)
          .addAttribute(CF.SAMPLE_DIMENSION, recordDimName).build());

  for (StructureMembers.Member m : featureData.getMembers()) {
    VariableSimpleIF dv = findDataVar(m.getName());
    if (dv != null)
      featureVars.add(dv);
  }

  if (isExtended) {
    Structure.Builder structb = writerb.addStructure(trajStructName, trajDimName);
    addCoordinatesExtended(structb, featureVars);
  } else {
    addCoordinatesClassic(trajDim, featureVars, featureVarMap);
  }
}
 
Example #22
Source File: WriterCFTrajectoryCollection.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
WriterCFTrajectoryCollection(String fileOut, AttributeContainer globalAtts, List<VariableSimpleIF> dataVars,
    CalendarDateUnit timeUnit, String altUnits, CFPointWriterConfig config) throws IOException {
  super(fileOut, globalAtts, dataVars, timeUnit, altUnits, config);
  writerb.addAttribute(new Attribute(CF.FEATURE_TYPE, CF.FeatureType.trajectory.name()));
  writerb.addAttribute(
      new Attribute(CF.DSG_REPRESENTATION, "Contiguous ragged array representation of trajectories, H.4.3"));
}
 
Example #23
Source File: NcOMObservationType.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static OMObservationType initOmObservation(OMObservationType omObservation,
    StationTimeSeriesFeature stationFeat, VariableSimpleIF dataVar) throws IOException {
  // @gml:id
  String id = MarshallingUtil.createIdForType(OMObservationType.class);
  omObservation.setId(id);

  // om:phenomenonTime
  NcTimeObjectPropertyType.initPhenomenonTime(omObservation.addNewPhenomenonTime(), stationFeat);

  // om:resultTime
  NcTimeInstantPropertyType.initResultTime(omObservation.addNewResultTime());

  // om:observedProperty
  NcReferenceType.initObservedProperty(omObservation.addNewObservedProperty(), dataVar);

  // om:procedure
  NcOMProcessPropertyType.initProcedure(omObservation.addNewProcedure());

  // om:featureOfInterest
  NcFeaturePropertyType.initFeatureOfInterest(omObservation.addNewFeatureOfInterest(), stationFeat);

  // om:result
  MeasurementTimeseriesDocument measurementTimeseriesDoc = MeasurementTimeseriesDocument.Factory.newInstance();
  NcMeasurementTimeseriesType.initMeasurementTimeseries(measurementTimeseriesDoc.addNewMeasurementTimeseries(),
      stationFeat, dataVar);
  omObservation.setResult(measurementTimeseriesDoc);

  return omObservation;
}
 
Example #24
Source File: FeatureDatasetCapabilitiesWriter.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static List<VariableSimpleIF> getDataVariables(Document doc) {
  Element root = doc.getRootElement();

  List<VariableSimpleIF> dataVars = new ArrayList<>();
  List<Element> varElems = root.getChildren("variable");
  for (Element varElem : varElems) {
    dataVars.add(new VariableSimpleAdapter(varElem));
  }
  return dataVars;
}
 
Example #25
Source File: WriterCFStationCollection.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
WriterCFStationCollection(String fileOut, AttributeContainer atts, List<VariableSimpleIF> dataVars,
    CalendarDateUnit timeUnit, String altUnits, CFPointWriterConfig config) throws IOException {
  super(fileOut, atts, dataVars, timeUnit, altUnits, config);
  writerb.addAttribute(new Attribute(CF.FEATURE_TYPE, CF.FeatureType.timeSeries.name()));
  writerb.addAttribute(new Attribute(CF.DSG_REPRESENTATION,
      "Timeseries of station data in the indexed ragged array representation, H.2.5"));
}
 
Example #26
Source File: WriterCFProfileCollection.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
protected void makeFeatureVariables(StructureData featureData, boolean isExtended) {

  // LOOK why not unlimited here ?
  Dimension profileDim = writerb.addDimension(profileDimName, nfeatures);

  // add the profile Variables using the profile dimension
  List<VariableSimpleIF> profileVars = new ArrayList<>();
  profileVars
      .add(VariableSimpleBuilder.makeScalar(latName, "profile latitude", CDM.LAT_UNITS, DataType.DOUBLE).build());
  profileVars
      .add(VariableSimpleBuilder.makeScalar(lonName, "profile longitude", CDM.LON_UNITS, DataType.DOUBLE).build());
  profileVars.add(VariableSimpleBuilder.makeString(profileIdName, "profile identifier", null, id_strlen)
      .addAttribute(CF.CF_ROLE, CF.PROFILE_ID).build()); // profileId:cf_role = "profile_id";

  profileVars
      .add(VariableSimpleBuilder.makeScalar(numberOfObsName, "number of obs for this profile", null, DataType.INT)
          .addAttribute(CF.SAMPLE_DIMENSION, recordDimName).build()); // rowSize:sample_dimension = "obs"

  profileVars.add(VariableSimpleBuilder
      .makeScalar(profileTimeName, "nominal time of profile", timeUnit.getUdUnit(), DataType.DOUBLE)
      .addAttribute(CF.CALENDAR, timeUnit.getCalendar().toString()).build());


  for (StructureMembers.Member m : featureData.getMembers()) {
    VariableSimpleIF dv = findDataVar(m.getName());
    if (dv != null)
      profileVars.add(dv);
  }

  if (isExtended) {
    Structure.Builder structb = writerb.addStructure(profileStructName, profileDimName);
    addCoordinatesExtended(structb, profileVars);
  } else {
    addCoordinatesClassic(profileDim, profileVars, featureVarMap);
  }
}
 
Example #27
Source File: WriterCFProfileCollection.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void writeHeader(ProfileFeature profile, PointFeature obs) throws IOException {

    Formatter coordNames = new Formatter().format("%s %s %s", profileTimeName, latName, lonName);
    List<VariableSimpleIF> coords = new ArrayList<>();
    if (useAlt) {
      coords.add(VariableSimpleBuilder.makeScalar(altitudeCoordinateName, "obs altitude", altUnits, DataType.DOUBLE)
          .addAttribute(CF.STANDARD_NAME, "altitude")
          .addAttribute(CF.POSITIVE, CF1Convention.getZisPositive(altitudeCoordinateName, altUnits)).build());
      coordNames.format(" %s", altitudeCoordinateName);
    }

    super.writeHeader(coords, profile.getFeatureData(), null, obs.getFeatureData(), coordNames.toString());
  }
 
Example #28
Source File: WriterCFProfileCollection.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
WriterCFProfileCollection(String fileOut, AttributeContainer globalAtts, List<VariableSimpleIF> dataVars,
    CalendarDateUnit timeUnit, String altUnits, CFPointWriterConfig config) throws IOException {
  super(fileOut, globalAtts, dataVars, timeUnit, altUnits, config);
  writerb.addAttribute(
      new Attribute(CF.DSG_REPRESENTATION, "Contiguous ragged array representation of profiles, H.3.4"));
  writerb.addAttribute(new Attribute(CF.FEATURE_TYPE, CF.FeatureType.profile.name()));
}
 
Example #29
Source File: CompositeStationCollectionFlattened.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
protected CompositeStationCollectionFlattened(String name, CalendarDateUnit timeUnit, String altUnits,
    List<String> stations, CalendarDateRange dateRange, List<VariableSimpleIF> varList,
    TimedCollection stnCollections) {
  super(name, timeUnit, altUnits);
  this.stationsSubset = stations; // note these will be from the original collection, must transfer
  this.dateRange = dateRange;
  this.varList = varList;
  this.stnCollections = stnCollections;

  wantStationsubset = (stations != null) && (!stations.isEmpty());
}
 
Example #30
Source File: CompositeDatasetFactory.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public List<VariableSimpleIF> getDataVariables() {
  if (dataVariables == null) {
    if (pfc instanceof CompositePointCollection)
      dataVariables = ((CompositePointCollection) pfc).getDataVariables();
    else if (pfc instanceof CompositeStationCollection)
      dataVariables = ((CompositeStationCollection) pfc).getDataVariables();
  }

  return dataVariables;
}