Skip to content

Commit 68b8b91

Browse files
committed
deleted local inits
1 parent 811160a commit 68b8b91

File tree

18 files changed

+57
-58
lines changed

18 files changed

+57
-58
lines changed

pyspod/weights.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,17 +69,17 @@ def geo_weights_trapz_3D(lat, lon, R, z, n_vars):
6969

7070

7171

72-
def apply_normalization(X, weights, n_variables, method='variance'):
72+
def apply_normalization(data, weights, n_variables, method='variance'):
7373
'''Normalization of weights if required.'''
7474

7575
# variable-wise normalization by variance via weight matrix
7676
if method.lower() == 'variance':
7777
print('')
7878
print('Normalization by variance')
7979
print('-------------------------')
80-
axis = tuple(np.arange(0,X[...,0].ndim))
80+
axis = tuple(np.arange(0, data[...,0].ndim))
8181
for i in range(0,n_variables):
82-
sigma2 = np.nanvar(X[...,i], axis=axis)
82+
sigma2 = np.nanvar(data[...,i], axis=axis)
8383
print(sigma2)
8484
weights[...,i] = weights[...,i] / sigma2
8585
else:

tests/test_basic_file.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def read_data_netCDF(data, t_0, t_end, variables):
9191
def test_basic_file_spod_low_storage():
9292
# Initialize libraries by using data_handler for the low storage algorithm
9393
spod_ls = SPOD_low_storage(
94-
X=os.path.join(CWD,'data.nc'),
94+
data=os.path.join(CWD,'data.nc'),
9595
params=params,
9696
data_handler=read_data_netCDF,
9797
variables=variables)
@@ -115,7 +115,7 @@ def test_basic_file_spod_low_storage():
115115
def test_basic_file_spod_low_ram():
116116
# Let's try the low_ram algorithm
117117
spod_ram = SPOD_low_ram(
118-
X=os.path.join(CWD,'data.nc'),
118+
data=os.path.join(CWD,'data.nc'),
119119
params=params,
120120
data_handler=read_data_netCDF,
121121
variables=variables)

tests/test_earthquakes.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def test_spod_low_storage_blockwise_mean():
6868
params['savefft'] = False
6969

7070
# SPOD analysis
71-
SPOD_analysis = SPOD_low_storage(X=X, params=params, data_handler=False, variables=variables)
71+
SPOD_analysis = SPOD_low_storage(data=X, params=params, data_handler=False, variables=variables)
7272
spod = SPOD_analysis.fit()
7373

7474
# Test results
@@ -98,7 +98,7 @@ def test_spod_low_storage_longtime_mean():
9898
params['savefft'] = False
9999

100100
# SPOD analysis
101-
SPOD_analysis = SPOD_low_storage(X=X, params=params, data_handler=False, variables=variables)
101+
SPOD_analysis = SPOD_low_storage(data=X, params=params, data_handler=False, variables=variables)
102102
spod = SPOD_analysis.fit()
103103

104104
# Test results
@@ -128,7 +128,7 @@ def test_spod_low_ram_blockwise_mean():
128128
params['savefft'] = False
129129

130130
# SPOD analysis
131-
SPOD_analysis = SPOD_low_ram(X=X, params=params, data_handler=False, variables=variables)
131+
SPOD_analysis = SPOD_low_ram(data=X, params=params, data_handler=False, variables=variables)
132132
spod = SPOD_analysis.fit()
133133

134134
# Test results
@@ -158,7 +158,7 @@ def test_spod_low_ram_longtime_mean():
158158
params['savefft'] = False
159159

160160
# SPOD analysis
161-
SPOD_analysis = SPOD_low_ram(X=X, params=params, data_handler=False, variables=variables)
161+
SPOD_analysis = SPOD_low_ram(data=X, params=params, data_handler=False, variables=variables)
162162
spod = SPOD_analysis.fit()
163163

164164
# Test results
@@ -189,7 +189,7 @@ def test_spod_streaming():
189189
params['savefft'] = False
190190

191191
# SPOD analysis
192-
SPOD_analysis = SPOD_streaming(X=X, params=params, data_handler=False, variables=variables)
192+
SPOD_analysis = SPOD_streaming(data=X, params=params, data_handler=False, variables=variables)
193193
spod = SPOD_analysis.fit()
194194

