Package ucar.nc2.dataset

Examples of ucar.nc2.dataset.CoordinateAxis$AxisComparator


  public static void test2() throws IOException {
    String filename = "C:/data/fmrc/apex_fmrc/Run_20091025_0000.nc";
    GridDataset gds = GridDataset.open(filename);
    GeoGrid grid = gds.findGridByName("temp");
    GridCoordSystem gcs = grid.getCoordinateSystem();
    CoordinateAxis lonAxis = gcs.getXHorizAxis();
    assert lonAxis instanceof CoordinateAxis2D;
    CoordinateAxis latAxis = gcs.getYHorizAxis();
    assert latAxis instanceof CoordinateAxis2D;

    GridCoordinate2D g2d = new GridCoordinate2D((CoordinateAxis2D) latAxis, (CoordinateAxis2D) lonAxis);
    doOne(g2d, 40.166959,-73.954234);
View Full Code Here


  public static void test3() throws IOException {
    String filename = "/data/testdata/cdmUnitTest/fmrc/rtofs/ofs.20091122/ofs_atl.t00z.F024.grb.grib2";
    GridDataset gds = GridDataset.open(filename);
    GeoGrid grid = gds.findGridByName("Sea_Surface_Height_Relative_to_Geoid");
    GridCoordSystem gcs = grid.getCoordinateSystem();
    CoordinateAxis lonAxis = gcs.getXHorizAxis();
    assert lonAxis instanceof CoordinateAxis2D;
    CoordinateAxis latAxis = gcs.getYHorizAxis();
    assert latAxis instanceof CoordinateAxis2D;

    GridCoordinate2D g2d = new GridCoordinate2D((CoordinateAxis2D) latAxis, (CoordinateAxis2D) lonAxis);
    doOne(g2d, -15.554099426977835, -0.7742870290336263);
View Full Code Here

    // count vertical axes
    int countVertCooordAxes = 0;
    List axes = ncd.getCoordinateAxes();
    for (int i = 0; i < axes.size(); i++) {
      CoordinateAxis axis =  (CoordinateAxis) axes.get(i);
      AxisType t = axis.getAxisType();
      if ((t == AxisType.GeoZ) || (t == AxisType.Height) || (t == AxisType.Pressure) )
        countVertCooordAxes++;
    }

    if (showCount) {
      System.out.println(" grids=" + countGrids + ((ngrids < 0) ? " *" : ""));
      System.out.println(" coordSys=" + countCoordSys + ((ncoordSys < 0) ? " *" : ""));
      System.out.println(" coordAxes=" + countCoordAxes + ((ncoordAxes < 0) ? " *" : ""));
      System.out.println(" vertAxes=" + countVertCooordAxes + ((nVertCooordAxes < 0) ? " *" : ""));
    }

    Iterator iter = gridDs.getGridsets().iterator();
    while (iter.hasNext()) {
      GridDataset.Gridset gridset = (GridDataset.Gridset) iter.next();
      gridset.getGeoCoordSystem();
    }

    GridDatatype grid = gridDs.findGridDatatype(gridName);
    assert (grid != null) : "Cant find grid "+gridName;

    GridCoordSystem gcs = grid.getCoordinateSystem();
    CoordinateAxis1DTime runtime = gcs.getRunTimeAxis();
    assert (runtime != null) : "Cant find runtime for "+gridName;
    CoordinateAxis time = gcs.getTimeAxis();
    assert (time != null) : "Cant find time for "+gridName;
    assert (time.getRank() == 2) : "Time should be 2D "+gridName;

    if (showCount) {
      System.out.println(" runtimes=" + runtime.getSize());
      System.out.println(" ntimes=" +  time.getDimension(1).getLength());
    }

    if (ngrids >= 0)
      assert ngrids == countGrids : "Grids " + ngrids + " != " + countGrids;
    //if (ncoordSys >= 0)
    //  assert ncoordSys == countCoordSys : "CoordSys " + ncoordSys + " != " + countCoordSys;
    if (ncoordAxes >= 0)
      assert ncoordAxes == countCoordAxes : "CoordAxes " + ncoordAxes + " != " + countCoordAxes;
    if (nVertCooordAxes >= 0)
      assert nVertCooordAxes == countVertCooordAxes : "VertAxes" + nVertCooordAxes + " != " + countVertCooordAxes;

    if (nruns >= 0)
      assert runtime.getSize() == nruns : runtime.getSize()+" != "+ nruns;
    if (nruns >= 0)
      assert time.getDimension(0).getLength() == nruns : " nruns should be "+ nruns;
    if (ntimes >= 0)
      assert time.getDimension(1).getLength() == ntimes : " ntimes should be "+ ntimes;

    gridDs.close();
  }
View Full Code Here

    // count vertical axes
    int countVertCooordAxes = 0;
    List axes = ncd.getCoordinateAxes();
    for (int i = 0; i < axes.size(); i++) {
      CoordinateAxis axis =  (CoordinateAxis) axes.get(i);
      AxisType t = axis.getAxisType();
      if ((t == AxisType.GeoZ) || (t == AxisType.Height) || (t == AxisType.Pressure) )
        countVertCooordAxes++;
    }

    if (showCount) {
      System.out.println(" grids=" + countGrids + ((ngrids < 0) ? " *" : ""));
      System.out.println(" coordSys=" + countCoordSys + ((ncoordSys < 0) ? " *" : ""));
      System.out.println(" coordAxes=" + countCoordAxes + ((ncoordAxes < 0) ? " *" : ""));
      System.out.println(" vertAxes=" + countVertCooordAxes + ((nVertCooordAxes < 0) ? " *" : ""));
    }

    Iterator iter = gridDs.getGridsets().iterator();
    while (iter.hasNext()) {
      GridDataset.Gridset gridset = (GridDataset.Gridset) iter.next();
      gridset.getGeoCoordSystem();
    }

    GridDatatype grid = gridDs.findGridDatatype(gridName);
    assert (grid != null) : "Cant find grid "+gridName;

    GridCoordSystem gcs = grid.getCoordinateSystem();
    CoordinateAxis1DTime runtime = gcs.getRunTimeAxis();
    //System.out.println(" has runtime axis=" +  (runtime != null));

    assert (runtime != null) : "Cant find runtime for "+gridName;
    //assert (runtime == null) : "Should not have runtime coord= "+runtime;

    CoordinateAxis time = gcs.getTimeAxis();
    assert (time != null) : "Cant find time for "+gridName;

    if (showCount) {
      System.out.println(" ntimes=" +  time.getDimension(0).getLength());
    }

    if (ngrids >= 0)
      assert ngrids == countGrids : "Grids " + ngrids + " != " + countGrids;
    /* if (ncoordSys >= 0)
      assert ncoordSys == countCoordSys : "CoordSys " + ncoordSys + " != " + countCoordSys;
    if (ncoordAxes >= 0)
      assert ncoordAxes == countCoordAxes : "CoordAxes " + ncoordAxes + " != " + countCoordAxes;
    if (nVertCooordAxes >= 0)
      assert nVertCooordAxes == countVertCooordAxes : "VertAxes" + nVertCooordAxes + " != " + countVertCooordAxes;  */
    if (ntimes >= 0)
      assert time.getDimension(0).getLength() == ntimes : " ntimes should be "+ ntimes+ "instead = "+ time.getDimension(0).getLength();


    gridDs.close();
  }
