Examples of GridCoordSystem


Examples of ucar.nc2.dt.GridCoordSystem

    HashSet<Date> dateHash = new HashSet<Date>();
    List<CoordinateAxis1DTime> timeAxes = new ArrayList<CoordinateAxis1DTime>();

    for (GridDatatype grid : grids) {
      GridCoordSystem gcs = grid.getCoordinateSystem();
      CoordinateAxis1DTime timeAxis = gcs.getTimeAxis1D();
      if ((timeAxis != null) && !timeAxes.contains(timeAxis)) {
        timeAxes.add(timeAxis);

        Date[] timeDates = timeAxis.getTimeDates();
        for (Date timeDate : timeDates)
View Full Code Here

Examples of ucar.nc2.dt.GridCoordSystem

  }

  public List<Date> getDates() { return dates; }

  public boolean hasTime( GridDatatype grid, Date date) {
    GridCoordSystem gcs = grid.getCoordinateSystem();
    CoordinateAxis1DTime timeAxis = gcs.getTimeAxis1D();
    return (timeAxis != null) && timeAxis.hasTime( date);
  }
View Full Code Here

Examples of ucar.nc2.dt.GridCoordSystem

    //VariableEnhanced ve = grid.getVariable();
    //return ve.getValidMax(); // LOOK bogus
  }

  public Point readData(GridDatatype grid, Date date, double lat, double lonthrows java.io.IOException {
    GridCoordSystem gcs = grid.getCoordinateSystem();

    CoordinateAxis1DTime timeAxis = gcs.getTimeAxis1D();
    int tidx = timeAxis.findTimeIndexFromDate( date);

    int[] xy = gcs.findXYindexFromLatLonBounded(lat, lon, null);

    Array data  = grid.readDataSlice(tidx, -1, xy[1], xy[0]);

    // use actual grid midpoint
    LatLonPoint latlon = gcs.getLatLon(xy[0], xy[1]);

    Point p = new Point();
    p.lat = latlon.getLatitude();
    p.lon = latlon.getLongitude();
    p.dataValue = data.getDouble( data.getIndex());
View Full Code Here

Examples of ucar.nc2.dt.GridCoordSystem

    p.dataValue = data.getDouble( data.getIndex());
    return p;
  }

  public boolean hasVert( GridDatatype grid, double zCoord) {
    GridCoordSystem gcs = grid.getCoordinateSystem();
    CoordinateAxis1D zAxis = gcs.getVerticalAxis();
    if (zAxis == null) return false;
    return (zAxis.findCoordElement( zCoord) >= 0);
  }
View Full Code Here

Examples of ucar.nc2.dt.GridCoordSystem

    if (zAxis == null) return false;
    return (zAxis.findCoordElement( zCoord) >= 0);
  }

  public Point readData(GridDatatype grid, Date date, double zCoord, double lat, double lonthrows java.io.IOException {
    GridCoordSystem gcs = grid.getCoordinateSystem();

    CoordinateAxis1DTime timeAxis = gcs.getTimeAxis1D();
    int tidx = timeAxis.findTimeIndexFromDate( date);

    CoordinateAxis1D zAxis = gcs.getVerticalAxis();
    int zidx = zAxis.findCoordElement( zCoord);

    int[] xy = gcs.findXYindexFromLatLon(lat, lon, null);

    Array data  = grid.readDataSlice(tidx, zidx, xy[1], xy[0]);

    // use actual grid midpoint
    LatLonPoint latlon = gcs.getLatLon(xy[0], xy[1]);

    Point p = new Point();
    p.lat = latlon.getLatitude();
    p.lon = latlon.getLongitude();
    p.z = zAxis.getCoordValue( zidx);
View Full Code Here

Examples of ucar.nc2.dt.GridCoordSystem

      assert null != grid;
      assert grid.getFullName().equals("T");
      assert grid.getRank() == 3;
      assert grid.getDataType() == DataType.DOUBLE;

      GridCoordSystem gcsys = grid.getCoordinateSystem();
      assert gcsys.getYHorizAxis() != null;
      assert gcsys.getXHorizAxis() != null;
      assert gcsys.getTimeAxis() != null;

      CoordinateAxis1DTime taxis = gcsys.getTimeAxis1D();
      assert taxis.getDataType() == DataType.STRING : taxis.getDataType();

      List names = taxis.getNames();
      java.util.Date[] dates = taxis.getTimeDates();
      assert dates != null;
View Full Code Here

Examples of ucar.nc2.dt.GridCoordSystem

    }
    getIosp();

    // add each variable
    for (GridDatatype gg : gds.getGrids()) {
      GridCoordSystem gcs = gg.getCoordinateSystem();
      Grid grid = new Grid(gg.getFullName());
      VariableEnhanced ve = gg.getVariable();
      Variable v = ve.getOriginalVariable();   // LOOK why original variable ??
      addMissing(v, gcs, grid);

      // LOOK: Note this assumes a dense coordinate system
      CoordinateAxis1D axis = gcs.getTimeAxis1D();
      if (axis != null) {
        TimeCoord tc = getTimeCoordinate(axis);
        tc.vars.add(grid);
        grid.parent = tc;
      }

      CoordinateAxis1D eaxis = gcs.getEnsembleAxis();
      if (eaxis != null) {
        int[] einfo = getEnsInfov );
        grid.ec = getEnsCoordinate(eaxis, einfo );
      }

      CoordinateAxis1D vaxis = gcs.getVerticalAxis();
      if (vaxis != null) {
        grid.vc = getVertCoordinate(vaxis);
      }

      LatLonRect rect = gcs.getLatLonBoundingBox();
      if (null == bb)
        bb = rect;
      else if (!bb.equals(rect))
        bb.extend(rect);
    }
