ucar.nc2.constants.FeatureType Java Examples

The following examples show how to use ucar.nc2.constants.FeatureType. 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: TestCoverageHorizSubset.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Test
@Category(NeedsCdmUnitTest.class)
public void testLongitudeSubset() throws Exception {
  String filename = TestDir.cdmUnitTestDir + "tds/ncep/GFS_Global_onedeg_20100913_0000.grib2";
  System.out.printf("open %s%n", filename);

  try (FeatureDatasetCoverage cc = CoverageDatasetFactory.open(filename)) {
    Assert.assertNotNull(filename, cc);
    CoverageCollection gcs = cc.findCoverageDataset(FeatureType.GRID);
    Assert.assertNotNull("gcs", gcs);
    String gribId = "VAR_0-3-0_L1";
    Coverage coverage = gcs.findCoverageByAttribute(Grib.VARIABLE_ID_ATTNAME, gribId); // "Pressure_Surface");
    Assert.assertNotNull(gribId, coverage);

    CoverageCoordSys cs = coverage.getCoordSys();
    Assert.assertNotNull("coordSys", cs);
    HorizCoordSys hcs = cs.getHorizCoordSys();
    Assert.assertNotNull("HorizCoordSys", hcs);
    Assert.assertEquals("rank", 3, cs.getShape().length);

    LatLonRect bbox = new LatLonRect(LatLonPoint.create(40.0, -100.0), 10.0, 20.0);
    checkLatLonSubset(gcs, coverage, bbox, new int[] {1, 11, 21});
  }
}
 
Example #2
Source File: TestCFPointDatasets.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public static List<Object[]> getStationDatasets() {
  List<Object[]> result = new ArrayList<>();

  result.add(new Object[] {CFpointObs_topdir + "stationSingle.ncml", FeatureType.STATION, 3});
  result.add(new Object[] {CFpointObs_topdir + "stationSingleWithZlevel.ncml", FeatureType.STATION, 3});
  result.add(new Object[] {CFpointObs_topdir + "stationMultidim.ncml", FeatureType.STATION, 15});
  result.add(new Object[] {CFpointObs_topdir + "stationMultidimTimeJoin.ncml", FeatureType.STATION, 15});
  result.add(new Object[] {CFpointObs_topdir + "stationMultidimUnlimited.nc", FeatureType.STATION, 15}); // */
  result.add(new Object[] {CFpointObs_topdir + "stationMultidimUnlimited.ncml", FeatureType.STATION, 15}); // */
  result.add(new Object[] {CFpointObs_topdir + "stationMultidimMissingTime.ncml", FeatureType.STATION, 12});
  result.add(new Object[] {CFpointObs_topdir + "stationMultidimMissingId.ncml", FeatureType.STATION, 9}); // */
  result.add(new Object[] {CFpointObs_topdir + "stationMultidimMissingIdString.ncml", FeatureType.STATION, 12});
  result.add(new Object[] {CFpointObs_topdir + "stationRaggedContig.ncml", FeatureType.STATION, 6});
  result.add(new Object[] {CFpointObs_topdir + "stationRaggedIndex.ncml", FeatureType.STATION, 6});
  result.add(new Object[] {CFpointObs_topdir + "stationRaggedMissing.ncml", FeatureType.STATION, 5});
  result.add(new Object[] {CFpointObs_topdir + "stationData2Levels.ncml", FeatureType.STATION, 15});
  return result;
}
 
Example #3
Source File: WriterCFPointDataset.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void createGlobalAttributes() {
  if (globalAtts != null) {
    for (Attribute att : globalAtts) {
      if (att.getShortName().equalsIgnoreCase("cdm_data_type"))
        continue;
      if (att.getShortName().equalsIgnoreCase("cdm_datatype"))
        continue;
      if (att.getShortName().equalsIgnoreCase("thredds_data_type"))
        continue;

      ncfileOut.addAttribute(null, att);
    }
  }
  ncfileOut.addAttribute(null, new Attribute(CDM.CONVENTIONS, "CF-1")); // LOOK CF-1.?
  ncfileOut.addAttribute(null, new Attribute(CF.FEATURE_TYPE, CF.FeatureType.point.name()));
}
 
