mirror of
https://github.com/meteoinfo/MeteoInfo.git
synced 2025-12-08 20:36:05 +00:00
add bitwise_and, bitwise_or and bitwise_xor functions
This commit is contained in:
parent
eba0fd101c
commit
89280538a9
@ -1,12 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<MeteoInfo File="milconfig.xml" Type="configurefile">
|
||||
<Path OpenPath="D:\Working\MIScript\Jython\mis\io\netcdf">
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\burf"/>
|
||||
<Path OpenPath="D:\Working\MIScript\Jython\mis\plot_types\animation">
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\binary"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\radar"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io"/>
|
||||
<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\plot"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\grads"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis"/>
|
||||
@ -16,17 +14,17 @@
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\meteo"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\meteo\wrf"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\io\netcdf"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\plot_types\animation"/>
|
||||
</Path>
|
||||
<File>
|
||||
<OpenedFiles>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\dataframe\dataframe_1.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\meteo\typhoon_path_trace.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\io\netcdf\era5_blh.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\plot_types\animation\magic_2.py"/>
|
||||
</OpenedFiles>
|
||||
<RecentFiles>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\dataframe\dataframe_1.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\meteo\typhoon_path_trace.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\io\netcdf\era5_blh.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\plot_types\animation\magic_2.py"/>
|
||||
</RecentFiles>
|
||||
</File>
|
||||
<Font>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@ -301,4 +301,4 @@ def fromjava(dt):
|
||||
|
||||
:returns: Python data type
|
||||
"""
|
||||
return DataType(dt.toString().lower())
|
||||
return DataType(dt.toString().lower())
|
||||
|
||||
Binary file not shown.
@ -22,10 +22,11 @@ from org.meteoinfo.ndarray import Array
|
||||
from org.meteoinfo.ndarray.math import ArrayMath, ArrayUtil
|
||||
from org.meteoinfo.math.linalg import LinalgUtil
|
||||
from org.python.core import PyComplex
|
||||
from org.meteoinfo.jython import JythonUtil
|
||||
|
||||
import _dtype
|
||||
from ._ndarray import NDArray
|
||||
from org.meteoinfo.jython import JythonUtil
|
||||
from .numerictypes import ScalarType
|
||||
|
||||
# Global variables
|
||||
pi = Math.PI
|
||||
@ -1950,7 +1951,8 @@ def isscalar(element):
|
||||
|
||||
:return: (*bool*) True if `element` is a scalar type, False if it is not.
|
||||
"""
|
||||
return isinstance(element, (numbers.Number, basestring, bool))
|
||||
return (type(element) in ScalarType
|
||||
or isinstance(element, numbers.Number))
|
||||
|
||||
def delnan(a):
|
||||
"""
|
||||
|
||||
@ -8,10 +8,11 @@ import math
|
||||
from org.meteoinfo.ndarray.math import ArrayMath
|
||||
|
||||
from ._ndarray import NDArray
|
||||
from .numeric import array, sign
|
||||
from .numeric import array, sign, asanyarray
|
||||
|
||||
__all__ = [
|
||||
'absolute','add','deg2rad','divmod','floor_divide','fmod','mod','rad2deg','remainder'
|
||||
'absolute','add','bitwise_and','bitwise_or','bitwise_xor','deg2rad','divmod','floor_divide','fmod',
|
||||
'mod','rad2deg','remainder'
|
||||
]
|
||||
|
||||
def absolute(x):
|
||||
@ -139,6 +140,91 @@ def fmod(x1, x2):
|
||||
s = sign(x1)
|
||||
return mod(x1, x2) * s
|
||||
|
||||
|
||||
def bitwise_and(x1, x2):
|
||||
"""
|
||||
Compute the bit-wise AND of two arrays element-wise.
|
||||
|
||||
Parameters:
|
||||
-----------
|
||||
x1, x2 : array_like
|
||||
Only integer and boolean types are handled.
|
||||
|
||||
Returns:
|
||||
--------
|
||||
out : NDArray or scalar
|
||||
Result. This is a scalar if both x1 and x2 are scalars.
|
||||
"""
|
||||
if isinstance(x1, (list, tuple)):
|
||||
x1 = NDArray(x1)
|
||||
|
||||
if isinstance(x2, (list, tuple)):
|
||||
x2 = NDArray(x2)
|
||||
|
||||
if isinstance(x1, NDArray):
|
||||
return x1.__and__(x2)
|
||||
elif isinstance(x2, NDArray):
|
||||
return x2.__and__(x1)
|
||||
else:
|
||||
return x1 & x2
|
||||
|
||||
|
||||
def bitwise_or(x1, x2):
|
||||
"""
|
||||
Compute the bit-wise OR of two arrays element-wise.
|
||||
|
||||
Parameters:
|
||||
-----------
|
||||
x1, x2 : array_like
|
||||
Only integer and boolean types are handled.
|
||||
|
||||
Returns:
|
||||
--------
|
||||
out : NDArray or scalar
|
||||
Result. This is a scalar if both x1 and x2 are scalars.
|
||||
"""
|
||||
if isinstance(x1, (list, tuple)):
|
||||
x1 = NDArray(x1)
|
||||
|
||||
if isinstance(x2, (list, tuple)):
|
||||
x2 = NDArray(x2)
|
||||
|
||||
if isinstance(x1, NDArray):
|
||||
return x1.__or__(x2)
|
||||
elif isinstance(x2, NDArray):
|
||||
return x2.__or__(x1)
|
||||
else:
|
||||
return x1 | x2
|
||||
|
||||
|
||||
def bitwise_xor(x1, x2):
|
||||
"""
|
||||
Compute the bit-wise XOR of two arrays element-wise.
|
||||
|
||||
Parameters:
|
||||
-----------
|
||||
x1, x2 : array_like
|
||||
Only integer and boolean types are handled.
|
||||
|
||||
Returns:
|
||||
--------
|
||||
out : NDArray or scalar
|
||||
Result. This is a scalar if both x1 and x2 are scalars.
|
||||
"""
|
||||
if isinstance(x1, (list, tuple)):
|
||||
x1 = NDArray(x1)
|
||||
|
||||
if isinstance(x2, (list, tuple)):
|
||||
x2 = NDArray(x2)
|
||||
|
||||
if isinstance(x1, NDArray):
|
||||
return x1.__xor__(x2)
|
||||
elif isinstance(x2, NDArray):
|
||||
return x2.__xor__(x1)
|
||||
else:
|
||||
return x1 ^ x2
|
||||
|
||||
|
||||
def rad2deg(x):
|
||||
"""
|
||||
Convert radians to degrees.
|
||||
|
||||
@ -1109,7 +1109,7 @@ public class FrmMeteoData extends javax.swing.JDialog {
|
||||
case MICAPS_7:
|
||||
case MICAPS_11:
|
||||
case MICAPS_13:
|
||||
LocalDateTime tt = _meteoDataInfo.getDataInfo().getTimes().get(0);
|
||||
LocalDateTime tt = _meteoDataInfo.getDataInfo().getTimes().getDate(0);
|
||||
tt = tt.minusHours(3);
|
||||
String aFile = _meteoDataInfo.getFileName();
|
||||
String path = new File(aFile).getParent();
|
||||
@ -1132,7 +1132,7 @@ public class FrmMeteoData extends javax.swing.JDialog {
|
||||
break;
|
||||
case MICAPS_1:
|
||||
case MICAPS_120:
|
||||
tt = _meteoDataInfo.getDataInfo().getTimes().get(0);
|
||||
tt = _meteoDataInfo.getDataInfo().getTimes().getDate(0);
|
||||
tt = tt.minusHours(1);
|
||||
aFile = _meteoDataInfo.getFileName();
|
||||
path = new File(aFile).getParent();
|
||||
@ -1205,7 +1205,7 @@ public class FrmMeteoData extends javax.swing.JDialog {
|
||||
case MICAPS_7:
|
||||
case MICAPS_11:
|
||||
case MICAPS_13:
|
||||
LocalDateTime tt = _meteoDataInfo.getDataInfo().getTimes().get(0);
|
||||
LocalDateTime tt = _meteoDataInfo.getDataInfo().getTimes().getDate(0);
|
||||
tt = tt.plusHours(3);
|
||||
String aFile = _meteoDataInfo.getFileName();
|
||||
String path = new File(aFile).getParent();
|
||||
@ -1228,7 +1228,7 @@ public class FrmMeteoData extends javax.swing.JDialog {
|
||||
break;
|
||||
case MICAPS_1:
|
||||
case MICAPS_120:
|
||||
tt = _meteoDataInfo.getDataInfo().getTimes().get(0);
|
||||
tt = _meteoDataInfo.getDataInfo().getTimes().getDate(0);
|
||||
tt = tt.plusHours(1);
|
||||
aFile = _meteoDataInfo.getFileName();
|
||||
path = new File(aFile).getParent();
|
||||
|
||||
@ -1096,7 +1096,7 @@ public class FrmOneDim extends javax.swing.JFrame {
|
||||
this.jComboBox_Time1.removeAllItems();
|
||||
DateTimeFormatter sdf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
|
||||
for (i = 0; i < _meteoDataInfo.getDataInfo().getTimeNum(); i++) {
|
||||
this.jComboBox_Time1.addItem(sdf.format(_meteoDataInfo.getDataInfo().getTimes().get(i)));
|
||||
this.jComboBox_Time1.addItem(sdf.format(_meteoDataInfo.getDataInfo().getTimes().getDate(i)));
|
||||
}
|
||||
this.jComboBox_Time1.setSelectedIndex(0);
|
||||
|
||||
|
||||
@ -1531,7 +1531,7 @@ public class FrmSectionPlot extends javax.swing.JFrame {
|
||||
this.jComboBox_Time1.removeAllItems();
|
||||
DateTimeFormatter sdf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
|
||||
for (i = 0; i < _meteoDataInfo.getDataInfo().getTimeNum(); i++) {
|
||||
this.jComboBox_Time1.addItem(sdf.format(_meteoDataInfo.getDataInfo().getTimes().get(i)));
|
||||
this.jComboBox_Time1.addItem(sdf.format(_meteoDataInfo.getDataInfo().getTimes().getDate(i)));
|
||||
}
|
||||
this.jComboBox_Time1.setSelectedIndex(0);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user