Package kameleon.document2

Examples of kameleon.document2.Array


    assert time.getDataType() == DataType.DOUBLE;

    assert time.getDimension(0) == ncfile.findDimension("time");

    time.setCachedData(null, false);
    Array data = time.read("1:2");
    assert data.getRank() == 1;
    assert data.getSize() == 2;
    assert data.getShape()[0] == 2;
    assert data.getElementType() == double.class;

    int count = 0;
    IndexIterator dataI = data.getIndexIterator();
    while (dataI.hasNext()) {
      assert TestAll.closeEnough(dataI.getDoubleNext(), result[count+1]);
      count++;
    }

    time.setCachedData(null, false);
    data = time.read("0:2:2");
    assert data.getRank() == 1;
    assert data.getSize() == 2;
    assert data.getShape()[0] == 2;
    assert data.getElementType() == double.class;

    count = 0;
    dataI = data.getIndexIterator();
    while (dataI.hasNext()) {
      assert TestAll.closeEnough(dataI.getDoubleNext(), result[count*2]);
      count++;
    }
  }
View Full Code Here


    assert newVar.getShortName().equals("titleAsVariable");
    assert newVar.getRank() == 0;
    assert newVar.getSize() == 1;
    assert newVar.getDataType() == DataType.STRING;

    Array data = newVar.read();
    assert data.getElementType() == String.class;

    Object val = data.getObject(0);
    assert val instanceof String;
    assert val.equals("COADS 1-degree Equatorial Enhanced");

    ////////////////
    newVar = ncfile.findVariable("titleAsVariable2");
    assert null != newVar;

    assert newVar.getShortName().equals("titleAsVariable2");
    assert newVar.getRank() == 0;
    assert newVar.getSize() == 1;
    assert newVar.getDataType() == DataType.STRING;

    data = newVar.read();
    assert data.getElementType() == String.class;

    val = data.getObject(0);
    assert val instanceof String;
    assert val.equals("COADS 1-degree Equatorial Enhanced");

    ///////////////
    newVar = ncfile.findVariable("VariableAttribute");
    assert null != newVar;

    assert newVar.getShortName().equals("VariableAttribute");
    assert newVar.getRank() == 1;
    assert newVar.getSize() == 2;
    assert newVar.getDataType() == DataType.DOUBLE;

    data = newVar.read();
    assert data.getRank() == 1;
    assert data.getSize() == 2;
    assert data.getElementType() == double.class;

    double[] result = new double[] { 715511.0, 729360.0};
    for (int i=0; i<result.length; i++) {
      assert result[i] == data.getDouble(i);
    }

    ncfile.close();
  }
View Full Code Here

    NetcdfFile ncfile = NcMLReader.readNcML(new StringReader(ncml), location, null);

    TestAll.readAllData(ncfile);

     Variable v = ncfile.findVariable("time");
     Array data = v.read();
     assert data.getSize() == 20;
     NCdumpW.printArray(data);

    ncfile.close();   
  }
View Full Code Here

   NetcdfFile ncfile = NetcdfDataset.openFile(filename, null);

   TestAll.readAllData(ncfile);

    Variable v = ncfile.findVariable("time");
    Array data = v.read();
    assert data.getSize() == 59;
    NCdumpW.printArray(data);

   ncfile.close();
}
View Full Code Here

              System.out.println("  Try to read variable " + v.getNameAndDimensions() + " size= " + v.getSize() + " section= " + s);
            v.read(s);
          } else {
            if (showDetail)
              System.out.println("  Try to read variable " + v.getNameAndDimensions() + " size= " + v.getSize());
            Array data = v.read();
            if (showData)
              NCdumpW.printArray(data, v.getFullName(), pw, null);
          }
        }
View Full Code Here

    CoordinateAxis1DTime timeAxis = gcs.getTimeAxis1D();
    int tidx = timeAxis.findTimeIndexFromDate( date);

    int[] xy = gcs.findXYindexFromLatLonBounded(lat, lon, null);

    Array data  = grid.readDataSlice(tidx, -1, xy[1], xy[0]);

    // use actual grid midpoint
    LatLonPoint latlon = gcs.getLatLon(xy[0], xy[1]);

    Point p = new Point();
    p.lat = latlon.getLatitude();
    p.lon = latlon.getLongitude();
    p.dataValue = data.getDouble( data.getIndex());
    return p;
  }
View Full Code Here

    CoordinateAxis1D zAxis = gcs.getVerticalAxis();
    int zidx = zAxis.findCoordElement( zCoord);

    int[] xy = gcs.findXYindexFromLatLon(lat, lon, null);

    Array data  = grid.readDataSlice(tidx, zidx, xy[1], xy[0]);

    // use actual grid midpoint
    LatLonPoint latlon = gcs.getLatLon(xy[0], xy[1]);

    Point p = new Point();
    p.lat = latlon.getLatitude();
    p.lon = latlon.getLongitude();
    p.z = zAxis.getCoordValue( zidx);
    p.dataValue = data.getDouble( data.getIndex());
    return p;
  }
View Full Code Here

    Variable v = ncd.findCoordinateAxis("Longitude");
    assert v != null;
    assert v instanceof CoordinateAxis1D;

    // if offset is applied twice, the result is not in +-180 range
    Array data = v.read();
    NCdumpW.printArray(data);
    IndexIterator ii = data.getIndexIterator();
    while (ii.hasNext()) {
      assert Math.abs(ii.getDoubleNext()) < 180 : ii.getDoubleCurrent();
    }
    ncd.close();
  }
View Full Code Here

    assert time.getShape()[0] == ntimes;
    assert time.getDataType() == DataType.DOUBLE;

    assert time.getDimension(0) == ncfile.findDimension("time");

    Array data = time.read();
    assert data.getRank() == 1;
    assert data.getSize() == ntimes;
    assert data.getShape()[0] == ntimes;
    assert data.getElementType() == double.class;

    IndexIterator dataI = data.getIndexIterator();
    while (dataI.hasNext())
      System.out.println(" coord="+dataI.getObjectNext());
  }
View Full Code Here

    assert gsys.getYHorizAxis() != null;
    assert gsys.getTimeAxis() != null;
    assert gsys.getVerticalAxis() == null;
    assert gsys.getProjection() != null;

    Array data = g.readVolumeData(0);
    assert data.getRank() == 2;
    assert data.getShape()[0] == 1008;
    assert data.getShape()[1] == 1536;
    assert data.getElementType() == short.class;
  }
View Full Code Here

TOP

Related Classes of kameleon.document2.Array

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.