Package ucar.nc2

Examples of ucar.nc2.NetcdfFile


    super(name);
  }

  public void utestNestedTable() throws IOException, InvalidRangeException {
    String filename = TestAll.cdmLocalTestDataDir + "dataset/nestedTable.bufr";
    NetcdfFile ncfile = ucar.nc2.dataset.NetcdfDataset.openFile(filename, null);
    Structure outer = (Structure) ncfile.findVariable(BufrIosp.obsRecord);
    StructureData data = outer.readStructure(0);
    //NCdumpW.printStructureData( new PrintWriter(System.out), data);

    assert data.getScalarShort("Latitude") == 32767;

    ArrayStructure as = data.getArrayStructure("struct1");
    assert as != null;
    assert as.getScalarShort(0, as.findMember("Wind_speed")) == 61;

    ncfile.close();
  }
View Full Code Here


    }

  }

  private void doOne(String filename) throws Exception {
    NetcdfFile ncfile = NetcdfDataset.acquireFile(filename, null);
    NetcdfDataset ncWrap = new NetcdfDataset( ncfile, true);

    NetcdfDataset ncd = NetcdfDataset.acquireDataset(filename, null);
    System.out.println(" dataset wraps= "+filename);
View Full Code Here

      " <aggregation type='joinNew' dimName='fake'>\n" +
      "  <netcdf location='"+dir+"dir mit blank/20070101.nc' coord='1'/>\n" +
      "  <netcdf location='"+dir+"dir mit blank/20070301.nc' coord='2'/>\n" +
      " </aggregation>\n" +
      "</netcdf> ";
    NetcdfFile ncfile = NcMLReader.readNcML(new StringReader(ncml), null);
    System.out.printf("result=%s %n", ncfile);
    ncfile.close();
  }
View Full Code Here

    //H4header.setDebugFlags(new ucar.nc2.util.DebugFlagsImpl("H4header/tag2 H4header/tagDetail H4header/construct"));
    //H4header.setDebugFlags(new ucar.nc2.util.DebugFlagsImpl("H4header/linked"));

    //TestAll.readAll("E:/problem/MAC021S0.A2007287.1920.002.2007289002404.hdf");

    NetcdfFile ncfile = NetcdfFile.open("R:\\testdata\\hdf4\\c402_rp_02.diag.sfc.20020122_0130z.hdf");
    Variable v = ncfile.findVariable("MOD_Grid_MOD17A2/Data Fields/PsnNet_1km");
    assert v != null;
    v.read();
    ncfile.close();
  }
View Full Code Here

  }

  public void testUnsigned() throws IOException, InvalidRangeException {
    String filename = testDir + "MOD021KM.A2004328.1735.004.2004329164007.hdf";
    NetcdfFile ncfile = NetcdfFile.open(filename);
    String vname = "/MODIS_SWATH_Type_L1B/Data Fields/EV_250_Aggr1km_RefSB";
    Variable v = ncfile.findVariable(vname);
    assert v != null : filename+" "+vname;

    Array data = v.read();
    System.out.printf(" sum =          %f%n", MAMath.sumDouble(data));
View Full Code Here

    void consume(Future x) throws ExecutionException, InterruptedException, IOException {
      if (x == null) return;

      if (x.isDone()) {
        NetcdfFile ncfile = (NetcdfFile) x.get();
        ncfile.close();
        //format.format("  closed qsize= %3d\n", queue.size());
      } else {
        // format.format("  lost file= %3d\n", queue.size());
        queue.add(x); // put it back
      }
View Full Code Here

  }

  private class MyAct implements TestAll.Act {

    public int doAct(String filename) throws IOException {
      NetcdfFile ncfile = null;

      try {
        ncfile = NetcdfFile.open(filename);
        Group root = ncfile.getRootGroup();
        Group g = root.findGroup("HDFEOS INFORMATION");
        if (g == null) g = ncfile.getRootGroup();

        Variable dset = g.findVariable("StructMetadata.0");
        if (dset != null) {
          System.out.println("EOS file=" + filename);
          return 1;
        }

        System.out.println("NOT EOS file=" + filename);
        return 0;
      } finally {
        if (ncfile != null) ncfile.close();
      }
    }
View Full Code Here

    System.out.println("starting files="+count);
    NetcdfDataset.initNetcdfFileCache(0, 2, 5, 10*60);

    for (int i=0; i<10; i++) {
      String ncmli = StringUtil.replace(ncml,'%',Integer.toString(i));
      NetcdfFile ncfile = NcMLReader.readNcML(new StringReader(ncmli), filename, null);
      System.out.println(" TestNcmlAggExisting.open "+ filename);

      Variable timev = ncfile.findVariable("time");
      Array timeD = timev.read();

      int count1 = RandomAccessFile.getOpenFiles().size();
      System.out.printf("count files at dir %d count= %d%n", i, count1);
      ncfile.close();
    }

    int count2 = RandomAccessFile.getOpenFiles().size();
    System.out.println("ending files="+count2);
    //assert count == count2 : "openFile count "+count +"!="+ count2;
View Full Code Here

    "</netcdf>";

  public void testWithDateFormatMark() throws Exception {
    System.out.printf("ncml=%s%n", ncml);
    String filename = "file:" + TestNcML.topDir + "testAggModify.ncml";
    NetcdfFile ncfile = NcMLReader.readNcML(new StringReader(ncml), filename, null);
    System.out.println(" TestNcmlAggExisting.open " + filename + "\n" + ncfile);

    Variable v = ncfile.findVariable("T");
    assert null != v;

    v = ncfile.findVariable("P");
    assert null == v;

    ncfile.close();
  }
View Full Code Here

      "  </aggregation>\n" +
      "</netcdf>";

    String filename = "file:./"+ TestNcML.topDir + "aggExisting1.xml";

    NetcdfFile ncfile = NcMLReader.readNcML( new StringReader(xml), null);
    System.out.println(" TestNcmlAggExisting.open "+ filename);

    Variable times = ncfile.findVariable("times");
    assert null != times;
    assert times.getRank() == 1;
    assert times.getSize() == 3;

    assert times.getDimension(0).getName().equals("time");
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.