Package com.google.api.ads.dfp.axis.v201208

Examples of com.google.api.ads.dfp.axis.v201208.Dimension


      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

      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"))
View Full Code Here

      return false;
    return true;
  }

  public TableConfig getConfig(FeatureType wantFeatureType, NetcdfDataset ds, Formatter errlog) {
    Dimension stationDim = CoordSysEvaluator.findDimensionByType(ds, AxisType.Lat);
    if (stationDim == null) {
      errlog.format("Must have a latitude coordinate");
      return null;
    }

    Variable stationVar = ds.findVariable(stationDim.getName());
    if (stationVar == null) {
      errlog.format("Must have a station coordinate variable");
      return null;
    }

    Dimension obsDim = CoordSysEvaluator.findDimensionByType(ds, AxisType.Time);
    if (obsDim == null) {
      errlog.format("Must have a Time coordinate");
      return null;
    }

    // station table
    TableConfig stationTable = new TableConfig(Table.Type.Structure, "station");
    stationTable.structName = "station";
    stationTable.structureType = TableConfig.StructureType.PsuedoStructure;
    stationTable.featureType = FeatureType.STATION;
    stationTable.dimName = stationDim.getName();

    stationTable.stnId = stationVar.getShortName();

    stationTable.lat = CoordSysEvaluator.findCoordNameByType(ds, AxisType.Lat);
    stationTable.lon = CoordSysEvaluator.findCoordNameByType(ds, AxisType.Lon);
    stationTable.stnAlt = CoordSysEvaluator.findCoordNameByType(ds, AxisType.Height);

    // obs table
    TableConfig obsTable;
    obsTable = new TableConfig(Table.Type.MultidimInner, "obs");
    obsTable.time = CoordSysEvaluator.findCoordNameByType(ds, AxisType.Time);
    obsTable.outerName = stationDim.getName();
    obsTable.dimName = obsDim.getName();

    stationTable.addChild(obsTable);
    return stationTable;
  }
View Full Code Here

TOP

Related Classes of com.google.api.ads.dfp.axis.v201208.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.