195195
# Test results
@@ -219,7 +219,7 @@ def test_spod_low_storage_savefft():
219219
params['savefft'] = False
220220

221221
# SPOD analysis
222-
SPOD_analysis = SPOD_low_storage(X=X, params=params, data_handler=False, variables=variables)
222+
SPOD_analysis = SPOD_low_storage(data=X, params=params, data_handler=False, variables=variables)
223223
spod = SPOD_analysis.fit()
224224

225225
# Test results 1
@@ -239,7 +239,7 @@ def test_spod_low_storage_savefft():
239239

240240
# SPOD analysis
241241
params['savefft'] = True
242-
SPOD_analysis = SPOD_low_storage(X=X, params=params, data_handler=False, variables=variables)
242+
SPOD_analysis = SPOD_low_storage(data=X, params=params, data_handler=False, variables=variables)
243243
spod = SPOD_analysis.fit()
244244

245245
# Test results 2 (after loading blocks from storage)
@@ -277,7 +277,7 @@ def test_spod_low_ram_savefft():
277277
params['savefft'] = False
278278

279279
# SPOD analysis
280-
SPOD_analysis = SPOD_low_ram(X=X, params=params, data_handler=False, variables=variables)
280+
SPOD_analysis = SPOD_low_ram(data=X, params=params, data_handler=False, variables=variables)
281281
spod = SPOD_analysis.fit()
282282

283283
# Test results 1
@@ -297,7 +297,7 @@ def test_spod_low_ram_savefft():
297297

298298
# SPOD analysis
299299
params['savefft'] = True
300-
SPOD_analysis = SPOD_low_ram(X=X, params=params, data_handler=False, variables=variables)
300+
SPOD_analysis = SPOD_low_ram(data=X, params=params, data_handler=False, variables=variables)
301301
spod = SPOD_analysis.fit()
302302

303303
# Test results 2 (after loading blocks from storage)

tests/test_fluidmechanics.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def test_spod_low_storage_blockwise_mean():
7373
params['savefft'] = False
7474

7575
# SPOD analysis
76-
SPOD_analysis = SPOD_low_storage(X=X, params=params, data_handler=False, variables=variables)
76+
SPOD_analysis = SPOD_low_storage(data=X, params=params, data_handler=False, variables=variables)
7777
spod = SPOD_analysis.fit()
7878

7979
# Test results
@@ -106,7 +106,7 @@ def test_spod_low_storage_longtime_mean():
106106
params['savefft'] = False
107107

108108
# SPOD analysis
109-
SPOD_analysis = SPOD_low_storage(X=X, params=params, data_handler=False, variables=variables)
109+
SPOD_analysis = SPOD_low_storage(data=X, params=params, data_handler=False, variables=variables)
110110
spod = SPOD_analysis.fit()
111111

112112
# Test results
@@ -136,7 +136,7 @@ def test_spod_low_ram_blockwise_mean():
136136
params['savefft'] = False
137137

138138
# SPOD analysis
139-
SPOD_analysis = SPOD_low_ram(X=X, params=params, data_handler=False, variables=variables)
139+
SPOD_analysis = SPOD_low_ram(data=X, params=params, data_handler=False, variables=variables)
140140
spod = SPOD_analysis.fit()
141141

142142
# Test results
@@ -166,7 +166,7 @@ def test_spod_low_ram_longtime_mean():
166166
params['savefft'] = False
167167

168168
# SPOD analysis
169-
SPOD_analysis = SPOD_low_ram(X=X, params=params, data_handler=False, variables=variables)
169+
SPOD_analysis = SPOD_low_ram(data=X, params=params, data_handler=False, variables=variables)
170170
spod = SPOD_analysis.fit()
171171

172172
# Test results
@@ -197,7 +197,7 @@ def test_spod_streaming():
197197
params['savefft'] = False
198198

199199
# SPOD analysis
200-
SPOD_analysis = SPOD_streaming(X=X, params=params, data_handler=False, variables=variables)
200+
SPOD_analysis = SPOD_streaming(data=X, params=params, data_handler=False, variables=variables)
201201
spod = SPOD_analysis.fit()
202202

203203
# Test results
@@ -227,7 +227,7 @@ def test_spod_low_storage_savefft():
227227
params['savefft'] = False
228228