Example #4
Source File: UnidataStationObsDataset.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public static boolean isValidFile(NetcdfFile ds) {
  if (!ds.findAttValueIgnoreCase(null, "cdm_data_type", "").equalsIgnoreCase(FeatureType.STATION.toString())
      && !ds.findAttValueIgnoreCase(null, "cdm_datatype", "").equalsIgnoreCase(FeatureType.STATION.toString()))
    return false;

  String conv = ds.findAttValueIgnoreCase(null, "Conventions", null);
  if (conv == null)
    return false;

  boolean convOk = false;
  StringTokenizer stoke = new StringTokenizer(conv, ",");
  while (stoke.hasMoreTokens()) {
    String toke = stoke.nextToken().trim();
    if (toke.equalsIgnoreCase("Unidata Observation Dataset v1.0"))
      convOk = true;
  }
  if (!convOk)
    return false;

  // must have this field to be a linked list
  Variable stationIndexVar = UnidataObsDatasetHelper.findVariable(ds, "parent_index");
  if (stationIndexVar == null)
    return false;

  return true;
}
 
Example #5
Source File: CFstationObsDataset.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public static boolean isValidFile(NetcdfFile ds) {
  if (!ds.findAttValueIgnoreCase(null, "cdm_datatype", "").equalsIgnoreCase(FeatureType.STATION.toString()))
    return false;

  String conv = ds.findAttValueIgnoreCase(null, "Conventions", null);
  if (conv == null)
    return false;

  StringTokenizer stoke = new StringTokenizer(conv, ",");
  while (stoke.hasMoreTokens()) {
    String toke = stoke.nextToken().trim();
    if (toke.equalsIgnoreCase("CF-1.0"))
      return true;
  }

  return false;
}
 
Example #6
Source File: TestCoverageHorizSubset.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Test
@Category(NeedsCdmUnitTest.class)
public void testCrossLongitudeSeam() throws Exception {
  String filename = TestDir.cdmUnitTestDir + "tds/ncep/GFS_Global_0p5deg_20100913_0000.grib2";
  System.out.printf("open %s%n", filename);

  try (FeatureDatasetCoverage cc = CoverageDatasetFactory.open(filename)) {
    Assert.assertNotNull(filename, cc);
    CoverageCollection gcs = cc.findCoverageDataset(FeatureType.GRID);
    Assert.assertNotNull("gcs", gcs);
    String gribId = "VAR_2-0-0_L1";
    Coverage coverage = gcs.findCoverageByAttribute(Grib.VARIABLE_ID_ATTNAME, gribId); // Land_cover_0__sea_1__land_surface
    Assert.assertNotNull(gribId, coverage);

    CoverageCoordSys cs = coverage.getCoordSys();
    Assert.assertNotNull("coordSys", cs);
    System.out.printf(" org coverage shape=%s%n", Arrays.toString(cs.getShape()));

    HorizCoordSys hcs = cs.getHorizCoordSys();
    Assert.assertNotNull("HorizCoordSys", hcs);
    Assert.assertEquals("rank", 3, cs.getShape().length);

    LatLonRect bbox = new LatLonRect(LatLonPoint.create(40.0, -100.0), 10.0, 120.0);
    checkLatLonSubset(gcs, coverage, bbox, new int[] {1, 21, 241});
  }
}
 
Example #7
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 #8
Source File: TestScanNonDatasets.java    From tds with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Test
public void testStandardServicesDatasetScan() throws IOException {
  String catalog = "/catalog/scanLocalHtml/catalog.xml";
  Catalog cat = TdsLocalCatalog.open(catalog);

  Dataset ds = cat.findDatasetByID("scanLocalHtml/esfgTest.html");

  FeatureType ft = ds.getFeatureType();
  Assert.assertNull(ft);

  Service s = ds.getServiceDefault();
  Assert.assertNotNull(s);
  Assert.assertTrue(s.getType() == ServiceType.HTTPServer);

  String v = ds.findProperty(Dataset.NotAThreddsDataset);
  Assert.assertNotNull(v);
  Assert.assertEquals("true", v);
}
 
