Skip to content
This repository was archived by the owner on Mar 6, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/openeo_processes/comparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import numpy as np
import xarray as xr
import dask as da
from openeo_processes.utils import process
from openeo_processes.utils import str2time
from openeo_processes.utils import keep_attrs
Expand Down Expand Up @@ -572,7 +573,7 @@ def exec_xar(x, y, delta=None, case_sensitive=True, reduce=False): # TODO: add
if eq_val is None:
return None
else:
return xr.ufuncs.logical_not(eq_val)
return da.array.logical_not(eq_val)

@staticmethod
def exec_da():
Expand Down Expand Up @@ -1284,9 +1285,9 @@ def exec_xar(x, min, max, exclude_max=False, reduce=False):
return False

if exclude_max:
bet = xr.ufuncs.logical_and(Gte.exec_xar(x, min, reduce=reduce) , Lt.exec_xar(x, max, reduce=reduce))
bet = da.array.logical_and(Gte.exec_xar(x, min, reduce=reduce) , Lt.exec_xar(x, max, reduce=reduce))
else:
bet = xr.ufuncs.logical_and(Gte.exec_xar(x, min, reduce=reduce) , Lte.exec_xar(x, max, reduce=reduce))
bet = da.array.logical_and(Gte.exec_xar(x, min, reduce=reduce) , Lte.exec_xar(x, max, reduce=reduce))
if isinstance(x, xr.DataArray):
bet.attrs = x.attrs
return bet
Expand Down
10 changes: 5 additions & 5 deletions src/openeo_processes/logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from openeo_processes.utils import process
from openeo_processes.comparison import is_empty
import xarray as xr

import dask as da

########################################################################################################################
# And Process
Expand Down Expand Up @@ -94,7 +94,7 @@ def exec_xar(x, y):
"""
x_nan = x.where(x == True, False) # Set NaN to False
y_nan = y.where(y == True, False)
logical_and = xr.ufuncs.logical_and(x, y)
logical_and = da.array.logical_and(x, y)
logical_and = logical_and.where(x == x_nan, np.nan)
logical_and = logical_and.where(y == y_nan, np.nan)
return logical_and
Expand Down Expand Up @@ -192,7 +192,7 @@ def exec_xar(x, y):
"""
x_nan = x.where(x == True, False) # Set NaN to False
y_nan = y.where(y == True, False)
logical_or = xr.ufuncs.logical_or(x, y)
logical_or = da.array.logical_or(x, y)
logical_or = logical_or.where(x == x_nan, np.nan)
logical_or = logical_or.where(y == y_nan, np.nan)
return logical_or
Expand Down Expand Up @@ -292,7 +292,7 @@ def exec_xar(x, y):
"""
x_nan = x.where(x == True, False) # Set NaN to False
y_nan = y.where(y == True, False)
logical_xor = xr.ufuncs.logical_xor(x, y)
logical_xor = da.array.logical_xor(x, y)
logical_xor = logical_xor.where(x == x_nan, np.nan)
logical_xor = logical_xor.where(y == y_nan, np.nan)
return logical_xor
Expand Down Expand Up @@ -380,7 +380,7 @@ def exec_xar(x):
xr.DataArray :
Inverted boolean values.
"""
return xr.ufuncs.logical_not(x)
return da.array.logical_not(x)

@staticmethod
def exec_da():
Expand Down
46 changes: 23 additions & 23 deletions src/openeo_processes/math.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import xarray as xr
import scipy
import scipy.ndimage
import dask as da

try:
import xarray_extras as xar_addons
Expand Down Expand Up @@ -130,7 +131,7 @@ def exec_xar(x):
xr.DataArray :
Numbers rounded down.
"""
return xr.ufuncs.floor(x)
return da.array.floor(x)

@staticmethod
def exec_da():
Expand Down Expand Up @@ -216,7 +217,7 @@ def exec_xar(x):
xr.DataArray :
Numbers rounded up.
"""
return xr.ufuncs.ceil(x)
return da.array.ceil(x)

@staticmethod
def exec_da():
Expand Down Expand Up @@ -309,7 +310,7 @@ def exec_xar(x):
xr.DataArray :
Integer part of the numbers.
"""
return xr.ufuncs.trunc(x)
return da.array.trunc(x)

@staticmethod
def exec_da():
Expand Down Expand Up @@ -419,7 +420,6 @@ def exec_xar(x, p=0):
xr.DataArray :
The rounded numbers.
"""
#error for float objects: 'float' object has no attribute 'round'
return x.round(p)

