Examples of GridDataset


Examples of ucar.nc2.dt.grid.GridDataset

  ///////////////////////////////////////////////////////////
  // show grid names and param ids
  public void showGrids(String filename) throws IOException {
    Formatter f = new Formatter(System.out);
    GridDataset ncd = null;

    try {
      ncd = GridDataset.open(filename);
      List<GridDatatype> grids = ncd.getGrids();
      Collections.sort(grids);

      for (GridDatatype g : grids) {
        f.format(" %s (", g.getFullName());
        Attribute att = g.findAttributeIgnoreCase("GRIB_param_id");
        if (att != null)
          f.format("%s/%s,param=%s", att.getNumericValue(1), att.getNumericValue(2), att.getNumericValue(3));
        f.format(")%n");
      }
    } catch (Throwable t) {
      System.out.printf("Failed on %s = %s%n", filename, t.getMessage());
      return;
    } finally {
      if (ncd != null) ncd.close();
    }
  }
View Full Code Here

Examples of ucar.nc2.dt.grid.GridDataset

  }

  ////////////////////////////////////////////////////////////////////////
  // show param names. how they relate to level, stat, ens, prob
  private void showNames(String filename) throws IOException {
    GridDataset ncd = GridDataset.open(filename);
    nfiles++;

    String format = "%-50s %-20s %-12s %-12s %-12s %n";
    System.out.printf(format, " ", "level", "stat", "ens", "prob" );

    List<GridDatatype> grids =  ncd.getGrids();
    Collections.sort(grids);
    for (GridDatatype g : grids) {
      GridCoordSystem gsys = g.getCoordinateSystem();
      CoordinateAxis t = gsys.getTimeAxis();
      Variable v = g.getVariable();
      String level = v.findAttribute("GRIB_level_type_name").getStringValue();
      Attribute att = v.findAttribute("GRIB_interval_stat_type");
      String stat = (att == null) ? "" : att.getStringValue();
      att = v.findAttribute("GRIB_ensemble");
      String ens = "";
      if (att != null) ens = att.getStringValue();
      else {
        att = v.findAttribute("GRIB_ensemble_derived_type");
        if (att != null) ens = att.getStringValue();
      }
      att = v.findAttribute("GRIB_probability_type");
      String prob = (att == null) ? "" : att.getStringValue();
      System.out.printf(format, v.getFullName(), level, stat, ens, prob);
    }
    System.out.printf("%n");
    ncd.close();
  }
View Full Code Here

Examples of ucar.nc2.dt.grid.GridDataset

  //////////////////////////////////////////////////////////////////////////
  // look for ProjectionImpl name
  public void showProjectionType(String filename) throws IOException {
    NetcdfDataset ncd = NetcdfDataset.openDataset(filename);
    GridDataset gds = new GridDataset(ncd);
    nfiles++;

    Map<String, HoldEm> map = new HashMap<String, HoldEm>();

    for (ucar.nc2.dt.GridDataset.Gridset g : gds.getGridsets()) {
      GridCoordSystem gsys = g.getGeoCoordSystem();
      for (CoordinateTransform t : gsys.getCoordinateTransforms()) {
        if (t instanceof ProjectionCT) {
          ncd.findVariable(t.getName());
          ProjectionImpl p = ((ProjectionCT)t).getProjection();
View Full Code Here

Examples of ucar.nc2.dt.grid.GridDataset

  ////////////////////////////////////////////////////////////////////////
// show GRIB_product_definition_template attribute value
  // Grib2 only
  private int showTemplateType2(String filename) throws IOException {
    GridDataset ncd = GridDataset.open(filename);
    nfiles++;

    HashMap<Integer, List<String>> map = new  HashMap<Integer, List<String>>();

    for (GridDatatype g : ncd.getGrids()) {
      GridCoordSystem gsys = g.getCoordinateSystem();
      CoordinateAxis t = gsys.getTimeAxis();
      Variable v = g.getVariable();
      Attribute param = v.findAttribute("GRIB_product_definition_template");
      Integer template = param.getNumericValue().intValue();
      List<String> list = map.get(template);
      if (list == null) {
        list = new ArrayList<String>();
        map.put(template, list);
      }
      list.add(v.getShortName());
    }
    ncd.close();

    for (Integer key : map.keySet()) {
      System.out.printf("template=%d:", key);
      List<String> list = map.get(key);
      for (String vname : list)
View Full Code Here

Examples of ucar.nc2.dt.grid.GridDataset

  public void testErie() throws IOException, InvalidRangeException {
    String uri = "C:\\data\\work\\signell/erie_test.ncml";
    String var = "temp";

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

    GridCoordSystem gcs = grid.getCoordinateSystem();
    VerticalTransform vt = gcs.getVerticalTransform();
View Full Code Here

Examples of ucar.nc2.dt.grid.GridDataset

    return vt;
  }

  private void testGrid(String uri, String var) throws IOException, InvalidRangeException {

    GridDataset ds = null;
    try {
      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())
        s = s.removeRange(0);
      assert s.equals(sv);
    } finally {
      if (ds != null) ds.close();
    }
  }
View Full Code Here

Examples of ucar.nc2.dt.grid.GridDataset

  }

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