Example #9
Source File: NdbcCoards.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 (!ds.getRootGroup().findAttributeString(CDM.CONVENTIONS, "").equalsIgnoreCase("COARDS"))
    return false;

  String dataProvider = ds.getRootGroup().findAttributeString("data_provider", null);
  if (dataProvider == null)
    dataProvider = ds.getRootGroup().findAttributeString("institution", "");
  if (!dataProvider.contains("National Data Buoy Center"))
    return false;

  if (null == ds.getRootGroup().findAttributeString("station", null))
    return false;
  if (null == ds.getRootGroup().findAttributeString("location", null))
    return false;

  // if (ds.findVariable("lat") == null) return false;
  // if (ds.findVariable("lon") == null) return false;

  // DODS wont have record !!
  return ds.hasUnlimitedDimension();

}
 
Example #10
Source File: FslWindProfiler.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) throws IOException {
  String title = ds.getRootGroup().findAttributeString("title", null);
  if (title == null)
    title = ds.getRootGroup().findAttributeString("DD_reference", null);
  assert (title != null);

  boolean isRass = title.startsWith("RASS data");
  String xml =
      isRass ? "resources/nj22/pointConfig/FslRassProfiler.xml" : "resources/nj22/pointConfig/FslWindProfiler.xml";

  PointConfigXML reader = new PointConfigXML();
  TableConfig tc = reader.readConfigXMLfromResource(xml, wantFeatureType, ds, errlog);

  for (TableConfig inner : tc.children.get(0).children)
    makeMultidimInner(ds, tc, inner, inner.outerName, inner.innerName);
  return tc;
}
 
Example #11
Source File: TestDtWithCoverageReadingP.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Parameterized.Parameters(name = "{0}")
public static List<Object[]> getTestParameters() {
  List<Object[]> result = new ArrayList<>();

  // NUWG - has CoordinateAlias
  result.add(new Object[] {TestDir.cdmUnitTestDir + "ft/coverage/03061219_ruc.nc", FeatureType.GRID});
  // scalar runtime
  result.add(new Object[] {TestDir.cdmUnitTestDir + "ft/coverage/ECME_RIZ_201201101200_00600_GB", FeatureType.GRID});
  // both x,y and lat,lon
  result.add(new Object[] {TestDir.cdmUnitTestDir + "ft/coverage/testCFwriter.nc", FeatureType.GRID});
  // SRC
  result
      .add(new Object[] {TestDir.cdmUnitTestDir + "gribCollections/tp/GFS_Global_onedeg_ana_20150326_0600.grib2.ncx4",
          FeatureType.GRID});

  // not GRID
  result.add(new Object[] {TestDir.cdmUnitTestDir + "gribCollections/gfs_2p5deg/gfs_2p5deg.ncx4", FeatureType.GRID});
  // ensemble, time-offset
  result.add(new Object[] {TestDir.cdmUnitTestDir + "ft/coverage/MM_cnrm_129_red.ncml", FeatureType.FMRC});
  // scalar vert LOOK change to TimeOffset ??
  // result.add(new Object[]{TestDir.cdmUnitTestDir + "ft/coverage/ukmo.nc", FeatureType.FMRC});
  // x,y axis but no projection
  result.add(new Object[] {TestDir.cdmUnitTestDir + "ft/coverage/Run_20091025_0000.nc", FeatureType.CURVILINEAR});
  return result;
}
 
Example #12
Source File: NdbcNetcdf4.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 (ds.getFileTypeId().equals("HDF5"))
    return false;

  String dataProvider = ds.getRootGroup().findAttributeString("data_provider", null);
  if (dataProvider == null)
    dataProvider = ds.getRootGroup().findAttributeString("institution", "");
  if (!dataProvider.contains("National Data Buoy Center"))
    return false;

  if (null == ds.getRootGroup().findAttributeString("station_name", null))
    return false;
  if (null == ds.getRootGroup().findAttributeString("nominal_latitude", null))
    return false;
  return null != ds.getRootGroup().findAttributeString("nominal_longitude", null);

}
 
Example #13
Source File: MadisAcars.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) {
  VNames vn = getVariableNames(ds, errlog);

  TableConfig trajTable = new TableConfig(Table.Type.Construct, "trajectory");
  trajTable.featureType = FeatureType.TRAJECTORY;
  trajTable.feature_id = TRAJ_ID;

  TableConfig obs = new TableConfig(Table.Type.ParentId, "record");
  obs.parentIndex = TRAJ_ID;
  obs.dimName = Evaluator.getDimensionName(ds, "recNum", errlog);
  obs.time = vn.obsTime;
  obs.timeNominal = vn.nominalTime;

  // obs.stnId = vn.stnId;
  // obs.stnDesc = vn.stnDesc;
  obs.lat = vn.lat;
  obs.lon = vn.lon;
  obs.elev = vn.elev;

  trajTable.addChild(obs);
  return trajTable;
}
 
