public int[] getCurrentCounter() { if (counter == null) counter = new Index(maa.getShape()); counter.setCurrentCounter( currElement); return counter.current; }
public int[] getCurrentCounter() { if (counter == null) counter = new Index(maa.getShape()); counter.setCurrentCounter( currElement); return counter.current; }
public int[] getCurrentCounter() { if (counter == null) // or counter == "" ? counter = Index.factory(maa.getShape()); counter.setCurrentCounter( currElement); return counter.current; }
public int[] getCurrentCounter() { if (counter == null) // or counter == "" ? counter = Index.factory(maa.getShape()); counter.setCurrentCounter( currElement); return counter.current; }
public static ByteString copyArrayToByteString(Array data) { int nbytes = (int) data.getSizeBytes(); if (nbytes < 0) { System.out.printf("copyArrayToByteString neg byte size %d dataType = %d data size %d shape = %s%n", nbytes, data.getDataType().getSize(), data.getSize(), Misc.showInts(data.getShape())); } ByteBuffer bb = ByteBuffer.allocate(nbytes); bb.order(ByteOrder.nativeOrder()); copyArrayToBB(data, false, bb); bb.flip(); return ByteString.copyFrom(bb); }
private void dump(Array data, int col) { int[] shape = data.getShape(); Index ima = data.getIndex(); for (int j = 0; j < shape[0]; j++) { float dd = data.getFloat(ima.set(j, col)); System.out.println(j + " value= " + dd); } }
private void dump(Array data, int col) { int[] shape = data.getShape(); Index ima = data.getIndex(); for (int j = 0; j < shape[0]; j++) { float dd = data.getFloat(ima.set(j, col)); System.out.println(j + " value= " + dd); } }
public ArrayDouble.D3 getCoordinateArray(int timeIndex) throws IOException, InvalidRangeException { Array data = readArray(existingData, timeIndex); // copy for now - better to just return Array, with promise its rank 3 int[] shape = data.getShape(); ArrayDouble.D3 ddata = (ArrayDouble.D3) Array.factory(double.class, shape); MAMath.copyDouble(ddata, data); return ddata; }
/** * Create a copy of this Array, copying the data so that physical order is the same as * logical order * * @return the new Array */ public Array copy() { Array newA = factory(getDataType(), getShape()); MAMath.copy(newA, this); return newA; }
public String toString() { if (counter == null) counter = new Index(maa.getShape()); counter.setCurrentCounter( currElement); return counter.toString(); } public int[] getCurrentCounter() {
public ArrayDouble.D3 getCoordinateArray(int timeIndex) throws IOException, InvalidRangeException { Array data = readArray(existingData, timeIndex); // copy for now - better to just return Array, with promise its rank 3 int[] shape = data.getShape(); ArrayDouble.D3 ddata = (ArrayDouble.D3) Array.factory(double.class, shape); MAMath.copyDouble(ddata, data); return ddata; }
public ArrayDouble.D3 getCoordinateArray(int timeIndex) throws IOException, InvalidRangeException { Array data = readArray(existingData, timeIndex); // copy for now - better to just return Array, with promise its rank 3 int[] shape = data.getShape(); ArrayDouble.D3 ddata = (ArrayDouble.D3) Array.factory(DataType.DOUBLE, shape); MAMath.copyDouble(ddata, data); return ddata; }
/** * Add extra outermost dimension with len = 1. * * @param org original array * @return rank1 array of rank + 1 */ static public Array makeArrayRankPlusOne(Array org) { int[] shape = new int[org.getRank() + 1]; System.arraycopy(org.getShape(), 0, shape, 1, org.getRank()); shape[0] = 1; return factory(org.getDataType(), shape, org.getStorage()); }
/** * Create a copy of this Array, copying the data so that physical order is the same as * logical order * * @return the new Array */ public Array copy() { Array newA = factory(getElementType(), getShape()); MAMath.copy(newA, this); newA.setUnsigned(isUnsigned()); return newA; }
public static Array convert2Unpacked(Array packed, ScaleOffset scaleOffset) { Array result = Array.factory(DataType.DOUBLE, packed.getShape()); IndexIterator riter = result.getIndexIterator(); while (packed.hasNext()) { riter.setDoubleNext( packed.nextDouble() * scaleOffset.scale + scaleOffset.offset); } return result; }
public static Array convert2Unpacked(Array packed, ScaleOffset scaleOffset) { //boolean isUnsigned = packed.isUnsigned(); Array result = Array.factory(DataType.DOUBLE, packed.getShape()); IndexIterator riter = result.getIndexIterator(); while (packed.hasNext()) { riter.setDoubleNext( packed.nextDouble() * scaleOffset.scale + scaleOffset.offset); } return result; }
public static Array convert2packed(Array unpacked, double missingValue, int nbits, boolean isUnsigned, DataType packedType) { MAMath.ScaleOffset scaleOffset = calcScaleOffsetSkipMissingData(unpacked, missingValue, nbits, isUnsigned); Array result = Array.factory(packedType, unpacked.getShape()); IndexIterator riter = result.getIndexIterator(); while (unpacked.hasNext()) { double uv = unpacked.nextDouble(); double pv = (uv - scaleOffset.offset) / scaleOffset.scale; riter.setDoubleNext( pv); } return result; }
private void checkLatLonSubset(CoverageCollection gcs, Coverage coverage, LatLonRect bbox, int[] expectedShape) throws Exception { System.out.printf(" coverage llbb = %s width=%f%n", gcs.getLatlonBoundingBox().toString2(), gcs.getLatlonBoundingBox().getWidth()); System.out.printf(" constrain bbox= %s width=%f%n", bbox.toString2(), bbox.getWidth()); SubsetParams params = new SubsetParams().setLatLonBoundingBox(bbox).setTimePresent(); GeoReferencedArray geo = coverage.readData(params); CoverageCoordSys gcs2 = geo.getCoordSysForData(); Assert.assertNotNull("CoordSysForData", gcs2); System.out.printf(" data cs shape=%s%n", Misc.showInts(gcs2.getShape())); System.out.printf(" data shape=%s%n", Misc.showInts(geo.getData().getShape())); Assert.assertArrayEquals("CoordSys=Data shape", gcs2.getShape(), geo.getData().getShape()); Assert.assertArrayEquals("expected data shape", expectedShape, geo.getData().getShape()); }
static public void testVarMatchesData( Variable v, boolean showStatus) throws IOException { Array data = v.read(); assert data.getSize() == v.getSize(); assert data.getElementType() == v.getDataType().getPrimitiveClassType(); assert data.getRank() == v.getRank(); int[] dataShape = data.getShape(); int[] varShape = v.getShape(); for (int i=0; i<data.getRank(); i++) assert dataShape[i] == varShape[i]; if (showStatus) logger.debug( "**** testReadData done on {}", v.getFullName()); } }