Package ucar.nc2.dataset

Examples of ucar.nc2.dataset.VariableDS


  protected void rebuildDataset() throws IOException {
    super.rebuildDataset();

    if (timeUnitsChange) {
      VariableDS joinAggCoord = (VariableDS) ncDataset.getRootGroup().findVariable(dimName);
      readTimeCoordinates(joinAggCoord, null);
    }
  }
View Full Code Here


        Variable v = ncfile.findVariable(timeAxis.getFullNameEscaped());
        if (v == null) {
          logger.warn("readTimeCoordinates: variable = " + timeAxis.getFullName() + " not found in file " + dataset.getLocation());
          return;
        }
        VariableDS vds = (v instanceof VariableDS) ? (VariableDS) v : new VariableDS( null, v, true);
        CoordinateAxis1DTime timeCoordVar = CoordinateAxis1DTime.factory(ncDataset, vds, null);
        java.util.Date[] dates = timeCoordVar.getTimeDates();
        dateList.addAll(Arrays.asList(dates));

        if (timeUnits == null)
View Full Code Here

    // run through all variables
    for (Variable v : typical.getVariables()) {
      if (isTiled(v)) {
        Group newGroup = DatasetConstructor.findGroup(ncDataset, v.getParentGroup());
        VariableDS vagg = new VariableDS(ncDataset, newGroup, null, v.getShortName(), v.getDataType(),
                v.getDimensionsString(), null, null);   // LOOK what about anon dimensions?
        vagg.setProxyReader( this); // do the reading here
        DatasetConstructor.transferVariableAttributes(v, vagg);

        newGroup.removeVariable(v.getShortName());
        newGroup.addVariable(vagg);
        // aggVars.add(vagg);
View Full Code Here

  public void testBzipProblem() throws IOException, InvalidRangeException {
    // file where there was an error unzipping the file
    String filename = TestAll.cdmUnitTestDir + "formats/nexrad/level2/Level2_KFTG_20060818_1814.ar2v.uncompress.missingradials";
    NetcdfDataset ncd = NetcdfDataset.openDataset( filename);

    VariableDS azi = (VariableDS) ncd.findVariable("azimuthR");
    assert azi != null;
    VariableDS elev = (VariableDS) ncd.findVariable("elevationR");
    assert elev != null;
    VariableDS time = (VariableDS) ncd.findVariable("timeR");
    assert time != null;
    VariableDS r = (VariableDS) ncd.findVariable("Reflectivity");
    assert r != null;
    checkMissingValues(elev, azi, time, r);

    azi = (VariableDS) ncd.findVariable("azimuthV");
    assert azi != null;
View Full Code Here

        return null;
      }
    }

    // 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)

    Table.Type obsTableType = null;
    Structure multidimStruct = null;
    if (obsTableType == null) {
      // Structure(station, time)
      multidimStruct = Evaluator.getStructureWithDimensions(ds, stationDim, obsDim);
      if (multidimStruct != null) {
        obsTableType = Table.Type.MultidimStructure;
      }
    }

    // multidim case
    if (obsTableType == null) {
      // time(station, time)
      if (time.getRank() == 2) {
        obsTableType = Table.Type.MultidimInner;
      }
    }

    if (obsTableType == null) {
        errlog.format("GempakCdm: Cannot figure out Station/obs table structure");
        return null;
    }

    TableConfig obs = new TableConfig(obsTableType, obsDim.getName());
    obs.dimName = obsDim.getName();
    obs.time = time.getFullName();
    obs.missingVar = "_isMissing";
    stnTable.addChild(obs);

    if (obsTableType == Table.Type.MultidimStructure) {
      obs.structName = multidimStruct.getFullName();
      obs.structureType = TableConfig.StructureType.Structure;
      // if time is not in this structure, need to join it
      if (multidimStruct.findVariable( time.getShortName()) == null) {
        obs.addJoin(new JoinArray( time, JoinArray.Type.raw, 0));
      }
    }

    if (obsTableType == Table.Type.MultidimInner) {
View Full Code Here

    // optional alt coord
    Variable alt = CoordSysEvaluator.findCoordByType(ds, AxisType.Height);

    // 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)

    Table.Type obsTableType = Table.Type.Structure;
    Structure multidimStruct = Evaluator.getStructureWithDimensions(ds, stationDim, obsDim);

    if (multidimStruct == null) {
        errlog.format("GempakCdm: Cannot figure out StationAsPoint table structure");
        return null;
    }

    TableConfig obs = new TableConfig(obsTableType, obsDim.getName());
    obs.dimName = obsDim.getName();
    obs.structName = multidimStruct.getFullName();
    obs.structureType = TableConfig.StructureType.Structure;
    obs.featureType = FeatureType.POINT;

    obs.lat= lat.getFullName();
    obs.lon= lon.getFullName();
    obs.time= time.getFullName();
    if (alt != null)
       obs.elev = alt.getFullName();

    List<String> vars = new ArrayList<String>(30);
    for (Variable v : ds.getVariables()) {
View Full Code Here

    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.getStructureWithDimensions(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.getName());
    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.getName());
    Structure nestedStruct = Evaluator.getNestedStructure(multidimStruct);
    if (nestedStruct == null) {
View Full Code Here

  private TableConfig getStationConfig(NetcdfDataset ds, Formatter errlog) throws IOException {
    EncodingInfo info = identifyEncodingStation(ds, CF.FeatureType.timeSeries, errlog);
    if (info == null) return null;

    // obs dimension
    VariableDS time = CoordSysEvaluator.findCoordByType(ds, AxisType.Time);
    Variable parentId = identifyParent(ds, CF.FeatureType.timeSeries);
    Dimension obsDim = info.childDim;

    // make station table
    TableConfig stnTable = makeStationTable(ds, FeatureType.STATION, info, errlog);
    if (stnTable == null) return null;

    TableConfig obsTable = null;
    switch (info.encoding) {
      case single:
        obsTable = makeSingle(ds, obsDim, errlog);
        break;

      case multidim:
        obsTable = makeMultidimInner(ds, stnTable, obsDim, errlog);
        if (time.getRank() == 1) { // time(time)
          obsTable.addJoin(new JoinArray(time, JoinArray.Type.raw, 0));
          obsTable.time = time.getShortName();
        }
        break;

      case raggedContiguous:
        obsTable = makeRaggedContiguous(ds, info.parentDim, info.childDim, errlog);
View Full Code Here

    if (parentTable.feature_id == null) {
      errlog.format("getProfileConfig cant find a profile id %n");
    }

    // obs table
    VariableDS z = CoordSysEvaluator.findCoordByType(ds, AxisType.Height);
    if (z == null) {
      errlog.format("getProfileConfig cant find a Height coordinate %n");
      return null;
    }
    //Dimension obsDim = z.getDimension(z.getRank() - 1); // may be z(z) or z(profile, z)

    TableConfig obsTable = null;
    switch (info.encoding) {
      case single:
        obsTable = makeSingle(ds, info.childDim, errlog);
        break;
      case multidim:
        obsTable = makeMultidimInner(ds, parentTable, info.childDim, errlog);
        if (z.getRank() == 1) // z(z)
          obsTable.addJoin(new JoinArray(z, JoinArray.Type.raw, 0));
        break;
      case raggedContiguous:
        obsTable = makeRaggedContiguous(ds, info.parentDim, info.childDim, errlog);
        break;
View Full Code Here

  private TableConfig getTimeSeriesProfileConfig(NetcdfDataset ds, Formatter errlog) throws IOException {
    EncodingInfo info = identifyEncodingTimeSeriesProfile(ds, CF.FeatureType.timeSeriesProfile, errlog);
    if (info == null) return null;

    VariableDS time = CoordSysEvaluator.findCoordByType(ds, AxisType.Time);
    if (time.getRank() == 0) {
      errlog.format("timeSeriesProfile cannot have a scalar time coordinate%n");
      return null;
    }

    // find the non-station altitude
    VariableDS z = findZAxisNotStationAlt(ds);
    if (z == null) {
      errlog.format("timeSeriesProfile must have a z coordinate%n");
      return null;
    }
    if (z.getRank() == 0) {
      errlog.format("timeSeriesProfile cannot have a scalar z coordinate%n");
      return null;
    }

    /* distinguish multidim from flat
    if ((info.encoding == Encoding.multidim) && (time.getRank() < 3) && (z.getRank() < 3)) {
      Variable parentId = identifyParent(ds, CF.FeatureType.timeSeriesProfile);
      if ((parentId != null) && (parentId.getRank() == 1) && (parentId.getDimension(0).equals(time.getDimension(0)))) {
        if (time.getRank() == 1) // multidim time must be 2 or 3 dim
          info = new EncodingInfo(Encoding.flat, parentId);
        else if (time.getRank() == 2) {
          Dimension zDim = z.getDimension(z.getRank() - 1); // may be z(z) or z(profile, z)
          if (zDim.equals(time.getDimension(1))) // flat 2D time will have time as inner dim
            info = new EncodingInfo(Encoding.flat, parentId);
        }
      }
    } */

    TableConfig stationTable = makeStationTable(ds, FeatureType.STATION_PROFILE, info, errlog);
    if (stationTable == null) return null;

    //Dimension stationDim = ds.findDimension(stationTable.dimName);
    //Dimension profileDim = null;
    //Dimension zDim = null;

    switch (info.encoding) {
      case single: {
        assert ((time.getRank() >= 1) && (time.getRank() <= 2)) : "time must be rank 1 or 2";
        assert ((z.getRank() >= 1) && (z.getRank() <= 2)) : "z must be rank 1 or 2";

        if (time.getRank() == 2) {
          if (z.getRank() == 2// 2d time, 2d z
            assert time.getDimensions().equals(z.getDimensions()) : "rank-2 time and z dimensions must be the same";
          else  // 2d time, 1d z
            assert time.getDimension(1).equals(z.getDimension(0)) : "rank-2 time must have z inner dimension";
          //profileDim = time.getDimension(0);
          //zDim = time.getDimension(1);

        } else { // 1d time
          if (z.getRank() == 2) { // 1d time, 2d z
            assert z.getDimension(0).equals(time.getDimension(0)) : "rank-2 z must have time outer dimension";
            //profileDim = z.getDimension(0);
            //zDim = z.getDimension(1);
          } else { // 1d time, 1d z
            assert !time.getDimension(0).equals(z.getDimension(0)) : "time and z dimensions must be different";
            //profileDim = time.getDimension(0);
            //zDim = z.getDimension(0);
          }
        }
        // make profile table
        TableConfig profileTable = makeStructTable(ds, FeatureType.PROFILE, new EncodingInfo(Encoding.multidim, info.childDim), errlog);
        if (profileTable == null) return null;
        if (time.getRank() == 1) // join time(time)
          profileTable.addJoin(new JoinArray(time, JoinArray.Type.raw, 0));
        stationTable.addChild(profileTable);

        // make the inner (z) table
        TableConfig zTable = makeMultidimInner(ds, profileTable, info.grandChildDim, errlog);
        if (z.getRank() == 1) // join z(z)
          zTable.addJoin(new JoinArray(z, JoinArray.Type.raw, 0));
        profileTable.addChild(zTable);

        break;
      }

      case multidim: {
        assert ((time.getRank() >= 2) && (time.getRank() <= 3)) : "time must be rank 2 or 3";
        assert ((z.getRank() == 1) || (z.getRank() == 3)) : "z must be rank 1 or 3";

        if (time.getRank() == 3) {
          if (z.getRank() == 3// 3d time, 3d z
            assert time.getDimensions().equals(z.getDimensions()) : "rank-3 time and z dimensions must be the same";
          else  // 3d time, 1d z
            assert time.getDimension(2).equals(z.getDimension(0)) : "rank-3 time must have z inner dimension";
          //profileDim = time.getDimension(1);
          //zDim = time.getDimension(2);

        } else { // 2d time
          if (z.getRank() == 3) { // 2d time, 3d z
            assert z.getDimension(1).equals(time.getDimension(1)) : "rank-2 time must have time inner dimension";
            //profileDim = z.getDimension(1);
            //zDim = z.getDimension(2);
          } else { // 2d time, 1d z
            assert !time.getDimension(0).equals(z.getDimension(0)) : "time and z dimensions must be different";
            assert !time.getDimension(1).equals(z.getDimension(0)) : "time and z dimensions must be different";
            //profileDim = time.getDimension(1);
            //zDim = z.getDimension(0);
          }
        }

        // make profile table
        //   private TableConfig makeMultidimInner(NetcdfDataset ds, TableConfig parentTable, Dimension obsDim, Formatter errlog) throws IOException {

        TableConfig profileTable = makeMultidimInner(ds, stationTable, info.childDim, errlog);
        if (profileTable == null) return null;
        stationTable.addChild(profileTable);

        // make the inner (z) table
        TableConfig zTable = makeMultidimInner3D(ds, stationTable, profileTable, info.grandChildDim, errlog);
        if (z.getRank() == 1) // join z(z)
          zTable.addJoin(new JoinArray(z, JoinArray.Type.raw, 0));
        profileTable.addChild(zTable);
        break;
      }

View Full Code Here

TOP

Related Classes of ucar.nc2.dataset.VariableDS

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.