Package ucar.nc2

Examples of ucar.nc2.NetcdfFile


    NCdump.printArray(data, "data", System.out, null);
  }

  public void test3() throws InvalidRangeException, IOException {
    H5header.setDebugFlags( new ucar.nc2.util.DebugFlagsImpl("H5header/reference"));
    NetcdfFile ncfile = TestH5.openH5("npoess/ExampleFiles/GDNBF-VNCCO_NPP_d2003125_t101038_e10116_b9_c2005829162517_dev.h5");
    Variable dset = ncfile.findVariable("Data_Products/VIIRS-DNB-FGEO/VIIRS-DNB-FGEO_Aggr");
    assert(null != dset );
  }
View Full Code Here


    assert(null != dset );
  }

  public void problem() throws InvalidRangeException, IOException {
    H5header.setDebugFlags( new ucar.nc2.util.DebugFlagsImpl("H5header/header"));
    NetcdfFile ncfile = TestH5.open("C:/data/HDF5Files/CrIMSS - CrIS - ATMS/ATMS/ATMS_SCIENCE_RDR/RASCI_npp_d20030125_t104457_e104505_b00016_c20061210190242_den_SWC.h5");
    Variable dset = ncfile.findVariable("Data_Products/ATMS-SCIENCE-RDR/ATMS-SCIENCE-RDR_Aggr");
    assert (null != dset );
    Array data = dset.read();
    NCdump.printArray(data, dset.getFullName(), System.out, null);
  }
View Full Code Here

  /**
   * Test ...
   */
  public void testMuckWithNcfSynchExtend()
  {
    NetcdfFile ncf = null;
    try
    {
      ncf = NetcdfFile.open( testDataFileOut );
    }
    catch ( IOException e )
    {
      assertTrue( "Couldn't open file <" + testDataFileOut + ">: " + e.getMessage(),
                  false );
      return;
    }

    Dimension timeDim = ncf.getRootGroup().findDimension( "time");
    int timeDimSize = timeDim.getLength();
    Variable timeVar = ncf.getRootGroup().findVariable( "time");
    Variable latVar = ncf.getRootGroup().findVariable( "latitude");
    Variable lonVar = ncf.getRootGroup().findVariable( "longitude");
    Variable altVar = ncf.getRootGroup().findVariable( "altitude");

    Attribute timeUnits = timeVar.findAttribute( "units");
    String newUnits = "test unit string";
    System.out.println( "Switching time units from \"" + timeUnits.toString() + " \" to \"" + newUnits + "\"" );
    timeVar.addAttribute( new Attribute( "units", newUnits) );

    Array latArray;
    try
    {
      latArray = latVar.read();
    }
    catch ( IOException e )
    {
      assertTrue( "Couldn't read latitude data: " + e.getMessage(),
                  false );
      return;
    }

    try { Thread.sleep( 5000);
    }
    catch ( InterruptedException e ) {
    }

    boolean extended;
    try
    {
      extended = ncf.syncExtend();
    }
    catch ( IOException e )
    {
      assertTrue( "Couldn't syncExtend() file <" + testDataFileOut + ">: " + e.getMessage(),
                  false );
      return;
    }

    if ( ! extended )
    {
      System.out.println( "Did not extend file <" + testDataFileOut + ">." );
    }

    Dimension timeDim2 = ncf.getRootGroup().findDimension( "time");
    if ( timeDim == timeDim2 )
      System.out.println( "Time dimension the same." );
    else
      System.out.println( "Time dimension not the same." );

    System.out.println( "Initial time dim size = " + timeDimSize );
    System.out.println( "New time dim size = " + timeDim2.getLength() );
    System.out.println( "New time dim size (1) = " + timeDim.getLength() );

    System.out.println( "Time var units string: " + timeVar.findAttribute( "units").toString() );

    if ( latVar == ncf.getRootGroup().findVariable( "latitude"))
      System.out.println( "Lat var the same." );
    else
      System.out.println( "Lat var not the same." );
  }
View Full Code Here

      }
    }
  }

  public void checkFile(String url) throws IOException {
    NetcdfFile file = null;
    try {
      file = NetcdfFile.open(url, null);
      System.out.printf("%s%n", file);
      assert file.findVariable(newVarName) != null;
    } finally {
      if (file != null) {
        file.close();
      }
    }
  }
View Full Code Here

  }

   public static void main( String arg[]) throws Exception {
     //TestReadandCount.doOne("Q:/grid/grib/grib1/data/", "ukm.wmo", -1, -1, -1, -1);

     NetcdfFile ncfile = NetcdfFile.open("//shemp/testdata/grid/grib/grib1/data/ukm.wmo", null);
     NetcdfFile ncfile1 = NetcdfFile.open("//shemp/testdata/grid/grib/grib1/data/ukm1.wmo", null);
     CompareNetcdf.compareFiles(ncfile, ncfile1, false, false, false);
  }
View Full Code Here

          throws IOException, InvalidRangeException
  {
    int[] origin = new int[] { j, i};
    int[] shape = new int[] {1,1};

    NetcdfFile ncf = NetcdfFile.open( datasetLocation);
    Variable latVar = ncf.findVariable( "lat" );
    Array latArray = latVar.read( origin, shape );
    Variable lonVar = ncf.findVariable( "lon" );
    Array lonArray = lonVar.read( origin, shape );

    double latVal = latArray.getDouble( latArray.getIndex());
    double lonVal = lonArray.getDouble( lonArray.getIndex());
View Full Code Here

            SAXException, TikaException {

        ByteArrayOutputStream os = new ByteArrayOutputStream();
        this.writeStreamToMemory(stream, os);

        NetcdfFile ncFile = NetcdfFile.openInMemory("", os.toByteArray());

        // first parse out the set of global attributes
        for (Attribute attr : ncFile.getGlobalAttributes()) {
            String attrName = attr.getName();
            if (attr.getDataType().isString()) {
                metadata.add(attrName, attr.getStringValue());
            } else if (attr.getDataType().isNumeric()) {
                metadata.add(attrName, String.valueOf(attr.getNumericValue()
View Full Code Here

            Metadata metadata, ParseContext context) throws IOException,
            SAXException, TikaException {
        ByteArrayOutputStream os = new ByteArrayOutputStream();
        this.writeStreamToMemory(stream, os);

        NetcdfFile ncFile = NetcdfFile.openInMemory("", os.toByteArray());
        this.unravelStringMet(ncFile, null, metadata);
    }
View Full Code Here

     * @throws IOException If an error occurred while opening the NetCDF file.
     * @throws DataStoreException Should never happen.
     */
    @Test
    public void testCanOpenFromUCAR() throws IOException, DataStoreException {
        final NetcdfFile file = open(NCEP);
        final StorageConnector c = new StorageConnector(file);
        final NetcdfStoreProvider provider = new NetcdfStoreProvider();
        assertTrue(provider.canOpen(c));
        file.close();
    }
View Full Code Here

        if (name == null) {
            name = "";
        }

        try {
            NetcdfFile ncFile = NetcdfFile.openInMemory(name, os.toByteArray());

            // first parse out the set of global attributes
            for (Attribute attr : ncFile.getGlobalAttributes()) {
                Property property = resolveMetadataKey(attr.getName());
                if (attr.getDataType().isString()) {
                    metadata.add(property, attr.getStringValue());
                } else if (attr.getDataType().isNumeric()) {
                    int value = attr.getNumericValue().intValue();
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.