Package ucar.nc2.dt

Examples of ucar.nc2.dt.GridCoordSystem


    showAtts(out, ds.getGlobalAttributes());
    out.println();

    if (gridDs == null) return;

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

      CoordinateAxis1D vaxis = gcs.getVerticalAxis();
      if (vaxis != null) {
        long nvert = vaxis.getSize();
        out.print("  Vertical axis= " + vaxis.getFullName() + " units=" + vaxis.getUnitsString() + " size= " + nvert);
        VerticalCT vt = gcs.getVerticalCT();
        if (vt != null)
          out.print(" transform= " + vt.getVerticalTransformType());

        List<NamedObject> vertNames = vaxis.getNames();
        for (NamedObject vertName : vertNames)
View Full Code Here


  public void utestBBSubsetVP2() throws Exception {
    String filename = "C:/Documents and Settings/caron/My Documents/downloads/MSG2-SEVI-MSGCLAI-0000-0000-20070522114500.000000000Z-582760.grb";
    GridDataset dataset = GridDataset.open(filename);
    GeoGrid grid = dataset.findGridByName("Pixel_scene_type");
    assert null != grid;
    GridCoordSystem gcs = grid.getCoordinateSystem();
    assert null != gcs;

    System.out.println("original bbox= " + gcs.getBoundingBox());
    System.out.println("lat/lon bbox= " + gcs.getLatLonBoundingBox());

    ucar.unidata.geoloc.LatLonRect llbb_subset = new LatLonRect(new LatLonPointImpl(), 20.0, 40.0);
    System.out.println("subset lat/lon bbox= " + llbb_subset);

    GeoGrid grid_section = grid.subset(null, null, llbb_subset, 1, 1, 1);
    GridCoordSystem gcs2 = grid_section.getCoordinateSystem();
    assert null != gcs2;

    System.out.println("result lat/lon bbox= " + gcs2.getLatLonBoundingBox());
    System.out.println("result bbox= " + gcs2.getBoundingBox());

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

    dataset.close();
  }
View Full Code Here

  public void utestNcmlRangeSubset() throws Exception {
    String filename = "D:/test/ncom_agg6.ncml";
    GridDataset dataset = GridDataset.open(filename);
    GeoGrid grid = dataset.findGridByName("water_temp");
    assert null != grid;
    GridCoordSystem gcs = grid.getCoordinateSystem();
    assert null != gcs;

    System.out.println("original bbox= " + gcs.getBoundingBox());
    System.out.println("lat/lon bbox= " + gcs.getLatLonBoundingBox());

    /*   tRange: 31:31
     zRange: 0:0
    yRange: 1:559
    zRange: 1:399 */
    GridDatatype subset = grid.makeSubset(null, null, new Range(31, 31), new Range(0, 0), new Range(1, 559), new Range(1, 399));
    assert subset != null;
    GridCoordSystem gcs2 = subset.getCoordinateSystem();
    assert null != gcs2;

    System.out.println("result lat/lon bbox= " + gcs2.getLatLonBoundingBox());
    System.out.println("result bbox= " + gcs2.getBoundingBox());

    Array data = subset.readVolumeData(0);
    int[] shape = data.getShape();
    assert shape.length == 3;
    assert shape[0] == 1;
View Full Code Here

    String filename = "dods://motherlode.ucar.edu:8080/thredds/dodsC/fmrc/NCEP/NAM/Alaska_11km/NCEP-NAM-Alaska_11km_best.ncd";
    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

  public void testScaleOffset() throws Exception {
    GridDataset dataset = GridDataset.open("http://esrl.noaa.gov/psd/thredds/dodsC/Datasets/noaa.oisst.v2/sst.wkmean.1990-present.nc");
    GeoGrid grid = dataset.findGridByName("sst");
    assert null != grid;
    GridCoordSystem gcs = grid.getCoordinateSystem();
    assert null != gcs;

    System.out.printf("original bbox= %s (%s) %n", gcs.getBoundingBox(), gcs.getLatLonBoundingBox());

    ucar.unidata.geoloc.LatLonRect llbb = gcs.getLatLonBoundingBox();
    ucar.unidata.geoloc.LatLonRect llbb_subset = new LatLonRect(llbb.getLowerLeftPoint(), 20.0, llbb.getWidth() / 2);

    GeoGrid grid2 = grid.subset(null, null, llbb_subset, 1, 1, 1);
    GridCoordSystem gcs2 = grid2.getCoordinateSystem();
    assert null != gcs2;

    System.out.printf("subset bbox= %s (%s) %n", gcs2.getBoundingBox(), gcs2.getLatLonBoundingBox());

    System.out.printf("%noriginal grid var= %s %n", grid.getVariable());
    System.out.printf("subset grid var= %s %n%n", grid2.getVariable());

    //   public Array readDataSlice(int rt, int e, int t, int z, int y, int x) throws java.io.IOException {
View Full Code Here

  public void utestScaleOffset2() throws Exception {   // keeps failing on nomads URL
    GridDataset dataset = GridDataset.open("dods://nomads.ncdc.noaa.gov/thredds/dodsC/cr20sixhr/air.1936.nc");
    GeoGrid grid = dataset.findGridByName("air");
    assert null != grid;
    GridCoordSystem gcs = grid.getCoordinateSystem();
    assert null != gcs;

    System.out.printf("original bbox= %s (%s) %n", gcs.getBoundingBox(), gcs.getLatLonBoundingBox());

    ucar.unidata.geoloc.LatLonRect llbb = gcs.getLatLonBoundingBox();
    ucar.unidata.geoloc.LatLonRect llbb_subset = new LatLonRect(llbb.getLowerLeftPoint(), 20.0, llbb.getWidth() / 2);

    GeoGrid grid2 = grid.subset(null, null, llbb_subset, 1, 1, 1);
    GridCoordSystem gcs2 = grid2.getCoordinateSystem();
    assert null != gcs2;

    System.out.printf("subset bbox= %s (%s) %n", gcs2.getBoundingBox(), gcs2.getLatLonBoundingBox());

    System.out.printf("%noriginal grid var= %s %n", grid.getVariable());
    System.out.printf("subset grid var= %s %n%n", grid2.getVariable());

    //   public Array readDataSlice(int rt, int e, int t, int z, int y, int x) throws java.io.IOException {
View Full Code Here

      ds = GridDataset.open(uri);
      GeoGrid grid = ds.findGridByName(var);
      Section s = new Section(grid.getShape());
      System.out.printf("var = %s %n", s);

      GridCoordSystem GridCoordS = grid.getCoordinateSystem();
      VerticalTransform vt = GridCoordS.getVerticalTransform();
      ArrayDouble.D3 z = vt.getCoordinateArray(0);
      Section sv = new Section(z.getShape());
      System.out.printf("3dcoord = %s %n", sv);

      if (vt.isTimeDependent())
View Full Code Here

  public void testPSscaleFactor() throws IOException {
    String filename = testDir+ "stereographic/foster.grib2";
    NetcdfDataset ncd = NetcdfDataset.openDataset(filename);
    GridDataset gds = new GridDataset(ncd);
    GridCoordSystem gsys = null;
    ProjectionImpl p = null;

    for (ucar.nc2.dt.GridDataset.Gridset g : gds.getGridsets()) {
      gsys = g.getGeoCoordSystem();
      for (CoordinateTransform t : gsys.getCoordinateTransforms()) {
        if (t instanceof ProjectionCT) {
          p = ((ProjectionCT)t).getProjection();
          break;
        }
      }
    }

    CoordinateAxis1D xaxis = (CoordinateAxis1D) gsys.getXHorizAxis();
    CoordinateAxis1D yaxis =  (CoordinateAxis1D) gsys.getYHorizAxis();
    p.projToLatLon(xaxis.getCoordValue(0), yaxis.getCoordValue(0)  );
    LatLonPointImpl start1 =  p.projToLatLon(xaxis.getCoordValue(0), yaxis.getCoordValue(0));
    LatLonPointImpl start2 =  p.projToLatLon(xaxis.getCoordValue((int)xaxis.getSize()-1), yaxis.getCoordValue((int)yaxis.getSize()-1));
    System.out.printf( "start = %f %f%n", start1.getLatitude(), start1.getLongitude());
    System.out.printf( "end = %f %f%n", start2.getLatitude(), start2.getLongitude());
View Full Code Here

    GridDatatype targetGrid = dataset.findGridDatatype(targetGridName);
    if (targetGrid == null) {
      throw new RuntimeException("Grid '" + targetGridName + "' does not exist in data file");
    }

    GridCoordSystem coordSys = targetGrid.getCoordinateSystem();
    validateIndices(coordSys, 38.0, -10.0, new int[]{92, 1});
    validateIndices(coordSys, 38.0, 350.0, new int[]{92, 1});
    validateIndices(coordSys, 38.0, -8.0, new int[]{94, 1});
    validateIndices(coordSys, 38.0, 352.0, new int[]{94, 1});
    validateIndices(coordSys, 38.0, -0.6, new int[]{101, 1});
View Full Code Here

    double latVal = latArray.getDouble( latArray.getIndex());
    double lonVal = lonArray.getDouble( lonArray.getIndex());

    GridDataset gd = GridDataset.open( datasetLocation );
    GeoGrid gg = gd.findGridByName( "hs" );
    GridCoordSystem gridCoordSys = gg.getCoordinateSystem();
    //gridCoordSys.getXHorizAxis().;
    //gridCoordSys.getYHorizAxis();
    LatLonPoint llPnt = gridCoordSys.getLatLon( 170, 62 );

    Assert.assertEquals( lat, llPnt.getLatitude(), 0.001 );
    Assert.assertEquals( lon, llPnt.getLongitude(), 0.001 );
  }
View Full Code Here

TOP

Related Classes of ucar.nc2.dt.GridCoordSystem

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.