コード例 #1
0
ファイル: TestFmrcMisc.java プロジェクト: qlongyinqw/thredds
  @Test
  public void testFloatingPointCompare() throws Exception {
    String spec =
        TestDir.cdmUnitTestDir + "ft/fmrc/fp_precision/sediment_thickness_#yyMMddHHmm#.*\\.nc$";
    System.out.printf("%n====================FMRC dataset %s%n", spec);
    Formatter errlog = new Formatter();
    Fmrc fmrc = Fmrc.open(spec, errlog);
    assert (fmrc != null) : errlog;

    try (ucar.nc2.dt.GridDataset gridDs = fmrc.getDatasetBest()) {
      GridDatatype v = gridDs.findGridByShortName("thickness_of_sediment");
      assert v != null;
      GridCoordSystem gcs = v.getCoordinateSystem();
      CoordinateAxis1DTime time = gcs.getTimeAxis1D();

      Assert.assertEquals("hours since 2015-03-08 12:51:00.000 UTC", time.getUnitsString());
      Assert.assertEquals(74, time.getSize());
      Array data = time.read();
      System.out.printf("%s%n", NCdumpW.toString(data));

      for (CalendarDate cd : time.getCalendarDates()) {
        assert cd.getFieldValue(CalendarPeriod.Field.Minute) == 0 : System.out.printf("%s%n", cd);
      }
    }
  }
コード例 #2
0
  public void testSingleDataset() throws IOException {
    InvCatalogImpl cat = TestTDSAll.open(null);

    InvDataset ds = cat.findDatasetByID("testSingleDataset");
    assert (ds != null) : "cant find dataset 'testSingleDataset'";
    assert ds.getDataType() == FeatureType.GRID;

    ThreddsDataFactory fac = new ThreddsDataFactory();

    ThreddsDataFactory.Result dataResult = fac.openFeatureDataset(ds, null);

    assert dataResult != null;
    assert !dataResult.fatalError;
    assert dataResult.featureDataset != null;

    GridDataset gds = (GridDataset) dataResult.featureDataset;
    GridDatatype grid = gds.findGridDatatype("Z_sfc");
    assert grid != null;
    GridCoordSystem gcs = grid.getCoordinateSystem();
    assert gcs != null;
    assert null == gcs.getVerticalAxis();

    CoordinateAxis1D time = gcs.getTimeAxis1D();
    assert time != null;
    assert time.getSize() == 1;
    assert 102840.0 == time.readScalarDouble();

    dataResult.featureDataset.close();
  }
コード例 #3
0
  public static DateRange extractDateRange(GridDataset gridDataset) {
    DateRange maxDateRange = null;

    for (GridDataset.Gridset gridset : gridDataset.getGridsets()) {
      GridCoordSystem gsys = gridset.getGeoCoordSystem();
      DateRange dateRange;

      CoordinateAxis1DTime time1D = gsys.getTimeAxis1D();
      if (time1D != null) {
        dateRange = time1D.getDateRange();
      } else {
        CoordinateAxis time = gsys.getTimeAxis();
        if (time == null) continue;

        try {
          DateUnit du = new DateUnit(time.getUnitsString());
          Date minDate = du.makeDate(time.getMinValue());
          Date maxDate = du.makeDate(time.getMaxValue());
          dateRange = new DateRange(minDate, maxDate);
        } catch (Exception e) {
          logger.warn("Illegal Date Unit " + time.getUnitsString());
          continue;
        }
      }

      if (maxDateRange == null) maxDateRange = dateRange;
      else maxDateRange.extend(dateRange);
    }

    return maxDateRange;
  }
コード例 #4
0
ファイル: GridUI.java プロジェクト: nbald/thredds
  void setField(GridDatatype field) {
    /*int idx = fieldChooser.setSelectedByName(field.toString());
    if (idx < 0)
      fieldChooser.setSelectedByIndex(0); */
    fieldChooser.setToolTipText(field.getName());

    GridCoordSystem gcs = field.getCoordinateSystem();

    // levels
    CoordinateAxis1D axis = gcs.getVerticalAxis();
    setChooserWanted("level", axis != null);
    if (axis != null) {
      List<NamedObject> levels = axis.getNames();
      levelChooser.setCollection(levels.iterator(), true);
      NamedObject no = levels.get(controller.getCurrentLevelIndex());
      levelChooser.setSelectedByName(no.getName());
    }

    // times
    if (gcs.hasTimeAxis()) {
      axis = gcs.hasTimeAxis1D() ? gcs.getTimeAxis1D() : gcs.getTimeAxisForRun(0);
      setChooserWanted("time", axis != null);
      if (axis != null) {
        List<NamedObject> names = axis.getNames();
        timeChooser.setCollection(names.iterator(), true);
        NamedObject no = names.get(controller.getCurrentTimeIndex());
        timeChooser.setSelectedByName(no.getName());
      }
    } else {
      setChooserWanted("time", false);
    }

    axis = gcs.getEnsembleAxis();
    setChooserWanted("ensemble", axis != null);
    if (axis != null) {
      List<NamedObject> names = axis.getNames();
      ensembleChooser.setCollection(names.iterator(), true);
      NamedObject no = names.get(controller.getCurrentEnsembleIndex());
      ensembleChooser.setSelectedByName(no.getName());
    }

    axis = gcs.getRunTimeAxis();
    setChooserWanted("runtime", axis != null);
    if (axis != null) {
      List<NamedObject> names = axis.getNames();
      runtimeChooser.setCollection(names.iterator(), true);
      NamedObject no = names.get(controller.getCurrentRunTimeIndex());
      runtimeChooser.setSelectedByName(no.getName());
    }

    setChoosers();

    colorScalePanel.setUnitString(field.getUnitsString());
  }