diff --git a/src/openeo_processes/comparison.py b/src/openeo_processes/comparison.py index a07e62d4..105fc413 100644 --- a/src/openeo_processes/comparison.py +++ b/src/openeo_processes/comparison.py @@ -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 @@ -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(): @@ -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 diff --git a/src/openeo_processes/logic.py b/src/openeo_processes/logic.py index c4d81b0b..649d134b 100644 --- a/src/openeo_processes/logic.py +++ b/src/openeo_processes/logic.py @@ -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 @@ -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 @@ -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 @@ -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 @@ -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(): diff --git a/src/openeo_processes/math.py b/src/openeo_processes/math.py index d0546439..8c663a6a 100644 --- a/src/openeo_processes/math.py +++ b/src/openeo_processes/math.py @@ -4,6 +4,7 @@ import xarray as xr import scipy import scipy.ndimage +import dask as da try: import xarray_extras as xar_addons @@ -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(): @@ -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(): @@ -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(): @@ -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 @@ -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(): @@ -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 @@ -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(): @@ -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(): @@ -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(): @@ -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(): @@ -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(): @@ -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(): @@ -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(): @@ -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(): @@ -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(): @@ -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(): @@ -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(): @@ -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(): @@ -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(): @@ -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 @@ -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(): @@ -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(): @@ -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():