229229
# SPOD analysis
230-
SPOD_analysis = SPOD_low_storage(X=X, params=params, data_handler=False, variables=variables)
230+
SPOD_analysis = SPOD_low_storage(data=X, params=params, data_handler=False, variables=variables)
231231
spod = SPOD_analysis.fit()
232232

233233
# Test results 1
@@ -247,7 +247,7 @@ def test_spod_low_storage_savefft():
247247

248248
# SPOD analysis
249249
params['savefft'] = True
250-
SPOD_analysis = SPOD_low_storage(X=X, params=params, data_handler=False, variables=variables)
250+
SPOD_analysis = SPOD_low_storage(data=X, params=params, data_handler=False, variables=variables)
251251
spod = SPOD_analysis.fit()
252252

253253
# Test results 2 (after loading blocks from storage)
@@ -282,7 +282,7 @@ def test_spod_low_ram_savefft():
282282
params['savefft'] = False
283283

284284
# SPOD analysis
285-
SPOD_analysis = SPOD_low_ram(X=X, params=params, data_handler=False, variables=variables)
285+
SPOD_analysis = SPOD_low_ram(data=X, params=params, data_handler=False, variables=variables)
286286
spod = SPOD_analysis.fit()
287287

288288
# Test results 1
@@ -302,7 +302,7 @@ def test_spod_low_ram_savefft():
302302

303303
# SPOD analysis
304304
params['savefft'] = True
305-
SPOD_analysis = SPOD_low_ram(X=X, params=params, data_handler=False, variables=variables)
305+
SPOD_analysis = SPOD_low_ram(data=X, params=params, data_handler=False, variables=variables)
306306
spod = SPOD_analysis.fit()
307307

308308
# Test results 2 (after loading blocks from storage)
@@ -337,7 +337,7 @@ def test_postprocessing():
337337
params['savefft'] = False
338338

339339
# SPOD analysis
340-
SPOD_analysis = SPOD_low_storage(X=X, params=params, data_handler=False, variables=variables)
340+
SPOD_analysis = SPOD_low_storage(data=X, params=params, data_handler=False, variables=variables)
341341
spod = SPOD_analysis.fit()
342342

343343
# Test postprocessing and results

