Examples of CoordinateAxis1D


Examples of ucar.nc2.dataset.CoordinateAxis1D

                    "Must have 1D x and y axes for " + grid.getFullName());
            }

        }

        CoordinateAxis1D xaxis = (CoordinateAxis1D) gcs.getXHorizAxis();
        CoordinateAxis1D yaxis = (CoordinateAxis1D) gcs.getYHorizAxis();
        if ( !xaxis.isRegular() || !yaxis.isRegular()) {
            throw new IllegalArgumentException(
                "Must be evenly spaced grid = " + grid.getFullName());
        }

        // read in data
        Array data = grid.readDataSlice(time, level, -1, -1);
        Array lon  = xaxis.read();
        Array lat  = yaxis.read();

        //latlon coord does not need to time 1000.0
        if (gcs.isLatLon()) {
            scaler = 1.0;
        } else {
            scaler = 1000.0;
        }

        if (yaxis.getCoordValue(0) < yaxis.getCoordValue(1)) {
            data = data.flip(0);
            lat  = lat.flip(0);
        }

        if (gcs.isLatLon()) {
            data = geoShiftDataAtLon(data, lon);
            lon  = geoShiftLon(lon);
        }
        // now it is time to subset the data out of latlonrect
        // it is assumed that latlonrect pt is in +-180
        LatLonPointImpl llp0   = pt.getLowerLeftPoint();
        LatLonPointImpl llpn   = pt.getUpperRightPoint();
        double          minLon = llp0.getLongitude();
        double          minLat = llp0.getLatitude();
        double          maxLon = llpn.getLongitude();
        double          maxLat = llpn.getLatitude();

        // (x1, y1) is upper left point and (x2, y2) is lower right point
        int    x1;
        int    x2;
        int    y1;
        int    y2;
        double xStart;
        double yStart;
        if ( !gcs.isLatLon()) {

            ProjectionPoint pjp0     = proj.latLonToProj(maxLat, minLon);
            double[]        lonArray = (double[]) lon.copyTo1DJavaArray();
            double[]        latArray = (double[]) lat.copyTo1DJavaArray();
            x1     = getXIndex(lon, pjp0.getX(), 0);
            y1     = getYIndex(lat, pjp0.getY(), 0);
            yStart = pjp0.getY() * 1000.0//latArray[y1];
            xStart = pjp0.getX() * 1000.0//lonArray[x1];
            ProjectionPoint pjpn = proj.latLonToProj(minLat, maxLon);
            x2 = getXIndex(lon, pjpn.getX(), 1);
            y2 = getYIndex(lat, pjpn.getY(), 1);

        } else {
            xStart = minLon;
            yStart = maxLat;
            x1     = getLonIndex(lon, minLon, 0);
            y1     = getLatIndex(lat, maxLat, 0);
            x2     = getLonIndex(lon, maxLon, 1);
            y2     = getLatIndex(lat, minLat, 1);
        }
        // data must go from top to bottom LOOK IS THIS REALLY NEEDED ?

        double xInc = xaxis.getIncrement() * scaler;
        double yInc = Math.abs(yaxis.getIncrement()) * scaler;

        // subseting data inside the box
        Array data1 = getYXDataInBox(data, x1, x2, y1, y2);

        if (pageNumber > 1) {
View Full Code Here

Examples of ucar.nc2.dataset.CoordinateAxis1D

        TimeCoord tc = getTimeCoordinate(axis);
        tc.addGridInventory(grid);
        grid.tc = tc;
      }

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

     /* not yet
View Full Code Here

Examples of ucar.nc2.dataset.CoordinateAxis1D

  }

  static public ThreddsMetadata.GeospatialCoverage extractGeospatial(GridDataset gridDataset) {
    ThreddsMetadata.GeospatialCoverage gc = new ThreddsMetadata.GeospatialCoverage();
    LatLonRect llbb = null;
    CoordinateAxis1D vaxis = null;

    for(GridDataset.Gridset gridset : gridDataset.getGridsets()) {
      GridCoordSystem gsys = gridset.getGeoCoordSystem();
      if (llbb == null)
        llbb = gsys.getLatLonBoundingBox();

      CoordinateAxis1D vaxis2 = gsys.getVerticalAxis();
      if (vaxis == null)
        vaxis = vaxis2;
      else if ((vaxis2 != null) && (vaxis2.getSize() > vaxis.getSize()))
        vaxis = vaxis2;
    }

    if (llbb != null)
      gc.setBoundingBox(llbb);
View Full Code Here

Examples of ucar.nc2.dataset.CoordinateAxis1D

  private Element genRectifiedGridElem( WcsCoverage coverage )
  {
    // ../spatialDomain/gml:RectifiedGrid
    Element rectifiedGridElem = new Element( "RectifiedGrid", gmlNS);

    CoordinateAxis1D xaxis = (CoordinateAxis1D) coverage.getCoordinateSystem().getXHorizAxis();
    CoordinateAxis1D yaxis = (CoordinateAxis1D) coverage.getCoordinateSystem().getYHorizAxis();
    CoordinateAxis1D zaxis = coverage.getCoordinateSystem().getVerticalAxis();

    // ../spatialDomain/gml:RectifiedGrid@srsName [0..1] (URI)
    rectifiedGridElem.setAttribute( "srsName", coverage.getNativeCrs() );

    // ../spatialDomain/gml:RectifiedGrid@dimension [1] (positive integer)
    int ndim = ( zaxis != null ) ? 3 : 2;
    rectifiedGridElem.setAttribute( "dimension", Integer.toString( ndim ) );

    // ../spatialDomain/gml:RectifiedGrid/gml:limits [1]
    int[] minValues = new int[ndim];
    int[] maxValues = new int[ndim];

    maxValues[0] = (int) ( xaxis.getSize() - 1 );
    maxValues[1] = (int) ( yaxis.getSize() - 1 );
    if ( zaxis != null )
      maxValues[2] = (int) ( zaxis.getSize() - 1 );

    Element limitsElem =  new Element( "limits", gmlNS);

    // ../spatialDomain/gml:RectifiedGrid/gml:limits/gml:GridEnvelope [1]
    // ../spatialDomain/gml:RectifiedGrid/gml:limits/gml:GridEnvelope/gml:low [1] (integer list)
    // ../spatialDomain/gml:RectifiedGrid/gml:limits/gml:GridEnvelope/gml:high [1] (integer list)
    limitsElem.addContent(
            new Element( "GridEnvelope", gmlNS)
                    .addContent( new Element( "low", gmlNS ).addContent( genIntegerListString( minValues)))
                    .addContent( new Element( "high", gmlNS).addContent( genIntegerListString( maxValues))) );

    rectifiedGridElem.addContent( limitsElem);

    // ../spatialDomain/gml:RectifiedGrid/gml:axisName [1..*] (string)
    rectifiedGridElem.addContent( new Element( "axisName", gmlNS).addContent( "x"));
    rectifiedGridElem.addContent( new Element( "axisName", gmlNS).addContent( "y"));
    if ( zaxis != null )
      rectifiedGridElem.addContent( new Element( "axisName", gmlNS ).addContent( "z" ) );

    // ../spatialDomain/gml:RectifiedGrid/gml:origin [1]
    // ../spatialDomain/gml:RectifiedGrid/gml:origin/gml:pos [1] (space seperated list of double values)
    // ../spatialDomain/gml:RectifiedGrid/gml:origin/gml:pos@dimension [0..1]  (number of entries in list)
    double[] origin = new double[ndim];
    origin[0] = xaxis.getStart();
    origin[1] = yaxis.getStart();
    if ( zaxis != null )
      origin[2] = zaxis.getStart();

    rectifiedGridElem.addContent(
            new Element( "origin", gmlNS).addContent(
                    new Element( "pos", gmlNS).addContent( genDoubleListString( origin))));

    // ../spatialDomain/gml:RectifiedGrid/gml:offsetVector [1..*] (space seperated list of double values)
    // ../spatialDomain/gml:RectifiedGrid/gml:offsetVector@dimension [0..1]  (number of entries in list)
    double[] xoffset = new double[ndim];
    xoffset[0] = xaxis.getIncrement();
    rectifiedGridElem.addContent(
            new Element( "offsetVector", gmlNS)
                    .addContent( genDoubleListString( xoffset)));

    double[] yoffset = new double[ndim];
    yoffset[1] = yaxis.getIncrement();
    rectifiedGridElem.addContent(
            new Element( "offsetVector", gmlNS )
                    .addContent( genDoubleListString( yoffset ) ) );

    if ( zaxis != null )
    {
      double[] zoffset = new double[ndim];
      zoffset[2] = zaxis.getIncrement();
      rectifiedGridElem.addContent(
              new Element( "offsetVector", gmlNS )
                      .addContent( genDoubleListString( zoffset ) ) );
    }

View Full Code Here

Examples of ucar.nc2.dataset.CoordinateAxis1D

    //this.supportedCoverageFormatList.add("application/x-netcdf");
    this.supportedCoverageFormatList.add( Request.Format.GeoTIFF);
    this.supportedCoverageFormatList.add( Request.Format.GeoTIFF_Float);
    this.supportedCoverageFormatList.add( Request.Format.NetCDF3);

    CoordinateAxis1D zaxis = this.coordSys.getVerticalAxis();
    WcsRangeField.Axis vertAxis;
    if ( zaxis != null )
    {
      List<String> vals = new ArrayList<String>();
      for ( int z = 0; z < zaxis.getSize(); z++ )
        vals.add( zaxis.getCoordName( z ).trim() );
      vertAxis = new WcsRangeField.Axis( "Vertical", zaxis.getFullName(),
                                         zaxis.getDescription(),
                                         zaxis.isNumeric(), vals );
    }
    else
      vertAxis = null;

    range = new WcsRangeField( this.getName(), this.getLabel(),
View Full Code Here

Examples of ucar.nc2.dataset.CoordinateAxis1D

    if ( minValue > maxValue )
    {
      log.error( "getRangeSetAxisRange(): Min is greater than max <" + minValue + ", " + maxValue + ">." );
      throw new IllegalArgumentException( "Min is greater than max <" + minValue + ", " + maxValue + ">." );
    }
    CoordinateAxis1D zaxis = coordSys.getVerticalAxis();
    if ( zaxis != null )
    {
      int minIndex = zaxis.findCoordElement( minValue);
      int maxIndex = zaxis.findCoordElement( maxValue);

      if ( minIndex == -1 || maxIndex == -1 )
        return null;

      try
View Full Code Here

Examples of ucar.nc2.dataset.CoordinateAxis1D

      if ( gcs == null )
      {
        log.error("getRange(): GridCoordSystem must be non-null.");
        throw new IllegalArgumentException( "GridCoordSystem must be non-null." );
      }
      CoordinateAxis1D vertAxis = gcs.getVerticalAxis();
      if ( vertAxis == null )
      {
        log.error( "getRange(): GridCoordSystem must have vertical axis." );
        throw new IllegalArgumentException( "GridCoordSystem must have vertical axis." );
      }
      if ( ! vertAxis.isNumeric())
      {
        log.error( "getRange(): GridCoordSystem must have numeric vertical axis to support min/max range." );
        throw new IllegalArgumentException( "GridCoordSystem must have numeric vertical axis to support min/max range." );
      }
      int minIndex = vertAxis.findCoordElement( min );
      int maxIndex = vertAxis.findCoordElement( max );
      if ( minIndex == -1 || maxIndex == -1 )
      {
        log.error( "getRange(): GridCoordSystem vertical axis does not contain min/max points." );
        throw new IllegalArgumentException( "GridCoordSystem vertical axis does not contain min/max points." );
      }

      if ( vertAxis.getPositive().equalsIgnoreCase( ucar.nc2.constants.CF.POSITIVE_DOWN ) )
        return new Range( maxIndex, minIndex, stride );
      else
        return new Range( minIndex, maxIndex, stride );
    }
View Full Code Here

Examples of ucar.nc2.dataset.CoordinateAxis1D

    GridDataset dataset = GridDataset.open(filename);
    GeoGrid grid = dataset.findGridByName("Geopotential_height");
    assert null != grid;

    GridCoordSystem gcs = grid.getCoordinateSystem();
    CoordinateAxis1D zaxis = gcs.getVerticalAxis();
    float zCoord = 10000;
    int zidx = zaxis.findCoordElement(zCoord);
    assert zidx == 28 : zidx;

    dataset.close();
  }
View Full Code Here

Examples of ucar.nc2.dataset.CoordinateAxis1D

    try {
      GridDataset fooGridDataset = new GridDataset(fooDataset);
      GridDatatype fooGrid = fooGridDataset.findGridDatatype("foo");

      CoordinateAxis1D fooTimeAxis = fooGrid.getCoordinateSystem().getTimeAxis1D();
      CoordinateAxis1D fooLatAxis = (CoordinateAxis1D) fooGrid.getCoordinateSystem().getYHorizAxis();
      CoordinateAxis1D fooLonAxis = (CoordinateAxis1D) fooGrid.getCoordinateSystem().getXHorizAxis();

      // Expected: [0.0, 31.0, 59.0, 90.0, 120.0]
      // Actual:   [0.0, 31.0, 59.0, 90.0, 120.0]
      System.out.println("mid time= " + Arrays.toString(fooTimeAxis.getCoordValues()));
      System.out.println("edge time= " + Arrays.toString(fooTimeAxis.getCoordEdges()));
      System.out.println();

      // Expected: [-90.0, -18.0, 36.0, 72.0, 90.0]
      // Actual:   [-90.0, -18.0, 36.0, 72.0, 90.0]
      System.out.println("mid lat= " + Arrays.toString(fooLatAxis.getCoordValues()));
      System.out.println("edge lat= " + Arrays.toString(fooLatAxis.getCoordEdges()));
      System.out.println();

      // Expected: [0.0, 36.0, 108.0, 216.0, 360.0]
      // Actual:   [0.0, 36.0, 108.0, 216.0, 360.0]
      System.out.println("mid lon= " + Arrays.toString(fooLonAxis.getCoordValues()));
      System.out.println("edge lon= " + Arrays.toString(fooLonAxis.getCoordEdges()));
      System.out.println();


      Range middleRange = new Range(1, 2);
      GridDatatype fooSubGrid = fooGrid.makeSubset(null, null, middleRange, null, middleRange, middleRange);

      CoordinateAxis1D fooSubTimeAxis = fooSubGrid.getCoordinateSystem().getTimeAxis1D();
      CoordinateAxis1D fooSubLatAxis = (CoordinateAxis1D) fooSubGrid.getCoordinateSystem().getYHorizAxis();
      CoordinateAxis1D fooSubLonAxis = (CoordinateAxis1D) fooSubGrid.getCoordinateSystem().getXHorizAxis();

      // Expected: [31.0, 59.0, 90.0]
      // Actual:   [30.25, 59.75, 89.25]
      System.out.println("mid time= " + Arrays.toString(fooSubTimeAxis.getCoordValues()));
      System.out.println("edge time= " + Arrays.toString(fooSubTimeAxis.getCoordEdges()));
      compare(fooSubTimeAxis.getCoordEdges(), new double[] {31.0, 59.0, 90.0} );
      System.out.println();

      // Expected: [-18.0, 36.0, 72.0]
      // Actual:   [-13.5, 31.5, 76.5]
      System.out.println("mid lat= " + Arrays.toString(fooSubLatAxis.getCoordValues()));
      System.out.println("edge lat= " + Arrays.toString(fooSubLatAxis.getCoordEdges()));
      compare(fooSubLatAxis.getCoordEdges(), new double[] {-18.0, 36.0, 72.0} );
      System.out.println();

      // Expected: [36.0, 108.0, 216.0]
      // Actual:   [27.0, 117.0, 207.0]
      System.out.println("mid lon= " + Arrays.toString(fooSubLonAxis.getCoordValues()));
      System.out.println("edge lon= " + Arrays.toString(fooSubLonAxis.getCoordEdges()));
      compare(fooSubLonAxis.getCoordEdges(), new double[] {36.0, 108.0, 216.0} );
      System.out.println();

    } finally {
      fooDataset.close();
    }
View Full Code Here

Examples of ucar.nc2.dataset.CoordinateAxis1D

                Variable dimVariable = group.findVariable(dimName);
                if (dimVariable == null) {
                    return false;
                }
                if (dimVariable instanceof CoordinateAxis1D) {
                    CoordinateAxis1D axis = (CoordinateAxis1D) dimVariable;
                    AxisType axisType = axis.getAxisType();
                    if (axisType == null) {
                        return false;
                    }
                    switch (axisType) {
                    case GeoX:
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.