本文整理了Java中ucar.ma2.Array.section()
方法的一些代码示例,展示了Array.section()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Array.section()
方法的具体详情如下:
包路径:ucar.ma2.Array
类名称:Array
方法名:section
[英]Create a new Array as a subsection of this Array, with rank reduction. No data is moved, so the new Array references the same backing store as the original.
[中]创建一个新数组作为该数组的一个子数组,并降低秩。不移动任何数据,因此新阵列引用与原始阵列相同的备份存储。
代码示例来源:origin: edu.ucar/cdm
/**
* Create a new Array as a subsection of this Array, with rank reduction.
* No data is moved, so the new Array references the same backing store as the original.
* <p/>
*
* @param origin int array specifying the starting index. Must be same rank as original Array.
* @param shape int array specifying the extents in each dimension.
* This becomes the shape of the returned Array. Must be same rank as original Array.
* If shape[dim] == 1, then the rank of the resulting Array is reduced at that dimension.
* @return the new Array
* @throws InvalidRangeException if ranges is invalid
*/
public Array section(int[] origin, int[] shape) throws InvalidRangeException {
return section(origin, shape, null);
}
代码示例来源:origin: edu.ucar/netcdf
/**
* Create a new Array as a subsection of this Array, with rank reduction.
* No data is moved, so the new Array references the same backing store as the original.
* <p/>
*
* @param origin int array specifying the starting index. Must be same rank as original Array.
* @param shape int array specifying the extents in each dimension.
* This becomes the shape of the returned Array. Must be same rank as original Array.
* If shape[dim] == 1, then the rank of the resulting Array is reduced at that dimension.
* @return the new Array
* @throws InvalidRangeException if ranges is invalid
*/
public Array section(int[] origin, int[] shape) throws InvalidRangeException {
return section(origin, shape, null);
}
代码示例来源:origin: Unidata/thredds
/**
* Create a new Array as a subsection of this Array, with rank reduction.
* No data is moved, so the new Array references the same backing store as the original.
* <p/>
*
* @param origin int array specifying the starting index. Must be same rank as original Array.
* @param shape int array specifying the extents in each dimension.
* This becomes the shape of the returned Array. Must be same rank as original Array.
* If shape[dim] == 1, then the rank of the resulting Array is reduced at that dimension.
* @return the new Array
* @throws InvalidRangeException if ranges is invalid
*/
public Array section(int[] origin, int[] shape) throws InvalidRangeException {
return section(origin, shape, null);
}
代码示例来源:origin: edu.ucar/cdm
/**
* Get an index iterator for traversing a section of the array in canonical order.
* This is equivalent to Array.section(ranges).getIterator();
*
* @param ranges list of Ranges that specify the array subset.
* Must be same rank as original Array.
* A particular Range: 1) may be a subset, or 2) may be null, meaning use entire Range.
* @return an IndexIterator over the named range.
* @throws InvalidRangeException if ranges is invalid
*/
public IndexIterator getRangeIterator(List<Range> ranges) throws InvalidRangeException {
return section(ranges).getIndexIterator();
}
代码示例来源:origin: edu.ucar/netcdf
/**
* Get an index iterator for traversing a section of the array in canonical order.
* This is equivalent to Array.section(ranges).getIterator();
*
* @param ranges list of Ranges that specify the array subset.
* Must be same rank as original Array.
* A particular Range: 1) may be a subset, or 2) may be null, meaning use entire Range.
* @return an IndexIterator over the named range.
* @throws InvalidRangeException if ranges is invalid
*/
public IndexIterator getRangeIterator(List<Range> ranges) throws InvalidRangeException {
return section(ranges).getIndexIterator();
}
代码示例来源:origin: Unidata/thredds
/**
* Get an index iterator for traversing a section of the array in canonical order.
* This is equivalent to Array.section(ranges).getIterator();
*
* @param ranges list of Ranges that specify the array subset.
* Must be same rank as original Array.
* A particular Range: 1) may be a subset, or 2) may be null, meaning use entire Range.
* @return an IndexIterator over the named range.
* @throws InvalidRangeException if ranges is invalid
*/
public IndexIterator getRangeIterator(List<Range> ranges) throws InvalidRangeException {
return section(ranges).getIndexIterator();
}
代码示例来源:origin: Unidata/thredds
public float[] getAzi(String aziName, int swpNumber) throws IOException {
try {
Array aziData = ds.findVariable(aziName).read();
int [] aziOrigin = new int[2];
aziOrigin[0] = swpNumber;
aziOrigin[1] = 0; //shape[1] - getRadialNumber();
int [] aziShape = {1, getRadialNumber()};
aziData = aziData.section(aziOrigin, aziShape);
return (float [])aziData.get1DJavaArray(Float.TYPE);
} catch (ucar.ma2.InvalidRangeException e) {
throw new IOException(e);
}
}
代码示例来源:origin: edu.ucar/cdm
public float[] getEle(String elevName, int swpNumber) throws IOException {
try {
Array eleData = ds.findVariable(elevName).read();
int [] eleOrigin = new int[2];
eleOrigin[0] = swpNumber;
eleOrigin[1] = 0;
int [] eleShape = {1, getRadialNumber()};
eleData = eleData.section(eleOrigin, eleShape);
return (float [])eleData.get1DJavaArray(Float.TYPE);
} catch (ucar.ma2.InvalidRangeException e) {
throw new IOException(e);
}
}
代码示例来源:origin: edu.ucar/cdm
public float[] getAzi(String aziName, int swpNumber) throws IOException {
try {
Array aziData = ds.findVariable(aziName).read();
int [] aziOrigin = new int[2];
aziOrigin[0] = swpNumber;
aziOrigin[1] = 0; //shape[1] - getRadialNumber();
int [] aziShape = {1, getRadialNumber()};
aziData = aziData.section(aziOrigin, aziShape);
return (float [])aziData.get1DJavaArray(Float.TYPE);
} catch (ucar.ma2.InvalidRangeException e) {
throw new IOException(e);
}
}
代码示例来源:origin: Unidata/thredds
public float[] getEle(String elevName, int swpNumber) throws IOException {
try {
Array eleData = ds.findVariable(elevName).read();
int [] eleOrigin = new int[2];
eleOrigin[0] = swpNumber;
eleOrigin[1] = 0;
int [] eleShape = {1, getRadialNumber()};
eleData = eleData.section(eleOrigin, eleShape);
return (float [])eleData.get1DJavaArray(Float.TYPE);
} catch (ucar.ma2.InvalidRangeException e) {
throw new IOException(e);
}
}
代码示例来源:origin: edu.ucar/cdm
public float[] getEle(String elevName, int swpNumber) throws IOException {
try {
Variable evar = ds.findVariable(elevName);
Array eleData = evar.read();
evar.setCachedData(eleData, false);
int [] eleOrigin = new int[2];
eleOrigin[0] = swpNumber;
eleOrigin[1] = 0;
int [] eleShape = {1, getRadialNumber()};
eleData = eleData.section(eleOrigin, eleShape);
return (float [])eleData.get1DJavaArray(Float.TYPE);
} catch (ucar.ma2.InvalidRangeException e) {
throw new IOException(e);
}
}
代码示例来源:origin: edu.ucar/cdm
public float[] getAzi(String aziName, int swpNumber) throws IOException {
try {
Variable avar = ds.findVariable(aziName);
Array aziData = avar.read();
avar.setCachedData(aziData, false);
int[] aziOrigin = new int[2];
aziOrigin[0] = swpNumber;
aziOrigin[1] = 0; //shape[1] - getRadialNumber();
int[] aziShape = {1, getRadialNumber()};
aziData = aziData.section(aziOrigin, aziShape);
return (float[])aziData.get1DJavaArray(Float.TYPE);
} catch (ucar.ma2.InvalidRangeException e) {
throw new IOException(e);
}
}
代码示例来源:origin: Unidata/thredds
public float[] getEle(String elevName, int swpNumber) throws IOException {
try {
Variable evar = ds.findVariable(elevName);
Array eleData = evar.read();
evar.setCachedData(eleData, false);
int [] eleOrigin = new int[2];
eleOrigin[0] = swpNumber;
eleOrigin[1] = 0;
int [] eleShape = {1, getRadialNumber()};
eleData = eleData.section(eleOrigin, eleShape);
return (float [])eleData.get1DJavaArray(Float.TYPE);
} catch (ucar.ma2.InvalidRangeException e) {
throw new IOException(e);
}
}
代码示例来源:origin: Unidata/thredds
public float[] getAzi(String aziName, int swpNumber) throws IOException {
try {
Variable avar = ds.findVariable(aziName);
Array aziData = avar.read();
avar.setCachedData(aziData, false);
int[] aziOrigin = new int[2];
aziOrigin[0] = swpNumber;
aziOrigin[1] = 0; //shape[1] - getRadialNumber();
int[] aziShape = {1, getRadialNumber()};
aziData = aziData.section(aziOrigin, aziShape);
return (float[])aziData.get1DJavaArray(Float.TYPE);
} catch (ucar.ma2.InvalidRangeException e) {
throw new IOException(e);
}
}
代码示例来源:origin: edu.ucar/netcdf
public float[] getAzi(String aziName, int swpNumber) throws IOException {
Array aziData = null;
if(aziData == null) {
try {
Array aziTmp = ds.findVariable(aziName).read();
int [] aziOrigin = new int[2];
aziOrigin[0] = swpNumber;
aziOrigin[1] = 0; //shape[1] - getRadialNumber();
int [] aziShape = {1, getRadialNumber()};
aziData = aziTmp.section(aziOrigin, aziShape);
} catch (IOException e) {
e.printStackTrace();
} catch (ucar.ma2.InvalidRangeException e) {
e.printStackTrace();
}
}
return (float [])aziData.get1DJavaArray(Float.TYPE);
}
代码示例来源:origin: Unidata/thredds
public float getAzimuth(int ray) throws IOException {
String aziName = "Azimuth";
try {
Array aziData = ds.findVariable(aziName).read();
if (isVolume) {
int[] aziOrigin = new int[2];
aziOrigin[0] = sweepno;
aziOrigin[1] = 0;
int[] aziShape = {1, getRadialNumber()};
aziData = aziData.section(aziOrigin, aziShape);
}
Index index = aziData.getIndex();
return aziData.getFloat(index.set(ray));
} catch (ucar.ma2.InvalidRangeException e) {
throw new IOException(e);
}
}
代码示例来源:origin: edu.ucar/cdm
public float getAzimuth(int ray) throws IOException {
String aziName = "Azimuth";
try {
Array aziData = ds.findVariable(aziName).read();
if(isVolume) {
int [] aziOrigin = new int[2];
aziOrigin[0] = sweepno;
aziOrigin[1] = 0;
int [] aziShape = {1, getRadialNumber()};
aziData = aziData.section(aziOrigin, aziShape);
}
Index index = aziData.getIndex();
return aziData.getFloat(index.set(ray));
} catch (ucar.ma2.InvalidRangeException e) {
throw new IOException(e);
}
}
代码示例来源:origin: edu.ucar/netcdf
public float getEle(String elevName, int swpNumber, int ray) throws IOException {
Array eleData = null;
try {
Array eleTmp = ds.findVariable(elevName).read();
int [] eleOrigin = new int[2];
eleOrigin[0] = swpNumber;
eleOrigin[1] = 0; //shape[1] - getRadialNumber();
int [] eleShape = {1, getRadialNumber()};
eleData = eleTmp.section(eleOrigin, eleShape);
} catch (IOException e) {
e.printStackTrace();
} catch (ucar.ma2.InvalidRangeException e) {
e.printStackTrace();
}
// if(eleData == null) initAzi();
Index index = eleData.getIndex();
return eleData.getFloat(index.set(ray));
}
代码示例来源:origin: edu.ucar/netcdf
public float getEle(String elevName, int swpNumber, int ray) throws IOException {
Array eleData = null;
try {
Variable evar = ds.findVariable(elevName);
Array eleTmp = evar.read();
evar.setCachedData(eleTmp, false);
int [] eleOrigin = new int[2];
eleOrigin[0] = swpNumber;
eleOrigin[1] = 0; //shape[1] - getRadialNumber();
int [] eleShape = {1, getRadialNumber()};
eleData = eleTmp.section(eleOrigin, eleShape);
} catch (IOException e) {
e.printStackTrace();
} catch (ucar.ma2.InvalidRangeException e) {
e.printStackTrace();
}
// if(eleData == null) initAzi();
Index index = eleData.getIndex();
return eleData.getFloat(index.set(ray));
}
代码示例来源:origin: edu.ucar/netcdf
static private void extractSection(ParsedSectionSpec child, ArrayStructure outerData, IndexIterator to) throws IOException, InvalidRangeException {
long wantNelems = child.section.computeSize();
StructureMembers.Member m = outerData.findMember(child.v.getShortName());
for (int recno = 0; recno < outerData.getSize(); recno++) {
Array innerData = outerData.getArray(recno, m);
if (child.child == null) { // inner variable
if (wantNelems != innerData.getSize())
innerData = innerData.section(child.section.getRanges());
MAMath.copy(child.v.getDataType(), innerData.getIndexIterator(), to);
} else { // not an inner variable - must be an ArrayStructure
if (innerData instanceof ArraySequence)
extractSectionFromSequence(child.child, (ArraySequence) innerData, to);
else {
if (wantNelems != innerData.getSize())
innerData = sectionArrayStructure(child, (ArrayStructure) innerData, m);
extractSection(child.child, (ArrayStructure) innerData, to);
}
}
}
}
内容来源于网络,如有侵权,请联系作者删除!