View Full Code Here

Examples of ucar.nc2.dt.GridCoordSystem

  }

  public Element genCoverageOfferingElem( String covId )
  {
    WcsCoverage coverage = this.getDataset().getAvailableCoverage( covId );
    GridCoordSystem gridCoordSystem = coverage.getCoordinateSystem();

    // CoverageDescription/CoverageOffering (wcs) [1..*]
    Element covDescripElem = genCoverageOfferingBriefElem( "CoverageOffering", covId,
                                                           coverage.getLabel(), coverage.getDescription(),
                                                           gridCoordSystem );
View Full Code Here

Examples of ucar.nc2.dt.GridCoordSystem

  }

  public void testCF() throws IOException {
    GridDataset ds = GridDataset.open(TestAll.cdmUnitTestDir + "conventions/cf/twoGridMaps.nc");
    GeoGrid grid = ds.findGridByName("altitude");
    GridCoordSystem gcs = grid.getCoordinateSystem();
    assert 1 == gcs.getCoordinateTransforms().size();
    CoordinateTransform ct = gcs.getCoordinateTransforms().get(0);
    assert ct.getTransformType() == TransformType.Projection;
    assert ct.getName().equals("projection_stere");
    ds.close();

  }
View Full Code Here

Examples of ucar.nc2.dt.GridCoordSystem

        continue;

      varNameList.add(gridName);

      GridDatatype grid = gds.findGridDatatype(gridName);
      GridCoordSystem gcsOrg = grid.getCoordinateSystem();
      CoordinateAxis1DTime timeAxis = gcsOrg.getTimeAxis1D();

      // make subset if needed
      Range timeRange = null;
      if ((dateRange != null) && (timeAxis != null)) {
        int startIndex = timeAxis.findTimeIndexFromDate(dateRange.getStart().getDate());
        int endIndex = timeAxis.findTimeIndexFromDate(dateRange.getEnd().getDate());
        if (startIndex < 0)
          throw new InvalidRangeException("start time=" + dateRange.getStart().getDate() + " must be >= " + timeAxis.getTimeDate(0));
        if (endIndex < 0)
          throw new InvalidRangeException("end time=" + dateRange.getEnd().getDate() + " must be >= " + timeAxis.getTimeDate(0));
        timeRange = new Range(startIndex, endIndex);
      }

      if ((null != timeRange) || (zRange != null) || (llbb != null) || (horizStride > 1)) {
        grid = grid.makeSubset(timeRange, zRange, llbb, 1, horizStride, horizStride);
      }

      Variable gridV = (Variable) grid.getVariable();
      varList.add(gridV);
      total_size += gridV.getSize() * gridV.getElementSize();

      // add coordinate axes
      GridCoordSystem gcs = grid.getCoordinateSystem();
      for (CoordinateAxis axis : gcs.getCoordinateAxes()) {
        if (!varNameList.contains(axis.getFullName())) {
          varNameList.add(axis.getFullName());
          varList.add(axis); // LOOK dont we have to subset these ??
          axisList.add(axis);
        }
      }

      // add coordinate transform variables
      for (CoordinateTransform ct : gcs.getCoordinateTransforms()) {
        Variable v = ncd.findVariable(ct.getName());
        if (!varNameList.contains(ct.getName()) && (null != v)) {
          varNameList.add(ct.getName());
          varList.add(v);
        }
      }

      // optional lat/lon
      if (addLatLon) {
        Projection proj = gcs.getProjection();
        if ((null != proj) && !(proj instanceof LatLonProjection)) {
          addLatLon2D(ncd, varList, proj, gcs.getXHorizAxis(), gcs.getYHorizAxis());
          addLatLon = false;
        }
      }
    }

    // check size is ok
    boolean isLargeFile = false;
    long maxSize = 2 * 1000 * 1000 * 1000;
    if (total_size > maxSize) {
      log.info("Request size = {} Mbytes", total_size / 1000 / 1000);
      isLargeFile = true;
    }

    FileWriter writer = new FileWriter(location, false, isLargeFile, -1);
    // global attributes
    for (Attribute att : gds.getGlobalAttributes())
      writer.writeGlobalAttribute(att);

    writer.writeGlobalAttribute(new Attribute("Conventions", "CF-1.0"));
    writer.writeGlobalAttribute(new Attribute("History",
            "Translated to CF-1.0 Conventions by Netcdf-Java CDM (NetcdfCFWriter)\n" +
                    "Original Dataset = " + gds.getLocationURI() + "; Translation Date = " + new Date()));


    writer.writeVariables(varList);

    // now add CF annotations as needed - dont change original ncd or gds
    NetcdfFileWriteable ncfile = writer.getNetcdf();
    Group root = ncfile.getRootGroup();
    for (String gridName : gridList) {
      GridDatatype grid = gds.findGridDatatype(gridName);
      Variable newV = root.findVariable(gridName);
      if (newV == null) {
        log.warn("NetcdfCFWriter cant find "+gridName+" in gds "+gds.getLocationURI());
        continue;
      }

      // annotate Variable for CF
      StringBuilder sbuff = new StringBuilder();
      GridCoordSystem gcs = grid.getCoordinateSystem();
      for (Variable axis : gcs.getCoordinateAxes()) {
        sbuff.append(axis.getFullName()).append(" ");
      }
      if (addLatLon)
        sbuff.append("lat lon");
      newV.addAttribute(new Attribute("coordinates", sbuff.toString()));

      // looking for coordinate transform variables
      for (CoordinateTransform ct : gcs.getCoordinateTransforms()) {
        Variable v = ncd.findVariable(ct.getName());
        if (ct.getTransformType() == TransformType.Projection)
          newV.addAttribute(new Attribute("grid_mapping", v.getFullName()));
      }
    }

    for (CoordinateAxis axis : axisList) {
      Variable newV = root.findVariable(axis.getShortName()); // LOOK ???
      if ((axis.getAxisType() == AxisType.Height) || (axis.getAxisType() == AxisType.Pressure) || (axis.getAxisType() == AxisType.GeoZ)) {
        if (null != axis.getPositive())
          newV.addAttribute(new Attribute("positive", axis.getPositive()));
      }
      if (axis.getAxisType() == AxisType.Lat) {
        newV.addAttribute(new Attribute("units", "degrees_north"));
        newV.addAttribute(new Attribute("standard_name", "latitude"));
      }
      if (axis.getAxisType() == AxisType.Lon) {
        newV.addAttribute(new Attribute("units", "degrees_east"));
        newV.addAttribute(new Attribute("standard_name", "longitude"));
      }
      if (axis.getAxisType() == AxisType.GeoX) {
        newV.addAttribute(new Attribute("standard_name", "projection_x_coordinate"));
      }
      if (axis.getAxisType() == AxisType.GeoY) {
        newV.addAttribute(new Attribute("standard_name", "projection_y_coordinate"));
      }
    }

    // coordinate transform variables : must convert false easting, northing to km
    List<Variable> ctvList = new ArrayList<Variable>();
    for (ucar.nc2.dt.GridDataset.Gridset gridSet : gds.getGridsets()) {
      ucar.nc2.dt.GridCoordSystem gcs = gridSet.getGeoCoordSystem();
      ProjectionCT pct = gcs.getProjectionCT();
      if (pct != null) {
        Variable v = root.findVariable(pct.getName()); // look for the ctv
        if ((v != null) && !ctvList.contains(v)) {
          convertProjectionCTV((NetcdfDataset) gds.getNetcdfFile(), v);
          ctvList.add(v);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.