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

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

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

Array.getElementType介绍

[英]Get the element class type of this Array
[中]获取此数组的元素类类型

代码示例

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

/**
 * Get the total number of bytes in the array.
 *
 * @return total number of bytes in the array
 */
public long getSizeBytes() {
 DataType dtype = DataType.getType( getElementType());
 return indexCalc.getSize() * dtype.getSize();
}

代码示例来源:origin: org.apache.sis.storage/sis-netcdf

/**
 * Reads all the data for this variable and returns them as an array of a Java primitive type.
 * Multi-dimensional variables are flattened as a one-dimensional array (wrapped in a vector).
 * This method may cache the returned vector, at UCAR library choice.
 */
@Override
public Vector read() throws IOException {
  final Array array = variable.read();                // May be cached by the UCAR library.
  return Vector.create(array.get1DJavaArray(array.getElementType()), variable.isUnsigned());
}

代码示例来源: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: edu.ucar/netcdf

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

void CheckSValue( Array a) {
 assert a.getRank() == 0;
 assert a.getElementType() == String.class;
 String str = (String) a.getObject(a.getIndex());
 assert str.equals("This is a data test string (pass 0).");
}

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

void CheckSValue( Array a) {
 assert a.getRank() == 0;
 assert a.getElementType() == String.class;
 String str = (String) a.getObject(a.getIndex());
 assert str.equals("This is a data test string (pass 0).");
}

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

void CheckLongValue( Array a) {
 assert a.getRank() == 0;
 assert a.getSize() == 1;
 assert a.getElementType() == long.class;
 assert a instanceof ArrayLong.D0;
 long vall = ((ArrayLong.D0)a).get();
 assert (vall == 0);
}

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

void CheckUInt32Value( Array a) {
 assert a.getRank() == 0;
 assert a.getSize() == 1;
 assert a.getElementType() == int.class;
 assert a instanceof ArrayInt.D0;
 int vall = ((ArrayInt.D0)a).get();
 assert (vall == 0);
}

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

void CheckInt16Value( Array a) {
 assert a.getRank() == 0;
 assert a.getSize() == 1;
 assert a.getElementType() == short.class;
 assert a instanceof ArrayShort.D0;
 short vals = ((ArrayShort.D0)a).get();
 assert (vals == 0);
}

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

void CheckInt32Value( Array a) {
 assert a.getRank() == 0;
 assert a.getSize() == 1;
 assert a.getElementType() == int.class;
 assert a instanceof ArrayInt.D0;
 int vali = ((ArrayInt.D0)a).get();
 assert (vali == 1) : vali;
}

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

void CheckDValue( Array a) {
 assert a.getRank() == 0;
 assert a.getSize() == 1;
 assert a.getElementType() == double.class;
 assert a instanceof ArrayDouble.D0;
 double vald = ((ArrayDouble.D0)a).get();
 assert (vald == 1000.0);
}

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

void CheckInt16Value( Array a) {
 assert a.getRank() == 0;
 assert a.getSize() == 1;
 assert a.getElementType() == short.class;
 assert a instanceof ArrayShort.D0;
 short vals = ((ArrayShort.D0)a).get();
 assert (vals == 0);
}

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

void CheckLongValue( Array a) {
 assert a.getRank() == 0;
 assert a.getSize() == 1;
 assert a.getElementType() == long.class;
 assert a instanceof ArrayLong.D0;
 long vall = ((ArrayLong.D0)a).get();
 assert (vall == 0);
}

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

void CheckFValue( Array a) {
 assert a.getRank() == 0;
 assert a.getSize() == 1;
 assert a.getElementType() == float.class;
 assert a instanceof ArrayFloat.D0;
 float valf = ((ArrayFloat.D0)a).get();
 assert (valf == 0.0);
}

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

void CheckInt32Value( Array a) {
 assert a.getRank() == 0;
 assert a.getSize() == 1;
 assert a.getElementType() == int.class;
 assert a instanceof ArrayInt.D0;
 int vali = ((ArrayInt.D0)a).get();
 assert (vali == 1) : vali;
}

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

void CheckFValue( Array a) {
 assert a.getRank() == 0;
 assert a.getSize() == 1;
 assert a.getElementType() == float.class;
 assert a instanceof ArrayFloat.D0;
 float valf = ((ArrayFloat.D0)a).get();
 assert (valf == 0.0);
}

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

void CheckByteValue( Array a) {
 assert a.getRank() == 0;
 assert a.getSize() == 1;
 assert a.getElementType() == byte.class;
 assert a instanceof ArrayByte.D0;
 byte valb = ((ArrayByte.D0)a).get();
 assert (valb == 0);
}

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

void CheckUint32Value( Array a) {
 assert a.getRank() == 0;
 assert a.getSize() == 1;
 assert a.getElementType() == int.class;
 assert a instanceof ArrayInt.D0;
 long vall = ((ArrayInt.D0)a).get();
 assert (vall == 0);
}

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

@org.junit.Test
public void test2() throws IOException {
 try (NetcdfFile ncfile = TestH5.open(testDir +"HIRDLS2-AFGL_b027_na.he5")) {
  Variable dset = ncfile.findVariable("HDFEOS/SWATHS/HIRDLS/Data_Fields/Altitude");
  //H5header.setDebugFlags( new ucar.nc2.util.DebugFlagsImpl("H5header/dataBtree"));
  Array data = dset.read();
  assert data.getElementType() == float.class;
 }
}

代码示例来源: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());
 }
}

相关文章

微信公众号

最新文章

更多