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

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

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

Array.makeArray介绍

[英]Make a 1D array from a start and incr.
[中]从一开始就做一个1D数组,然后递增。

代码示例

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

/**
 * Make an 1D array from a list of strings.
 *
 * @param dtype        data type of the array. Assumed unsigned
 * @param stringValues list of strings.
 * @return resulting 1D array.
 * @throws NumberFormatException if string values not parseable to specified data type
 */
static public Array makeArray(DataType dtype, List<String> stringValues) throws NumberFormatException {
 return makeArray(dtype, false, stringValues);
}

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

/**
 * Make a 1D array from a list of strings.
 *
 * @param dtype        data type of the array.
 * @param stringValues list of strings.
 * @return resulting 1D array.
 * @throws NumberFormatException if string values not parssable to specified data type
 * @deprecated use Array#makeArray directly
 */
static public Array makeArray(DataType dtype, List<String> stringValues) throws NumberFormatException {
 return Array.makeArray(dtype, stringValues);
}

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

/**
 * Make a 1D array from a list of strings.
 *
 * @param dtype        data type of the array.
 * @param stringValues list of strings.
 * @return resulting 1D array.
 * @throws NumberFormatException if string values not parssable to specified data type
 * @deprecated use Array#makeArray directly
 */
static public Array makeArray(DataType dtype, List<String> stringValues) throws NumberFormatException {
 return Array.makeArray(dtype, stringValues);
}

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

/**
 * Make a 1D array from a list of strings.
 *
 * @param dtype        data type of the array.
 * @param stringValues list of strings.
 * @return resulting 1D array.
 * @throws NumberFormatException if string values not parssable to specified data type
 * @deprecated use Array#makeArray directly
 */
static public Array makeArray(DataType dtype, List<String> stringValues) throws NumberFormatException {
 return Array.makeArray(dtype, stringValues);
}

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

/**
 * Make an 1D array from an array of strings.
 *
 * @param dtype        data type of the array. Assumed unsigned
 * @param stringValues list of strings.
 * @return resulting 1D array.
 * @throws NumberFormatException if string values not parseable to specified data type
 */
static public Array makeArray(DataType dtype, String[] stringValues) throws NumberFormatException {
 return makeArray(dtype, Arrays.asList(stringValues));
}

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

/**
 * Make an 1D array from an array of strings.
 *
 * @param dtype        data type of the array. Assumed unsigned
 * @param stringValues list of strings.
 * @return resulting 1D array.
 * @throws NumberFormatException if string values not parseable to specified data type
 */
static public Array makeArray(DataType dtype, String[] stringValues) throws NumberFormatException {
 return makeArray(dtype, Arrays.asList(stringValues));
}

代码示例来源:origin: bcdev/beam

public void testIsGlobalShifted180() {
    Array longitudeData = Array.makeArray(DataType.DOUBLE, 480, 0.0, 0.75);
    assertTrue(CfGeocodingPart.isGlobalShifted180(longitudeData));

    longitudeData = Array.makeArray(DataType.DOUBLE, 480, 0.75, 0.75);
    assertTrue(CfGeocodingPart.isGlobalShifted180(longitudeData));

    longitudeData = Array.makeArray(DataType.DOUBLE, 480, 0.375, 0.75);
    assertTrue(CfGeocodingPart.isGlobalShifted180(longitudeData));

    longitudeData = Array.makeArray(DataType.DOUBLE, 480, 1.0, 0.75);
    assertFalse(CfGeocodingPart.isGlobalShifted180(longitudeData));

    longitudeData = Array.makeArray(DataType.DOUBLE, 480, -0.375, 0.75);
    assertFalse(CfGeocodingPart.isGlobalShifted180(longitudeData));
  }
}

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

/**
 * Generate the list of values from a starting value and an increment.
 * Will reshape to variable if needed.
 *
 * @param npts  number of values, must = v.getSize()
 * @param start starting value
 * @param incr  increment
 */
public void setValues(int npts, double start, double incr) {
 if (npts != getSize())
  throw new IllegalArgumentException("bad npts = " + npts + " should be " + getSize());
 Array data = Array.makeArray(getDataType(), npts, start, incr);
 if (getRank() != 1)
  data = data.reshape(getShape());
 setCachedData(data, true);
}

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

