类 ArrayUtil
- java.lang.Object
-
- org.meteoinfo.ndarray.math.ArrayUtil
-
public class ArrayUtil extends Object
- 作者:
- yaqiang
-
-
构造器概要
构造器 构造器 说明 ArrayUtil()
-
方法概要
所有方法 静态方法 实例方法 具体方法 修饰符和类型 方法 说明 static ArrayargSort(Array a, Integer axis)Get sorted array index along an axisstatic Arrayarray(Object data)Create an arraystatic Arrayarray(Object data, DataType dt)Create an arraystatic Arrayarray_list(List data, DataType dt)Create an arraystatic ArrayarrayComplex(double[] real, double[] image)Create complex array from real and image data arraystatic ArrayarrayRange(Number start, Number stop, Number step)Array rangestatic ArrayarrayRange_bak(Number start, Number stop, Number step)Array rangestatic ArrayarrayRange1(Number start, int length, Number step)Array rangestatic List<Array>arraySplit(Array a, int sections, int axis)Split an Arraystatic Arraybroadcast(Array a, int[] shape)Broadcast array to a new shapestatic Arraybroadcast(Array a, List<Integer> shape)Broadcast array to a new shapestatic int[]broadcastShapes(List<List<Integer>> shapes)Broadcast shape list to a new shapestatic Arrayconcatenate(List<Array> arrays, Integer axis)Concatenate arrays to one array along an axisstatic Arrayconcatenate(Array a, Array b, Integer axis)Concatenate two arrays to one array along an axisstatic ArrayconvertEncoding(ArrayChar a, String encoding)Convert char array encoding from UTF-8static ArrayconvertToDataType(Array a, DataType dataType)Convert array to another data typestatic StringconvertToString(Array a)Array to stringprotected static voidcopyTo1DJavaArray(IndexIterator iter, Object javaArray)protected static voidcopyTo1DJavaArray(IndexIterator iter, Object javaArray, double missingValue)protected static voidcopyTo1DJavaArray_Long(IndexIterator iter, Object javaArray)static ObjectcopyToNDJavaArray(Array a)Convert array to N-Dimension double Java arraystatic ObjectcopyToNDJavaArray(Array a, String dtype)Convert array to N-Dimension double Java arraystatic ObjectcopyToNDJavaArray_Double(Array a)Convert array to N-Dimension double Java arraystatic ObjectcopyToNDJavaArray_Double(Array a, double missingValue)Convert array to N-Dimension double Java arraystatic ObjectcopyToNDJavaArray_Long(Array a)Convert array to N-Dimension double Java arraystatic EndianDataOutputStreamcreateBinFile(String fn)Create a binary filestatic Arraycressman(List<Number> x_s, List<Number> y_s, Array v_s, List<Number> X, List<Number> Y, List<Number> radList)Cressman analysisstatic Arraycressman_bak(List<Number> x_s, List<Number> y_s, Array v_s, List<Number> X, List<Number> Y, List<Number> radList)Cressman analysisstatic StringdataTypeString(DataType dt)Get data type stringstatic Arraydelete(Array a, int idx, int axis)Return a new array with sub-arrays along an axis deletedstatic Arraydelete(Array a, List<Integer> idx, int axis)Return a new array with sub-arrays along an axis deletedstatic Arraydiag(Array a, int k)Extract a diagonal or construct a diagonal array.static Arrayempty(List<Integer> shape, DataType dtype)Get zero arraystatic Array[]extendHalfCell(Array x, Array y)Extend the grid to half cell, so the grid points are the centers of the cellsstatic Arrayeye(int n, int m, int k, DataType dtype)Return a 2-D array with ones on the diagonal and zeros elsewhere.static Object[]findIndices(List<List<Number>> points, List<Number> xi)Find indicesstatic Object[]findIndices(List<Array> points, Array xi)Find indicesstatic ArrayflatNonZero(Array a)Return the flat indices of the elements that are non-zero.static ArrayfromBuffer(byte[] buffer, DataType dataType, int count, int offset)Read array from a buffer byte arraystatic ArrayfromBuffer(byte[] buffer, DataType dataType, int count, int offset, String byteOrder)Read array from a buffer byte arraystatic Arrayfull(int[] shape, Object fillValue, DataType dtype)Return a new array of given shape and type, filled with fill value.static Arrayfull(List<Integer> shape, Object fillValue, DataType dtype)Return a new array of given shape and type, filled with fill value.static Arrayfull(List<Integer> shape, Array fillValue, DataType dtype)Return a new array of given shape and type, filled with fill value.static intgetDimIndex(Array dim, Number v)Get value index in a dimension arraystatic StringgetString(ArrayChar a, String encoding)Get string from a char arraystatic int[]gridIndex(double[][] xdim, double[][] ydim, double x, double y)Get grid array x/y value indexstatic int[]gridIndex(Array xdim, Array ydim, double x, double y)Get grid array x/y value indexstatic List<Array>histogram(Array a, double[] bins)Histogram x/y arraystatic List<Array>histogram(Array a, int nbins)Histogram x/y arraystatic List<Array>histogram(Array a, Array bins)Histogram x/y arraystatic Arrayidentity(int n, DataType dtype)Return the identity array - a square array with ones on the main diagonal.static Arrayinterpn(List<Array> points, Array values, List<Array> xi)Multidimensional interpolation on regular grids.static Objectinterpn(List<Array> points, Array values, Array xi)Multidimensional interpolation on regular grids.static doubleinterpn_s(List<List<Number>> points, Array values, List<Number> xi)Multidimensional interpolation on regular grids.static doubleinterpn_s(List<Array> points, Array values, Array xi)Multidimensional interpolation on regular grids.Arrayinterpolate(Array a, List<Number> X, List<Number> Y)Interpolate array datastatic Arrayinterpolate_1d(double x, Array xp, Array a, int axis)Interpolates data with any shape over a specified axis.static Arrayinterpolate_1d(Array xa, Array xp, Array a, int axis)Interpolates data with any shape over a specified axis.static Arrayinterpolation_Inside(List<Number> x_s, List<Number> y_s, Array a, List<Number> X, List<Number> Y)Interpolate with inside method - The grid cell value is the average value of the inside points or fill value if no inside point.static Objectinterpolation_Inside_Count(List<Number> x_s, List<Number> y_s, List<Number> X, List<Number> Y, boolean pointDensity, boolean centerPoint)Interpolate with inside method - The grid cell value is the count number of the inside points or fill value if no inside point.static Arrayinterpolation_Inside_Max(List<Number> x_s, List<Number> y_s, Array a, List<Number> X, List<Number> Y)Interpolate with inside method - The grid cell value is the maximum value of the inside points or fill value if no inside point.static Arrayinterpolation_Inside_Mean(Array x_s, Array y_s, Array a, Array X, Array Y, boolean center)Interpolate with inside method - The grid cell value is the average value of the inside points or fill value if no inside point.static Arrayinterpolation_Inside_Min(List<Number> x_s, List<Number> y_s, Array a, List<Number> X, List<Number> Y)Interpolate with inside method - The grid cell value is the minimum value of the inside points or fill value if no inside point.static Arrayinterpolation_Nearest_1(List<Number> x_s, List<Number> y_s, Array a, List<Number> X, List<Number> Y, double radius, double fill_value)Interpolate with the nearest methodstatic Arrayinterpolation_Nearest_bak(List<Number> x_s, List<Number> y_s, Array a, List<Number> X, List<Number> Y, double radius)Interpolate with nearest methodstatic booleanisUnique(Array a, int limit)Check array is unique by unique value numberstatic ArraylineSpace(Number start, Number stop, int n)Array line space - stop is includedstatic ArraylineSpace(Number start, Number stop, int n, boolean endpoint)Array line spacestatic ArraylineSpace_bak(Number start, Number stop, int n, boolean endpoint)Array line spacestatic Arraylinint2(Array a, Array X, Array Y, Array newX, Array newY)Interpolates from a rectilinear grid to another rectilinear grid using bilinear interpolation.static Arraymagic(int n)Generate magic 2D arraystatic DataTypemergeDataType(DataType dt1, DataType dt2)Merge data type to one data typestatic Array[]meshgrid(Array x)Mesh gridstatic Array[]meshgrid(Array... xs)Mesh gridstatic Array[]meshgrid(Array x, Array y)Mesh gridstatic List<Array>nonzero(Array a)Return the indices of the elements that are non-zero.static intnumASCIICol(String fileName, String delimiter, int headerLines)Get row number of an ASCII filestatic intnumASCIIRow(String fileName)Get row number of a ASCII filestatic Arrayones(int n)Get ones arraystatic Arrayones(List<Integer> shape, DataType dtype)Get ones arraystatic doublerand()Get random valuestatic Arrayrand(int n)Get random array - one dimensionstatic Arrayrand(List<Integer> shape)Get random arraystatic ArrayreadASCIIFile(String fileName, String delimiter, int headerLines, String dataType, List<Integer> shape, boolean readFirstCol)Read ASCII data file to an arraystatic ArrayreadASCIIFile(String fileName, String delimiter, int headerLines, DataType dataType, List<Integer> shape, boolean readFirstCol)Read ASCII data file to an arraystatic ArrayreadASCIIFile(String fileName, DataType dataType, int count, String delimiter)Read ASCII data file to an arraystatic ArrayreadBinFile(String fn, List<Integer> dims, String dataType, int skip, String byteOrder)Read array from a binary filestatic ArrayreadBinFile(String fn, DataType dataType, int count, int offset)Read array from a binary filestatic ArrayreadBinFile(String fn, DataType dataType, int count, int offset, String byteOrder)Read array from a binary filestatic Arrayrepeat(Number v, int n)Repeat a value n timesstatic Arrayrepeat(Array a, List<Integer> repeats)Repeat elements of an array.static Arrayrepeat(Array a, List<Integer> repeats, int axis)Repeat elements of an array.static Arrayresample_Bilinear(Array a, List<Number> X, List<Number> Y, List<Number> newX, List<Number> newY)Resample grid array with bilinear methodstatic Arrayresample_Bilinear(Array a, Array X, Array Y, Array newX, Array newY)Resample grid array with bilinear methodstatic Arrayresample_Neighbor(Array a, Array X, Array Y, Array newX, Array newY)Resample grid array with neighbor methodstatic voidsaveASCIIFile(String fn, Array a, int colNum, String format, String delimiter)Save an array data to a ASCII filestatic voidsaveBinFile(String fn, Array a, String byteOrder, boolean append, boolean sequential)Save an array data to a binary filestatic intsearchSorted(List<Number> a, double v)Search sorted list indexstatic intsearchSorted(Array a, double v)Search sorted list indexstatic intsearchSorted(Array a, Number v, boolean left)Find indices where elements should be inserted to maintain order.static ArraysearchSorted(Array a, Array v, boolean left)Find indices where elements should be inserted to maintain order.static int[]searchSorted1(Array a, double v)Search sorted list indexstatic Arrayslice(Array a, int axis, int idx)Get slice array along an axisstatic Arrayslice(Array a, int axis, Array dim, double v)Get slice array along an axisstatic Arraysmooth5(Array a)Smooth with 5 pointsstatic Arraysmooth5(Array a, int rowNum, int colNum, double unDefData)Smooth with 5 pointsstatic Arraysmooth9(Array a)Smooth with 9 pointsstatic Arraysort(Array a, Integer axis)Sort array along an axisstatic Arraytile(Number v, int n)Repeat a value n timesstatic Arraytile(Number v, List<Integer> repeats)Repeat a value n timesstatic Arraytile(Array a, List<Integer> repeats)Repeat elements of an array.static ArraytoBoolean(Array a)Convert array to boolean typestatic DataTypetoDataType(String dt)To data type - ucar.ma2static ArraytoDate(Array a)Convert array to date typestatic ArraytoDouble(Array a)Convert array to double typestatic Arraytoeplitz(Array col, Array row)Returns a Toeplitz matrix in which each descending diagonal from left to right is constant.static ArraytoFloat(Array a)Convert array to float typestatic ArraytoInteger(Array a)Convert array to integer typestatic doubletoStation(Array data, List<Number> xArray, List<Number> yArray, double x, double y)Interpolate data to a station pointstatic doubletoStation(Array data, List<Number> xArray, List<Number> yArray, double x, double y, double missingValue)Interpolate data to a station pointstatic doubletoStation(Array data, Array xArray, Array yArray, double x, double y)Interpolate data to a station pointstatic doubletoStation_Neighbor(Array data, List<Number> xArray, List<Number> yArray, double x, double y)Interpolate data to a station pointstatic doubletoStation_Neighbor(Array data, List<Number> xArray, List<Number> yArray, double x, double y, double missingValue)Interpolate data to a station pointstatic doubletoStation_Neighbor(Array data, Array xArray, Array yArray, double x, double y)Interpolate data to a station pointstatic StringtoString_old(Array a)Array to stringstatic Arrayunique(Array a, Integer axis)Find the unique elements of an array.static Array[]uniqueIndex(Array a, Integer axis)Find the unique elements and index of an array.static ArrayunPack(Array a, double missingValue, double scaleFactor, double addOffset)Unpack array by missing value, scale factor and add offsetstatic Arrayview(Array a)New view of array with the same data.static voidwriteBinFile(EndianDataOutputStream outs, Array a, String byteOrder, boolean sequential)Save an array data to a binary filestatic Arrayzeros(int n)Get zero arraystatic Arrayzeros(int[] shape, DataType dtype)Get zero arraystatic Arrayzeros(List<Integer> shape, String dtype)Get zero arraystatic Arrayzeros(List<Integer> shape, DataType dtype)Get zero array
-
-
-
方法详细资料
-
readASCIIFile
public static Array readASCIIFile(String fileName, String delimiter, int headerLines, String dataType, List<Integer> shape, boolean readFirstCol) throws UnsupportedEncodingException, FileNotFoundException, IOException
Read ASCII data file to an array- 参数:
fileName- File namedelimiter- DelimiterheaderLines- Headerline numberdataType- Data type stringshape- ShapereadFirstCol- Read first column data or not- 返回:
- Result array
- 抛出:
UnsupportedEncodingExceptionFileNotFoundExceptionIOException
-
readASCIIFile
public static Array readASCIIFile(String fileName, String delimiter, int headerLines, DataType dataType, List<Integer> shape, boolean readFirstCol) throws UnsupportedEncodingException, FileNotFoundException, IOException
Read ASCII data file to an array- 参数:
fileName- File namedelimiter- DelimiterheaderLines- Headerline numberdataType- Data typeshape- ShapereadFirstCol- Read first column data or not- 返回:
- Result array
- 抛出:
UnsupportedEncodingExceptionFileNotFoundExceptionIOException
-
readASCIIFile
public static Array readASCIIFile(String fileName, DataType dataType, int count, String delimiter) throws UnsupportedEncodingException, FileNotFoundException, IOException
Read ASCII data file to an array- 参数:
fileName- File namedataType- Data typecount- Number of items to readdelimiter- Delimiter- 返回:
- Result array
- 抛出:
UnsupportedEncodingExceptionFileNotFoundExceptionIOException
-
numASCIIRow
public static int numASCIIRow(String fileName) throws FileNotFoundException
Get row number of a ASCII file- 参数:
fileName- File name- 返回:
- Row number
- 抛出:
FileNotFoundException
-
numASCIICol
public static int numASCIICol(String fileName, String delimiter, int headerLines) throws FileNotFoundException, IOException
Get row number of an ASCII file- 参数:
fileName- File namedelimiter-headerLines-- 返回:
- Row number
- 抛出:
FileNotFoundExceptionIOException
-
createBinFile
public static EndianDataOutputStream createBinFile(String fn) throws IOException
Create a binary file- 参数:
fn- The file path- 返回:
- EndianDataOutputStream
- 抛出:
IOException
-
writeBinFile
public static void writeBinFile(EndianDataOutputStream outs, Array a, String byteOrder, boolean sequential)
Save an array data to a binary file- 参数:
outs- EndianDataOutputStreama- ArraybyteOrder- Byte ordersequential- If write as sequential binary file - Fortran
-
saveBinFile
public static void saveBinFile(String fn, Array a, String byteOrder, boolean append, boolean sequential)
Save an array data to a binary file- 参数:
fn- File patha- ArraybyteOrder- Byte orderappend- If append to existing filesequential- If write as sequential binary file - Fortran
-
saveASCIIFile
public static void saveASCIIFile(String fn, Array a, int colNum, String format, String delimiter) throws IOException
Save an array data to a ASCII file- 参数:
fn- File patha- ArraycolNum- Column number of each lineformat- String formatdelimiter- Delimiter- 抛出:
IOException
-
readBinFile
public static Array readBinFile(String fn, List<Integer> dims, String dataType, int skip, String byteOrder)
Read array from a binary file- 参数:
fn- Binary file namedims- DimensionsdataType- Data type stringskip- Skip bytesbyteOrder- Byte order- 返回:
- Result array
-
readBinFile
public static Array readBinFile(String fn, DataType dataType, int count, int offset) throws IOException
Read array from a binary file- 参数:
fn- Binary file namedataType- Data typecount- Number of items to read. -1 means all items (i.e., the complete file)offset- Offset bytes- 返回:
- Result array
- 抛出:
IOException
-
readBinFile
public static Array readBinFile(String fn, DataType dataType, int count, int offset, String byteOrder) throws IOException
Read array from a binary file- 参数:
fn- Binary file namedataType- Data typecount- Number of items to read. -1 means all items (i.e., the complete file)offset- Offset bytesbyteOrder- Byte order- 返回:
- Result array
- 抛出:
IOException
-
fromBuffer
public static Array fromBuffer(byte[] buffer, DataType dataType, int count, int offset)
Read array from a buffer byte array- 参数:
buffer- Buffer datadataType- Data typecount- Number of items to read. -1 means all items (i.e., the complete file)offset- Offset bytes- 返回:
- Result array
-
fromBuffer
public static Array fromBuffer(byte[] buffer, DataType dataType, int count, int offset, String byteOrder)
Read array from a buffer byte array- 参数:
buffer- Buffer datadataType- Data typecount- Number of items to read. -1 means all items (i.e., the complete file)offset- Offset bytesbyteOrder- Byte order- 返回:
- Result array
-
array
public static Array array(Object data, DataType dt)
Create an array- 参数:
data- Objectdt- Data type- 返回:
- Array
-
arrayComplex
public static Array arrayComplex(double[] real, double[] image)
Create complex array from real and image data array- 参数:
real- Real data arrayimage- Image data array- 返回:
- Complex array
-
array_list
public static Array array_list(List data, DataType dt)
Create an array- 参数:
data- Array like datadt- Data type- 返回:
- Array
-
view
public static Array view(Array a)
New view of array with the same data.- 参数:
a- Input array- 返回:
- View array
-
arrayRange_bak
public static Array arrayRange_bak(Number start, Number stop, Number step)
Array range- 参数:
start- Start valuestop- Stop valuestep- Step value- 返回:
- Array
-
arrayRange
public static Array arrayRange(Number start, Number stop, Number step)
Array range- 参数:
start- Start valuestop- Stop valuestep- Step value- 返回:
- Array
-
arrayRange1
public static Array arrayRange1(Number start, int length, Number step)
Array range- 参数:
start- Start valuelength- Lengthstep- Step value- 返回:
- Array
-
lineSpace
public static Array lineSpace(Number start, Number stop, int n)
Array line space - stop is included- 参数:
start- Start valuestop- Stop valuen- Number value- 返回:
- Array
-
lineSpace
public static Array lineSpace(Number start, Number stop, int n, boolean endpoint)
Array line space- 参数:
start- Start valuestop- Stop valuen- Number valueendpoint- If stop is included- 返回:
- Array
-
lineSpace_bak
public static Array lineSpace_bak(Number start, Number stop, int n, boolean endpoint)
Array line space- 参数:
start- Start valuestop- Stop valuen- Number valueendpoint- If stop is included- 返回:
- Array
-
zeros
public static Array zeros(int n)
Get zero array- 参数:
n- Number- 返回:
- Array
-
zeros
public static Array zeros(List<Integer> shape, String dtype)
Get zero array- 参数:
shape- Shapedtype- Data type- 返回:
- Array Result array
-
zeros
public static Array zeros(List<Integer> shape, DataType dtype)
Get zero array- 参数:
shape- Shapedtype- Data type- 返回:
- Array Result array
-
zeros
public static Array zeros(int[] shape, DataType dtype)
Get zero array- 参数:
shape- Shapedtype- Data type- 返回:
- Array Result array
-
empty
public static Array empty(List<Integer> shape, DataType dtype)
Get zero array- 参数:
shape- Shapedtype- Data type- 返回:
- Array Result array
-
full
public static Array full(int[] shape, Object fillValue, DataType dtype)
Return a new array of given shape and type, filled with fill value.- 参数:
shape- ShapefillValue- Fill valuedtype- Data type- 返回:
- Array Result array
-
full
public static Array full(List<Integer> shape, Object fillValue, DataType dtype)
Return a new array of given shape and type, filled with fill value.- 参数:
shape- ShapefillValue- Fill valuedtype- Data type- 返回:
- Array Result array
-
full
public static Array full(List<Integer> shape, Array fillValue, DataType dtype)
Return a new array of given shape and type, filled with fill value.- 参数:
shape- ShapefillValue- Fill value arraydtype- Data type- 返回:
- Array Result array
-
ones
public static Array ones(int n)
Get ones array- 参数:
n- Number- 返回:
- Array Result array
-
ones
public static Array ones(List<Integer> shape, DataType dtype)
Get ones array- 参数:
shape- Shapedtype- Data type- 返回:
- Array Result array
-
identity
public static Array identity(int n, DataType dtype)
Return the identity array - a square array with ones on the main diagonal.- 参数:
n- Number of rows (and columns) in n x n output.dtype- Data type- 返回:
- Identity array
-
eye
public static Array eye(int n, int m, int k, DataType dtype)
Return a 2-D array with ones on the diagonal and zeros elsewhere.- 参数:
n- Number of rows in the output.m- Number of columns in the output.k- Index of the diagonal: 0 (the default) refers to the main diagonal, a positive value refers to an upper diagonal, and a negative value to a lower diagonal.dtype- Data type- 返回:
- Created array
-
diag
public static Array diag(Array a, int k)
Extract a diagonal or construct a diagonal array.- 参数:
a- If a is a 2-D array, return a copy of its k-th diagonal. If a is a 1-D array, return a 2-D array with a on the k-th diagonal.k- Diagonal in question.- 返回:
- Diagonal array
-
magic
public static Array magic(int n)
Generate magic 2D array- 参数:
n- Dimension length- 返回:
- Magic 2D array
-
toeplitz
public static Array toeplitz(Array col, Array row)
Returns a Toeplitz matrix in which each descending diagonal from left to right is constant.- 参数:
col- First column of the matrix.A[i, j] = kl[i - j]fori > jrow- First row of the matrix.A[i, j] = ku[j - i]fori <= j- 返回:
- the Toeplitz matrix.
-
repeat
public static Array repeat(Number v, int n)
Repeat a value n times- 参数:
v- The valuen- N times- 返回:
- Repeated array
-
repeat
public static Array repeat(Array a, List<Integer> repeats)
Repeat elements of an array.- 参数:
a- The valuerepeats- The number of repetitions for each element- 返回:
- Repeated array
-
repeat
public static Array repeat(Array a, List<Integer> repeats, int axis)
Repeat elements of an array.- 参数:
a- The valuerepeats- The number of repetitions for each elementaxis- The axis- 返回:
- Repeated array
-
tile
public static Array tile(Number v, int n)
Repeat a value n times- 参数:
v- The valuen- N times- 返回:
- Repeated array
-
tile
public static Array tile(Number v, List<Integer> repeats)
Repeat a value n times- 参数:
v- The valuerepeats- The number of repetitions for each element- 返回:
- Repeated array
-
tile
public static Array tile(Array a, List<Integer> repeats)
Repeat elements of an array.- 参数:
a- The valuerepeats- The number of repetitions for each element- 返回:
- Repeated array
-
rand
public static double rand()
Get random value- 返回:
- Random value
-
rand
public static Array rand(int n)
Get random array - one dimension- 参数:
n- Array length- 返回:
- Result array
-
rand
public static Array rand(List<Integer> shape)
Get random array- 参数:
shape- Shape- 返回:
- Array Result array
-
mergeDataType
public static DataType mergeDataType(DataType dt1, DataType dt2)
Merge data type to one data type- 参数:
dt1- Data type 1dt2- Data type 2- 返回:
- Merged data type
-
nonzero
public static List<Array> nonzero(Array a)
Return the indices of the elements that are non-zero.- 参数:
a- Input array- 返回:
- Indices
-
flatNonZero
public static Array flatNonZero(Array a)
Return the flat indices of the elements that are non-zero.- 参数:
a- Input array- 返回:
- Flat indices
-
convertToString
public static String convertToString(Array a)
Array to string- 参数:
a- Array a- 返回:
- String
-
dataTypeString
public static String dataTypeString(DataType dt)
Get data type string- 参数:
dt- The data type- 返回:
- Data type string
-
toDataType
public static DataType toDataType(String dt)
To data type - ucar.ma2- 参数:
dt- Data type string- 返回:
- Data type
-
convertToDataType
public static Array convertToDataType(Array a, DataType dataType)
Convert array to another data type- 参数:
a- The input arraydataType- The data type to be converted- 返回:
- Converted array
-
toInteger
public static Array toInteger(Array a)
Convert array to integer type- 参数:
a- Array a- 返回:
- Result array
-
toFloat
public static Array toFloat(Array a)
Convert array to float type- 参数:
a- Array a- 返回:
- Result array
-
toDouble
public static Array toDouble(Array a)
Convert array to double type- 参数:
a- Array a- 返回:
- Result array
-
toBoolean
public static Array toBoolean(Array a)
Convert array to boolean type- 参数:
a- Array a- 返回:
- Result array
-
toDate
public static Array toDate(Array a)
Convert array to date type- 参数:
a- Array a- 返回:
- Result array
-
convertEncoding
public static Array convertEncoding(ArrayChar a, String encoding)
Convert char array encoding from UTF-8- 参数:
a- Char arrayencoding- The encoding convert to- 返回:
- Converted array
-
getString
public static String getString(ArrayChar a, String encoding)
Get string from a char array- 参数:
a- Char arrayencoding- The encoding convert to- 返回:
- The string
-
concatenate
public static Array concatenate(List<Array> arrays, Integer axis) throws InvalidRangeException
Concatenate arrays to one array along an axis- 参数:
arrays- Array listaxis- The axis- 返回:
- Concatenated array
- 抛出:
InvalidRangeException
-
concatenate
public static Array concatenate(Array a, Array b, Integer axis) throws InvalidRangeException
Concatenate two arrays to one array along an axis- 参数:
a- Array ab- Array baxis- The axis- 返回:
- Concatenated array
- 抛出:
InvalidRangeException
-
arraySplit
public static List<Array> arraySplit(Array a, int sections, int axis)
Split an Array- 参数:
a- Input arraysections-axis-- 返回:
-
unPack
public static Array unPack(Array a, double missingValue, double scaleFactor, double addOffset)
Unpack array by missing value, scale factor and add offset- 参数:
a- Input arraymissingValue- Missing valuescaleFactor- Scale factoraddOffset- Add offset- 返回:
- Output array
-
sort
public static Array sort(Array a, Integer axis) throws InvalidRangeException
Sort array along an axis- 参数:
a- Array aaxis- The axis- 返回:
- Sorted array
- 抛出:
InvalidRangeException
-
argSort
public static Array argSort(Array a, Integer axis) throws InvalidRangeException
Get sorted array index along an axis- 参数:
a- Array aaxis- The axis- 返回:
- Index of sorted array
- 抛出:
InvalidRangeException
-
searchSorted
public static int searchSorted(Array a, Number v, boolean left)
Find indices where elements should be inserted to maintain order.- 参数:
a- Input arrayv- Valueleft- Left side or right side- 返回:
- indices
-
searchSorted
public static Array searchSorted(Array a, Array v, boolean left)
Find indices where elements should be inserted to maintain order.- 参数:
a- Input arrayv- Value arrayleft- Left side or right side- 返回:
- indices
-
unique
public static Array unique(Array a, Integer axis) throws InvalidRangeException
Find the unique elements of an array.- 参数:
a- Array aaxis- The axis- 返回:
- The sorted unique elements of an array
- 抛出:
InvalidRangeException
-
isUnique
public static boolean isUnique(Array a, int limit)
Check array is unique by unique value number- 参数:
a- The arraylimit- The limit unique value number- 返回:
- Is unique or not
-
uniqueIndex
public static Array[] uniqueIndex(Array a, Integer axis) throws InvalidRangeException
Find the unique elements and index of an array.- 参数:
a- Array aaxis- The axis- 返回:
- The sorted unique elements and index of an array
- 抛出:
InvalidRangeException
-
copyToNDJavaArray
public static Object copyToNDJavaArray(Array a, String dtype)
Convert array to N-Dimension double Java array- 参数:
a- Array adtype- Data type string- 返回:
- N-D Java array
-
copyToNDJavaArray
public static Object copyToNDJavaArray(Array a)
Convert array to N-Dimension double Java array- 参数:
a- Array a- 返回:
- N-D Java array
-
copyToNDJavaArray_Long
public static Object copyToNDJavaArray_Long(Array a)
Convert array to N-Dimension double Java array- 参数:
a- Array a- 返回:
- N-D Java array
-
copyToNDJavaArray_Double
public static Object copyToNDJavaArray_Double(Array a)
Convert array to N-Dimension double Java array- 参数:
a- Array a- 返回:
- N-D Java array
-
copyToNDJavaArray_Double
public static Object copyToNDJavaArray_Double(Array a, double missingValue)
Convert array to N-Dimension double Java array- 参数:
a- Array amissingValue- The missing value- 返回:
- N-D Java array
-
copyTo1DJavaArray
protected static void copyTo1DJavaArray(IndexIterator iter, Object javaArray)
-
copyTo1DJavaArray
protected static void copyTo1DJavaArray(IndexIterator iter, Object javaArray, double missingValue)
-
copyTo1DJavaArray_Long
protected static void copyTo1DJavaArray_Long(IndexIterator iter, Object javaArray)
-
delete
public static Array delete(Array a, int idx, int axis)
Return a new array with sub-arrays along an axis deleted- 参数:
a- Input arrayidx- Indexaxis- The axis- 返回:
-
delete
public static Array delete(Array a, List<Integer> idx, int axis)
Return a new array with sub-arrays along an axis deleted- 参数:
a- Input arrayidx- Indexaxis- The axis- 返回:
-
histogram
public static List<Array> histogram(Array a, int nbins)
Histogram x/y array- 参数:
a- Data arraynbins- bin number- 返回:
- X/Y arrays
-
histogram
public static List<Array> histogram(Array a, Array bins)
Histogram x/y array- 参数:
a- Data arraybins- bin edges- 返回:
- X/Y arrays
-
histogram
public static List<Array> histogram(Array a, double[] bins)
Histogram x/y array- 参数:
a- Data arraybins- bin edges- 返回:
- X/Y arrays
-
broadcastShapes
public static int[] broadcastShapes(List<List<Integer>> shapes)
Broadcast shape list to a new shape- 参数:
shapes- The shape list- 返回:
- Result shape
-
broadcast
public static Array broadcast(Array a, int[] shape)
Broadcast array to a new shape- 参数:
a- Array ashape- Shape- 返回:
- Result array
-
broadcast
public static Array broadcast(Array a, List<Integer> shape)
Broadcast array to a new shape- 参数:
a- Array ashape- Shape- 返回:
- Result array
-
meshgrid
public static Array[] meshgrid(Array x, Array y)
Mesh grid- 参数:
x- X array - vectory- Y array - vector- 返回:
- Result arrays - matrix
-
meshgrid
public static Array[] meshgrid(Array x)
Mesh grid- 参数:
x- X array - vector- 返回:
- Result arrays - matrix
-
meshgrid
public static Array[] meshgrid(Array... xs)
Mesh grid- 参数:
xs- X arrays- 返回:
- Result arrays - matrix
-
smooth5
public static Array smooth5(Array a, int rowNum, int colNum, double unDefData)
Smooth with 5 points- 参数:
a- ArrayrowNum- Row numbercolNum- Column numberunDefData- Missing value- 返回:
- Result array
-
interpolation_Nearest_1
public static Array interpolation_Nearest_1(List<Number> x_s, List<Number> y_s, Array a, List<Number> X, List<Number> Y, double radius, double fill_value)
Interpolate with the nearest method- 参数:
x_s- scatter X arrayy_s- scatter Y arraya- scatter value arrayX- x coordinateY- y coordinateradius- Radiusfill_value- undefine value- 返回:
- grid data
-
interpolation_Nearest_bak
public static Array interpolation_Nearest_bak(List<Number> x_s, List<Number> y_s, Array a, List<Number> X, List<Number> Y, double radius)
Interpolate with nearest method- 参数:
x_s- scatter X arrayy_s- scatter Y arraya- scatter value arrayX- x coordinateY- y coordinateradius- Radius- 返回:
- grid data
-
extendHalfCell
public static Array[] extendHalfCell(Array x, Array y)
Extend the grid to half cell, so the grid points are the centers of the cells- 参数:
x- Input x coordinatey- Input y coordinate- 返回:
- Result x and y coordinates
-
interpolation_Inside
public static Array interpolation_Inside(List<Number> x_s, List<Number> y_s, Array a, List<Number> X, List<Number> Y)
Interpolate with inside method - The grid cell value is the average value of the inside points or fill value if no inside point.- 参数:
x_s- scatter X arrayy_s- scatter Y arraya- scatter value arrayX- x coordinateY- y coordinate- 返回:
- grid data
-
interpolation_Inside_Mean
public static Array interpolation_Inside_Mean(Array x_s, Array y_s, Array a, Array X, Array Y, boolean center)
Interpolate with inside method - The grid cell value is the average value of the inside points or fill value if no inside point.- 参数:
x_s- scatter X arrayy_s- scatter Y arraya- scatter value arrayX- x coordinateY- y coordinatecenter- If the grid point is center or border- 返回:
- grid data
-
interpolation_Inside_Max
public static Array interpolation_Inside_Max(List<Number> x_s, List<Number> y_s, Array a, List<Number> X, List<Number> Y)
Interpolate with inside method - The grid cell value is the maximum value of the inside points or fill value if no inside point.- 参数:
x_s- scatter X arrayy_s- scatter Y arraya- scatter value arrayX- x coordinateY- y coordinate- 返回:
- grid data
-
interpolation_Inside_Min
public static Array interpolation_Inside_Min(List<Number> x_s, List<Number> y_s, Array a, List<Number> X, List<Number> Y)
Interpolate with inside method - The grid cell value is the minimum value of the inside points or fill value if no inside point.- 参数:
x_s- scatter X arrayy_s- scatter Y arraya- scatter value arrayX- x coordinateY- y coordinate- 返回:
- grid data
-
interpolation_Inside_Count
public static Object interpolation_Inside_Count(List<Number> x_s, List<Number> y_s, List<Number> X, List<Number> Y, boolean pointDensity, boolean centerPoint)
Interpolate with inside method - The grid cell value is the count number of the inside points or fill value if no inside point.- 参数:
x_s- scatter X arrayy_s- scatter Y arrayX- x coordinateY- y coordinatepointDensity- If return point density valuecenterPoint- points locate at center or border of grid- 返回:
- grid data
-
cressman
public static Array cressman(List<Number> x_s, List<Number> y_s, Array v_s, List<Number> X, List<Number> Y, List<Number> radList)
Cressman analysis- 参数:
x_s- scatter X arrayy_s- scatter Y arrayv_s- scatter value arrayX- x arrayY- y arrayradList- radii list- 返回:
- result grid data
-
cressman_bak
public static Array cressman_bak(List<Number> x_s, List<Number> y_s, Array v_s, List<Number> X, List<Number> Y, List<Number> radList)
Cressman analysis- 参数:
x_s- scatter X arrayy_s- scatter Y arrayv_s- scatter value arrayX- x arrayY- y arrayradList- radii list- 返回:
- result grid data
-
linint2
public static Array linint2(Array a, Array X, Array Y, Array newX, Array newY)
Interpolates from a rectilinear grid to another rectilinear grid using bilinear interpolation.- 参数:
a- The sample arrayX- X coordinate of the sample arrayY- Y coordinate of the sample arraynewX- X coordinate of the query pointsnewY- Y coordinate of the query points- 返回:
- Resampled array
-
slice
public static Array slice(Array a, int axis, int idx) throws InvalidRangeException
Get slice array along an axis- 参数:
a- The original arrayaxis- The axisidx- The axis index- 返回:
- Slice array
- 抛出:
InvalidRangeException
-
slice
public static Array slice(Array a, int axis, Array dim, double v) throws InvalidRangeException
Get slice array along an axis- 参数:
a- The original arrayaxis- The axisdim- axis dimension arrayv- axis value of slice- 返回:
- Slice array
- 抛出:
InvalidRangeException
-
resample_Bilinear
public static Array resample_Bilinear(Array a, List<Number> X, List<Number> Y, List<Number> newX, List<Number> newY)
Resample grid array with bilinear method- 参数:
a- The sample arrayX- X coordinate of the sample arrayY- Y coordinate of the sample arraynewX- X coordinate of the query pointsnewY- Y coordinate of the query points- 返回:
- Resampled array
-
resample_Bilinear
public static Array resample_Bilinear(Array a, Array X, Array Y, Array newX, Array newY)
Resample grid array with bilinear method- 参数:
a- The sample arrayX- X coordinate of the sample arrayY- Y coordinate of the sample arraynewX- X coordinate of the query pointsnewY- Y coordinate of the query points- 返回:
- Resampled array
-
resample_Neighbor
public static Array resample_Neighbor(Array a, Array X, Array Y, Array newX, Array newY)
Resample grid array with neighbor method- 参数:
a- The sample arrayX- X coordinate of the sample arrayY- Y coordinate of the sample arraynewX- X coordinate of the query pointsnewY- Y coordinate of the query points- 返回:
- Resampled array
-
interpolate
public Array interpolate(Array a, List<Number> X, List<Number> Y)
Interpolate array data- 参数:
a- ArrayX- X coordinatesY- Y coordinates- 返回:
- Result array data
-
interpn_s
public static double interpn_s(List<List<Number>> points, Array values, List<Number> xi)
Multidimensional interpolation on regular grids.- 参数:
points- The points defining the regular grid in n dimensions.values- The data on the regular grid in n dimensions.xi- The coordinates to sample the gridded data at- 返回:
- Interpolation value
-
interpn_s
public static double interpn_s(List<Array> points, Array values, Array xi)
Multidimensional interpolation on regular grids.- 参数:
points- The points defining the regular grid in n dimensions.values- The data on the regular grid in n dimensions.xi- The coordinates to sample the gridded data at- 返回:
- Interpolation value
-
interpn
public static Array interpn(List<Array> points, Array values, List<Array> xi)
Multidimensional interpolation on regular grids.- 参数:
points- The points defining the regular grid in n dimensions.values- The data on the regular grid in n dimensions.xi- The coordinates to sample the gridded data at - 2D- 返回:
- Interpolation value
-
interpn
public static Object interpn(List<Array> points, Array values, Array xi) throws InvalidRangeException
Multidimensional interpolation on regular grids.- 参数:
points- The points defining the regular grid in n dimensions.values- The data on the regular grid in n dimensions.xi- The coordinates to sample the gridded data at - 2D- 返回:
- Interpolation value
- 抛出:
ucar.ma2.InvalidRangeExceptionInvalidRangeException
-
findIndices
public static Object[] findIndices(List<List<Number>> points, List<Number> xi)
Find indices- 参数:
points- The points defining the regular grid in n dimensions.xi- The coordinates to sample the gridded data at- 返回:
- Indices
-
findIndices
public static Object[] findIndices(List<Array> points, Array xi)
Find indices- 参数:
points- The points defining the regular grid in n dimensions.xi- The coordinates to sample the gridded data at- 返回:
- Indices
-
searchSorted
public static int searchSorted(List<Number> a, double v)
Search sorted list index- 参数:
a- Sorted listv- value- 返回:
- Index
-
searchSorted
public static int searchSorted(Array a, double v)
Search sorted list index- 参数:
a- Sorted listv- value- 返回:
- Index
-
searchSorted1
public static int[] searchSorted1(Array a, double v)
Search sorted list index- 参数:
a- Sorted listv- value- 返回:
- Index
-
interpolate_1d
public static Array interpolate_1d(double x, Array xp, Array a, int axis) throws InvalidRangeException
Interpolates data with any shape over a specified axis.- 参数:
x- Desired interpolated valuexp- The x-coordinates of the data points.a- The data to be interpolated.axis- The axis to interpolate over.- 返回:
- Interpolated data
- 抛出:
InvalidRangeException
-
interpolate_1d
public static Array interpolate_1d(Array xa, Array xp, Array a, int axis) throws InvalidRangeException
Interpolates data with any shape over a specified axis.- 参数:
xa- Desired interpolated valuesxp- The x-coordinates of the data points.a- The data to be interpolated.axis- The axis to interpolate over.- 返回:
- Interpolated data
- 抛出:
InvalidRangeException
-
toStation
public static double toStation(Array data, List<Number> xArray, List<Number> yArray, double x, double y, double missingValue)
Interpolate data to a station point- 参数:
data- Data arrayxArray- X arrayyArray- Y arrayx- X coordinate of the stationy- Y coordinate of the stationmissingValue- Missing value- 返回:
- Interpolated value
-
toStation
public static double toStation(Array data, List<Number> xArray, List<Number> yArray, double x, double y)
Interpolate data to a station point- 参数:
data- Data arrayxArray- X arrayyArray- Y arrayx- X coordinate of the stationy- Y coordinate of the station- 返回:
- Interpolated value
-
getDimIndex
public static int getDimIndex(Array dim, Number v)
Get value index in a dimension array- 参数:
dim- Dimension arrayv- The value- 返回:
- value index
-
gridIndex
public static int[] gridIndex(Array xdim, Array ydim, double x, double y)
Get grid array x/y value index- 参数:
xdim- X coordinate arrayydim- Y coordinate arrayx- X valuey- Y value- 返回:
- X/Y index
-
gridIndex
public static int[] gridIndex(double[][] xdim, double[][] ydim, double x, double y)Get grid array x/y value index- 参数:
xdim- X coordinate arrayydim- Y coordinate arrayx- X valuey- Y value- 返回:
- X/Y index
-
toStation
public static double toStation(Array data, Array xArray, Array yArray, double x, double y)
Interpolate data to a station point- 参数:
data- Data arrayxArray- X arrayyArray- Y arrayx- X coordinate of the stationy- Y coordinate of the station- 返回:
- Interpolated value
-
toStation_Neighbor
public static double toStation_Neighbor(Array data, List<Number> xArray, List<Number> yArray, double x, double y, double missingValue)
Interpolate data to a station point- 参数:
data- Data arrayxArray- X arrayyArray- Y arrayx- X coordinate of the stationy- Y coordinate of the stationmissingValue- Missing value- 返回:
- Interpolated value
-
toStation_Neighbor
public static double toStation_Neighbor(Array data, List<Number> xArray, List<Number> yArray, double x, double y)
Interpolate data to a station point- 参数:
data- Data arrayxArray- X arrayyArray- Y arrayx- X coordinate of the stationy- Y coordinate of the station- 返回:
- Interpolated value
-
-