Skip to content

Commit 0e15e22

Browse files
committed
removed some issues
1 parent d93978e commit 0e15e22

File tree

12 files changed

+24
-35
lines changed

12 files changed

+24
-35
lines changed

pyspod/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
"""
2-
PySPOD init
3-
"""
1+
"""PySPOD init"""
42
__all__ = ['spod_base', 'spod_low_storage', 'spod_low_ram', 'spod_streaming']
53

64
from .spod_base import SPOD_base
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""subpackaging maps."""

pyspod/postprocessing.py

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
"""
2-
Derived module from spodbase.py for classic spod.
3-
"""
1+
"""Derived module from spodbase.py for classic spod."""
42

53
# import standard python packages
64
import os
@@ -9,11 +7,8 @@
97
import matplotlib as mpl
108
import matplotlib.pyplot as plt
119
from matplotlib import animation
12-
import matplotlib.gridspec as gridspec
13-
from mpl_toolkits.axes_grid1 import make_axes_locatable
1410
mpl.rc('figure', max_open_warning = 0)
1511
from os.path import splitext
16-
import warnings
1712

1813
# Current, parent and file paths
1914
CWD = os.getcwd()
@@ -55,7 +50,7 @@ def find_nearest_coords(coords, x, data_space_dim):
5550
coords = np.asarray(coords)
5651
if isinstance(x, list):
5752
grid = np.array(np.meshgrid(*x))
58-
elif isinstance(x,np.ndarray) == data:
53+
elif isinstance(x,np.ndarray):
5954
if x.shape == data_space_dim:
6055
grid = x
6156
else:
@@ -108,7 +103,7 @@ def get_mode_from_file(filename):
108103
file at a given frequency.
109104
:rtype: numpy.ndarray
110105
"""
111-
basename, ext = splitext(filename)
106+
_, ext = splitext(filename)
112107
if ext.lower() == '.npy':
113108
m = np.load(filename)
114109
elif ext.lower() == '.mat':
@@ -670,7 +665,6 @@ def plot_2D_mode_slice_vs_time(modes, freq_required, freq, vars_idx=[0],
670665
# axis management
671666
ax.set_xlim(np.nanmin(t )*1.05,np.nanmax(t )*1.05)
672667
ax.set_ylim(np.nanmin(x2)*1.05,np.nanmax(x2)*1.05)
673-
xlim = ax.get_xlim()
674668
ax_divider = make_axes_locatable(ax)
675669
cax = ax_divider.append_axes("bottom", size="5%", pad=0.65)
676670
plt.colorbar(ax_obj, cax=cax, orientation="horizontal")
@@ -1243,7 +1237,8 @@ def plot_data_tracers(X, coords_list, x=None, time_limits=[0,10],
12431237

12441238
def generate_2D_data_video(X, time_limits=[0,10], vars_idx=None, sampling=1,
12451239
x1=None, x2=None, coastlines='', figsize=(12,8), path='CWD', filename='data_video.mp4'):
1246-
"""Make movie of 2D data.
1240+
"""
1241+
Make movie of 2D data.
12471242
12481243
:param numpy.ndarray X: 2D data to be plotted. \
12491244
First dimension must be time. Last dimension must be variable.
@@ -1283,10 +1278,6 @@ def generate_2D_data_video(X, time_limits=[0,10], vars_idx=None, sampling=1,
12831278
# filename
12841279
basename, ext = splitext(filename)
12851280

1286-
# figure dimensions
1287-
axes_ratio = (np.nanmax(x2) - np.nanmin(x2)) \
1288-
/ (np.nanmax(x1) - np.nanmin(x1))
1289-
12901281
# check dimension axes and data
12911282
if x1.shape[0] != X[0,:,:].shape[0] or \
12921283
x2.shape[0] != X[0,:,:].shape[1]:
@@ -1304,8 +1295,8 @@ def generate_2D_data_video(X, time_limits=[0,10], vars_idx=None, sampling=1,
13041295
cst = True
13051296

13061297
# Generate movie
1307-
vmin = np.nanmin(X)
1308-
vmax = np.nanmax(X)
1298+
#vmin = np.nanmin(X)
1299+
#vmax = np.nanmax(X)
13091300
vmean = np.nanmean(X)
13101301
for i in vars_idx:
13111302
fig = plt.figure()

pyspod/spod_base.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ def parse_parameters(self, isrealx, params):
395395
else:
396396
raise ValueError(mean_type, 'not recognized.')
397397
elif isinstance(mean_type,np.ndarray):
398-
x_mean = kwargs.get('mean')
398+
x_mean = mean_type
399399
mean_name = 'user-specified'
400400
else:
401401
raise ValueError(type(mean_type), 'data type not recognized. ',
@@ -528,6 +528,7 @@ def _nextpow2(a):
528528
of 2 that satisfy 2^p >= abs(a)
529529
'''
530530
p = 0
531+
v = 0
531532
while v < np.abs(a):
532533
v = 2 ** p
533534
p += 1

pyspod/spod_low_ram.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from numpy import linalg as la
1212
import scipy.special as sc
1313
from scipy.fft import fft
14-
import warnings
1514
import shutil
1615

1716
# Import PySPOD base class for SPOD_low_ram

pyspod/spod_low_storage.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
"""
2-
Derived module from spod_base.py for low storage SPOD.
3-
"""
1+
"""Derived module from spod_base.py for low storage SPOD."""
42

53
# import standard python packages
64
import os

pyspod/spod_streaming.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ class SPOD_streaming(SPOD_base):
2929
the `SPOD_base` class.
3030
"""
3131
def __init__(self, X, params, data_handler, variables):
32-
super().__init__(X, params, data_handler, variables)
32+
"""Constructor of SPOD_streaming."""
33+
super().__init__(X, params, data_handler, variables)
3334

3435
def fit(self):
3536
"""

pyspod/weights.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
"""
2-
Derived module from spodbase.py for classic spod.
3-
"""
1+
"""Module implementing weights for standard cases.."""
42

53
# import standard python packages
64
import numpy as np
@@ -9,7 +7,8 @@
97

108
def geo_weights_trapz_2D(lat, lon, R, n_vars):
119
'''
12-
2D integration weights for geospatial data via trapezoidal rule
10+
2D integration weights for geospatial
11+
data via trapezoidal rule
1312
'''
1413
n_lat = len(lat)
1514
n_lon = len(lon)
@@ -40,7 +39,8 @@ def geo_weights_trapz_2D(lat, lon, R, n_vars):
4039

4140
def geo_weights_trapz_3D(lat, lon, R, z, n_vars):
4241
'''
43-
3D integration weights for geospatial data via trapezoidal rule
42+
3D integration weights for geospatial
43+
data via trapezoidal rule
4444
'''
4545
n_lat = len(lat)
4646
n_lon = len(lon)
@@ -101,6 +101,7 @@ def geo_weights_trapz_3D(lat, lon, R, z, n_vars):
101101

102102

103103
def apply_normalization(X, weights, method='variance'):
104+
'''Normalization of weights if required.'''
104105

105106
# variable-wise normalization by variance via weight matrix
106107
if method.lower() == 'variance':

tests/test_basic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def test_basic_spod_streaming():
152152
modes_idx=[0,1],
153153
vars_idx=[0],
154154
filename='tmp.png')
155-
tol = 1e-10
155+
# tol = 1e-10
156156
# assert((np.abs(modes_at_freq[5,10,0,0]) < 0.010067915390717594 +tol) & \
157157
# (np.abs(modes_at_freq[5,10,0,0]) > 0.010067915390717594 -tol))
158158
# assert((np.abs(modes_at_freq[0,0,0,0]) < 0.012179481869151793 +tol) & \

tests/test_basic_file.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def read_data_netCDF(data, t_0, t_end, variables):
5555
if t_0 == t_end: ti = [t_0]
5656
else : ti = np.arange(t_0,t_end)
5757
X = np.empty([len(ti), x2.shape[0], x1.shape[0], len(variables)])
58-
for i,var in enumerate(variables):
58+
for _,var in enumerate(variables):
5959
X = np.array(ds[var].isel(time=ti))
6060
return X
6161
x_nc = read_data_netCDF('data.nc', t_0=0, t_end=t.shape[0], variables=variables)
@@ -205,7 +205,7 @@ def test_basic_file_spod_streaming():
205205
modes_idx=[0,1],
206206
vars_idx=[0],
207207
filename='tmp.png')
208-
tol = 1e-10
208+
# tol = 1e-10
209209
# assert((np.abs(modes_at_freq[5,10,0,0]) < 0.010067915390717594 +tol) & \
210210
# (np.abs(modes_at_freq[5,10,0,0]) > 0.010067915390717594 -tol))
211211
# assert((np.abs(modes_at_freq[0,0,0,0]) < 0.012179481869151793 +tol) & \

0 commit comments

Comments
 (0)