ucar.ma2.Array.getShape()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(6.9k)|赞(0)|评价(0)|浏览(147)

本文整理了Java中ucar.ma2.Array.getShape()方法的一些代码示例,展示了Array.getShape()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Array.getShape()方法的具体详情如下:
包路径:ucar.ma2.Array
类名称:Array
方法名:getShape

Array.getShape介绍

[英]Get the shape: length of array in each dimension.
[中]获取形状:每个维度中数组的长度。

代码示例

代码示例来源:origin: edu.ucar/cdm

/**
 * Check that two arrays are conformable.
 *
 * @param a operand
 * @param b operand
 * @return true if conformable
 */
public static boolean conformable(Array a, Array b) {
 return conformable(a.getShape(), b.getShape());
}

代码示例来源:origin: edu.ucar/netcdf

public int[] getCurrentCounter() {
 if (counter == null)
  counter = new Index(maa.getShape());
 counter.setCurrentCounter( currElement);
 return counter.current;
}

代码示例来源:origin: edu.ucar/cdm

public int[] getCurrentCounter() {
 if (counter == null)
  counter = new Index(maa.getShape());
 counter.setCurrentCounter( currElement);
 return counter.current;
}

代码示例来源:origin: edu.ucar/cdm

public int[] getCurrentCounter() {
 if (counter == null)   // or counter == "" ?
  counter = Index.factory(maa.getShape());
 counter.setCurrentCounter( currElement);
 return counter.current;
}

代码示例来源:origin: Unidata/thredds

public int[] getCurrentCounter() {
 if (counter == null)   // or counter == "" ?
  counter = Index.factory(maa.getShape());
 counter.setCurrentCounter( currElement);
 return counter.current;
}

代码示例来源:origin: Unidata/thredds

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);
}

代码示例来源:origin: edu.ucar/netcdf

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);
 }
}

代码示例来源:origin: edu.ucar/cdm

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);
 }
}

代码示例来源:origin: edu.ucar/netcdf

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;
}

代码示例来源:origin: Unidata/thredds

/**
 * 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;
}

代码示例来源:origin: Unidata/thredds

public String toString() {
 if (counter == null)
  counter = new Index(maa.getShape());
 counter.setCurrentCounter( currElement);
 return counter.toString();
}
public int[] getCurrentCounter() {

代码示例来源:origin: edu.ucar/cdm

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;
}

代码示例来源:origin: Unidata/thredds

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;
}

代码示例来源:origin: Unidata/thredds

/**
 * 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());
}

代码示例来源:origin: edu.ucar/cdm

/**
 * 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;
}

代码示例来源:origin: Unidata/thredds

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;
}

代码示例来源:origin: edu.ucar/cdm

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;
}

代码示例来源:origin: edu.ucar/netcdf

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;
}

代码示例来源:origin: Unidata/thredds

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());
}

代码示例来源:origin: Unidata/thredds

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());
 }
}

相关文章

微信公众号

最新文章

更多