Package ucar.nc2.dt.grid

Examples of ucar.nc2.dt.grid.GridDataset


    return (NetcdfFile) cache.acquire(factory, hashKey, location, buffer_size, cancelTask, spiObject);
  }

  static private class DodsFactory implements FileFactory {
    public NetcdfFile open(String location, int buffer_size, ucar.nc2.util.CancelTask cancelTask, Object spiObject) throws IOException {
      return new DODSNetcdfFile(location, cancelTask);
    }
View Full Code Here


  public GridCoordSys getGridCoordSys(VariableEnhanced ve) {
    List<CoordinateSystem> csList = ve.getCoordinateSystems();
    for (CoordinateSystem cs : csList) {
      if (GridCoordSys.isGridCoordSys(null, cs, ve)) {
        return new GridCoordSys(cs, null);
      }
    }
    return null;
  }
View Full Code Here

    List<CoordinateSystem> csList = ds.getCoordinateSystems();
    for (CoordinateSystem cs : csList) {
      Element csElem;
      if (GridCoordSys.isGridCoordSys(null, cs, null)) {
        GridCoordSys gcs = new GridCoordSys(cs, null);
        csElem = new Element("gridCoordSystem");
        csElem.setAttribute("name", cs.getName());
        csElem.setAttribute("horizX", gcs.getXHorizAxis().getFullName());
        csElem.setAttribute("horizY", gcs.getYHorizAxis().getFullName());
        if (gcs.hasVerticalAxis())
          csElem.setAttribute("vertical", gcs.getVerticalAxis().getFullName());
        if (gcs.hasTimeAxis())
          csElem.setAttribute("time", cs.getTaxis().getFullName());
      } else {
        csElem = new Element("coordSystem");
        csElem.setAttribute("name", cs.getName());
      }

      List<CoordinateTransform> coordTransforms = cs.getCoordinateTransforms();
      for (CoordinateTransform ct : coordTransforms) {
        Element ctElem = new Element("coordTransform");
        csElem.addContent(ctElem);
        ctElem.setAttribute("name", ct.getName());
        ctElem.setAttribute("type", ct.getTransformType().toString());
      }

      rootElem.addContent(csElem);
    }

    List<CoordinateTransform> coordTransforms = ds.getCoordinateTransforms();
    for (CoordinateTransform ct : coordTransforms) {
      Element ctElem = new Element("coordTransform");
      rootElem.addContent(ctElem);

      ctElem.setAttribute("name", ct.getName());
      ctElem.setAttribute("type", ct.getTransformType().toString());
      List<Parameter> params = ct.getParameters();
      for (Parameter pp : params) {
        Element ppElem = new Element("param");
        ctElem.addContent(ppElem);
        ppElem.setAttribute("name", pp.getName());
        ppElem.setAttribute("value", pp.getStringValue());
      }
    }

    for (Variable var : ds.getVariables()) {
      VariableEnhanced ve = (VariableEnhanced) var;
      if (ve instanceof CoordinateAxis) continue;
      GridCoordSys gcs = getGridCoordSys(ve);
      if (null != gcs) {
        nDataVariables++;
        Element gridElem = new Element("grid");
        rootElem.addContent(gridElem);

        gridElem.setAttribute("name", ve.getFullName());
        gridElem.setAttribute("decl", getDecl(ve));
        if (ve.getUnitsString() != null) {
          gridElem.setAttribute("units", ve.getUnitsString());
          gridElem.setAttribute("udunits", isUdunits(ve.getUnitsString()));
        }
        gridElem.setAttribute("coordSys", gcs.getName());
      }
    }

    for (Variable var : ds.getVariables()) {
      VariableEnhanced ve =  (VariableEnhanced) var;
      if (ve instanceof CoordinateAxis) continue;
      GridCoordSys gcs = getGridCoordSys(ve);
      if (null == gcs) {
        nOtherVariables++;
        Element elem = new Element("variable");
        rootElem.addContent(elem);
View Full Code Here

  }

  public void testNcmlGrid() throws IOException {
    String filename = "file:" + TestAll.cdmUnitTestDir + "ncml/nc/seawifs/aggDirectory.ncml";

    GridDataset gds = GridDataset.open( filename);
    System.out.println(" TestNcmlAggExisting.openGrid "+ filename);

    List grids = gds.getGrids();
    assert grids.size() == 2;

    gds.close();
  }
View Full Code Here

*/
public class ReadGrid {

  public static void read( String filename) throws IOException {

    GridDataset gds = GridDataset.open (filename);
    GeoGrid grid = gds.findGridByName("Temperature");

    long startTime = System.currentTimeMillis();

    Array data = grid.readDataSlice(0, -1, -1, -1);

View Full Code Here

    //String defaultFilename = "R:/testdata2/motherlode/grid/NAM_Alaska_45km_conduit_20060801_0000.grib1";
    String defaultFilename = "R:/testdata/grid/grib/grib2/test/NAM_CONUS_12km_20060305_1200.grib2";
    String filename = (arg.length > 0) ? arg[0] : defaultFilename;
    try {
      long start = System.currentTimeMillis();
      GridDataset gridDs = GridDataset.open (filename);
      GeoGrid gg = gridDs.findGridByName("Temperature");
      long took = System.currentTimeMillis() - start;
      System.out.println("open took = " + took+" msecs");

      start = System.currentTimeMillis();
      Array data = gg.readVolumeData(0);
View Full Code Here

  // I really don't think this is a problem with your code
  // may be bug in HDF5 1.8.4-patch1
  public void utestTiling() throws IOException {
    // Global Heap 1t 13059 runs out with no heap id = 0
    String filename = testDir+"tiling.nc4";
    GridDataset gridDataset = GridDataset.open(filename);
    GridDatatype grid = gridDataset.findGridByName("Turbulence_SIGMET_AIRMET" );
    System.out.printf("grid=%s%n", grid);
    grid.readDataSlice( 4, 13, 176, 216 ); // FAILS
    gridDataset.close();
  }
View Full Code Here

    ncfile.close();
  }

  public void utestMargolis() throws IOException, InvalidRangeException {
    String dataDir = TestAll.cdmUnitTestDir + "nomads/gfs-hi/";
    GridDataset gridDataset = GridDataset.open( "D:/AStest/margolis/grib2ncdf.ncml" );
    GeoGrid grid = gridDataset.findGridByName( "Turbulence_SIGMET_AIRMET" );
    System.out.println("Grid= "+grid+" section="+ new Section(grid.getShape()));
    System.out.println(" coordSys= "+grid.getCoordinateSystem());

    GeoGrid subset = (GeoGrid) grid.makeSubset(new Range(0, 0), null, new Range(1,1), null, null, null);
    System.out.println("subset= "+subset+" section="+ new Section(subset.getShape()));
    System.out.println(" coordSys= "+subset.getCoordinateSystem());

    gridDataset.close();
  }
View Full Code Here

    assert v.getDataType() == DataType.INT;
    assert v instanceof CoordinateAxis;
    CoordinateAxis axis = (CoordinateAxis) v;
    assert axis.getAxisType() == AxisType.Time;
   
    GridDataset gd = new GridDataset(ncd, null);

    GeoGrid grid = (GeoGrid) gd.findGridByName("rh");
    assert grid != null;
    assert grid.getDataType() == DataType.INT;
    System.out.printf("%s%n", ncd);

    ncfile.close();
View Full Code Here

    NetcdfDataset ds = NetcdfDataset.openDataset(location);
    ds.close();
  }

  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

TOP

Related Classes of ucar.nc2.dt.grid.GridDataset

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.