Package ucar.nc2.dataset

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


    //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

    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

      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

    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

    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

                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

    SimpleDateFormat format = new SimpleDateFormat("ddMMMyyyyHHmm");
    format.setTimeZone(java.util.TimeZone.getTimeZone("GMT"));
    try {
      Date d = format.parse(dateS+timeS);
      VariableDS time = new VariableDS(ds, vhrr, null, "time", DataType.LONG, "",
          "seconds since 1970-01-01 00:00", "time generated from PRODUCT_METADATA/PRODUCT_DETAILS");

      time.addAttribute( new Attribute(_Coordinate.AxisType, AxisType.Time.toString())); // // LOOK : cant handle scalar coordinates yet ??
      time.addAttribute( new Attribute("IsoDate", new DateFormatter().toDateTimeStringISO(d)));
      ds.addVariable(vhrr, time);
      ArrayLong.D0 timeData = new ArrayLong.D0();
      timeData.set(d.getTime() / 1000);
      time.setCachedData(timeData, true);

    } catch (ParseException e) {
      e.printStackTrace();
      throw new IOException(e.getMessage());
    }
View Full Code Here

  private VerticalCT makeWRFEtaVerticalCoordinateTransform(NetcdfDataset ds, CoordinateSystem cs) {
    if ((null == ds.findVariable("PH")) || (null == ds.findVariable("PHB")) ||
        (null == ds.findVariable("P")) || (null == ds.findVariable("PB")))
      return null;

    WRFEtaTransformBuilder builder = new WRFEtaTransformBuilder(cs);
    return (VerticalCT) builder.makeCoordinateTransform(ds, null);
  }
View Full Code Here

  }
*/

  static private NetcdfFile acquireDODS(FileCache cache, FileFactory factory, Object hashKey,
                                        String location, int buffer_size, ucar.nc2.util.CancelTask cancelTask, Object spiObject) throws IOException {
    if (cache == null) return new DODSNetcdfFile(location, cancelTask);

    if (factory == null) factory = new DodsFactory();
    return (NetcdfFile) cache.acquire(factory, hashKey, location, buffer_size, cancelTask, spiObject);
  }
View Full Code Here

TOP

Related Classes of ucar.nc2.dataset.CoordinateAxis1D

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.