Package ucar.nc2

Examples of ucar.nc2.Dimension


    if ( ! gribInit_1_8() ) return false;

    netcdfObj = openNc( ncObjType, gribIospVer );

    int timeDimLengthExpected = 8;
    Dimension timeDim = netcdfObj.findDimension( "time" );
    assertEquals( "Length of time dimension [" + timeDim.getLength() + "] not as expected [" + timeDimLengthExpected + "].",
                  timeDim.getLength(),
                  timeDimLengthExpected );

    // Setup 2: data file (1-8), index file (1-8, CHANGE).
    //          [Sync should not use index in cache. HOW TO TEST?]
    if ( ! indexSetup1_8() ) return false;

    if ( ! syncNc( netcdfObj ) ) return false;

    timeDim = netcdfObj.findDimension( "time" );
    assertEquals( "Length of time dimension [" + timeDim.getLength() + "] not as expected [" + timeDimLengthExpected + "].",
                  timeDim.getLength(),
                  timeDimLengthExpected );

    // Setup 3: data file (1-12, CHANGE), index file (1-8).
    if ( ! gribAppend9_12()) return false;

    if ( ! syncNc( netcdfObj ) ) return false;

    timeDim = netcdfObj.findDimension( "time" );
    assertEquals( "Length of time dimension [" + timeDim.getLength() + "] not as expected [" + timeDimLengthExpected + "].",
                  timeDim.getLength(),
                  timeDimLengthExpected );

    // Setup 4: data file (1-12), index file (1-12, CHANGE).
    if ( ! indexSetup1_12()) return false;

    if ( ! syncNc( netcdfObj ) ) return false;

    timeDimLengthExpected = 12;
    timeDim = netcdfObj.findDimension( "time" );
    assertEquals( "Length of time dimension [" + timeDim.getLength() + "] not as expected [" + timeDimLengthExpected + "].",
                  timeDim.getLength(),
                  timeDimLengthExpected );

    // Setup 5: data file (1-18, CHANGE), index file (1-12).
    if ( ! gribAppend13_18()) return false;

    if ( ! syncNc( netcdfObj ) ) return false;

    timeDim = netcdfObj.findDimension( "time" );
    assertEquals( "Length of time dimension [" + timeDim.getLength() + "] not as expected [" + timeDimLengthExpected + "].",
                  timeDim.getLength(),
                  timeDimLengthExpected );

    // Setup 6: data file (1-18), index file (1-18, CHANGE).
    if ( ! indexSetup1_18()) return false;

    if ( ! syncNc( netcdfObj ) ) return false;

    timeDimLengthExpected = 18;
    timeDim = netcdfObj.findDimension( "time" );
    assertEquals( "Length of time dimension [" + timeDim.getLength() + "] not as expected [" + timeDimLengthExpected + "].",
                  timeDim.getLength(),
                  timeDimLengthExpected );

    // Setup 7: data file (1-21, CHANGE), index file (1-21, CHANGE).
    if ( ! gribAppend19_21()) return false;
    if ( ! indexSetup1_21()) return false;

    if ( ! syncNc( netcdfObj ) ) return false;

    timeDimLengthExpected = 21;
    timeDim = netcdfObj.findDimension( "time" );
    assertEquals( "Length of time dimension [" + timeDim.getLength() + "] not as expected [" + timeDimLengthExpected + "].",
                  timeDim.getLength(),
                  timeDimLengthExpected );

    DiskCache.simulateUnwritableDir = false;

    return true;
View Full Code Here


    catch ( IOException e )
    {
      fail( "exception opening");
    }

    Dimension timePartial = netcdfObj.findDimension( "time" );

    assertTrue( "Time dimension ["+ timePartial.getLength()+"] not as expected [4].", timePartial.getLength() == 4 );

    // Switch to use the complete GRIB file.
    if ( ! switchToCompleteGrib() )
      return;

    if ( ! switchToCompleteGribIndex() )
      return;

    // sync() the dataset with new index.
    try
    {
      netcdfObj.sync();
    }
    catch ( IOException e )
    {
      fail( "Failed to sync() data file [" + dataFile.getPath() + "]: " + e.getMessage() );
      return;
    }

    Dimension timeNew = netcdfObj.findDimension( "time" );

    assertTrue( "Time dimension [" + timeNew.getLength() + "] not as expected [21].", timeNew.getLength() == 21 );
    DiskCache.simulateUnwritableDir = false;
  }
