Package ucar.nc2.units

Examples of ucar.nc2.units.DateUnit


    }

    TimeCoord(Date runDate, CoordinateAxis1D axis) {
      this.axis = axis;

      DateUnit unit = null;
      try {
        unit = new DateUnit(axis.getUnitsString());
      } catch (Exception e) {
        throw new IllegalArgumentException("Not a unit of time "+axis.getUnitsString());
      }

      int n = (int) axis.getSize();
      offset = new double[n];
      for (int i = 0; i < axis.getSize(); i++) {
        Date d = unit.makeDate(axis.getCoordValue(i));
        offset[i] = getOffsetInHours(runDate, d);
      }
    }
View Full Code Here


    List axes = ds.getCoordinateAxes();
    for (int i = 0; i < axes.size(); i++) {
      CoordinateAxis axis = (CoordinateAxis) axes.get(i);
      if (axis.getAxisType() == AxisType.Time) {
        String units = axis.getUnitsString();
        dateUnits =  new DateUnit(units);
        return;
      }
    }
    parseInfo.append("*** Time Units not Found\n");
  }
View Full Code Here

    if (axis == null) {
      parseInfo.append("*** Time Units not Found\n");

    } else {
      String units = axis.getUnitsString();
      dateUnits = new DateUnit(units);
    }

  }
View Full Code Here

    {4194.0, 4197.0, 4200.0, 4203.0, 4206.0, 4209.0, 4212.0, 4215.0, 4218.0, 4221.0, 4224.0, 4227.0, 4230.0, 4233.0, 4236.0, 4239.0, 4242.0, 4245.0, 4248.0, 4251.0, 4254.0, 4257.0, 4260.0, 4263.0, 4266.0, 4269.0, 4272.0, 4275.0, 4278.0},
    {4200.0, 4203.0, 4206.0, 4209.0, 4212.0, 4215.0, 4218.0, 4221.0, 4224.0, 4227.0, 4230.0, 4233.0, 4236.0, 4239.0, 4242.0, 4245.0, 4248.0, 4251.0, 4254.0, 4257.0, 4260.0, 4263.0, 4266.0, 4269.0, 4272.0, 4275.0, 4278.0, 4281.0, 4284.0},
    {4206.0, 4209.0, 4212.0, 4215.0, 4218.0, 4221.0, 4224.0, 4227.0, 4230.0, 4233.0, 4236.0, 4239.0, 4242.0, 4245.0, 4248.0, 4251.0, 4254.0, 4257.0, 4260.0, 4263.0, 4266.0, 4269.0, 4272.0, 4275.0, 4278.0, 4281.0, 4284.0, 4287.0, 4290.0}
  };

    testAggCoordVar(ncfile, naggs, new DateUnit("hours since 2006-03-15T18:00:00Z"), runhours);
    testTimeCoordVar(ncfile, naggs, 29, "time", timevals);

    System.out.println("TestAggForecastModel.testReadData ");   
    testReadData(ncfile, naggs);
//   testReadSlice(ncfile);
View Full Code Here

    String timeVarName = "time";
    String timeDimName = "time";
    testDimensions(ncfile, naggs, timeDimName);
    testCoordVar(ncfile, 257);
    int[] runtimes = new int[] {0,6,12,18};
    testAggCoordVar(ncfile, naggs, new DateUnit("hours since 2006-07-29T18:00:00Z"), runtimes);
    testTimeCoordVar(ncfile, naggs, 29, timeVarName, evals);

    ncfile.close();
  }
View Full Code Here

    assert time.getShape()[0] == nagg;
    assert time.getShape()[1] == ntimes;
    assert time.getDataType() == DataType.DOUBLE || time.getDataType() == DataType.INT;

    String units = time.getUnitsString();
    DateUnit du = new DateUnit( units);

    DateFormatter formatter = new DateFormatter();
    Array data = time.read();
    if (true) {
      PrintWriter pw = new PrintWriter(System.out);
      NCdumpW.printArray(data, "timeCoords", pw, null);
      pw.flush();
    }

    assert data.getSize() == nagg * ntimes;
    assert data.getShape()[0] == nagg;
    assert data.getShape()[1] == ntimes;
    assert data.getElementType() == double.class || data.getElementType() == int.class;

    while (data.hasNext()) {
      double val = data.nextDouble();
      Date date = du.makeDate(val);
      // if (showValues) System.out.println(" date= "+ formatter.toDateTimeStringISO(date));
    }

    Index ima = data.getIndex();
    for (int run=0; run<nagg; run++)
View Full Code Here

    CoordValueVar(String varName, DataType dtype, String units) {
      super(varName, dtype);
      this.units = units;
      try {
        du = new DateUnit(units);
      } catch (Exception e) {
        // ok to fail - may not be a time coordinate
      }
    }
View Full Code Here

    startDate = new Date();
    endDate = new Date();

    try {
      timeUnit = new DateUnit("hours since 1991-01-01T00:00");
    } catch (Exception e) {
      e.printStackTrace();
    }

    parser = new MetarParseReport();
View Full Code Here

      }

    } else {     
      timeAxis.setDataType(DataType.DOUBLE); // otherwise fractional values get lost

      DateUnit du;
      try {
        du = new DateUnit(timeUnits);
      } catch (Exception e) {
        throw new IOException(e.getMessage());
      }
      timeAxis.addAttribute(new Attribute("units", timeUnits));

      for (Date date : dateList) {
        double val = du.makeValue(date);
        ii.setDoubleNext(val);
      }
    }

    timeAxis.setCachedData(timeCoordVals, false);
View Full Code Here

            DateUnit.getStandardOrISO((String) radarTimeSpan.get(0));
        this.endDate =
            DateUnit.getStandardOrISO((String) radarTimeSpan.get(1));

        try {
            timeUnit = new DateUnit("hours since 1991-01-01T00:00");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
View Full Code Here

TOP

Related Classes of ucar.nc2.units.DateUnit

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.