Package ucar.nc2

Examples of ucar.nc2.VariableSimpleIF


        List<Dimension> dims = new ArrayList<Dimension>();
        dims.add( scanDim);
        dims.add( radialDim);
        dims.add( gateDim);

        Variable v = new Variable(ncfile, null, null, shortName+abbrev);
        v.setDataType(DataType.SHORT);
        v.setDimensions(dims);
        ncfile.addVariable(null, v);

        v.addAttribute( new Attribute("units", firstRay.getDatatypeUnits(abbrev)));
        v.addAttribute( new Attribute("long_name", longName));
        v.addAttribute( new Attribute("abbrev", abbrev));
        v.addAttribute( new Attribute("missing_value", firstRay.getMissingData()));
        v.addAttribute( new Attribute("signal_below_threshold", firstRay.getDatatypeRangeFoldingThreshhold(abbrev)));
        v.addAttribute( new Attribute("scale_factor", firstRay.getDatatypeScaleFactor(abbrev)));
        v.addAttribute( new Attribute("add_offset", firstRay.getDatatypeAddOffset(abbrev)));
       // v.addAttribute( new Attribute("_Unsigned", "false"));

        v.addAttribute( new Attribute("range_folding_threshold" ,firstRay.getDatatypeRangeFoldingThreshhold(abbrev)));

        List<Dimension> dim2 = new ArrayList<Dimension>();
        dim2.add( scanDim);
        dim2.add( radialDim);

        // add time coordinate variable
        String timeCoordName = "time"+abbrev;
        Variable timeVar = new Variable(ncfile, null, null, timeCoordName);
        timeVar.setDataType(DataType.INT);
        timeVar.setDimensions(dim2);
        ncfile.addVariable(null, timeVar);


        // int julianDays = volScan.getTitleJulianDays();
        // Date d = Level2Record.getDate( julianDays, 0);
        Date d = firstRay.getDate();
        String units = "msecs since "+formatter.toDateTimeStringISO(d);

        timeVar.addAttribute( new Attribute("long_name", "time since base date"));
        timeVar.addAttribute( new Attribute("units", units));
        timeVar.addAttribute( new Attribute("missing_value", firstRay.getMissingData()));
        timeVar.addAttribute( new Attribute(_Coordinate.AxisType, AxisType.Time.toString()));

        // add elevation coordinate variable
        String elevCoordName = "elevation"+abbrev;
        Variable elevVar = new Variable(ncfile, null, null, elevCoordName);
        elevVar.setDataType(DataType.FLOAT);
        elevVar.setDimensions(dim2);
        ncfile.addVariable(null, elevVar);

        elevVar.addAttribute( new Attribute("units", "degrees"));
        elevVar.addAttribute( new Attribute("long_name", "elevation angle in degres: 0 = parallel to pedestal base, 90 = perpendicular"));
        elevVar.addAttribute( new Attribute("missing_value", firstRay.getMissingData()));
        elevVar.addAttribute( new Attribute(_Coordinate.AxisType, AxisType.RadialElevation.toString()));

        // add azimuth coordinate variable
        String aziCoordName = "azimuth"+abbrev;
        Variable aziVar = new Variable(ncfile, null, null, aziCoordName);
        aziVar.setDataType(DataType.FLOAT);
        aziVar.setDimensions(dim2);
        ncfile.addVariable(null, aziVar);

        aziVar.addAttribute( new Attribute("units", "degrees"));
        aziVar.addAttribute( new Attribute("long_name", "azimuth angle in degrees: 0 = true north, 90 = east"));
        aziVar.addAttribute( new Attribute("missing_value", firstRay.getMissingData()));
        aziVar.addAttribute( new Attribute(_Coordinate.AxisType, AxisType.RadialAzimuth.toString()));

        // add gate coordinate variable
        String gateCoordName = "distance"+abbrev;
        Variable gateVar = new Variable(ncfile, null, null, gateCoordName);
        gateVar.setDataType(DataType.FLOAT);
        gateVar.setDimensions(gateDimName);
        Array data = Array.makeArray( DataType.FLOAT, ngates,
            (double) firstRay.getGateStart(abbrev), (double) firstRay.getGateSize(abbrev));
        gateVar.setCachedData( data, false);
        ncfile.addVariable(null, gateVar);
  //      radarRadius = firstRay.getGateStart(datatype) + ngates * firstRay.getGateSize(datatype);

        gateVar.addAttribute( new Attribute("units", "m"));
        gateVar.addAttribute( new Attribute("long_name", "radial distance to start of gate"));
        gateVar.addAttribute( new Attribute(_Coordinate.AxisType, AxisType.RadialDistance.toString()));

        // add number of radials variable
        String nradialsName = "numRadials"+abbrev;
        Variable nradialsVar = new Variable(ncfile, null, null, nradialsName);
        nradialsVar.setDataType(DataType.INT);
        nradialsVar.setDimensions(scanDim.getName());
        nradialsVar.addAttribute( new Attribute("long_name", "number of valid radials in this scan"));
        ncfile.addVariable(null, nradialsVar);

        // add number of gates variable
        String ngateName = "numGates"+abbrev;
        Variable ngateVar = new Variable(ncfile, null, null, ngateName);
        ngateVar.setDataType(DataType.INT);
        ngateVar.setDimensions(scanDim.getName());
        ngateVar.addAttribute( new Attribute("long_name", "number of valid gates in this scan"));
        ncfile.addVariable(null, ngateVar);

        makeCoordinateDataWithMissing(abbrev, timeVar, elevVar, aziVar, nradialsVar, ngateVar, groups);

        // back to the data variable
