Package ucar.nc2.units

Examples of ucar.nc2.units.DateRange


  }

  public DateRange getDateRange() {
    if (!calcBounds) return null;
    if (timeUnit == null) return null;
    return new DateRange(timeUnit.makeDate(minTime), timeUnit.makeDate(maxTime));
  }
View Full Code Here


  public void calcBounds() throws java.io.IOException {
    if ((boundingBox != null) && (dateRange != null)) return;

    LatLonRect bb = null;
    DateRange dates = null;
    for (FeatureCollection fc : collectionList) {

      if (fc instanceof PointFeatureCollection) {
        PointFeatureCollection pfc = (PointFeatureCollection) fc;
        pfc.calcBounds();
        if (bb == null)
          bb = pfc.getBoundingBox();
        else
          bb.extend(pfc.getBoundingBox());
        if (dates == null)
          dates = pfc.getDateRange();
        else
          dates.extend(pfc.getDateRange());

      else if (fc instanceof StationTimeSeriesFeatureCollection) {

        StationTimeSeriesFeatureCollection sc = (StationTimeSeriesFeatureCollection) fc;
        if (bb == null)
           bb = sc.getBoundingBox();
         else
           bb.extend(sc.getBoundingBox());

        PointFeatureCollection pfc = sc.flatten(null, null);
        pfc.calcBounds();
        if (dates == null)
          dates = pfc.getDateRange();
        else
          dates.extend(pfc.getDateRange());
      }

    }

    if (boundingBox == null) boundingBox = bb;
View Full Code Here

    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,
            1, 1, 1);

  }
View Full Code Here

    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,
            1, 1, 1);

  }
View Full Code Here

          // into flattened representation
          PointFeatureCollection pfc = stsfc.flatten(
                  new LatLonRect(
                          new LatLonPointImpl(-90, -180),
                          new LatLonPointImpl(90, 180)),
                  new DateRange(
                          df.parse("1900-01-01"),
                          df.parse("2100-01-01")));
          PointFeatureIterator pfi = pfc.getPointFeatureIterator(-1);
          try {
            while (pfi.hasNext()) {
View Full Code Here

      return new GridDataset(ncd);

    } else {
      List<VariableSimpleIF> dataVars = FeatureDatasetPointXML.getDataVariables(doc);
      LatLonRect bb = FeatureDatasetPointXML.getSpatialExtent(doc);
      DateRange dr = FeatureDatasetPointXML.getTimeSpan(doc);

      return new PointDatasetRemote(ft, uri, dataVars, bb, dr);
    }
  }
View Full Code Here

    }

  }

  static public 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;
        }
      }
View Full Code Here

    public static DateRange dateRangeToNcDateRange( ThreddsMetadata.DateRange dateRange )
            throws ParseException
    {
        DateType startDate = new DateType( dateRange.getStartDate(), dateRange.getStartDateFormat(), null );
        DateType endDate = new DateType( dateRange.getEndDate(), dateRange.getEndDateFormat(), null );
        return new DateRange( startDate, endDate, new TimeDuration( dateRange.getDuration()), null );
    }
View Full Code Here

    public static DateRange dateRangeBuilderToNcDateRange( ThreddsMetadataBuilder.DateRangeBuilder dateRange )
            throws ParseException
    {
        DateType startDate = new DateType( dateRange.getStartDate(), dateRange.getStartDateFormat(), null );
        DateType endDate = new DateType( dateRange.getEndDate(), dateRange.getEndDateFormat(), null );
        return new DateRange( startDate, endDate, new TimeDuration( dateRange.getDuration()), null );
    }
View Full Code Here

    GridCoordSystem gcsMax = null;
    LatLonRect llbbMax = null;

    LatLonRect llbb = null;
    DateRange dateRange = null;
    long nx = 0, ny = 0;

    for (GridDataset.Gridset gset : gridDs.getGridsets()) {
      GridCoordSystem gcs = gset.getGeoCoordSystem();

      CoordinateAxis1D xaxis = (CoordinateAxis1D) gcs.getXHorizAxis();
      CoordinateAxis1D yaxis = (CoordinateAxis1D) gcs.getYHorizAxis();
      long nx2 = xaxis.getSize();
      long ny2 = yaxis.getSize();
      if ((nx != nx2) || (ny != ny2)) {
        nx = nx2;
        ny = ny2;
        double dx = xaxis.getIncrement();
        double dy = yaxis.getIncrement();
        out.println("  horizontal = " + nx + " by " + ny + " points, resolution " + Format.d(dx, 4) + " " + Format.d(dy, 4)
            + " " + xaxis.getUnitsString());
      }

      ProjectionImpl proj = gcs.getProjection();
      if (proj != null) {
        out.println(", " + proj.getClassName() + " projection;");

        List<Parameter> params = proj.getProjectionParameters();
        for (Parameter p : params)
          out.println("       " + p.getName() + " " + p.getStringValue());

      } else
        out.println();

      LatLonRect llbb2 = gcs.getLatLonBoundingBox();
      if ((llbb == null) || !llbb2.equals(llbb)) {
        llbb = llbb2;

        if (llbbMax == null)
          llbbMax = llbb;
        else
          llbbMax.extend(llbb);

        if (llbb.getWidth() >= 360.0) {
          out.println("  BoundingBox == GLOBAL");

        } else {
          StringBuffer buff = new StringBuffer();
          LatLonPointImpl ll = llbb.getLowerLeftPoint();
          LatLonPointImpl ur = llbb.getUpperRightPoint();
          buff.append(Double.toString(ll.getLongitude()));
          buff.append(" ");
          buff.append(Double.toString(ll.getLatitude()));
          buff.append(" ");
          buff.append(Double.toString(ur.getLongitude()));
          buff.append(" ");
          buff.append(Double.toString(ur.getLatitude()));
          buff.append(" ");
          out.println("  BoundingBox == " + llbb + " width= " + llbb.getWidth() + " " + (llbb.getWidth() >= 360.0 ? "global" : ""));
        }

      }

      CoordinateAxis1DTime taxis = gcs.getTimeAxis1D();

      DateRange dateRange2 = gcs.getDateRange();
      if ((taxis != null) && ((dateRange == null) || !dateRange2.equals(dateRange))) {

        long ntimes = taxis.getSize();
        try {
          TimeUnit tUnit = taxis.getTimeResolution();
          dateRange = new DateRange(dateRange2, "1 hour");
          out.println("  DateRange == " + "start= " + dateRange.getStart() + " end= " + dateRange.getEnd() +
              " duration= " + dateRange.getDuration() + " ntimes = " + ntimes + " data resolution = " + tUnit);
        } catch (Exception e) {
          e.printStackTrace();
        }
View Full Code Here

TOP

Related Classes of ucar.nc2.units.DateRange

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.