View Full Code Here

      else if (csys.getCoordinateAxes().size() > use.getCoordinateAxes().size())
        use = csys;
    }

    if (use == null) return false;
    CoordinateAxis lat = use.getLatAxis();
    CoordinateAxis lon = use.getLonAxis();
    if ((lat != null) && (lat.getSize() <= 1)) return false; // COARDS singletons
    if ((lon != null) && (lon.getSize() <= 1)) return false;

    // hueristics - cant say i like this, multidim point features could eaily violate
    return (use.getRankDomain() > 2) && (use.getRankDomain() <= use.getRankRange());
  }
View Full Code Here

      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;
        }
      }

      if (maxDateRange == null)
View Full Code Here

    // count vertical axes
    int countVertCooordAxes = 0;
    List axes = gridDs.getNetcdfDataset().getCoordinateAxes();
    for (int i = 0; i < axes.size(); i++) {
      CoordinateAxis axis =  (CoordinateAxis) axes.get(i);
      AxisType t = axis.getAxisType();
      if ((t == AxisType.GeoZ) || (t == AxisType.Height) || (t == AxisType.Pressure) )
        countVertCooordAxes++;
    }

    Iterator iter = gridDs.getGridsets().iterator();
View Full Code Here

    assert null != grid;
    GridCoordSystem gcs = grid.getCoordinateSystem();
    assert null != gcs;
    assert grid.getRank() == 4;

    CoordinateAxis zaxis = gcs.getVerticalAxis();
    assert zaxis.getUnitsString().equals("hectopascals");

    GeoGrid grid_section = grid.subset(null, null, null, 3, 3, 3);

    GridCoordSystem gcs_section = grid_section.getCoordinateSystem();
    CoordinateAxis zaxis2 = gcs_section.getVerticalAxis();
    assert zaxis2.getSize() == 7;
    assert zaxis2.getUnitsString().equals("hectopascals");
    assert gcs_section.getTimeAxis().equals(gcs.getTimeAxis());

    Array data = grid_section.readDataSlice(-1, -1, -1, -1);
    assert data.getShape()[0] == 2 : data.getShape()[0];
    assert data.getShape()[1] == 7 : data.getShape()[1];