View Full Code Here


  public void problemV() throws IOException {
    H5header.setDebugFlags(new ucar.nc2.util.DebugFlagsImpl("H5header/header"));
    String filename = testDir + "ssec-h5/MYD04_L2.A2006188.1830.005.2006194121515.hdf";
    NetcdfFile ncfile = NetcdfFile.open(filename);
    Variable v = ncfile.findVariable("/U-MARF/EPS/IASI_xxx_1C/DATA/SPECT_LAT_ARRAY");
    Array data = v.read();
    System.out.println("\n**** testReadNetcdf4 done\n\n" + ncfile);
    NCdump.printArray(data, "primary_cloud", System.out, null);
    ncfile.close();
  }
View Full Code Here

        String         vName = var.getShortName();
        int            tIdx  = var.findDimensionIndex("time");
        int            rIdx  = var.findDimensionIndex("range");

        if ((tIdx == 0) && (rIdx == 1)) {
            VariableSimpleIF v = new MyRadialVariableAdapter(vName,
                                     var.getAttributes());
            rsvar = makeRadialVariable(nds, v, var);
        }

        if (rsvar != null) {
View Full Code Here

        RadialVariable rsvar = null;
        String vName = var.getShortName() ;
        int rnk = var.getRank();

        if(rnk == 2)  {
            VariableSimpleIF v = new MyRadialVariableAdapter(vName, var.getAttributes());
            rsvar = makeRadialVariable(nds, v, var);
        }

        if(rsvar != null)
            dataVariables.add(rsvar);
View Full Code Here

        int rnk = var.getRank();

        setIsVolume(nds);

        if(isVolume && rnk == 3) {
            VariableSimpleIF v = new MyRadialVariableAdapter(vName, var.getAttributes());
            rsvar = makeRadialVariable(nds, v, var);
        } else if(!isVolume && rnk == 2) {
            VariableSimpleIF v = new MyRadialVariableAdapter(vName, var.getAttributes());
            rsvar = makeRadialVariable(nds, v, var);
        }

        if(rsvar != null)
            dataVariables.add(rsvar);
View Full Code Here

    // grids
    List vars = sobs.getDataVariables();
    Collections.sort(vars);
    for (int i = 0; i < vars.size(); i++) {
      VariableSimpleIF v = (VariableSimpleIF) vars.get(i);
      rootElem.addContent(writeVariable(v));
    }

    /* global attributes
    Iterator atts = sobs.getGlobalAttributes().iterator();
View Full Code Here

    RadialVariable rsvar = null;
    String vName = var.getShortName();
    int rnk = var.getRank();

    if (!var.getShortName().endsWith("RAW") && rnk == 2) {
      VariableSimpleIF v = new MyRadialVariableAdapter(vName, var.getAttributes());
      rsvar = new Nids2Variable(nds, v, var);
    }

    if (rsvar != null)
      dataVariables.add(rsvar);
View Full Code Here

  protected abstract void setBoundingBox(); // reminder for subclasses to set this

  protected void removeDataVariable( String varName) {
    Iterator iter = dataVariables.iterator();
    while (iter.hasNext()) {
      VariableSimpleIF v = (VariableSimpleIF) iter.next();
      if (v.getShortName().equals( varName) )
        iter.remove();
    }
  }
View Full Code Here

      assert d1.before(d2) || d1.equals(d2);

    List dataVars = fdataset.getDataVariables();
    assert dataVars != null;
    for (int i = 0; i < dataVars.size(); i++) {
      VariableSimpleIF v = (VariableSimpleIF) dataVars.get(i);
      assert null != fdataset.getDataVariable(v.getShortName());
    }

    // FeatureDatasetPoint
    assert fdataset instanceof FeatureDatasetPoint;
    FeatureDatasetPoint fdpoint = (FeatureDatasetPoint) fdataset;
View Full Code Here

    List dataVars = trajDs.getDataVariables();
    assertTrue( "Data vars list is null.",
                dataVars != null );
    assertTrue( "Size of data vars list <" + dataVars.size() + "> not as expected <" + trajDsInfo.getNumVars() + ">.",
                dataVars.size() == trajDsInfo.getNumVars() );
    VariableSimpleIF tdv = trajDs.getDataVariable( trajDsInfo.getExampleVarName() );
    assertTrue( "Variable \"" + trajDsInfo.getExampleVarName() + "\" not found.",
                tdv != null );
    assertTrue( "Variable name <" + tdv.getShortName() + "> not as expected <" + trajDsInfo.getExampleVarName() + ">.",
                tdv.getShortName().equals( trajDsInfo.getExampleVarName() ) );
    assertTrue( "Variable description <" + tdv.getDescription() + "> not as expected <" + trajDsInfo.getExampleVarDescription() + ">.",
                tdv.getDescription().equals( trajDsInfo.getExampleVarDescription() ) );
    assertTrue( "Variable units <" + tdv.getUnitsString() + "> not convertable to <" + trajDsInfo.getExampleVarUnitsString() + ">.",
                tdv.getUnitsString().equals( trajDsInfo.getExampleVarUnitsString() ) ||
                SimpleUnit.isCompatible( tdv.getUnitsString(), trajDsInfo.getExampleVarUnitsString() ) );
    assertTrue( "Variable rank <" + tdv.getRank() + "> not as expected <" + trajDsInfo.getExampleVarRank() + ">.",
                tdv.getRank() == trajDsInfo.getExampleVarRank() );
    assertTrue( "Variable shape <" + toStringIntArray( tdv.getShape() ) + "> not as expected <" + toStringIntArray( trajDsInfo.getExampleVarShape() ) + ">.",
                compareIntArray( tdv.getShape(), trajDsInfo.getExampleVarShape() ) );
    assertTrue( "Variable data type <" + tdv.getDataType() + "> not as expected <" + trajDsInfo.getExampleVarDataType() + ">.",
                tdv.getDataType().equals( DataType.getType( trajDsInfo.getExampleVarDataType()) ) );
    assertTrue( "Num variable attributes <" + tdv.getAttributes().size() + "> not as expected <" + trajDsInfo.getExampleVarNumAtts() + ">.",
                tdv.getAttributes().size() == trajDsInfo.getExampleVarNumAtts() );

    // Check the underlying nc file.
    assertTrue( "Underlying netCDF file <" + trajDs.getNetcdfFile().getLocation() + "> not as expected <" + trajDsInfo.getLocationURI() + ">.",
                trajDs.getNetcdfFile().getLocation().equals( trajDsInfo.getLocationURI() ) );
View Full Code Here

TOP

Related Classes of ucar.nc2.VariableSimpleIF

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.