/**
 * Generate the list of values from a starting value and an increment.
 * Will reshape to variable if needed.
 *
 * @param npts  number of values, must = v.getSize()
 * @param start starting value
 * @param incr  increment
 */
public void setValues(int npts, double start, double incr) {
 if (npts != getSize())
  throw new IllegalArgumentException("bad npts = " + npts + " should be " + getSize());
 Array data = Array.makeArray(getDataType(), npts, start, incr);
 if (getRank() != 1)
  data = data.reshape(getShape());
 setCachedData(data, true);
}

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

/**
 * Generate the list of values from a starting value and an increment.
 * Will reshape to variable if needed.
 *
 * @param npts  number of values, must = v.getSize()
 * @param start starting value
 * @param incr  increment
 */
public void setValues(int npts, double start, double incr) {
 if (npts != getSize())
  throw new IllegalArgumentException("bad npts = " + npts + " should be " + getSize());
 Array data = Array.makeArray(getDataType(), npts, start, incr);
 if (getRank() != 1)
  data = data.reshape(getShape());
 setCachedData(data, true);
}

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

/**
 * Generate the list of values from a starting value and an increment.
 * Will reshape to variable if needed.
 *
 * @param v     for this variable
 * @param npts  number of values, must = v.getSize()
 * @param start starting value
 * @param incr  increment
 * @deprecated use Variable.setValues()
 */
public void setValues(Variable v, int npts, double start, double incr) {
 if (npts != v.getSize())
  throw new IllegalArgumentException("bad npts = " + npts + " should be " + v.getSize());
 Array data = Array.makeArray(v.getDataType(), npts, start, incr);
 if (v.getRank() != 1)
  data = data.reshape(v.getShape());
 v.setCachedData(data, true);
}

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

/**
 * Generate the list of values from a starting value and an increment.
 * Will reshape to variable if needed.
 *
 * @param v     for this variable
 * @param npts  number of values, must = v.getSize()
 * @param start starting value
 * @param incr  increment
 * @deprecated use Variable.setValues()
 */
public void setValues(Variable v, int npts, double start, double incr) {
 if (npts != v.getSize())
  throw new IllegalArgumentException("bad npts = " + npts + " should be " + v.getSize());
 Array data = Array.makeArray(v.getDataType(), npts, start, incr);
 if (v.getRank() != 1)
  data = data.reshape(v.getShape());
 v.setCachedData(data, true);
}

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

/**
 * Generate the list of values from a starting value and an increment.
 * Will reshape to variable if needed.
 *
 * @param v     for this variable
 * @param npts  number of values, must = v.getSize()
 * @param start starting value
 * @param incr  increment
 * @deprecated use Variable.setValues()
 */
public void setValues(Variable v, int npts, double start, double incr) {
 if (npts != v.getSize())
  throw new IllegalArgumentException("bad npts = " + npts + " should be " + v.getSize());
 Array data = Array.makeArray(v.getDataType(), npts, start, incr);
 if (v.getRank() != 1)
  data = data.reshape(v.getShape());
 v.setCachedData(data, true);
}

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

/**
 * Set the data values from a list of Strings.
 *
 * @param values list of Strings
 * @throws IllegalArgumentException if values array not correct size, or values wont parse to the correct type
 */
public void setValues(List<String> values) throws IllegalArgumentException {
 Array data = Array.makeArray(getDataType(),  values);
 if (data.getSize() != getSize())
  throw new IllegalArgumentException("Incorrect number of values specified for the Variable " + getFullName() +
      " needed= " + getSize() + " given=" + data.getSize());
 if (getRank() != 1) // dont have to reshape for rank 1
  data = data.reshape(getShape());
 setCachedData(data, true);
}

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

/**
 * Set the data values from a list of Strings.
 *
 * @param values list of Strings
 * @throws IllegalArgumentException if values array not correct size, or values wont parse to the correct type
 */
public void setValues(List<String> values) throws IllegalArgumentException {
 Array data = Array.makeArray(getDataType(), values);
 if (data.getSize() != getSize())
  throw new IllegalArgumentException("Incorrect number of values specified for the Variable " + getFullName() +
      " needed= " + getSize() + " given=" + data.getSize());
 if (getRank() != 1) // dont have to reshape for rank 1
  data = data.reshape(getShape());
 setCachedData(data, true);
}

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

