Package io

Examples of io.ADXInterpreter$Variable


    //H4header.setDebugFlags(new ucar.nc2.util.DebugFlagsImpl("H4header/linked"));

    //TestAll.readAll("E:/problem/MAC021S0.A2007287.1920.002.2007289002404.hdf");

    NetcdfFile ncfile = NetcdfFile.open("R:\\testdata\\hdf4\\c402_rp_02.diag.sfc.20020122_0130z.hdf");
    Variable v = ncfile.findVariable("MOD_Grid_MOD17A2/Data Fields/PsnNet_1km");
    assert v != null;
    v.read();
    ncfile.close();
  }
View Full Code Here


  public void testUnsigned() throws IOException, InvalidRangeException {
    String filename = testDir + "MOD021KM.A2004328.1735.004.2004329164007.hdf";
    NetcdfFile ncfile = NetcdfFile.open(filename);
    String vname = "/MODIS_SWATH_Type_L1B/Data Fields/EV_250_Aggr1km_RefSB";
    Variable v = ncfile.findVariable(vname);
    assert v != null : filename+" "+vname;

    Array data = v.read();
    System.out.printf(" sum =          %f%n", MAMath.sumDouble(data));

    double sum2 = 0;
    double sum3 = 0;
    int[] varShape = v.getShape();
    int[] origin = new int[3];
    int[] size = new int[]{1, varShape[1], varShape[2]};
    for (int i = 0; i < varShape[0]; i++) {
      origin[0] = i;
      Array data2D = v.read(origin, size);

      double sum = MAMath.sumDouble(data2D);
      System.out.printf("  %d sum3D =        %f%n", i, sum);
      sum2 += sum;
View Full Code Here

    int recsize = vinfo.elemSize;

    // create the ArrayStructure
    StructureMembers members = s.makeStructureMembers();
    for (StructureMembers.Member m : members.getMembers()) {
      Variable v2 = s.findVariable(m.getName());
      H4header.Minfo minfo = (H4header.Minfo) v2.getSPobject();
      m.setDataParam(minfo.offset);
    }
    members.setStructureSize(recsize);
    ArrayStructureBB structureArray = new ArrayStructureBB(members, section.getShape())// LOOK subset
View Full Code Here

    return structureArray;
  }

  public String toStringDebug(Object o) {
    if (o instanceof Variable) {
      Variable v = (Variable) o;
      H4header.Vinfo vinfo = (H4header.Vinfo) v.getSPobject();
      return (vinfo != null) ? vinfo.toString() : "";
    }
    return null;
  }
View Full Code Here

    for (int i=0; i<10; i++) {
      String ncmli = StringUtil.replace(ncml,'%',Integer.toString(i));
      NetcdfFile ncfile = NcMLReader.readNcML(new StringReader(ncmli), filename, null);
      System.out.println(" TestNcmlAggExisting.open "+ filename);

      Variable timev = ncfile.findVariable("time");
      Array timeD = timev.read();

      int count1 = RandomAccessFile.getOpenFiles().size();
      System.out.printf("count files at dir %d count= %d%n", i, count1);
      ncfile.close();
    }
View Full Code Here

        ncfile = NetcdfFile.open(filename);
        Group root = ncfile.getRootGroup();
        Group g = root.findGroup("HDFEOS INFORMATION");
        if (g == null) g = ncfile.getRootGroup();

        Variable dset = g.findVariable("StructMetadata.0");
        if (dset != null) {
          System.out.println("EOS file=" + filename);
          return 1;
        }
View Full Code Here

    System.out.printf("ncml=%s%n", ncml);
    String filename = "file:" + TestNcML.topDir + "testAggModify.ncml";
    NetcdfFile ncfile = NcMLReader.readNcML(new StringReader(ncml), filename, null);
    System.out.println(" TestNcmlAggExisting.open " + filename + "\n" + ncfile);

    Variable v = ncfile.findVariable("T");
    assert null != v;

    v = ncfile.findVariable("P");
    assert null == v;
View Full Code Here

    String filename = "file:./"+ TestNcML.topDir + "aggExisting1.xml";

    NetcdfFile ncfile = NcMLReader.readNcML( new StringReader(xml), null);
    System.out.println(" TestNcmlAggExisting.open "+ filename);

    Variable times = ncfile.findVariable("times");
    assert null != times;
    assert times.getRank() == 1;
    assert times.getSize() == 3;

    assert times.getDimension(0).getName().equals("time");
  }
