예제 #1
0
 public static void main(String arg[]) throws IOException {
   NetcdfFile ncfile1 =
       NetcdfDataset.openFile(
           "dods://thredds.cise-nsf.gov:8080/thredds/dodsC/satellite/SFC-T/SUPER-NATIONAL_1km/20090516/SUPER-NATIONAL_1km_SFC-T_20090516_2200.gini",
           null);
   NetcdfFile ncfile2 =
       NetcdfDataset.openFile(
           "dods://motherlode.ucar.edu:8080/thredds/dodsC/satellite/SFC-T/SUPER-NATIONAL_1km/20090516/SUPER-NATIONAL_1km_SFC-T_20090516_2200.gini",
           null);
   compareFiles(ncfile1, ncfile2, new Formatter(System.out), false, true, false);
 }
예제 #2
0
  public static void main(String args[]) throws Exception {

    // String fileIn =
    // "C:/data/bufr/edition3/newIdd/IcingTropopause/IcingTropopause_20080529_0000.bufr";
    String fileIn =
        "C:\\data\\bufr\\edition3\\meteosat\\METEOSAT7-MVIRI-MTPHRWW-NA-1-20080405123005.000000000Z-909326.bfr ";
    NetcdfFile ncf = NetcdfDataset.openFile(fileIn, null);
    System.out.println(ncf.toString());

    new Write2ncRect(ncf, "C:/data/bufr2nc.meteosat.nc", true);
  }
  private void doOne(String urlString) throws IOException {
    System.out.println("Open and read " + urlString);

    NetcdfFile ncd = NetcdfDataset.openFile(urlString, null);
    assert ncd != null;

    // pick a random variable to read
    List vlist = ncd.getVariables();
    int n = vlist.size();
    assert n > 0;
    Variable v = (Variable) vlist.get(n / 2);
    Array data = v.read();
    assert data.getSize() == v.getSize();

    ncd.close();
  }
예제 #4
0
 @Override
 public int doAct(String filename) throws IOException {
   try (NetcdfFile ncfile = NetcdfDataset.openFile(filename, null)) {
     System.out.printf("  Open McIdas File %s ", filename);
     String ft = ncfile.findAttValueIgnoreCase(null, "featureType", "none");
     String iosp = ncfile.getIosp().getFileTypeId();
     System.out.printf(" iosp=%s ft=%s%n", iosp, ft);
     assert iosp.equals("McIDASArea") || iosp.equals("McIDASGrid") : iosp;
     assert ft.equals(FeatureType.GRID.toString()) : ft;
     return 1;
   } catch (Throwable t) {
     System.out.printf(" FAILED =%s%n", t.getMessage());
     t.printStackTrace();
     countFail++;
     return 0;
   }
 }
  @Override
  public List<LocationWeatherData> handleDataFile() {
    logger.debug("Analyzing weather data file " + getFile().getName());

    NetcdfFile netcdfFile = null;
    try {
      netcdfFile = NetcdfDataset.openFile(getFile().getAbsolutePath(), null);
      logger.debug("Opened file in netcdf " + getFile().getName());
      return process(netcdfFile);
    } catch (IOException e) {
      logger.error("Trying to open " + getFile().getName(), e);
    } finally {
      if (netcdfFile != null) {
        try {
          netcdfFile.close();
        } catch (IOException e) {
          logger.error("Trying to close " + getFile().getName(), e);
        }
      }
    }
    return null;
  }
예제 #6
0
  private void compareDataset(CompareDialog.Data data) {
    if (data.name == null) return;

    NetcdfFile compareFile = null;
    try {
      compareFile = NetcdfDataset.openFile(data.name, null);

      Formatter f = new Formatter();
      CompareNetcdf2 cn = new CompareNetcdf2(f, data.showCompare, data.showDetails, data.readData);
      if (data.howMuch == CompareDialog.HowMuch.All) cn.compare(ds, compareFile);
      else {
        NestedTable nested = nestedTableList.get(0);
        Variable org = getCurrentVariable(nested.table);
        if (org == null) return;
        Variable ov = compareFile.findVariable(org.getFullNameEscaped());
        if (ov != null) cn.compareVariable(org, ov);
      }

      infoTA.setText(f.toString());
      infoTA.gotoTop();
      infoWindow.setTitle("Compare");
      infoWindow.show();

    } catch (Throwable ioe) {
      ByteArrayOutputStream bos = new ByteArrayOutputStream(10000);
      ioe.printStackTrace(new PrintStream(bos));
      infoTA.setText(bos.toString());
      infoTA.gotoTop();
      infoWindow.show();

    } finally {
      if (compareFile != null)
        try {
          compareFile.close();
        } catch (Exception eek) {
        }
    }
  }