public void testSlice3D() throws InvalidRangeException, IOException {
  Array a = Array.makeArray(DataType.DOUBLE, 1000, 0.0, 1.0);
  Array a3 = a.reshape(new int[] {10,10,10});

  logger.debug("{}", NCdumpW.toString(a3, "test a3", null));
  Array a2 = a3.slice(0,1);

  logger.debug("{}", NCdumpW.toString(a2, "a3.slice(0,1)", null));

  Array a1 = a2.slice(0,1);

  logger.debug("{}", NCdumpW.toString(a1, "a2.slice(0,1)", null));

  ArrayDouble.D2 twoD = (ArrayDouble.D2) a2;
  System.out.printf("wrong= %f%n", a2.getDouble(0));
  System.out.printf("right= %f%n", twoD.get(0, 0));

  ArrayDouble.D1 oneD = (ArrayDouble.D1) a1;
  System.out.printf("wrong= %f%n", a1.getDouble(0));
  System.out.printf("right= %f%n", oneD.get(0));
  }
}

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

/**
 * Set the data values from a list of Strings.
 *
 * @param v      for this variable
 * @param values list of Strings
 * @throws IllegalArgumentException if values array not correct size, or values wont parse to the correct type
 * @deprecated use Variable.setValues()
 */
public void setValues(Variable v, List<String> values) throws IllegalArgumentException {
 Array data = Array.makeArray(v.getDataType(), values);
 if (data.getSize() != v.getSize())
  throw new IllegalArgumentException("Incorrect number of values specified for the Variable " + v.getFullName() +
      " needed= " + v.getSize() + " given=" + data.getSize());
 if (v.getRank() != 1) // dont have to reshape for rank 1
  data = data.reshape(v.getShape());
 v.setCachedData(data, true);
}

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

/**
 * Set the data values from a list of Strings.
 *
 * @param values list of Strings
 * @throws IllegalArgumentException if values array not correct size, or values wont parse to the correct type
 */
public void setValues(List<String> values) throws IllegalArgumentException {
 Array data = Array.makeArray(getDataType(), isUnsigned(),  values);
 if (data.getSize() != getSize())
  throw new IllegalArgumentException("Incorrect number of values specified for the Variable " + getFullName() +
      " needed= " + getSize() + " given=" + data.getSize());
 if (getRank() != 1) // dont have to reshape for rank 1
  data = data.reshape(getShape());
 setCachedData(data, true);
}

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

/**
 * Set the data values from a list of Strings.
 *
 * @param v      for this variable
 * @param values list of Strings
 * @throws IllegalArgumentException if values array not correct size, or values wont parse to the correct type
 * @deprecated use Variable.setValues()
 */
public void setValues(Variable v, List<String> values) throws IllegalArgumentException {
 Array data = Array.makeArray(v.getDataType(), v.isUnsigned(), values);
 if (data.getSize() != v.getSize())
  throw new IllegalArgumentException("Incorrect number of values specified for the Variable " + v.getFullName() +
      " needed= " + v.getSize() + " given=" + data.getSize());
 if (v.getRank() != 1) // dont have to reshape for rank 1
  data = data.reshape(v.getShape());
 v.setCachedData(data, true);
}

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

private boolean addTimeCoordinate(NetcdfDataset ds) {
 // add time coordinate
 CalendarDate cd = parseFilenameForDate(ds.getLocation());
 if (cd == null) return false;
 ds.addAttribute(ds.getRootGroup(), new Attribute("_MODIS_Date", cd.toString()));
 // add the time dimension
 int nTimesDim = 1;
 Dimension newDim = new Dimension(TIME_NAME, nTimesDim);
 ds.addDimension( null, newDim);
 // add the coordinate variable
 String units = "seconds since "+cd.toString();
 String desc = "time coordinate";
 Array data = Array.makeArray(DataType.DOUBLE, 1, 0.0, 0.0) ;
 CoordinateAxis1D timeCoord = new CoordinateAxis1D( ds, null, TIME_NAME, DataType.DOUBLE, "", units, desc);
 timeCoord.setCachedData(data, true);
 timeCoord.addAttribute(new Attribute(_Coordinate.AxisType, AxisType.Time.toString()));
 ds.addCoordinateAxis(timeCoord);
 return true;
}

相关文章

微信公众号

最新文章

更多