View Full Code Here

    readHDR();

    ncfile.addDimension(null, new Dimension("lat", nlats));
    ncfile.addDimension(null, new Dimension("lon", nlons));

    Variable elev = new Variable(ncfile, null, null, "elevation");
    elev.setDataType(DataType.SHORT);
    elev.setDimensions("lat lon");

    elev.addAttribute(new Attribute("units", "m"));
    elev.addAttribute(new Attribute("units_desc", "meters above sea level"));
    elev.addAttribute(new Attribute("long_name", "digital elevation in meters above mean sea level"));
    elev.addAttribute(new Attribute("missing_value", (short) -9999));
    ncfile.addVariable(null, elev);

    Variable lat = new Variable(ncfile, null, null, "lat");
    lat.setDataType(DataType.FLOAT);
    lat.setDimensions("lat");
    lat.addAttribute(new Attribute("units", "degrees_north"));
    ncfile.addVariable(null, lat);
    Array data = Array.makeArray(DataType.FLOAT, nlats, starty, -incr);
    lat.setCachedData(data, false);

    Variable lon = new Variable(ncfile, null, null, "lon");
    lon.setDataType(DataType.FLOAT);
    lon.setDimensions("lon");
    lon.addAttribute(new Attribute("units", "degrees_east"));
    ncfile.addVariable(null, lon);
    Array lonData = Array.makeArray(DataType.FLOAT, nlons, startx, incr);
    lon.setCachedData(lonData, false);

    ncfile.addAttribute(null, new Attribute("Conventions", "CF-1.0"));
    ncfile.addAttribute(null, new Attribute("History", "Direct read by Netcdf-Java CDM library"));
    ncfile.addAttribute(null, new Attribute("Source", "http://eros.usgs.gov/products/elevation/gtopo30.html"));
View Full Code Here

   try {

     dataFile = NetcdfFile.open(filename, null);

     // Get the latitude and longitude Variables.
     Variable latVar = dataFile.findVariable("latitude");
     if (latVar == null) {
       System.out.println("Cant find Variable latitude");
       return;
     }

     Variable lonVar = dataFile.findVariable("longitude");
     if (lonVar == null) {
       System.out.println("Cant find Variable longitude");
       return;
     }

     // Get the lat/lon data from the file.
     ArrayFloat.D1 latArray;
     ArrayFloat.D1 lonArray;

     latArray = (ArrayFloat.D1) latVar.read();
     lonArray = (ArrayFloat.D1) lonVar.read();


     // Check the coordinate variable data.
     for (int lat = 0; lat < NLAT; lat++)
       if (latArray.get(lat) != START_LAT + 5. * lat)
         System.err.println("ERROR incorrect value in variable latitude");

     for (int lon = 0; lon < NLON; lon++)
       if (lonArray.get(lon) != START_LON + 5. * lon)
         System.err.println("ERROR incorrect value in variable longtitude");

     // Get the pressure and temperature variables.
     Variable presVar = dataFile.findVariable("pressure");
     if (presVar == null) {
       System.out.println("Cant find Variable pressure");
       return;
     }

     Variable tempVar = dataFile.findVariable("temperature");
     if (lonVar == null) {
       System.out.println("Cant find Variable temperature");
       return;
     }

     int [] shape = presVar.getShape();
     int recLen = shape[0]; // number of times

     int[] origin = new int[4];
     shape[0] = 1; // only one rec per read

     // loop over the rec dimension
     for (int rec = 0; rec < recLen; rec++) {
       origin[0] = rec;  // read this index

       // read 3D array for that index
       ArrayFloat.D3 presArray, tempArray;

       presArray = (ArrayFloat.D3) (presVar.read(origin, shape).reduce());
       tempArray = (ArrayFloat.D3) (tempVar.read(origin, shape).reduce());


       // now checking the value
       int count = 0;
       for (int lvl = 0; lvl < NLVL; lvl++)
View Full Code Here

TOP

Related Classes of io.ADXInterpreter$Variable

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.