View Full Code Here

      catch ( IOException e )
      {
        fail( "exception opening");
      }

      Dimension timePartial = netcdfObj.findDimension( "time" );

      assertTrue( "Time dimension ["+ timePartial.getLength()+"] not as expected [4].", timePartial.getLength() == 4 );

      // Switch to use the complete GRIB file.
      if ( ! switchToCompleteGrib() )
        return;

      try
      {
        netcdfObj.sync();
      }
      catch ( IOException e )
      {
        fail( "Failed to sync() data file [" + dataFile.getPath() + "]: " + e.getMessage() );
        return;
      }

      Dimension timeNew = netcdfObj.findDimension( "time" );

      assertTrue( "Time dimension [" + timeNew.getLength() + "] not as expected [21].", timeNew.getLength() == 21 );
    }
View Full Code Here

    catch ( IOException e )
    {
      fail( "exception opening");
    }

    Dimension timeComplete = netcdfObj.findDimension( "time" );

    assertTrue( "Time dimension ["+ timeComplete.getLength()+"] not as expected [21].", timeComplete.getLength() == 21 );

    // sync() the dataset with  index.
    try
    {
      netcdfObj.sync();
    }
    catch ( IOException e )
    {
      fail( "Failed to sync() data file [" + dataFile.getPath() + "]: " + e.getMessage() );
      return;
    }

    Dimension timeNew = netcdfObj.findDimension( "time" );

    assertTrue( "Time dimension [" + timeNew.getLength() + "] not as expected [21].", timeNew.getLength() == 21 );

  }
View Full Code Here

      try {
        System.out.println("Open "+grib);
        NetcdfFile ncf = NetcdfFile.open( grib );
        Variable var = ncf.findVariable( parameter );
        Dimension dim = var.getDimension( 0 );
        String bounds = dim.getName() +"_bounds";
        Variable interval = ncf.findVariable( bounds );
        Array data = interval.read();
        IndexIterator iter = data.getIndexIterator();
        int idx = 0;
        while (iter.hasNext()) {
View Full Code Here

      assert (Hybrida.getNameAndDimensions().equals("hybrida(hybrid=91)"));
      Variable Hybridb = ncfile.findVariable("hybridb");
      assert (Hybridb.getNameAndDimensions().equals("hybridb(hybrid=91)"));

      int idx = Hybrid.findDimensionIndex("hybrid");
      Dimension dim = Hybrid.getDimension(idx);

    } else if (filename.equals("07010418_arw_d01.GrbF01500")) {
      Variable Hybrid = ncfile.findVariable("hybrid");
      assert (Hybrid.getNameAndDimensions().equals("hybrid(hybrid=2)"));
    }
View Full Code Here

    if ( ! indexSetup1_8() ) return false;

    netcdfObj = openNc( ncObjType, gribIospVer );

    int timeDimLengthExpected = 8;
    Dimension timeDim = netcdfObj.findDimension( "time" );
    assertEquals( "Length of time dimension [" + timeDim.getLength() + "] not as expected [" + timeDimLengthExpected + "].",
                  timeDim.getLength(),
                  timeDimLengthExpected );

    // Setup 2: data file (1-12, CHANGE), index file (1-8).
    if ( ! gribAppend9_12() ) return false;
    if ( ! syncNc( netcdfObj ) ) return false;

    timeDim = netcdfObj.findDimension( "time" );
    assertEquals( "Length of time dimension [" + timeDim.getLength() + "] not as expected [" + timeDimLengthExpected + "].",
                  timeDim.getLength(),
                  timeDimLengthExpected );

    // Setup 2: data file (1-12), index file (1-12, CHANGE).
    if ( ! indexSetup1_12() ) return false;
    if ( ! syncNc( netcdfObj ) ) return false;

    timeDimLengthExpected = 12;
    timeDim = netcdfObj.findDimension( "time" );
    assertEquals( "Length of time dimension [" + timeDim.getLength() + "] not as expected [" + timeDimLengthExpected + "].",
                  timeDim.getLength(),
                  timeDimLengthExpected );

    // Setup 2: data file (1-18, CHANGE), index file (1-18, CHANGE).
    if ( ! gribAppend13_18() ) return false;
    if ( ! indexSetup1_18() ) return false;
    if ( ! syncNc( netcdfObj ) ) return false;

    timeDimLengthExpected = 18;
    timeDim = netcdfObj.findDimension( "time" );
    assertEquals( "Length of time dimension [" + timeDim.getLength() + "] not as expected [" + timeDimLengthExpected + "].",
                  timeDim.getLength(),
                  timeDimLengthExpected );

    // Setup 2: data file (1-21, CHANGE), index file (1-21, CHANGE).
    if ( ! gribAppend19_21() ) return false;
    if ( ! indexSetup1_21() ) return false;

    if ( ! syncNc( netcdfObj ) ) return false;

    timeDimLengthExpected = 21;
    timeDim = netcdfObj.findDimension( "time" );
    assertEquals( "Length of time dimension [" + timeDim.getLength() + "] not as expected [" + timeDimLengthExpected + "].",
                  timeDim.getLength(),
                  timeDimLengthExpected );

    return true;
  }