Example #14
Source File: AllowedServices.java    From tds with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public Service getStandardServices(FeatureType featType) {
  ServiceType compoundService = ServiceType.Compound;
  if (featType.isCoverageFeatureType()) {
    return new Service("GridServices", "", compoundService.toString(), compoundService.getDescription(), null,
        allowedGridServices, null, compoundService.getAccessType());
  }

  if (featType.isPointFeatureType()) {
    return new Service("PointServices", "", compoundService.toString(), compoundService.getDescription(), null,
        allowedPointServices, null, compoundService.getAccessType());
  }

  if (featType == FeatureType.RADIAL) {
    return new Service("RadialServices", "", compoundService.toString(), compoundService.getDescription(), null,
        allowedRadialServices, null, compoundService.getAccessType());
  }

  return null;
}
 
Example #15
Source File: TestCFPointWriterMisc.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Test
@Category(NeedsCdmUnitTest.class)
public void testPointProblem() throws IOException {
  String filename = TestDir.cdmUnitTestDir + "ft/point/netcdf/Surface_Buoy_20090921_0000.nc";
  TestCFPointWriter.writeDataset(filename, FeatureType.POINT,
      new CFPointWriterConfig(NetcdfFileWriter.Version.netcdf3), false, tempFolder.newFile());
}
 
Example #16
Source File: TestCoverageSubsetTime.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Test
public void testSrcTimePresent() throws IOException, InvalidRangeException {
  String endpoint = TestDir.cdmUnitTestDir + "ncss/GFS/CONUS_80km/GFS_CONUS_80km_20120227_0000.grib1";
  String covName = "Temperature_isobaric";

  logger.debug("testSrcTimePresent Dataset {} coverage {}", endpoint, covName);

  try (FeatureDatasetCoverage cc = CoverageDatasetFactory.open(endpoint)) {
    Assert.assertNotNull(endpoint, cc);
    CoverageCollection gcs = cc.findCoverageDataset(FeatureType.GRID);
    Assert.assertNotNull("gcs", gcs);
    Coverage cover = gcs.findCoverage(covName);
    Assert.assertNotNull(covName, cover);

    CoverageCoordSys cs = cover.getCoordSys();
    CoverageCoordAxis timeAxis = cs.getAxis(AxisType.Time);
    Assert.assertNotNull("timeoffset axis", timeAxis);
    Assert.assertEquals(36, timeAxis.getNcoords());

    SubsetParams params = new SubsetParams();
    params.set(SubsetParams.timePresent, true);
    logger.debug("  subset {}", params);
    GeoReferencedArray geo = cover.readData(params);

    int[] resultShape = geo.getData().getShape();
    int[] expectShape = new int[] {1, 29, 65, 93};
    Assert.assertArrayEquals("shape", expectShape, resultShape);

    CoverageCoordSys geocs = geo.getCoordSysForData();
    CoverageCoordAxis toAxis2 = geocs.getAxis(AxisType.Time);
    Assert.assertNotNull("timeoffset axis", toAxis2);
    Assert.assertEquals(1, toAxis2.getNcoords());
  }
}
 
