mirror of
https://github.com/meteoinfo/MeteoInfo.git
synced 2025-12-08 20:36:05 +00:00
add deg2rad and rad2deg functions
This commit is contained in:
parent
d08f639379
commit
1c79a5b405
@ -1,35 +1,32 @@
|
|||||||
<?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\array">
|
<Path OpenPath="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\surf">
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\toolbox\miml"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\toolbox\miml"/>
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\toolbox\miml\regression"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\toolbox\miml\regression"/>
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d"/>
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\3d_earth"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\3d_earth"/>
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl"/>
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\volume"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\volume"/>
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\surf"/>
|
|
||||||
<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\common_math"/>
|
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math\optimize"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math\optimize"/>
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis"/>
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io"/>
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\micaps"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\micaps"/>
|
||||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\array"/>
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\array"/>
|
||||||
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math"/>
|
||||||
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math\linalg"/>
|
||||||
|
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\surf"/>
|
||||||
</Path>
|
</Path>
|
||||||
<File>
|
<File>
|
||||||
<OpenedFiles>
|
<OpenedFiles>
|
||||||
<OpenedFile File="D:\MyProgram\java\MeteoInfoDev\toolbox\meteoview3d\mainGUI.py"/>
|
<OpenedFile File="D:\MyProgram\java\MeteoInfoDev\toolbox\meteoview3d\mainGUI.py"/>
|
||||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\surf\surf_2.py"/>
|
|
||||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\isosurface\heart_cdata.py"/>
|
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\isosurface\heart_cdata.py"/>
|
||||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\array\sec_1.py"/>
|
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\surf\surf_spherical_harmonic_1.py"/>
|
||||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\array\sec_2.py"/>
|
|
||||||
</OpenedFiles>
|
</OpenedFiles>
|
||||||
<RecentFiles>
|
<RecentFiles>
|
||||||
<RecentFile File="D:\MyProgram\java\MeteoInfoDev\toolbox\meteoview3d\mainGUI.py"/>
|
<RecentFile File="D:\MyProgram\java\MeteoInfoDev\toolbox\meteoview3d\mainGUI.py"/>
|
||||||
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\surf\surf_2.py"/>
|
|
||||||
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\isosurface\heart_cdata.py"/>
|
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\isosurface\heart_cdata.py"/>
|
||||||
<RecentFile File="D:\Working\MIScript\Jython\mis\array\sec_1.py"/>
|
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\surf\surf_spherical_harmonic_1.py"/>
|
||||||
<RecentFile File="D:\Working\MIScript\Jython\mis\array\sec_2.py"/>
|
|
||||||
</RecentFiles>
|
</RecentFiles>
|
||||||
</File>
|
</File>
|
||||||
<Font>
|
<Font>
|
||||||
|
|||||||
Binary file not shown.
@ -1941,7 +1941,6 @@ def hstack(tup):
|
|||||||
else:
|
else:
|
||||||
return concatenate(arrs, 1)
|
return concatenate(arrs, 1)
|
||||||
|
|
||||||
|
|
||||||
def dot(a, b):
|
def dot(a, b):
|
||||||
"""
|
"""
|
||||||
Matrix multiplication.
|
Matrix multiplication.
|
||||||
@ -1956,8 +1955,13 @@ def dot(a, b):
|
|||||||
|
|
||||||
if isinstance(a, list):
|
if isinstance(a, list):
|
||||||
a = array(a)
|
a = array(a)
|
||||||
|
|
||||||
if isinstance(b, list):
|
if isinstance(b, list):
|
||||||
b = array(b)
|
b = array(b)
|
||||||
|
|
||||||
|
if a.ndim == 1 and b.ndim == 1:
|
||||||
|
return vdot(a, b)
|
||||||
|
|
||||||
r = LinalgUtil.dot(a.asarray(), b.asarray())
|
r = LinalgUtil.dot(a.asarray(), b.asarray())
|
||||||
return NDArray(r)
|
return NDArray(r)
|
||||||
|
|
||||||
@ -1976,8 +1980,10 @@ def vdot(a, b):
|
|||||||
"""
|
"""
|
||||||
if isinstance(a, list):
|
if isinstance(a, list):
|
||||||
a = array(a)
|
a = array(a)
|
||||||
|
|
||||||
if isinstance(b, list):
|
if isinstance(b, list):
|
||||||
b = array(b)
|
b = array(b)
|
||||||
|
|
||||||
if a.ndim > 1:
|
if a.ndim > 1:
|
||||||
a = a.flatten()
|
a = a.flatten()
|
||||||
if b.ndim > 1:
|
if b.ndim > 1:
|
||||||
|
|||||||
@ -3,11 +3,15 @@ Universal math functions
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import __builtin__
|
import __builtin__
|
||||||
|
import math
|
||||||
|
|
||||||
|
from org.meteoinfo.ndarray.math import ArrayMath
|
||||||
|
|
||||||
from ._ndarray import NDArray
|
from ._ndarray import NDArray
|
||||||
from .numeric import sign
|
from .numeric import array, sign
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'absolute','add','divmod','floor_divide','fmod','mod','remainder'
|
'absolute','add','deg2rad','divmod','floor_divide','fmod','mod','rad2deg','remainder'
|
||||||
]
|
]
|
||||||
|
|
||||||
def absolute(x):
|
def absolute(x):
|
||||||
@ -21,6 +25,7 @@ def absolute(x):
|
|||||||
"""
|
"""
|
||||||
if isinstance(x, list):
|
if isinstance(x, list):
|
||||||
x = array(x)
|
x = array(x)
|
||||||
|
|
||||||
if isinstance(x, NDArray):
|
if isinstance(x, NDArray):
|
||||||
return x.abs()
|
return x.abs()
|
||||||
else:
|
else:
|
||||||
@ -132,4 +137,36 @@ def fmod(x1, x2):
|
|||||||
:return: Element-wise remainder array.
|
:return: Element-wise remainder array.
|
||||||
"""
|
"""
|
||||||
s = sign(x1)
|
s = sign(x1)
|
||||||
return mod(x1, x2) * s
|
return mod(x1, x2) * s
|
||||||
|
|
||||||
|
def rad2deg(x):
|
||||||
|
"""
|
||||||
|
Convert radians to degrees.
|
||||||
|
|
||||||
|
:param x: (*array_like*) Array in radians.
|
||||||
|
|
||||||
|
:returns: (*array_like*) Array in degrees.
|
||||||
|
"""
|
||||||
|
if isinstance(x, (list, tuple)):
|
||||||
|
x = array(x)
|
||||||
|
|
||||||
|
if isinstance(x, NDArray):
|
||||||
|
return NDArray(ArrayMath.toDegrees(x.asarray()))
|
||||||
|
else:
|
||||||
|
return math.degrees(x)
|
||||||
|
|
||||||
|
def deg2rad(x):
|
||||||
|
"""
|
||||||
|
Convert degrees to radians.
|
||||||
|
|
||||||
|
:param x: (*array_like*) Array in degrees.
|
||||||
|
|
||||||
|
:returns: (*array_like*) Array in radians.
|
||||||
|
"""
|
||||||
|
if isinstance(x, (list, tuple)):
|
||||||
|
x = array(x)
|
||||||
|
|
||||||
|
if isinstance(x, NDArray):
|
||||||
|
return NDArray(ArrayMath.toRadians(x.asarray()))
|
||||||
|
else:
|
||||||
|
return math.radians(x)
|
||||||
@ -5020,7 +5020,7 @@ public class ArrayMath {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
IndexIterator iterA = a.getIndexIterator();
|
IndexIterator iterA = a.getIndexIterator();
|
||||||
IndexIterator iterB = a.getIndexIterator();
|
IndexIterator iterB = b.getIndexIterator();
|
||||||
while (iterA.hasNext()) {
|
while (iterA.hasNext()) {
|
||||||
r += iterA.getDoubleNext() * iterB.getDoubleNext();
|
r += iterA.getDoubleNext() * iterB.getDoubleNext();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user