View Full Code Here

    assert null != grid;
    GridCoordSystem gcs = grid.getCoordinateSystem();
    assert null != gcs;
    assert grid.getRank() == 4;

    CoordinateAxis zaxis = gcs.getVerticalAxis();
    assert zaxis.getSize() == 27;

    VerticalTransform vt = gcs.getVerticalTransform();
    assert vt != null;
    assert vt.getUnitString().equals("Pa");

    GeoGrid grid_section = grid.subset(null, null, null, 3, 3, 3);

    Array data = grid_section.readDataSlice(-1, -1, -1, -1);
    assert data.getShape()[0] == 13 : data.getShape()[0];
    assert data.getShape()[1] == 9 : data.getShape()[1];
    assert data.getShape()[2] == 20 : data.getShape()[2];
    assert data.getShape()[3] == 25 : data.getShape()[3];

    GridCoordSystem gcs_section = grid_section.getCoordinateSystem();
    CoordinateAxis zaxis2 = gcs_section.getVerticalAxis();
    assert zaxis2.getSize() == 9 : zaxis2.getSize();

    assert zaxis2.getUnitsString().equals(zaxis.getUnitsString());
    assert gcs_section.getTimeAxis().equals(gcs.getTimeAxis());

    VerticalTransform vt_section = gcs_section.getVerticalTransform();
    assert vt_section != null;
    assert vt_section.getUnitString().equals(vt.getUnitString());
View Full Code Here

    ProjectionRect pr = gcs2.getProjection().getDefaultMapArea();
    System.out.println("projection mapArea= " + pr);
    assert (pr.equals(gcs2.getBoundingBox()));

    CoordinateAxis xaxis = gcs.getXHorizAxis();
    CoordinateAxis yaxis = gcs.getYHorizAxis();
    System.out.println("(nx,ny)= " + xaxis.getSize() + "," + yaxis.getSize());

    dataset.close();
  }
View Full Code Here

TOP

Related Classes of ucar.nc2.dataset.CoordinateAxis$AxisComparator

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.