Example #17
Source File: TestPointDatasets.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static List<Object[]> getGempakDatasets() {
  List<Object[]> result = new ArrayList<>();

  // gempack sounding
  result.add(new Object[] {TestDir.cdmUnitTestDir + "ft/sounding/gempak/19580807_upa.ncml",
      FeatureType.STATION_PROFILE, 8769});

  // gempak surface
  result.add(new Object[] {TestDir.cdmUnitTestDir + "ft/point/gempak/2009103008_sb.gem", FeatureType.POINT, 3337});
  result.add(new Object[] {TestDir.cdmUnitTestDir + "ft/point/gempak/2009110100_ship.gem", FeatureType.POINT, 938});
  result.add(new Object[] {TestDir.cdmUnitTestDir + "ft/station/gempak/20091030_syn.gem", FeatureType.POINT, 55856});
  result
      .add(new Object[] {TestDir.cdmUnitTestDir + "ft/station/gempak/20091030_syn.gem", FeatureType.STATION, 28328});

  result.add(new Object[] {TestDir.cdmUnitTestDir + "ft/sounding/gempak/19580807_upa.ncml",
      FeatureType.STATION_PROFILE, 8769});

  // (GEMPAK IOSP) stn = psuedoStruct, obs = multidim Structure, time(time) as extraJoin
  // checkPointDataset(TestDir.cdmUnitTestDir + "formats/gempak/surface/19580807_sao.gem", FeatureType.STATION, true);

  // stationAsPoint (GEMPAK IOSP) stn = psuedoStruct, obs = multidim Structure, time(time) as extraJoin
  // testPointDataset(TestDir.cdmUnitTestDir + "formats/gempak/surface/20090521_sao.gem", FeatureType.POINT, true);

  // testGempakAll(TestDir.cdmUnitTestDir + "formats/gempak/surface/20090524_sao.gem");
  // testGempakAll(TestDir.cdmUnitTestDir+"C:/data/ft/station/09052812.sf");

  // testPointDataset("collection:C:/data/formats/gempak/surface/#yyyyMMdd#_sao\\.gem", FeatureType.STATION, true);
  // checkPointDataset("collection:D:/formats/gempak/surface/#yyyyMMdd#_sao\\.gem", FeatureType.STATION, true);

  return result;
}
 
Example #18
Source File: TestCfDocDsgExamples.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private static List<Object[]> getProfileDatasets() {
  List<Object[]> result = new ArrayList<>();

  result.add(new Object[] {"H.3.1.1.ncml", FeatureType.PROFILE, 56});
  result.add(new Object[] {"H.3.3.1.ncml", FeatureType.PROFILE, 42});
  result.add(new Object[] {"H.3.4.1.ncml", FeatureType.PROFILE, 37});
  result.add(new Object[] {"H.3.5.1.ncml", FeatureType.PROFILE, 37});

  return result;
}
 
Example #19
Source File: CoverageAsPoint.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
CoverageAsFeatureDatasetPoint(FeatureType featureType) {
  super(featureType);
  CoverageAsStationFeatureCollection fc =
      new CoverageAsStationFeatureCollection(gcd.getName() + " AsStationFeatureCollection", dateUnit, null);
  setPointFeatureCollection(fc);

  List<VariableSimpleIF> dataVars = new ArrayList<>();
  for (VarData vd : varData) {
    VariableSimpleIF simple = VariableSimpleBuilder
        .makeScalar(vd.cov.getName(), vd.cov.getDescription(), vd.cov.getUnitsString(), vd.cov.getDataType())
        .build();
    dataVars.add(simple);
  }
  this.dataVariables = dataVars;
}
 
Example #20
Source File: FeatureDatasetFactoryManager.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * @deprecated use open(FeatureType wantFeatureType, String location, ucar.nc2.util.CancelTask task, Formatter errlog)
 */
public static FeatureDataset open(FeatureType wantFeatureType, String location, ucar.nc2.util.CancelTask task)
    throws IOException, NoFactoryFoundException {

  Formatter errlog = new Formatter();
  FeatureDataset fd = FeatureDatasetFactoryManager.open(wantFeatureType, location, task, errlog);

  if (fd == null) {
    throw new NoFactoryFoundException(errlog.toString());
  } else {
    return fd;
  }
}
 
Example #21
Source File: BufrConfig.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private FeatureType guessFeatureType(StandardFields.StandardFieldsFromMessage standardFields) {
  if (standardFields.hasStation())
    return FeatureType.STATION;
  if (standardFields.hasTime())
    return FeatureType.POINT;
  return FeatureType.ANY;
}
 
Example #22
Source File: TestConventionFeatureTypes.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Test
public void testCoverageDatasets() throws IOException {
  if (type != FeatureType.GRID) {
    return;
  }
  for (File f : getAllFilesInDirectoryStandardFilter(dir)) {
    logger.debug("Open CoverageDataset {}", f.getPath());
    try (NetcdfDataset ds = NetcdfDatasets.openDataset(f.getPath())) {
      DtCoverageCSBuilder builder = DtCoverageCSBuilder.classify(ds, new Formatter());
      Assert.assertNotNull(builder);
    }
  }
}
 