tutorials/basic/methods_comparison/methods_comparison.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@
187187
"cell_type": "markdown",
188188
"metadata": {},
189189
"source": [
190-
"Once we have loaded the data and defined the required and optional parameters, we can perform the analysis. This step is accomplished by calling the `PySPOD` constructor, `SPOD_streaming(X=X, params=params, data_handler=False, variables=variables)` and the `fit` method, `SPOD_analysis.fit()`. \n",
190+
"Once we have loaded the data and defined the required and optional parameters, we can perform the analysis. This step is accomplished by calling the `PySPOD` constructor, `SPOD_streaming(data=X, params=params, data_handler=False, variables=variables)` and the `fit` method, `SPOD_analysis.fit()`. \n",
191191
"\n",
192192
"The `PySPOD` constructor takes `X`, that can either be a `numpy.ndarray` containing the data or the path to the data file , the parameters `params`, a parameter called `data_handler` that can be either `False` or a function to read the data, and `variables` that is the list containing the names of our variables. If, as `data_handler`, we pass `False`, then we need to load the entire matrix of data into RAM, and that must comply with the **PySPOD** input data requirements (i.e. the dimension of the data matrix must correspond to (time $\\times$ spatial dimension shape $\\times$ number of variables). \n",
193193
"\n",

tutorials/basic/methods_comparison_file/methods_comparison_file.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@
240240
"cell_type": "markdown",
241241
"metadata": {},
242242
"source": [
243-
"Once we have loaded the data and defined the required and optional parameters, we can perform the analysis. This step is accomplished by calling the `PySPOD` constructor, `SPOD_streaming(X=X, params=params, data_handler=False, variables=variables)` and the `fit` method, `SPOD_analysis.fit()`. \n",
243+
"Once we have loaded the data and defined the required and optional parameters, we can perform the analysis. This step is accomplished by calling the `PySPOD` constructor, `SPOD_streaming(data=X, params=params, data_handler=False, variables=variables)` and the `fit` method, `SPOD_analysis.fit()`. \n",
244244
"\n",
245245
"The `PySPOD` constructor takes `X`, that can either be a `numpy.ndarray` containing the data or the path to the data file , the parameters `params`, a parameter called `data_handler` that can be either `False` or a function to read the data, and `variables` that is the list containing the names of our variables. If, as `data_handler`, we pass `False`, then we need to load the entire matrix of data into RAM, and that must comply with the **PySPOD** input data requirements (i.e. the dimension of the data matrix must correspond to (time $\\times$ spatial dimension shape $\\times$ number of variables). \n",
246246
"\n",

tutorials/basic/methods_comparison_file/methods_comparison_file.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def read_data_netCDF(data, t_0, t_end, variables):
8585

8686
# Initialize libraries by using data_handler for the low storage algorithm
8787
spod_ls = SPOD_low_storage(
88-
X=os.path.join(CWD,'data.nc'),
88+
data=os.path.join(CWD,'data.nc'),
8989
params=params,
9090
data_handler=read_data_netCDF,
9191
variables=variables)
@@ -116,7 +116,7 @@ def read_data_netCDF(data, t_0, t_end, variables):
116116

117117
# Let's try the low_ram algorithm
118118
spod_ram = SPOD_low_ram(
119-
X=os.path.join(CWD,'data.nc'),
119+
data=os.path.join(CWD,'data.nc'),
120120
params=params,
121121
data_handler=read_data_netCDF,
122122
variables=variables)
@@ -140,7 +140,7 @@ def read_data_netCDF(data, t_0, t_end, variables):
140140

141141
# Finally, we can try the streaming algorithm
142142
spod_st = SPOD_streaming(
143-
X=os.path.join(CWD,'data.nc'),
143+
data=os.path.join(CWD,'data.nc'),
144144
params=params,
145145
data_handler=read_data_netCDF,
146146
variables=variables)

tutorials/climate/ERA20C_MEI_2D/ERA20C_MEI_2D.ipynb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@
369369
"if params['normalize']:\n",
370370
"\tparams['weights'] = \\\n",
371371
" weights.apply_normalization(\\\n",
372-
" X=X, \n",
372+
" data=X, \n",
373373
" n_variables=params['nv'], \n",
374374
" weights=params['weights'], \n",
375375
" method='variance')"
@@ -386,7 +386,7 @@
386386
"cell_type": "markdown",
387387
"metadata": {},
388388
"source": [
389-
"Once we have loaded the data and defined the required and optional parameters, we can perform the analysis. This step is accomplished by calling the `PySPOD` constructor, `SPOD_low_storage(X=X, params=params, data_handler=False, variables=variables)` and the `fit` method, `SPOD_analysis.fit()`. \n",
389+
"Once we have loaded the data and defined the required and optional parameters, we can perform the analysis. This step is accomplished by calling the `PySPOD` constructor, `SPOD_low_storage(data=X, params=params, data_handler=False, variables=variables)` and the `fit` method, `SPOD_analysis.fit()`. \n",
390390
"\n",
391391
"The `PySPOD` constructor takes `X`, that can either be a `numpy.ndarray` containing the data or the path to the data file , the parameters `params`, a parameter called `data_handler` that can be either `False` or a function to read the data, and `variables` that is the list containing the names of our variables. If, as `data_handler`, we pass `False`, then we need to load the entire matrix of data into RAM, and that must comply with the **PySPOD** input data requirements (i.e. the dimension of the data matrix must correspond to (time $\\times$ spatial dimension shape $\\times$ number of variables). \n",
392392
"\n",
@@ -503,7 +503,7 @@
503503
],
504504
"source": [
505505
"# Perform SPOD analysis using low storage module\n",
506-
"SPOD_analysis = SPOD_low_storage(X=X, params=params, data_handler=False, variables=variables)\n",
506+
"SPOD_analysis = SPOD_low_storage(data=X, params=params, data_handler=False, variables=variables)\n",
507507
"spod = SPOD_analysis.fit()"
508508
]
509509
},
@@ -789,8 +789,8 @@
789789
"The results are stored in the results folder defined in the parameter you specified under `params[savedir]`. We can load the results for both modes and eigenvalues, and use any other postprocessing tool that is more suitable to your application. The files are stored in `numpy` binary format `.npy`. There exists several tools to convert them in `netCDF`, `MATLAB` and several other formats that can be better suited to you specific post-processing pipeline.\n",
790790
"\n",
791791
"This tutorial was intended to help you setup your own multivariate case. You can play with the parameters we explored above to gain more insights into the capabilities of the library. You can also run on the same data the other two SPOD algorithms implemented as part of this library by simply calling:\n",
792-
"- SPOD_analysis = SPOD_low_ram(X=X, params=params, file_handler=False)\n",
793-
"- SPOD_analysis = SPOD_streaming(X=X, params=params, file_handler=False)\n",
792+
"- SPOD_analysis = SPOD_low_ram(data=X, params=params, file_handler=False)\n",
793+
"- SPOD_analysis = SPOD_streaming(data=X, params=params, file_handler=False)\n",
794794
"\n",
795795
"and compare the results."
796796
]

