mirror of
https://github.com/meteoinfo/MeteoInfo.git
synced 2025-12-08 20:36:05 +00:00
add spacing function
This commit is contained in:
parent
a4bfa3b8fc
commit
fc8f674e71
@ -1,30 +1,34 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
<MeteoInfo File="milconfig.xml" Type="configurefile">
|
<MeteoInfo File="milconfig.xml" Type="configurefile">
|
||||||
<Path OpenPath="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\isosurface">
|
<Path OpenPath="D:\Working\MIScript\Jython\mis\plot_types\animation">
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math\interpolate"/>
|
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\imshow"/>
|
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\surf"/>
|
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl"/>
|
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d"/>
|
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types"/>
|
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\funny"/>
|
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis"/>
|
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\array"/>
|
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\meteo\wrf"/>
|
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\awx"/>
|
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io"/>
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\json"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\json"/>
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\contour"/>
|
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\isosurface"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\isosurface"/>
|
||||||
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl"/>
|
||||||
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d"/>
|
||||||
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\no_opengl"/>
|
||||||
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\geoshow"/>
|
||||||
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\satellite"/>
|
||||||
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\satellite\oco-2"/>
|
||||||
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\map"/>
|
||||||
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis"/>
|
||||||
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\array"/>
|
||||||
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\contour"/>
|
||||||
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types"/>
|
||||||
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\animation"/>
|
||||||
</Path>
|
</Path>
|
||||||
<File>
|
<File>
|
||||||
<OpenedFiles>
|
<OpenedFiles>
|
||||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\contour\contourf_extend_max.py"/>
|
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\geoshow\geoshow_image_2.py"/>
|
||||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\isosurface\isosurface_4.py"/>
|
<OpenedFile File="D:\Working\MIScript\Jython\mis\map\northarrow_lcc.py"/>
|
||||||
|
<OpenedFile File="D:\Working\MIScript\Jython\mis\array\spacing.py"/>
|
||||||
|
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\animation\surf.py"/>
|
||||||
</OpenedFiles>
|
</OpenedFiles>
|
||||||
<RecentFiles>
|
<RecentFiles>
|
||||||
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\contour\contourf_extend_max.py"/>
|
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\geoshow\geoshow_image_2.py"/>
|
||||||
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\isosurface\isosurface_4.py"/>
|
<RecentFile File="D:\Working\MIScript\Jython\mis\map\northarrow_lcc.py"/>
|
||||||
|
<RecentFile File="D:\Working\MIScript\Jython\mis\array\spacing.py"/>
|
||||||
|
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\animation\surf.py"/>
|
||||||
</RecentFiles>
|
</RecentFiles>
|
||||||
</File>
|
</File>
|
||||||
<Font>
|
<Font>
|
||||||
|
|||||||
Binary file not shown.
@ -12,6 +12,7 @@ import math
|
|||||||
from ... import miutil
|
from ... import miutil
|
||||||
import numbers
|
import numbers
|
||||||
import operator
|
import operator
|
||||||
|
import sys
|
||||||
import __builtin__
|
import __builtin__
|
||||||
from java.lang import Math, Double
|
from java.lang import Math, Double
|
||||||
from java.util import Calendar
|
from java.util import Calendar
|
||||||
@ -47,7 +48,7 @@ __all__ = [
|
|||||||
'magnitude','max','maximum','mean','median','meshgrid','min','minimum','monthname',
|
'magnitude','max','maximum','mean','median','meshgrid','min','minimum','monthname',
|
||||||
'moveaxis','newaxis','ones','ones_like','outer','peaks','pol2cart','power','radians','reciprocal','reshape',
|
'moveaxis','newaxis','ones','ones_like','outer','peaks','pol2cart','power','radians','reciprocal','reshape',
|
||||||
'repeat','roll','rolling_mean','rot90','round','sec','sign','sin','sinh','shape','smooth5','smooth9','sort',
|
'repeat','roll','rolling_mean','rot90','round','sec','sign','sin','sinh','shape','smooth5','smooth9','sort',
|
||||||
'sphere','squeeze','split','sqrt','square','std','swapaxes','take','tan','tanh','tile',
|
'spacing','sphere','squeeze','split','sqrt','square','std','swapaxes','take','tan','tanh','tile',
|
||||||
'transpose','trapz','vdot','unravel_index','var','vstack','zeros','zeros_like'
|
'transpose','trapz','vdot','unravel_index','var','vstack','zeros','zeros_like'
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -1203,6 +1204,22 @@ def conj(x):
|
|||||||
:return: (*array*) Complex conjugate array.
|
:return: (*array*) Complex conjugate array.
|
||||||
"""
|
"""
|
||||||
return conjugate(x)
|
return conjugate(x)
|
||||||
|
|
||||||
|
def spacing(x):
|
||||||
|
"""
|
||||||
|
Return the distance between x and the nearest adjacent number.
|
||||||
|
|
||||||
|
:param x: (*array*) Values to find the spacing of.
|
||||||
|
|
||||||
|
:return: (*array*) The spacing of values of x. This is a scalar if x is a scalar.
|
||||||
|
"""
|
||||||
|
if isinstance(x, (list, tuple)):
|
||||||
|
x = array(x)
|
||||||
|
|
||||||
|
if isinstance(x, NDArray):
|
||||||
|
return NDArray(ArrayMath.spacing(x._array))
|
||||||
|
else:
|
||||||
|
return Math.ulp(x)
|
||||||
|
|
||||||
def any(x, axis=None):
|
def any(x, axis=None):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@ -4955,6 +4955,33 @@ public class ArrayMath {
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the distance between x and the nearest adjacent number
|
||||||
|
*
|
||||||
|
* @param x Input array
|
||||||
|
* @return Spacing array
|
||||||
|
*/
|
||||||
|
public static Array spacing(Array x) {
|
||||||
|
DataType dataType = DataType.FLOAT;
|
||||||
|
if (x.getDataType() == DataType.DOUBLE) {
|
||||||
|
dataType = DataType.DOUBLE;
|
||||||
|
}
|
||||||
|
Array r = Array.factory(dataType, x.getShape());
|
||||||
|
if (x.getIndexPrivate().isFastIterator()) {
|
||||||
|
for (int i = 0; i < r.getSize(); i++) {
|
||||||
|
r.setObject(i, Math.ulp(x.getDouble(i)));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
IndexIterator iterX = x.getIndexIterator();
|
||||||
|
IndexIterator iterR = r.getIndexIterator();
|
||||||
|
while (iterX.hasNext()) {
|
||||||
|
iterR.setObjectNext(Math.ulp(iterX.getDoubleNext()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
// </editor-fold>
|
// </editor-fold>
|
||||||
// <editor-fold desc="Matrix">
|
// <editor-fold desc="Matrix">
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user