Example #23
Source File: TestCFRadial.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Test
public void testBasic() throws IOException {
  try (RadialDatasetSweep ds = testData()) {
    Assert.assertEquals(FeatureType.RADIAL, ds.getFeatureType());
    Assert.assertEquals("CF/RadialNetCDF", ds.getDataFormat());
    Assert.assertTrue(ds.isVolume());
    Assert.assertEquals(2, ds.getDataVariables().size());
    Assert.assertNotNull(ds.getDataVariable("DBZ"));
    Assert.assertNotNull(ds.getDataVariable("VR"));
  }
}
 
Example #24
Source File: InvDatasetImpl.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Construct an InvDatasetImpl which refers to a urlPath.
 * This is used to create a standalone InvDatasetImpl, outside of an InvCatalog.
 * An "anonymous" InvServerImpl is created and attached to the InvDataset.
 *
 * @param urlPath : construct URL from this path
 * @param dataType : data type
 * @param stype : ServiceType
 */
public InvDatasetImpl(String urlPath, FeatureType dataType, ServiceType stype) {
  super(null, "local file");
  tm.setDataType(dataType);
  tm.setServiceName("anon");
  this.urlPath = urlPath;

  // create anonymous service
  addService(new InvService(tm.getServiceName(), stype.toString(), "", "", null));

  finish();
}
 
Example #25
Source File: TestCoverageFileWritingCompare.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Parameterized.Parameters(name = "{0}")
public static List<Object[]> getTestParameters() {
  List<Object[]> result = new ArrayList<>();

  // SRC
  result.add(new Object[] {TestDir.cdmUnitTestDir + "ncss/GFS/CONUS_80km/GFS_CONUS_80km_20120227_0000.grib1",
      FeatureType.GRID, Lists.newArrayList("Temperature_isobaric"),
      new SubsetParams().set(SubsetParams.timePresent, true), NetcdfFileFormat.NETCDF3});

  result.add(new Object[] {TestDir.cdmUnitTestDir + "ft/coverage/03061219_ruc.nc", FeatureType.GRID,
      Lists.newArrayList("P_sfc", "P_trop"), null, NetcdfFileFormat.NETCDF3});

  result.add(new Object[] {TestDir.cdmUnitTestDir + "ft/coverage/03061219_ruc.nc", FeatureType.GRID,
      Lists.newArrayList("P_sfc", "P_trop", "T"), null, NetcdfFileFormat.NETCDF3});

  result.add(new Object[] {TestDir.cdmUnitTestDir + "ft/coverage/ECME_RIZ_201201101200_00600_GB", FeatureType.GRID,
      Lists.newArrayList("Surface_pressure_surface"), null, NetcdfFileFormat.NETCDF3}); // scalar runtime, ens
  // coord
  result.add(new Object[] {TestDir.cdmUnitTestDir + "ft/coverage/testCFwriter.nc", FeatureType.GRID,
      Lists.newArrayList("PS", "Temperature"), null, NetcdfFileFormat.NETCDF3}); // both x,y and lat,lon

  /// netcdf4
  result.add(new Object[] {TestDir.cdmUnitTestDir + "ft/coverage/03061219_ruc.nc", FeatureType.GRID,
      Lists.newArrayList("P_sfc", "P_trop"), null, NetcdfFileFormat.NETCDF4});

  result.add(new Object[] {TestDir.cdmUnitTestDir + "gribCollections/gfs_2p5deg/gfs_2p5deg.ncx4", FeatureType.GRID,
      Lists.newArrayList("Soil_temperature_depth_below_surface_layer"), null, NetcdfFileFormat.NETCDF4}); // TwoD

  return result;
}
 
