Package ucar.nc2.units

Examples of ucar.nc2.units.DateFormatter


    assert time.getRank() == 1;
    assert time.getSize() == nagg;
    assert time.getShape()[0] == nagg;
    assert time.getDataType() == DataType.DOUBLE;

    DateFormatter formatter = new DateFormatter();
    try {
      Array data = time.read();
      assert data.getRank() == 1;
      assert data.getSize() == nagg;
      assert data.getShape()[0] == nagg;
View Full Code Here


    List<String> gridList = new ArrayList<String>();
    gridList.add("RH");
    gridList.add("T");

    DateFormatter format = new DateFormatter();
    Date start = format.isoDateTimeFormat("2005-12-06T18:00:00Z");
    Date end = format.isoDateTimeFormat("2005-12-07T18:00:00Z");

    writer.makeFile(fileOut, gds, gridList,
            new LatLonRect(new LatLonPointImpl(37, -109), 400, 7),
            new DateRange(start, end),
            true,
View Full Code Here

    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();
View Full Code Here

    NetcdfCFWriter writer = new NetcdfCFWriter();

    List<String> gridList = new ArrayList<String>();
    gridList.add("Z_sfc");

    DateFormatter format = new DateFormatter();
    Date start = format.isoDateTimeFormat("2003-06-01T03:00:00Z");
    Date end = format.isoDateTimeFormat("2004-01-01T00:00:00Z");

    writer.makeFile(fileOut, gds, gridList, null,
            // new LatLonRect(new LatLonPointImpl(30, -109), 10, 50),
            new DateRange(start, end),
            true,
View Full Code Here

    if (ncfile == null) return null;
    return ncfile.findGlobalAttributeIgnoreCase( name);
  }

  public void getDetailInfo( java.util.Formatter sf) {
    DateFormatter formatter = new DateFormatter();

    sf.format("FeatureDataset on location= %s\n", getLocation());
    sf.format("  featureType= %s\n",getFeatureType());
    sf.format("  title= %s\n",getTitle());
    sf.format("  desc= %s\n",getDescription());
    sf.format("  range= %s\n",getDateRange());
    sf.format("  start= %s\n", formatter.toDateTimeString(getStartDate()));
    sf.format("  end  = %s\n",formatter.toDateTimeString(getEndDate()));
    LatLonRect bb = getBoundingBox();
    sf.format("  bb   = %s\n", bb);
    if (bb != null)
      sf.format("  bb   = %s\n",getBoundingBox().toString2());
View Full Code Here

        //log.error("GridDatasetInv missing rundate in file=" + location);
        //throw new IllegalArgumentException("File must have " + _Coordinate.ModelBaseDate + " or " + _Coordinate.ModelRunDate + " attribute ");
      }
    }

    DateFormatter df = new DateFormatter();
    this.runTime = df.toDateTimeStringISO(this.runDate);

    // add each variable, collect unique time and vertical axes
    for (GridDatatype gg : gds.getGrids()) {
      GridCoordSystem gcs = gg.getCoordinateSystem();
      Grid grid = new Grid(gg.getFullName());
View Full Code Here

    Element rootElem = new Element("gridInventory");
    Document doc = new Document(rootElem);
    rootElem.setAttribute("location", location);
    rootElem.setAttribute("runTime", runTime);
    if (lastModified != null) {
      DateFormatter df = new DateFormatter();
      rootElem.setAttribute("lastModified", df.toDateTimeString(lastModified));
    }
    rootElem.setAttribute("version", Integer.toString(CURR_VERSION));

    // list all the vertical coords
    Collections.sort(vaxes);
View Full Code Here

    fmr.runTime = rootElem.getAttributeValue("runTime");
    fmr.location = rootElem.getAttributeValue("location");
    if (fmr.location == null)
      fmr.location = rootElem.getAttributeValue("name"); // old way
    String lastModifiedS = rootElem.getAttributeValue("lastModified");
    DateFormatter df = new DateFormatter();
    if (lastModifiedS != null)
      fmr.lastModified = df.getISODate(lastModifiedS);
    String version = rootElem.getAttributeValue("version");
    fmr.version = (version == null) ? 0 : Integer.parseInt(version);
    if (fmr.version < REQ_VERSION) return fmr;

    DateFormatter formatter = new DateFormatter();
    fmr.runDate = formatter.getISODate(fmr.runTime);

    java.util.List<Element> vList = rootElem.getChildren("vertCoord");
    for (Element vertElem : vList) {
      VertCoord vc = new VertCoord();
      fmr.vaxes.add(vc);
View Full Code Here

    this.isInterval = true;
  }

  @Override
  public String toString() {
    DateFormatter df = new DateFormatter();
    Formatter out = new Formatter();
    out.format("%-10s %-26s offsets=", getName(), df.toDateTimeString(runDate));
    if (isInterval)
      for (int i=0; i<bound1.length; i++) out.format("(%3.1f,%3.1f) ", bound1[i], bound2[i]);
    else
      for (double val : offset) out.format("%3.1f, ", val);
    return out.toString();
View Full Code Here

  // show params that are time intervals, how they relate to Grib2Pds.makeDate().
  // Grib2 only
  public void showTimeInterval2(String filename) throws IOException {
    GridServiceProvider.debugOpen = true;
    NetcdfFile ncd = NetcdfFile.open(filename);
    DateFormatter df = new DateFormatter();
    Calendar cal = Calendar.getInstance();

    GribGridServiceProvider iosp = (GribGridServiceProvider) ncd.getIosp();
    GridIndex index = (GridIndex) iosp.sendIospMessage("GridIndex");

    List<GridRecord> grList = index.getGridRecords();
    for (GridRecord gr : grList) {
      GribGridRecord ggr = (GribGridRecord) gr;
      if (!ggr.isInterval()) continue;

      Grib2Pds pds = (Grib2Pds) ggr.getPds();
      System.out.printf(" ref=%s fore=%s%n", df.toDateTimeStringISO(gr.getReferenceTime()), df.toDateTimeStringISO(pds.getForecastDate()));

      Grib2Pds.PdsInterval pdsIntv = (Grib2Pds.PdsInterval) pds;
      long timeEnd = pdsIntv.getIntervalTimeEnd();
      int[] intv = pds.getForecastTimeInterval();
      long startDate = Grib2Pds.makeDate(gr.getReferenceTime().getTime(), pds.getTimeUnit(), intv[0], cal);
      long endDate = Grib2Pds.makeDate(gr.getReferenceTime().getTime(), pds.getTimeUnit(), intv[1], cal);

      System.out.printf("  intv=[%s, %s] = [%d,%d]%n",  df.toDateTimeStringISO(new Date(startDate)),
              df.toDateTimeStringISO(new Date(endDate)), intv[0], intv[1]);
      System.out.printf("  timeEnd=%s", df.toDateTimeStringISO(new Date(timeEnd)));

      if (timeEnd == startDate)
        System.out.printf(" agrees with intv start");
      if (timeEnd == endDate)
        System.out.printf(" agrees with intv end");
View Full Code Here

TOP

Related Classes of ucar.nc2.units.DateFormatter

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.