Package ucar.nc2.dataset

Examples of ucar.nc2.dataset.NetcdfDataset


    assert v2 != null;

    Array data = v2.read();
    assert data.getElementType() == int.class;

    NetcdfDataset ncd = TestH5.openH5dataset("support/enum.h5");
    v2 = ncd.findVariable("enum");
    assert v2 != null;

    data = v2.read();
    assert data.getElementType() == String.class;
    ncfile.close();
View Full Code Here


    assert v2 != null;

    Array data = v2.read();
    assert data.getElementType() == byte.class;

    NetcdfDataset ncd = NetcdfDataset.openDataset("D:/netcdf4/tst_enum_data.nc");
    v2 = ncd.findVariable("primary_cloud");
    assert v2 != null;

    data = v2.read();
    assert data.getElementType() == String.class;
    ncfile.close();
View Full Code Here

        "In which case, you deserve what you get.",
        "  --  Professor Cheng Man-ch'ing"};
    String c_name = "Hello!";

    //H5header.setDebugFlags(new ucar.nc2.util.DebugFlagsImpl("H5header/header"));
    NetcdfDataset ncfile = NetcdfDataset.openDataset(TestH5.testDir + "complex/compound_complex.h5");

    Variable dset = null;
    assert (null != (dset = ncfile.findVariable("CompoundComplex")));
    assert (dset.getDataType() == DataType.STRUCTURE);
    assert (dset.getRank() == 1);
    assert (dset.getSize() == 6);

    Dimension d = dset.getDimension(0);
    assert (d.getLength() == 6);

    Structure s = (Structure) dset;

    // read all with the iterator
    StructureDataIterator iter = s.getStructureIterator();
    while (iter.hasNext()) {
      StructureData sd = (StructureData) iter.next();
      assert sd.getScalarInt("a_name") == a_name;
      a_name++;
      assert sd.getScalarString("c_name").equals(c_name);
      String[] results = sd.getJavaArrayString(sd.findMember("b_name"));
      assert results.length == b_name.length;
      int count = 0;
      for (String r : results)
        assert r.equals(b_name[count++]);

      Iterator viter = sd.getMembers().iterator();
      while (viter.hasNext()) {
        StructureMembers.Member m = (StructureMembers.Member) viter.next();
        Array data = sd.getArray(m);
        NCdump.printArray(data, m.getName(), out, null);
      }
    }

    ncfile.close();
    System.out.println("*** testH5StructureDS ok");

  }
View Full Code Here

  }

  public static NetcdfDataset openH5dataset( String filename) {
    try {
      System.out.println("**** Open "+ testDir+filename);
      NetcdfDataset ncfile = NetcdfDataset.openDataset( testDir+filename);
      if (TestH5.dumpFile) System.out.println("open H5 "+ncfile);
      return ncfile;

    } catch (java.io.IOException e) {
      System.out.println(" fail = "+e);
View Full Code Here

      measureSize(g.getName(), g, null, false);
  }

  static void testNcd() throws IOException {
    String filename = "C:/data/test2.nc";
    NetcdfDataset ncfile = NetcdfDataset.openDataset(filename);
    measureSize("C:/data/test2.nc", ncfile, null, true);

    NetcdfDatasetInfo info = new NetcdfDatasetInfo(filename);
    measureSize("info", info, null, true);
    String pifo = info.getParseInfo();
    System.out.println("info= " + pifo);
    ncfile.close();
  }
View Full Code Here

    ncfile.close();
  }

  static void testNcml() throws IOException {
    String filename = "C:/dev/tds/thredds/cdm/src/test/data/ncml/aggUnionSimple.xml";
    NetcdfDataset ncfile = NetcdfDataset.openDataset(filename, false, null);
    measureSize("aggUnionSimple", ncfile, null, true);
    ncfile.close();
  }
View Full Code Here

      }

      byte[] mbytes = scan.getMessageBytesFromLast(m);

      NetcdfFile ncfile = NetcdfFile.openInMemory("test", mbytes);
      NetcdfDataset ncd = new NetcdfDataset(ncfile);

      writeMessage(m, ncd);
      count++;
    }
    raf.close();
View Full Code Here

    System.out.println(" testNcmlDatasetWcoords.closed ");
  }

  public void testNcmlDatasetNoCoords() throws IOException, InvalidRangeException {
    String filename = "file:./"+TestNcML.topDir + "aggExistingNoCoords.xml";
    NetcdfDataset ncd = null;

    try {
      ncd = NetcdfDataset.openDataset( filename, true, null);
    } catch (Exception e) {
      //e.printStackTrace();
      assert true;
      return;
    } finally {
      if (ncd != null) ncd.close();
    }
    assert false;
    /*System.out.println(" TestNcmlAggExisting.open "+ filename);

    testDimensions(ncfile);
View Full Code Here

  public static void rewrite(String fileIn, String fileOut) throws IOException {
    long start = System.currentTimeMillis();

    // do it in memory for speed
    NetcdfFile ncfile = NetcdfFile.openInMemory(fileIn);
    NetcdfDataset ncd = new NetcdfDataset( ncfile);

    StringBuilder errlog = new StringBuilder();
    StationObsDataset sobs = (StationObsDataset) TypedDatasetFactory.open(FeatureType.STATION, ncd, null, errlog);

    List<ucar.unidata.geoloc.Station> stns = sobs.getStations();
View Full Code Here

    <scan location="file:src/test/data/ncml/nc/" suffix="mean.nc"/>
  </aggregation>
  */
  public void testScan() throws IOException {
    String filename = "file:./" + TestNcML.topDir + "aggUnionScan.xml";
    NetcdfDataset scanFile = NetcdfDataset.openDataset(filename, false, null);
    CompareNetcdf.compareFiles(ncfile, scanFile, true, true, false);
    scanFile.close();
  }
View Full Code Here

TOP

Related Classes of ucar.nc2.dataset.NetcdfDataset

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.