@staticmethod
Expand Down Expand Up @@ -506,7 +506,7 @@ def exec_xar(p):
xr.DataArray :
The computed values for e raised to the power of `p`.
"""
return xr.ufuncs.exp(p)
return da.array.exp(p)

@staticmethod
def exec_da():
Expand Down Expand Up @@ -604,7 +604,7 @@ def exec_xar(x, base):
xr.DataArray :
The computed logarithm.
"""
l = xr.ufuncs.log(x)/xr.ufuncs.log(base)
l = da.array.log(x)/da.array.log(base)
if isinstance(x, xr.DataArray):
l.attrs = x.attrs
return l
Expand Down Expand Up @@ -699,7 +699,7 @@ def exec_xar(x):
xr.DataArray :
The computed natural logarithms.
"""
return xr.ufuncs.log(x)
return da.array.log(x)

@staticmethod
def exec_da():
Expand Down Expand Up @@ -786,7 +786,7 @@ def exec_xar(x):
The computed cosines of `x`.

"""
return xr.ufuncs.cos(x)
return da.array.cos(x)

@staticmethod
def exec_da():
Expand Down Expand Up @@ -876,7 +876,7 @@ def exec_xar(x):
The computed angles in radians.

"""
return xr.ufuncs.arccos(x)
return da.array.arccos(x)

@staticmethod
def exec_da():
Expand Down Expand Up @@ -962,7 +962,7 @@ def exec_xar(x):
xr.DataArray :
The computed hyperbolic cosines of `x`.
"""
return xr.ufuncs.cosh(x)
return da.array.cosh(x)

@staticmethod
def exec_da():
Expand Down Expand Up @@ -1052,7 +1052,7 @@ def exec_xar(x):
The computed angles in radians.

"""
return xr.ufuncs.arccosh(x)
return da.array.arccosh(x)

@staticmethod
def exec_da():
Expand Down Expand Up @@ -1138,7 +1138,7 @@ def exec_xar(x):
xr.DataArray :
The computed sines of `x`.
"""
return xr.ufuncs.sin(x)
return da.array.sin(x)

@staticmethod
def exec_da():
Expand Down Expand Up @@ -1227,7 +1227,7 @@ def exec_xar(x):
xr.DataArray :
The computed angles in radians.
"""
return xr.ufuncs.arcsin(x)
return da.array.arcsin(x)

@staticmethod
def exec_da():
Expand Down Expand Up @@ -1313,7 +1313,7 @@ def exec_xar(x):
xr.DataArray :
The computed hyperbolic sines of `x`.
"""
return xr.ufuncs.sinh(x)
return da.array.sinh(x)

@staticmethod
def exec_da():
Expand Down Expand Up @@ -1402,7 +1402,7 @@ def exec_xar(x):
xr.DataArray :
The computed angles in radians.
"""
return xr.ufuncs.arcsinh(x)
return da.array.arcsinh(x)

@staticmethod
def exec_da():
Expand Down Expand Up @@ -1491,7 +1491,7 @@ def exec_xar(x):
xr.DataArray :
The computed tangents of `x`.
"""
return xr.ufuncs.tan(x)
return da.array.tan(x)

@staticmethod
def exec_da():
Expand Down Expand Up @@ -1581,7 +1581,7 @@ def exec_xar(x):
The computed angles in radians.

"""
return xr.ufuncs.arctan(x)
return da.array.arctan(x)

@staticmethod
def exec_da():
Expand Down Expand Up @@ -1670,7 +1670,7 @@ def exec_xar(x):
xr.DataArray :
The computed hyperbolic tangents of `x`.
"""
return xr.ufuncs.tanh(x)
return da.array.tanh(x)

@staticmethod
def exec_da():
Expand Down Expand Up @@ -1759,7 +1759,7 @@ def exec_xar(x):
xr.DataArray :
The computed angles in radians.
"""
return xr.ufuncs.arctanh(x)
return da.array.arctanh(x)

@staticmethod
def exec_da():
Expand Down Expand Up @@ -1855,7 +1855,7 @@ def exec_xar(y, x):
The computed angles in radians.

"""
arct = xr.ufuncs.arctan2(y, x)
arct = da.array.arctan2(y, x)
return keep_attrs(x, y, arct)

@staticmethod
Expand Down Expand Up @@ -2261,7 +2261,7 @@ def exec_xar(x):
xr.DataArray :
The computed absolute values.
"""
return xr.ufuncs.fabs(x)
return da.array.fabs(x)

@staticmethod
def exec_da():
Expand Down Expand Up @@ -2362,7 +2362,7 @@ def exec_xar(x):
xr.DataArray :
The computed signum values of `x`.
"""
return xr.ufuncs.sign(x)
return da.array.sign(x)

@staticmethod
def exec_da():
Expand Down Expand Up @@ -2454,7 +2454,7 @@ def exec_xar(x):
xr.DataArray :
The computed square roots.
"""
return xr.ufuncs.sqrt(x)
return da.array.sqrt(x)

@staticmethod
def exec_da():
Expand Down