tutorials/climate/ERA20C_MEI_2D/ERA20C_MEI_2D.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,13 @@
6767
if params['normalize']:
6868
params['weights'] = \
6969
weights.apply_normalization(\
70-
X=X,
70+
data=X,
7171
n_variables=params['nv']
7272
weights=params['weights'],
7373
method='variance')
7474

7575
# Perform SPOD analysis using low storage module
76-
SPOD_analysis = SPOD_low_storage(X=X, params=params, data_handler=False, variables=variables)
76+
SPOD_analysis = SPOD_low_storage(data=X, params=params, data_handler=False, variables=variables)
7777
spod = SPOD_analysis.fit()
7878

7979
# Show results

tutorials/climate/ERA20C_QBO_3D/ERA20C_QBO_3D.ipynb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@
357357
"cell_type": "markdown",
358358
"metadata": {},
359359
"source": [
360-
"Once we have loaded the data and defined the required and optional parameters, we can perform the analysis. This step is accomplished by calling the `PySPOD` constructor, `SPOD_low_storage(X=X, params=params, file_handler=False)` and the `fit` method, `SPOD_analysis.fit()`. \n",
360+
"Once we have loaded the data and defined the required and optional parameters, we can perform the analysis. This step is accomplished by calling the `PySPOD` constructor, `SPOD_low_storage(data=X, params=params, file_handler=False)` and the `fit` method, `SPOD_analysis.fit()`. \n",
361361
"\n",
362362
"The `PySPOD` constructor takes `X`, that can either be a `numpy.ndarray` containing the data or the path to the data file , the parameters `params`, a parameter called `data_handler` that can be either `False` or a function to read the data, and `variables` that is the list containing the names of our variables. If, as `data_handler`, we pass `False`, then we need to load the entire matrix of data into RAM, and that must comply with the **PySPOD** input data requirements (i.e. the dimension of the data matrix must correspond to (time $\\times$ spatial dimension shape $\\times$ number of variables). \n",
363363
"\n",
@@ -466,7 +466,7 @@
466466
],
467467
"source": [
468468
"# Perform SPOD analysis using low storage module\n",
469-
"SPOD_analysis = SPOD_low_ram(X=X, params=params, data_handler=False, variables=variables)\n",
469+
"SPOD_analysis = SPOD_low_ram(data=X, params=params, data_handler=False, variables=variables)\n",
470470
"spod = SPOD_analysis.fit()"
471471
]
472472
},
@@ -765,8 +765,8 @@
765765
"The results are stored in the results folder defined in the parameter you specified under `params[savedir]`. You can load the results for both modes and eigenvalues, and use any other postprocessing tool that is more suitable to your application. The files are stored in `numpy` binary format `.npy`. There exists several tools to convert them in `netCDF`, `MATLAB` and several other formats that can be better suited to you specific post-processing pipeline.\n",
766766
"\n",
767767
"This tutorial was intended to help you setup your own three-dimensional case. You can play with the parameters we explored above to gain more insights into the capabilities of the library. You can also run on the same data the other two SPOD algorithms implemented as part of this library by simply calling:\n",
768-
"- SPOD_analysis = SPOD_low_storage(X=X, params=params, file_handler=False)\n",
769-
"- SPOD_analysis = SPOD_streaming(X=X, params=params, file_handler=False)\n",
768+
"- SPOD_analysis = SPOD_low_storage(data=X, params=params, file_handler=False)\n",
769+
"- SPOD_analysis = SPOD_streaming(data=X, params=params, file_handler=False)\n",
770770
"\n",
771771
"and compare the results."
772772
]

0 commit comments

Comments
 (0)