Package ucar.nc2

Examples of ucar.nc2.NetcdfFile


  }

  ///////////////////////////////////////////////////////////
  // just open files - see if there are error messages
  public void checkOpen(String filename) throws IOException {
    NetcdfFile ncd = null;
    try {
      ncd = NetcdfFile.open(filename);
    } catch (Exception t) {
      System.out.printf("Failed on %s = %s%n", filename, t.getMessage());
      return;
    } 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


  ////////////////////////////////////////////////////////////////////////
  // show getGenProcessType()
  public void showGenType(String filename, boolean showVars) throws IOException {
    GridServiceProvider.debugOpen = true;
    NetcdfFile ncd = null;
    try {
      ncd = NetcdfFile.open(filename);
    } catch (Throwable t) {
      System.out.printf("Failed on %s = %s%n", filename, t.getMessage());
      return;
    }

    GribGridServiceProvider iosp = (GribGridServiceProvider) ncd.getIosp();
    GridIndex index = (GridIndex) iosp.sendIospMessage("GridIndex");
    boolean isGrib1 = iosp.getFileTypeId().equals("GRIB1");

    boolean first = true;
    Map<Integer, List<String>> map = new HashMap<Integer, List<String>>();
View Full Code Here

  ////////////////////////////////////////////////////////////////////////
  // show getStatisticalProcessType()
  public void showStatType(String filename, boolean showVars) throws IOException {
    GridServiceProvider.debugOpen = true;
    NetcdfFile ncd = null;
    try {
      ncd = NetcdfFile.open(filename);
    } catch (Throwable t) {
      System.out.printf("Failed on %s = %s%n", filename, t.getMessage());
      return;
    }

    GribGridServiceProvider iosp = (GribGridServiceProvider) ncd.getIosp();
    GridIndex index = (GridIndex) iosp.sendIospMessage("GridIndex");
    boolean isGrib1 = iosp.getFileTypeId().equals("GRIB1");

    boolean first = true;
    Map<String, List<Integer>> map = new HashMap<String, List<Integer>>();
View Full Code Here

  ////////////////////////////////////////////////////////////////////////
  // show getTableVersion()
  public void showTableVersion(String filename, boolean showVars) throws IOException {
    GridServiceProvider.debugOpen = true;
    NetcdfFile ncd = null;
    try {
      ncd = NetcdfFile.open(filename);
    } catch (Throwable t) {
      System.out.printf("Failed on %s = %s%n", filename, t.getMessage());
      return;
    }

    GribGridServiceProvider iosp = (GribGridServiceProvider) ncd.getIosp();
    GridIndex index = (GridIndex) iosp.sendIospMessage("GridIndex");
    boolean isGrib1 = iosp.getFileTypeId().equals("GRIB1");
    if (!isGrib1) return;

    boolean first = true;
View Full Code Here

  ////////////////////////////////////////////////////////////////////////
  // show timeIncrementType
  // Grib2 only
  public void showTimeIntervalType2(String filename) throws IOException {
    GridServiceProvider.debugOpen = true;
    NetcdfFile ncd = NetcdfFile.open(filename);

    GribGridServiceProvider iosp = (GribGridServiceProvider) ncd.getIosp();
    GridIndex index = (GridIndex) iosp.sendIospMessage("GridIndex");

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

    List<GridRecord> grList = index.getGridRecords();
View Full Code Here

  ////////////////////////////////////////////////////////////////////////
  // show params that are time intervals, how they relate to Grib2Pds.makeDate().
  // Grib2 only
  public void showTimeInterval2(String filename) throws IOException {
    GridServiceProvider.debugOpen = true;
    NetcdfFile ncd = NetcdfFile.open(filename);
    DateFormatter df = new DateFormatter();
    Calendar cal = Calendar.getInstance();

    GribGridServiceProvider iosp = (GribGridServiceProvider) ncd.getIosp();
    GridIndex index = (GridIndex) iosp.sendIospMessage("GridIndex");

    List<GridRecord> grList = index.getGridRecords();
    for (GridRecord gr : grList) {
      GribGridRecord ggr = (GribGridRecord) gr;
View Full Code Here

    return 1;
  } */


  private int analalyseIntervals(String filename) throws IOException {
    NetcdfFile ncd = NetcdfFile.open(filename);
    nfiles++;
    //System.out.printf("==============================================================================%n");

    GribGridServiceProvider iosp = (GribGridServiceProvider) ncd.getIosp();
    GridIndex index = (GridIndex) iosp.sendIospMessage("GridIndex");

    Map<Integer, Product> pdsSet = new HashMap<Integer, Product>();

    List<GridRecord> grList = index.getGridRecords();
    for (GridRecord gr : grList) {
      GribGridRecord ggr = (GribGridRecord) gr;
      GribPds pds =  ggr.getPds();
      if (!pds.isInterval()) continue;

      //int startInterval = ggr.startOfInterval;
      //if ((startInterval == GribNumbers.UNDEFINED) || (startInterval == GribNumbers.MISSING)) continue;

      /* check valid time == base time + forecast
      int forecast = ggr.forecastTime;
      Date validTime = ggr.getValidTime();
      Date refTime = ggr.getReferenceTime();
      if (forecast != startInterval) {
        String name = ParameterTable.getParameterName(ggr.discipline, ggr.category, ggr.paramNumber) +"/" + Grib2Tables.codeTable4_5(ggr.levelType1);
        System.out.printf(" **time %s %d != %d%n", name, forecast, startInterval);
      } */

      Product bean = pdsSet.get(ggr.cdmVariableHash());
      if (bean == null) {
        bean = new Product(ggr);
        pdsSet.put(ggr.cdmVariableHash(), bean);
        nintVars++;
      }
      bean.list.add(ggr);
    }

    List<Product> sortList = new ArrayList<Product>();
    sortList.addAll(pdsSet.values());
    Collections.sort(sortList);
    for (Product p : sortList) {
      p.sort();
      System.out.printf("  %s (%d)%n", p.name, p.ggr.getPds().getParameterNumber());
      System.out.printf("%s%n", p.doAccumAlgo(false));
    }

    ncd.close();
    return 1;
  }
View Full Code Here

  protected void buildNetcdfDataset(CancelTask cancelTask) throws IOException {
    // each Dataset just gets "transfered" into the resulting NetcdfDataset
    List<Dataset> nestedDatasets = getDatasets();
    for (Dataset vnested : nestedDatasets) {
      // LOOK could just open the file, not use acquire.
      NetcdfFile ncfile = vnested.acquireFile(cancelTask);
      DatasetConstructor.transferDataset(ncfile, ncDataset, null);
      // do not close - all stay open. Could use Proxy if need to open only as needed.
      openDatasets.add(ncfile);
    }
  }
View Full Code Here

  }

  private void doOne(String filename) throws Exception {
    System.out.println("read file= "+filename);
    NetcdfFile ncfile = NetcdfDataset.openFile( filename, null);
    System.out.println(" Generating_Process_or_Model="+ncfile.findAttValueIgnoreCase(null, "Generating_Process_or_Model", "NONE"));
    ncfile.close();
  }
View Full Code Here

    TestH5read.readAllData(TestAll.cdmUnitTestDir +"formats/hdf5/npoess/ExampleFiles/AVAFO_NPP_d2003125_t10109_e101038_b9_c2005829155458_devl_Tst.h5");
  }

  public void test2() throws InvalidRangeException, IOException {
    //H5header.setDebugFlags( new ucar.nc2.util.DebugFlagsImpl("H5header/header"));
    NetcdfFile ncfile = TestH5.openH5("npoess/ExampleFiles/AVAFO_NPP_d2003125_t10109_e101038_b9_c2005829155458_devl_Tst.h5");
    Variable dset = ncfile.findVariable("Data_Products/VIIRS-AF-EDR/VIIRS-AF-EDR_Gran_0");
    Array data = dset.read();
    NCdump.printArray(data, "data", System.out, null);
  }
View Full Code Here

TOP

Related Classes of ucar.nc2.NetcdfFile

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.