diff --git a/OceanLab/__init.py__ b/OceanLab/__init__.py similarity index 100% rename from OceanLab/__init.py__ rename to OceanLab/__init__.py diff --git a/OceanLab/eof.py b/OceanLab/eof.py index 2f1e922..215d35a 100644 --- a/OceanLab/eof.py +++ b/OceanLab/eof.py @@ -1,9 +1,7 @@ import numpy as np import scipy.linalg as la -from dask import delayed from scipy.signal import hilbert import xarray as xr -from dask.distributed import Client, LocalCluster # functions #========================================= @@ -130,14 +128,14 @@ def my_eof_interp(M,nmodes,errmin=1e-15,repmax=None): #========================================= # PERFORM COMPLEX EOF #========================================= -def ceof(lon, lat, data, nkp = 10, parallel = True): +def ceof(lon, lat, data, nkp = 10): ''' Complex (Hilbert) EOF to detect propagating features: waves, meanders, etc. Note: the mean field in each coordinate is subtracted within the function. Do not subtract the time-mean field before inputing. - NaN values are removed in the algorithm. + NaN values are removed in the algorithm. The user can input the data as it is. - - First written in MATLAB and found in Prof. Daniel J. Vimont webpage + + First written in MATLAB and found in Prof. Daniel J. Vimont webpage (https://www.aos.wisc.edu/~dvimont/matlab/Stat_Tools/complex_eof.html) ============================================================================== INPUT: @@ -145,8 +143,6 @@ def ceof(lon, lat, data, nkp = 10, parallel = True): lat = latitude (array) data = original data set [time, lat, lon] nkp = number of modes to return (default = 10) - parallel = create a standard client kernel for parallel computing - [switch parallel to False, in case you created your own client] OUTPUT: The variables below return inside a DataArray. @@ -158,12 +154,7 @@ def ceof(lon, lat, data, nkp = 10, parallel = True): TAmp = temporal amplitude [time, nkp] TPhase = temporal phase [time, nkp] ============================================================================== - ''' - # Configure client for parallel computing - if parallel: - cluster = LocalCluster() - client = Client(cluster) - + ''' # Organizing the data as time vs space data_ceof = _org_data_ceof(lon, lat, data) # We need to remove the mean field (i.e., the trend) in each coordinate to @@ -184,9 +175,9 @@ def ceof(lon, lat, data, nkp = 10, parallel = True): data_hilbert = hilbert(data_ceof) # Compute the covariance matrix in the Hilbert transform print('2: Computing covariance matrix') - c = delayed(np.dot)(data_hilbert.conjugate().T, data_hilbert).compute()/ntim + c = np.dot(data_hilbert.conjugate().T, data_hilbert)/ntim print('3: Solving the eigenvalue problem') - lamda, loadings = delayed(la.eig)(c).compute() # lamda: eigenvalue, loadings: eigenvectors + lamda, loadings = la.eig(c) # lamda: eigenvalue, loadings: eigenvectors l = lamda.conjugate().T k = np.argsort(l) diff --git a/OceanLab/utils.py b/OceanLab/utils.py index 6b8c35b..9525534 100644 --- a/OceanLab/utils.py +++ b/OceanLab/utils.py @@ -2,8 +2,6 @@ import scipy.signal as sg import xarray as xr -from dask.distributed import Client - ##### User functions #============================================================================= # NEAREST DISTANCE @@ -133,29 +131,4 @@ def timefilter(prop,filtdays=60): return m_prop,p_prop #============================================================================= -##### Functions for relative imports -# ============================================================================= -# KERNEL FOR PARALLEL COMPUTING -# ============================================================================= -def _parallel_client(cpu_params=dict(tpw=2,nw=4,ml=7.5)): - """ - Create client kernel for parallel computing - ==================================================== - INPUT: - -> cpu_params: dict containing floats with keys - -> tpw: threads_per_worker - -> nw: n_workers - -> ml: memory_limit per worker [GB] - OUTPUT: - -> client: configuration of parallel computing - ==================================================== - """ - - client = Client(threads_per_worker=cpu_params['tpw'], - n_workers=cpu_params['nw'], - memory_limit=str(cpu_params['ml'])+'GB') - return client -#============================================================================= - - diff --git a/examples/DYN_EOF.ipynb b/examples/DYN_EOF.ipynb index 6f04e4f..4375754 100644 --- a/examples/DYN_EOF.ipynb +++ b/examples/DYN_EOF.ipynb @@ -2,16 +2,10 @@ "cells": [ { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "metadata": {}, "outputs": [], - "source": [ - "import numpy as np\n", - "import matplotlib.pyplot as plt\n", - "from sympy import *\n", - "from OceanLab import EOF,DYN\n", - "import seawater as sw" - ] + "source": "import numpy as np\nimport matplotlib.pyplot as plt\nfrom sympy import *\nimport OceanLab.eof as EOF\nimport OceanLab.dyn as DYN\nimport seawater as sw" }, { "cell_type": "code", @@ -447,4 +441,4 @@ }, "nbformat": 4, "nbformat_minor": 4 -} +} \ No newline at end of file diff --git a/examples/OA.ipynb b/examples/OA.ipynb index 92b2156..89b5549 100644 --- a/examples/OA.ipynb +++ b/examples/OA.ipynb @@ -2,15 +2,10 @@ "cells": [ { "cell_type": "code", - "execution_count": 102, + "execution_count": null, "metadata": {}, "outputs": [], - "source": [ - "import numpy as np\n", - "import matplotlib.pyplot as plt\n", - "from sympy import *\n", - "from OceanLab import OA" - ] + "source": "import numpy as np\nimport matplotlib.pyplot as plt\nfrom sympy import *\nimport OceanLab.oa as OA" }, { "cell_type": "code", @@ -168,4 +163,4 @@ }, "nbformat": 4, "nbformat_minor": 4 -} +} \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 948d657..7eaaec1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,4 @@ -numpy >= 1.8.2 seawater >= 3.3.1 +numpy >= 1.8.2 scipy >= 1.6.3 xarray >= 0.18.2 -dask >= 2021.06.0 -dask[distributed] >= 2021.06.0 diff --git a/setup.py b/setup.py index 8a31867..518b4a7 100644 --- a/setup.py +++ b/setup.py @@ -28,11 +28,9 @@ def read(file): "Operating System :: OS Independent", ], install_requires = [ - 'seawater ~= 3.3', - 'numpy ~= 1.18', - 'scipy ~= 1.6', - 'xarray ~= 0.18', - 'dask ~= 2021.06', - 'dask[distributed] ~= 2021.06' + 'seawater >= 3.3', + 'numpy >= 1.8.2', + 'scipy >= 1.6', + 'xarray >= 0.18', ], )