Example #26
Source File: TestDtWithCoverageReadingP.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Ignore("takes too long")
@Test
public void testGridCoverageDataset() throws IOException {
  System.out.printf("Test Dataset %s%n", endpoint);

  try (FeatureDatasetCoverage cc = CoverageDatasetFactory.open(endpoint)) {
    Assert.assertNotNull(endpoint, cc);
    CoverageCollection gcs = cc.findCoverageDataset(expectType);
    Assert.assertNotNull(expectType.toString(), gcs);

    // check DtCoverageCS
    try (GridDataset ds = GridDataset.open(endpoint)) {
      for (GridDatatype dt : ds.getGrids()) {
        if (expectType == FeatureType.FMRC && !dt.getFullName().startsWith("TwoD"))
          continue;
        if (expectType == FeatureType.GRID && dt.getFullName().startsWith("TwoD"))
          continue;

        GridCoordSystem csys = dt.getCoordinateSystem();
        CoordinateAxis1DTime rtAxis = csys.getRunTimeAxis();
        CoordinateAxis1D ensAxis = csys.getEnsembleAxis();
        CoordinateAxis1D vertAxis = csys.getVerticalAxis();

        Coverage cover = gcs.findCoverage(dt.getShortName());
        if (cover == null) {
          System.out.printf("Cant find %s%n", dt.getFullName());
          continue;
        }
        System.out.printf(" Grid %s%n", dt.getFullName());

        readAllRuntimes(cover, dt, rtAxis, ensAxis, vertAxis);
      }
    }
  }
}
 
Example #27
Source File: SimpleGeometryCSBuilder.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public SimpleGeometryCS makeCoordSys() {
  if (type == null)
    return null;

  if (type == FeatureType.SIMPLE_GEOMETRY) {
    return new SimpleGeometryCS(this);
  }
  return null;
}
 
Example #28
Source File: CFpointObs.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private TableConfig makeStructTableTestTraj(NetcdfDataset ds, FeatureType ftype, EncodingInfo info,
    Formatter errlog) {
  Table.Type tableType = Table.Type.Structure;
  if (info.encoding == Encoding.single)
    tableType = Table.Type.Top;
  if (info.encoding == Encoding.flat)
    tableType = Table.Type.ParentId;

  String name = (info.parentDim == null) ? " single" : info.parentDim.getShortName();
  TableConfig tableConfig = new TableConfig(tableType, name);
  tableConfig.lat = CoordSysEvaluator.findCoordNameByType(ds, AxisType.Lat);
  tableConfig.lon = CoordSysEvaluator.findCoordNameByType(ds, AxisType.Lon);
  tableConfig.elev = CoordSysEvaluator.findCoordNameByType(ds, AxisType.Height);
  if (tableConfig.elev == null)
    tableConfig.elev = CoordSysEvaluator.findCoordNameByType(ds, AxisType.Pressure);
  if (tableConfig.elev == null)
    tableConfig.elev = CoordSysEvaluator.findCoordNameByType(ds, AxisType.GeoZ);
  tableConfig.time = CoordSysEvaluator.findCoordNameByType(ds, AxisType.Time);
  tableConfig.featureType = ftype;

  if (info.encoding != Encoding.single && info.parentDim != null) {
    tableConfig.dimName = name;
    makeStructureInfo(tableConfig, ds, null, info.parentDim);
  }

  return tableConfig;
}
 
Example #29
Source File: CatalogTree_appendToNodeTest.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
private InvDatasetImpl createDataset(InvCatalogImpl catalog, String datasetName, final String serviceName) {
    final InvDatasetImpl dapDataset = new InvDatasetImpl(null, datasetName, FeatureType.NONE, serviceName, "http://wherever.you.want.bc");
    dapDataset.setCatalog(catalog);
    final InvService dapService = new InvService(serviceName, serviceName, "irrelevant", "irrelevant", "irrelevant");
    dapDataset.addAccess(new InvAccessImpl(dapDataset, "http://y.z", dapService));
    dapDataset.finish();
    return dapDataset;
}
 
Example #30
Source File: BufrFeatureDatasetFactory.java    From netcdf-java with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private BufrStationDataset(NetcdfDataset ncfile, BufrCdmIndex index) {
  super(ncfile, FeatureType.STATION);
  this.index = index;

  // create the list of data variables
  munger = new Munge();
  obs = (SequenceDS) ncfile.findVariable(BufrIosp2.obsRecordName);
  this.dataVariables = munger.makeDataVariables(index, obs);

  BufrStationCollection bufrCollection = new BufrStationCollection(ncfile.getLocation());
  setPointFeatureCollection(bufrCollection);

  CalendarDateRange dateRange = CalendarDateRange.of(CalendarDate.of(index.start), CalendarDate.of(index.end));
  setDateRange(dateRange);
}