View Full Code Here

    if ( ! gribAppend9_12() ) return false;

    netcdfObj = openNc( ncObjType, gribIospVer );

    int timeDimLengthExpected = 8;
    Dimension timeDim = netcdfObj.findDimension( "time" );
    assertEquals( "Length of time dimension [" + timeDim.getLength() + "] not as expected [" + timeDimLengthExpected + "].",
                  timeDim.getLength(),
                  timeDimLengthExpected );

    // Setup 2: data file (1-12), index file (1-12, CHANGE).
    if ( ! indexSetup1_12() ) return false;
    if ( ! syncNc( netcdfObj ) ) return false;

    timeDimLengthExpected = 12;
    timeDim = netcdfObj.findDimension( "time" );
    assertEquals( "Length of time dimension [" + timeDim.getLength() + "] not as expected [" + timeDimLengthExpected + "].",
                  timeDim.getLength(),
                  timeDimLengthExpected );

    // Setup 3: data file (1-18, CHANGE), index file (1-18, CHANGE).
    if ( ! gribAppend13_18() ) return false;
    if ( ! indexSetup1_18() ) return false;
    if ( ! syncNc( netcdfObj ) ) return false;

    timeDimLengthExpected = 18;
    timeDim = netcdfObj.findDimension( "time" );
    assertEquals( "Length of time dimension [" + timeDim.getLength() + "] not as expected [" + timeDimLengthExpected + "].",
                  timeDim.getLength(),
                  timeDimLengthExpected );

    return true;
  }
View Full Code Here

        }
      }

      private void testRead( NetcdfFile nexrad2) throws IOException {
        Dimension scanR = nexrad2.findDimension("scanR");
        assert null != scanR;
        Dimension scanR_HI = nexrad2.findDimension("scanR_HI");
        assert null != scanR_HI;
        Dimension scanV = nexrad2.findDimension("scanV");
        assert null != scanV;
        Dimension scanV_HI = nexrad2.findDimension("scanV_HI");
        assert null != scanV_HI;

        assert scanR.getLength() == scanV.getLength();

        Variable elevR =  nexrad2.findVariable("elevationR");
View Full Code Here

        if(v != null)
            data = v.read();
      }

      private void testCoordSystem( NetcdfFile nexrad2) throws IOException {
        Dimension scanR = nexrad2.findDimension("scanR");
        assert null != scanR;
        Dimension scanR_HI = nexrad2.findDimension("scanR_HI");
        assert null != scanR_HI;
        Dimension scanV = nexrad2.findDimension("scanV");
        assert null != scanV;
        Dimension scanV_HI = nexrad2.findDimension("scanV_HI");
        assert null != scanV_HI;

        assert scanR.getLength() == scanV.getLength();

        Variable elevR =  nexrad2.findVariable("elevationR");
View Full Code Here

TOP

Related Classes of ucar.nc2.Dimension

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.