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"?>
|
||||
<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\regression"/>
|
||||
<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\jogl"/>
|
||||
<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\common_math"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\common_math\optimize"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\micaps"/>
|
||||
<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>
|
||||
<File>
|
||||
<OpenedFiles>
|
||||
<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\array\sec_1.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\array\sec_2.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\surf\surf_spherical_harmonic_1.py"/>
|
||||
</OpenedFiles>
|
||||
<RecentFiles>
|
||||
<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\array\sec_1.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\array\sec_2.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\3d\jogl\surf\surf_spherical_harmonic_1.py"/>
|
||||
</RecentFiles>
|
||||
</File>
|
||||
<Font>
|
||||
|
||||
Binary file not shown.
@ -1941,7 +1941,6 @@ def hstack(tup):
|
||||
else:
|
||||
return concatenate(arrs, 1)
|
||||
|
||||
|
||||
def dot(a, b):
|
||||
"""
|
||||
Matrix multiplication.
|
||||
@ -1956,8 +1955,13 @@ def dot(a, b):
|
||||
|
||||
if isinstance(a, list):
|
||||
a = array(a)
|
||||
|
||||
if isinstance(b, list):
|
||||
b = array(b)
|
||||
|
||||
if a.ndim == 1 and b.ndim == 1:
|
||||
return vdot(a, b)
|
||||
|
||||
r = LinalgUtil.dot(a.asarray(), b.asarray())
|
||||
return NDArray(r)
|
||||
|
||||
@ -1976,8 +1980,10 @@ def vdot(a, b):
|
||||
"""
|
||||
if isinstance(a, list):
|
||||
a = array(a)
|
||||
|
||||
if isinstance(b, list):
|
||||
b = array(b)
|
||||
|
||||
if a.ndim > 1:
|
||||
a = a.flatten()
|
||||
if b.ndim > 1:
|
||||
|
||||
@ -3,11 +3,15 @@ Universal math functions
|
||||
"""
|
||||
|
||||
import __builtin__
|
||||
import math
|
||||
|
||||
from org.meteoinfo.ndarray.math import ArrayMath
|
||||
|
||||
from ._ndarray import NDArray
|
||||
from .numeric import sign
|
||||
from .numeric import array, sign
|
||||
|
||||
__all__ = [
|
||||
'absolute','add','divmod','floor_divide','fmod','mod','remainder'
|
||||
'absolute','add','deg2rad','divmod','floor_divide','fmod','mod','rad2deg','remainder'
|
||||
]
|
||||
|
||||
def absolute(x):
|
||||
@ -21,6 +25,7 @@ def absolute(x):
|
||||
"""
|
||||
if isinstance(x, list):
|
||||
x = array(x)
|
||||
|
||||
if isinstance(x, NDArray):
|
||||
return x.abs()
|
||||
else:
|
||||
@ -132,4 +137,36 @@ def fmod(x1, x2):
|
||||
:return: Element-wise remainder array.
|
||||
"""
|
||||
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 {
|
||||
IndexIterator iterA = a.getIndexIterator();
|
||||
IndexIterator iterB = a.getIndexIterator();
|
||||
IndexIterator iterB = b.getIndexIterator();
|
||||
while (iterA.hasNext()) {
|
||||
r += iterA.getDoubleNext() * iterB.getDoubleNext();
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user