modulo-vki 2.1.2__py3-none-any.whl → 2.1.5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -51,9 +51,8 @@ def Spatial_basis_POD(D, PSI_P, Sigma_P, MEMORY_SAVING,
51
51
  if verbose:
52
52
  print("Completing Spatial Structures Modes: \n")
53
53
 
54
- for i in tqdm(range(0, R)):
55
- # Normalize the columns of C to get spatial modes
56
- Phi_P[:, i] = PHI_P_SIGMA_P[:, i] / Sigma_P[i]
54
+ Sigma_P[:] = np.linalg.norm(PHI_P_SIGMA_P, axis=0)
55
+ Phi_P = PHI_P_SIGMA_P / Sigma_P
57
56
 
58
57
  else:
59
58
  # We take only the first R modes.
@@ -156,7 +155,7 @@ def Spatial_basis_POD(D, PSI_P, Sigma_P, MEMORY_SAVING,
156
155
  R1 = (i - 1) * dim_col
157
156
  R2 = i * dim_col
158
157
 
159
- if (b == tot_blocks_row) and (N_S - dim_row * N_PARTITIONS > 0): # Change here
158
+ if (b == tot_blocks_row) and (N_S - dim_row * N_PARTITIONS > 0):
160
159
  C1 = C2
161
160
  C2 = C1 + (N_S - dim_row * N_PARTITIONS)
162
161
  else:
@@ -169,13 +168,13 @@ def Spatial_basis_POD(D, PSI_P, Sigma_P, MEMORY_SAVING,
169
168
  if rescale:
170
169
  for j in range(R1, R2):
171
170
  jj = j - R1
172
- Sigma_P[jj] = np.linalg.norm(dps[:, jj])
173
- Phi_P = dps[:, jj] / Sigma_P[jj]
171
+ Sigma_P[j] = np.linalg.norm(dps[:, jj])
172
+ Phi_P = dps[:, jj] / Sigma_P[j]
174
173
  np.savez(FOLDER_OUT + f"/phi_{j + 1}", phi_p=Phi_P)
175
174
  else:
176
175
  for j in range(R1, R2):
177
176
  jj = j - R1
178
- Phi_P = dps[:, jj] / Sigma_P[j] # Change here
177
+ Phi_P = dps[:, jj] / Sigma_P[j]
179
178
  np.savez(FOLDER_OUT + f"/phi_{j + 1}", phi_p=Phi_P)
180
179
 
181
180
  Phi_P_M = np.zeros((N_S, R))
modulo_vki/modulo.py CHANGED
@@ -131,6 +131,9 @@ class ModuloVKI:
131
131
 
132
132
  if self.MEMORY_SAVING:
133
133
  os.makedirs(self.FOLDER_OUT, exist_ok=True)
134
+
135
+ if data is not None:
136
+ raise ValueError("The memory saving option is active, so MODULO cannot be initialized with the full snapshot matrix. Use 'ReadData' routines to process the data in chunks instead.")
134
137
 
135
138
  # Load the data matrix
136
139
  if isinstance(data, np.ndarray):
@@ -657,14 +660,13 @@ class ModuloVKI:
657
660
  Sigma_sP : numpy.ndarray, shape (n_Modes,)
658
661
  Modal energies (eigenvalues of the filtered covariance).
659
662
  """
660
- if self.D is None:
661
- D = np.load(self.FOLDER_OUT + '/MODULO_tmp/data_matrix/database.npz')['D']
662
- else:
663
- D = self.D
664
-
663
+
665
664
  self.K = CorrelationMatrix(self.N_T, self.N_PARTITIONS, self.MEMORY_SAVING,
666
- self.FOLDER_OUT, self.SAVE_K, D=D)
667
-
665
+ self.FOLDER_OUT, self.SAVE_K, D=self.Dstar)
666
+
667
+ if self.MEMORY_SAVING:
668
+ self.K = np.load(self.FOLDER_OUT + '/correlation_matrix/k_matrix.npz')['K']
669
+
668
670
  # additional step: diagonal spectral filter of K
669
671
  K_F = spectral_filter(self.K, N_o=N_O, f_c=f_c)
670
672
 
@@ -672,7 +674,7 @@ class ModuloVKI:
672
674
  Psi_P, Sigma_P = Temporal_basis_POD(K_F, SAVE_SPOD, self.FOLDER_OUT, n_Modes)
673
675
 
674
676
  # but with a normalization aspect to handle the non-orthogonality of the SPOD modes
675
- Phi_P = Spatial_basis_POD(D, N_T=self.K.shape[0],
677
+ Phi_P = Spatial_basis_POD(self.D, N_T=self.K.shape[0],
676
678
  PSI_P=Psi_P, Sigma_P=Sigma_P,
677
679
  MEMORY_SAVING=self.MEMORY_SAVING,
678
680
  FOLDER_OUT=self.FOLDER_OUT,
@@ -53,7 +53,7 @@ def Plot_Field_TEXT_JET(File):
53
53
  ax.set_xlim([0, 35])
54
54
  ax.set_ylim(10, 29)
55
55
  ax.invert_yaxis() # Invert Axis for plotting purpose
56
- plt.show()
56
+ # plt.show()
57
57
  Name[len(Name) - 12:len(Name)] + ' Plotted'
58
58
  return n_s, Xg, Yg, Vxg, -Vyg, X_S, Y_S
59
59
 
@@ -1,313 +1,357 @@
1
- Metadata-Version: 2.4
2
- Name: modulo_vki
3
- Version: 2.1.2
4
- Summary: MODULO (MODal mULtiscale pOd) is a software developed at the von Karman Institute to perform Multiscale Modal Analysis of numerical and experimental data.
5
- Home-page: https://github.com/mendezVKI/MODULO/tree/master/modulo_python_package/
6
- Author: ['R. Poletti', 'L. Schena', 'D. Ninni', 'M. A. Mendez']
7
- Author-email: mendez@vki.ac.be
8
- License: BSD (3-clause)
9
- Classifier: Development Status :: 4 - Beta
10
- Classifier: Natural Language :: English
11
- Classifier: Programming Language :: Python :: 3
12
- Requires-Python: >=3.6
13
- Description-Content-Type: text/x-rst
14
- License-File: LICENSE
15
- Requires-Dist: tqdm
16
- Requires-Dist: numpy
17
- Requires-Dist: scipy
18
- Requires-Dist: scikit-learn
19
- Requires-Dist: ipykernel
20
- Requires-Dist: ipython
21
- Requires-Dist: ipython-genutils
22
- Requires-Dist: ipywidgets
23
- Requires-Dist: matplotlib
24
- Dynamic: author
25
- Dynamic: author-email
26
- Dynamic: classifier
27
- Dynamic: description
28
- Dynamic: description-content-type
29
- Dynamic: home-page
30
- Dynamic: license
31
- Dynamic: license-file
32
- Dynamic: requires-dist
33
- Dynamic: requires-python
34
- Dynamic: summary
35
-
36
- MODULO: a python toolbox for data-driven modal decomposition
37
- ------------------------------------------------------------
38
-
39
- .. image:: https://modulo.readthedocs.io/en/latest/_images/modulo_logo.png
40
- :alt: MODULO logo
41
- :width: 500px
42
- :align: center
43
-
44
-
45
- **MODULO** is a modal decomposition package developed at the von Karman Institute for Fluid Dynamics (VKI). It offers a wide range of decomposition techniques, allowing users to choose the most appropriate method for their specific problem. MODULO can efficiently handle large datasets natively, thanks to a memory-saving feature that partitions the data and processes the decomposition in chunks (`Nini et al. (2022) <https://www.sciencedirect.com/science/article/pii/S2352711020303356>`_). Moreover, it supports non-uniform meshes through a weighted inner product formulation. Currently, MODULO heavily relies on NumPy routines and does not offer additional parallel computing capabilities beyond those naturally provided by NumPy.
46
-
47
- While the discontinued MATLAB version of MODULO is accessible in the “Old_Matlab_Implementation” branch,
48
- it is no longer maintained. The latest decomposition techniques are exclusively available in the current Python version (`Poletti et al. (2024) <https://joss.theoj.org/papers/10.21105/joss.06753>`_).
49
-
50
- As a part of the MODULO project, we provide a series of lectures on data-driven modal decomposition, and its applications.
51
- These are available at the `MODULO YouTube channel <https://www.youtube.com/@modulompod5682>`_.
52
-
53
- .. contents:: Table of contents
54
-
55
- Modal decompositions
56
- --------------------
57
- Modal decompositions aim to describe the data as a linear combination of *modes*, obtained by projecting the data
58
- onto a suitable set of basis. Different decompositions employ different bases, such as prescribed Fourier basis for
59
- the Discrete Fourier Transform (DFT), or data-driven basis, i.e. tailored on the dataset at hand,
60
- for the Proper Orthogonal Decomposition (POD). We refer to `Mendez (2022) <https://doi.org/10.48550/arXiv.2201.03847>`_, `Mendez (2023) <https://doi.org/10.1017/9781108896214.013>`_, and `Mendez et al. (2023) <https://arxiv.org/abs/2208.07746>`_ for an introduction to the topic.
61
- MODULO currently features the following decompositions:
62
-
63
- - Discrete Fourier Transform (DFT) (`Briggs et al. (1997) <https://epubs.siam.org/doi/book/10.1137/1.9781611971514>`_)
64
- - Proper Orthogonal Decomposition (POD) (`Sirovich et al. (1987) <https://www.ams.org/journals/qam/1987-45-03/S0033-569X-1987-0910464-1/S0033-569X-1987-0910464-1.pdf>`_ , `Berkooz et al. (1993) <https://doi.org/10.1146/annurev.fl.25.010193.002543>`_)
65
- - Multi-Scale Proper Orthogonal Decomposition (mPOD) (`Mendez et al. (2019) <https://arxiv.org/abs/1804.09646>`_)
66
- - Dynamic Mode Decomposition (DMD) (`Schmid (2010) <https://doi.org/10.1017/S0022112010001217>`_)
67
- - Spectral Proper Orthogonal Decomposition (SPOD) (`Sieber et al. (2016) <https://doi.org/10.48550/arXiv.1508.04642>`_, `Towne et al. (2018) <https://doi.org/10.48550/arXiv.1708.04393>`_),
68
- note that the two are different formulations, and both are available in MODULO.
69
- - Kernel Proper Orthogonal Decomposition (KPOD) (`Mika et al. (1998) <https://proceedings.neurips.cc/paper_files/paper/1998/file/226d1f15ecd35f784d2a20c3ecf56d7f-Paper.pdf>`_)
70
-
71
- We remind the curious reader to the respective references for a detailed description of each decomposition, and to the
72
- documentation for a practical guide on how to use them in MODULO.
73
-
74
- Release Notes
75
- -------------
76
- This version of MODULO includes the following updates:
77
-
78
- 1. **mPOD bug fix:** the previous version of mPOD was skipping the last scale of the frequency splitting vector. Fixed in this version.
79
-
80
- 2. **SPOD parallelisation:** CSD - SPOD can now be parallelized, leveraging `joblib`. The user needs just to pass the argument `n_processes` for the computation to be
81
- split between different workers.
82
-
83
- 3. **Simplified decomposition interface:** the interface of the decomposition methods has been simplified to improve user experience.
84
-
85
- 4. **Enhanced POD selection:** the POD function has been redesigned, allowing users to easily choose between different POD methods.
86
-
87
- 5. **Improved computational efficiency:** the code of the decomposition functions has been optimised, resulting in reduced computation time. mPOD now includes two additional optional arguments to enable faster filtering and to avoid recomputing the Sigmas after QR polishing.
88
-
89
- 6. **Extended documentation:** the documentation has been significantly enriched, now including theoretical foundations for all the supported modal decomposition techniques.
90
-
91
-
92
- Documentation
93
- -------------
94
-
95
- The documentation of MODULO is available `here <https://lorenzoschena.github.io/MODULO/intro.html>`_. It
96
- contains a comprehensive guide on how to install and use the package, as well as a detailed description of the
97
- decompositions required inputs and outputs. A `list of YouTube videos <https://www.youtube.com/@modulompod5682>`_
98
- is also available to guide the introduce the user to modal decomposition and MODULO.
99
-
100
- Installation
101
- -------------
102
-
103
- Installation via pip
104
- ^^^^^^^^^^^^^^^^^^^^
105
-
106
- You can access the latest update of the modulo python package on PyPI using the command line:
107
-
108
- .. code-block:: bash
109
-
110
- $ pip install modulo_vki
111
-
112
- Installation from source
113
- ^^^^^^^^^^^^^^^^^^^^^^^^
114
-
115
- Alternatively, you can clone the repository and install the package locally:
116
-
117
- .. code-block:: bash
118
-
119
- $ git clone https://github.com/mendezVKI/MODULO.git
120
-
121
- $ cd MODULO
122
-
123
- $ python setup.py install
124
-
125
- or, if you have pip installed in your environment,
126
-
127
- .. code-block:: bash
128
-
129
- $ pip install .
130
-
131
-
132
- Example
133
- -------------
134
-
135
- Example 1: POD decomposition
136
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
137
-
138
- The following example illustrates how to decompose a data set (D) using the POD decomposition.
139
-
140
- .. code-block:: python
141
-
142
- from modulo_vki import ModuloVKI
143
- import numpy as np
144
-
145
- # Create a random dataset
146
- D = np.random.rand(100, 1000)
147
-
148
- # Initialize the ModuloVKI object
149
- m = ModuloVKI(D)
150
-
151
- # Compute the POD decomposition
152
- phi_POD, Sigma_POD, psi_POD = m.POD()
153
-
154
- which returns the spatial basis ($\phi$), the temporal basis ($\psi$), and the modal
155
- amplitudes ($\Sigma$) of the POD decomposition.
156
-
157
- Example 2: Memory Saving option
158
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
159
-
160
- For the Memory Saving option, MODULO decomposes $D$ in `N_partitions`, defined
161
- by the user (refer to `examples/ex_04_Memory_Saving.py`).
162
-
163
- .. code-block:: python
164
-
165
- from modulo_vki import ModuloVKI
166
- import numpy as np
167
-
168
- # Create a random dataset
169
- D = np.random.rand(100, 1000)
170
-
171
- # Initialize the ModuloVKI object
172
- m = ModuloVKI(D, N_PARTITIONS=10)
173
-
174
- # Compute the POD decomposition
175
- phi_POD, Sigma_POD, psi_POD = m.POD()
176
-
177
- Example 3: non-uniform grid
178
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
179
-
180
- If you are dealing with non-uniform grid (e.g. output of a Computational Fluid Dynamic (CFD) simulation),
181
- you can use the weighted inner product formulation (refer to `examples/ex_05_nonUniform_POD.py`).
182
-
183
- .. code-block:: python
184
-
185
- from modulo_vki import ModuloVKI
186
- import numpy as np
187
-
188
- # Create a random dataset
189
- D = np.random.rand(100, 1000)
190
-
191
- # Get the area of the grid
192
- a_dataSet = gridData.compute_cell_sizes()
193
- area = a_dataSet['Area']
194
-
195
- # Compute weights
196
- areaTot = np.sum(area)
197
- weights = area/areaTot # sum should be equal to 1
198
-
199
- # Initialize the ModuloVKI object
200
- m = ModuloVKI(D, weights=weights)
201
-
202
- # Compute the POD decomposition
203
- phi_POD, Sigma_POD, psi_POD = m.POD()
204
-
205
- Community guidelines
206
- ---------------------
207
-
208
- Contributing to MODULO
209
- ^^^^^^^^^^^^^^^^^^^^^^^
210
- We welcome contributions to MODULO.
211
-
212
- It is recommended to perform a shallow clone of the repository to avoid downloading the entire history of the project:
213
-
214
- .. code-block:: bash
215
-
216
- $ git clone --depth 1 https://github.com/mendezVKI/MODULO.git
217
-
218
- This will download only the latest version of the repository, which is sufficient for contributing to the project, and will save
219
- you time and disk space.
220
-
221
- To create a new feature, please submit a pull request, specifying the proposed changes and
222
- providing an example of how to use the new feature (that will be included in the `examples/` folder).
223
-
224
- The pull request will be reviewed by the MODULO team before being merged into the main branch, and your contribution duly acknowledged.
225
-
226
- Report bugs
227
- ^^^^^^^^^^^^
228
- If you find a bug, or you encounter unexpected behaviour, please open an issue on the MODULO GitHub repository.
229
-
230
- Ask for help
231
- ^^^^^^^^^^^^
232
- If you have troubles using MODULO, or you need help with a specific decomposition, please open an issue on the MODULO GitHub repository.
233
-
234
- Citation
235
- --------
236
-
237
- If you use MODULO in your research, please cite it as follows:
238
-
239
- Poletti, R., Schena, L., Ninni, D., Mendez, M. A. (2024).
240
- *MODULO: A Python toolbox for data-driven modal decomposition*.
241
- Journal of Open Source Software, 9(102), 6753. https://doi.org/10.21105/joss.06753
242
-
243
- .. code-block:: text
244
-
245
- @article{Poletti2024,
246
- doi = {10.21105/joss.06753},
247
- url = {https://doi.org/10.21105/joss.06753},
248
- year = {2024},
249
- publisher = {The Open Journal},
250
- volume = {9},
251
- number = {102},
252
- pages = {6753},
253
- author = {R. Poletti and L. Schena and D. Ninni and M. A. Mendez},
254
- title = {MODULO: A Python toolbox for data-driven modal decomposition},
255
- journal = {Journal of Open Source Software}
256
- }
257
-
258
- and
259
-
260
- Ninni, D., & Mendez, M. A. (2020).
261
- *MODULO: A software for Multiscale Proper Orthogonal Decomposition of data*.
262
- SoftwareX, 12, 100622. https://doi.org/10.1016/j.softx.2020.100622
263
-
264
- .. code-block:: text
265
-
266
- @article{ninni2020modulo,
267
- title={MODULO: A software for Multiscale Proper Orthogonal Decomposition of data},
268
- author={Ninni, Davide and Mendez, Miguel A},
269
- journal={SoftwareX},
270
- volume={12},
271
- pages={100622},
272
- year={2020},
273
- publisher={Elsevier}
274
- }
275
-
276
-
277
- References
278
- ----------
279
-
280
- - Mendez, Miguel Alfonso. "Statistical Treatment, Fourier and Modal Decomposition." arXiv preprint arXiv:2201.03847 (2022).
281
- - Mendez, M. A. (2023) "Generalized and Multiscale Modal Analysis". In : Mendez M.A., Ianiro, A., Noack, B.R., Brunton, S. L. (Eds),
282
- "Data-Driven Fluid Mechanics: Combining First Principles and Machine Learning". Cambridge University Press, 2023:153-181.
283
- https://doi.org/10.1017/9781108896214.013. The pre-print is available at https://arxiv.org/abs/2208.12630.
284
- - Ninni, Davide, and Miguel A. Mendez. "MODULO: A software for Multiscale Proper Orthogonal Decomposition of data." SoftwareX 12 (2020): 100622.
285
- - Poletti, Romain, Schena, Lorenzo, Ninni, David, and Mendez, Miguel A. "Modulo: A python toolbox for data-driven modal decomposition". Journal of Open Source Software (2024), 9(102), 6753.
286
- - Mendez, Miguel A. "Linear and nonlinear dimensionality reduction from fluid mechanics to machine learning." Measurement Science and Technology 34.4 (2023): 042001.
287
- - Briggs, William L., and Van Emden Henson. The DFT: an owner's manual for the discrete Fourier transform. Society for Industrial and Applied Mathematics, 1995.
288
- - Berkooz, Gal, Philip Holmes, and John L. Lumley. "The proper orthogonal decomposition in the analysis of turbulent flows." Annual review of fluid mechanics 25.1 (1993): 539-575.
289
- - Sirovich, Lawrence. "Turbulence and the dynamics of coherent structures. III. Dynamics and scaling." Quarterly of Applied mathematics 45.3 (1987): 583-590.
290
- - Mendez, M. A., M. Balabane, and J-M. Buchlin. "Multi-scale proper orthogonal decomposition of complex fluid flows." Journal of Fluid Mechanics 870 (2019): 988-1036.
291
- - Schmid, Peter J. "Dynamic mode decomposition of numerical and experimental data." Journal of fluid mechanics 656 (2010): 5-28.
292
- - Sieber, Moritz, C. Oliver Paschereit, and Kilian Oberleithner. "Spectral proper orthogonal decomposition." Journal of Fluid Mechanics 792 (2016): 798-828.
293
- - Towne, Aaron, Oliver T. Schmidt, and Tim Colonius. "Spectral proper orthogonal decomposition and its relationship to dynamic mode decomposition and resolvent analysis." Journal of Fluid Mechanics 847 (2018): 821-867.
294
- - Mika, Sebastian, et al. "Kernel PCA and de-noising in feature spaces." Advances in neural information processing systems 11 (1998).
295
-
296
- Related projects
297
- ----------------
298
- MODULO encapsulates a wide range of decomposition techniques, but not all of them. We refer to the project below for an additional set of decomposition techniques:
299
-
300
- - ModRed, https://github.com/belson17/modred
301
-
302
- There are also decomposition-specific projects, some of which are listed below:
303
-
304
- - Rogowski, Marcin, Brandon CY Yeung, Oliver T. Schmidt, Romit Maulik, Lisandro Dalcin, Matteo Parsani, and Gianmarco Mengaldo. "Unlocking massively parallel spectral proper orthogonal decompositions in the PySPOD package." Computer Physics Communications 302 (2024): 109246.
305
- - Lario, A., Maulik, R., Schmidt, O.T., Rozza, G. and Mengaldo, G., 2022. Neural-network learning of SPOD latent dynamics. Journal of Computational Physics, 468, p.111475.
306
- - Ichinaga, Andreuzzi, Demo, Tezzele, Lapo, Rozza, Brunton, Kutz. PyDMD: A Python package for robust dynamic mode decomposition. arXiv preprint, 2024.
307
- - Rogowski, Marcin, et al. "Unlocking massively parallel spectral proper orthogonal decompositions in the PySPOD package." Computer Physics Communications 302 (2024): 109246.
308
-
309
-
310
-
311
-
312
-
313
-
1
+ Metadata-Version: 2.4
2
+ Name: modulo_vki
3
+ Version: 2.1.5
4
+ Summary: MODULO (MODal mULtiscale pOd) is a software developed at the von Karman Institute to perform Multiscale Modal Analysis of numerical and experimental data.
5
+ Home-page: https://github.com/mendezVKI/MODULO/tree/master/modulo_python_package/
6
+ Author: ['R. Poletti', 'L. Schena', 'D. Ninni', 'M. A. Mendez']
7
+ Author-email: mendez@vki.ac.be
8
+ License: BSD (3-clause)
9
+ Classifier: Development Status :: 4 - Beta
10
+ Classifier: Natural Language :: English
11
+ Classifier: Programming Language :: Python :: 3
12
+ Requires-Python: >=3.6
13
+ Description-Content-Type: text/x-rst
14
+ License-File: LICENSE
15
+ Requires-Dist: tqdm
16
+ Requires-Dist: numpy
17
+ Requires-Dist: scipy
18
+ Requires-Dist: scikit-learn
19
+ Requires-Dist: ipykernel
20
+ Requires-Dist: ipython
21
+ Requires-Dist: ipython-genutils
22
+ Requires-Dist: ipywidgets
23
+ Requires-Dist: matplotlib
24
+ Dynamic: author
25
+ Dynamic: author-email
26
+ Dynamic: classifier
27
+ Dynamic: description
28
+ Dynamic: description-content-type
29
+ Dynamic: home-page
30
+ Dynamic: license
31
+ Dynamic: license-file
32
+ Dynamic: requires-dist
33
+ Dynamic: requires-python
34
+ Dynamic: summary
35
+
36
+ MODULO: a python toolbox for data-driven modal decomposition
37
+ -------------------------------------------------------------
38
+
39
+ .. image:: https://modulo.readthedocs.io/en/latest/_images/modulo_logo.png
40
+ :alt: MODULO logo
41
+ :width: 500px
42
+ :align: center
43
+
44
+
45
+ **MODULO** is a modal decomposition package developed at the von Karman Institute for Fluid Dynamics (VKI). It offers a wide range of decomposition techniques, allowing users to choose the most appropriate method for their specific problem. MODULO can efficiently handle large datasets natively, thanks to a memory-saving feature that partitions the data and processes the decomposition in chunks (`Nini et al. (2022) <https://www.sciencedirect.com/science/article/pii/S2352711020303356>`_). Moreover, it supports non-uniform meshes through a weighted inner product formulation. Currently, MODULO heavily relies on NumPy routines and does not offer additional parallel computing capabilities beyond those naturally provided by NumPy.
46
+
47
+ While the discontinued MATLAB version of MODULO is accessible in the “Old_Matlab_Implementation” branch,
48
+ it is no longer maintained. The latest decomposition techniques are exclusively available in the current Python version (`Poletti et al. (2024) <https://joss.theoj.org/papers/10.21105/joss.06753>`_).
49
+
50
+ As a part of the MODULO project, we provide a series of lectures on data-driven modal decomposition, and its applications.
51
+ These are available at the `MODULO YouTube channel <https://www.youtube.com/@modulompod5682>`_.
52
+ The full package documentation can be found at: `MODULO ReadTheDocs <https://lorenzoschena.github.io/MODULO/intro.html>`_.
53
+
54
+ .. contents:: Table of contents
55
+
56
+ Modal decompositions
57
+ --------------------
58
+ Modal decompositions aim to describe the data as a linear combination of *modes*, obtained by projecting the data
59
+ onto a suitable set of basis. Different decompositions employ different bases, such as prescribed Fourier basis for
60
+ the Discrete Fourier Transform (DFT), or data-driven basis, i.e. tailored on the dataset at hand,
61
+ for the Proper Orthogonal Decomposition (POD). We refer to `Mendez (2022) <https://doi.org/10.48550/arXiv.2201.03847>`_, `Mendez (2023) <https://doi.org/10.1017/9781108896214.013>`_, and `Mendez et al. (2023) <https://arxiv.org/abs/2208.07746>`_ for an introduction to the topic.
62
+ MODULO currently features the following decompositions:
63
+
64
+ - Discrete Fourier Transform (DFT) (`Briggs et al. (1997) <https://epubs.siam.org/doi/book/10.1137/1.9781611971514>`_)
65
+ - Proper Orthogonal Decomposition (POD) (`Sirovich et al. (1987) <https://www.ams.org/journals/qam/1987-45-03/S0033-569X-1987-0910464-1/S0033-569X-1987-0910464-1.pdf>`_ , `Berkooz et al. (1993) <https://doi.org/10.1146/annurev.fl.25.010193.002543>`_)
66
+ - Multi-Scale Proper Orthogonal Decomposition (mPOD) (`Mendez et al. (2019) <https://arxiv.org/abs/1804.09646>`_)
67
+ - Dynamic Mode Decomposition (DMD) (`Schmid (2010) <https://doi.org/10.1017/S0022112010001217>`_)
68
+ - Spectral Proper Orthogonal Decomposition (SPOD) (`Sieber et al. (2016) <https://doi.org/10.48550/arXiv.1508.04642>`_, `Towne et al. (2018) <https://doi.org/10.48550/arXiv.1708.04393>`_),
69
+ note that the two are different formulations, and both are available in MODULO.
70
+ - Kernel Proper Orthogonal Decomposition (KPOD) (`Mika et al. (1998) <https://proceedings.neurips.cc/paper_files/paper/1998/file/226d1f15ecd35f784d2a20c3ecf56d7f-Paper.pdf>`_)
71
+
72
+ We remind the curious reader to the respective references for a detailed description of each decomposition, and to the
73
+ documentation for a practical guide on how to use them in MODULO.
74
+
75
+ Release Notes
76
+ -------------
77
+ This version of MODULO includes the following updates:
78
+
79
+ 1. **mPOD bug fix:** the previous version of mPOD was skipping the last scale of the frequency splitting vector. Fixed in this version.
80
+
81
+ 2. **SPOD parallelisation:** CSD - SPOD can now be parallelized, leveraging `joblib`. The user needs just to pass the argument `n_processes` for the computation to be
82
+ split between different workers.
83
+
84
+ 3. **Simplified decomposition interface:** the interface of the decomposition methods has been simplified to improve user experience.
85
+
86
+ 4. **Enhanced POD selection:** the POD function has been redesigned, allowing users to easily choose between different POD methods.
87
+
88
+ 5. **Improved computational efficiency:** the code of the decomposition functions has been optimised, resulting in reduced computation time. mPOD now includes two additional optional arguments to enable faster filtering and to avoid recomputing the Sigmas after QR polishing.
89
+
90
+ 6. **Extended documentation:** the documentation has been significantly enriched, now including theoretical foundations for all the supported modal decomposition techniques.
91
+
92
+
93
+ Documentation
94
+ -------------
95
+
96
+ The documentation of MODULO is available `here <https://lorenzoschena.github.io/MODULO/intro.html>`_. It
97
+ contains a comprehensive guide on how to install and use the package, as well as a detailed description of the
98
+ decompositions required inputs and outputs. A `list of YouTube videos <https://www.youtube.com/@modulompod5682>`_
99
+ is also available to guide the introduce the user to modal decomposition and MODULO.
100
+
101
+ Installation
102
+ -------------
103
+
104
+ Installation via pip
105
+ ^^^^^^^^^^^^^^^^^^^^
106
+
107
+ You can access the latest update of the modulo python package on PyPI using the command line:
108
+
109
+ .. code-block:: bash
110
+
111
+ $ pip install modulo_vki
112
+
113
+ Installation from source
114
+ ^^^^^^^^^^^^^^^^^^^^^^^^
115
+
116
+ Alternatively, you can clone the repository and install the package locally:
117
+
118
+ .. code-block:: bash
119
+
120
+ $ git clone https://github.com/mendezVKI/MODULO.git
121
+
122
+ $ cd MODULO
123
+
124
+ $ python setup.py install
125
+
126
+ or, if you have pip installed in your environment,
127
+
128
+ .. code-block:: bash
129
+
130
+ $ pip install .
131
+
132
+
133
+ Example
134
+ -------------
135
+
136
+ Example 1: POD decomposition
137
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
138
+
139
+ The following example illustrates how to decompose a data set (D) using the POD decomposition.
140
+
141
+ .. code-block:: python
142
+
143
+ from modulo_vki import ModuloVKI
144
+ import numpy as np
145
+
146
+ # Create a random dataset
147
+ D = np.random.rand(100, 1000)
148
+
149
+ # Initialize the ModuloVKI object
150
+ m = ModuloVKI(D)
151
+
152
+ # Compute the POD decomposition
153
+ phi_POD, Sigma_POD, psi_POD = m.POD()
154
+
155
+ which returns the spatial basis ($\phi$), the temporal basis ($\psi$), and the modal
156
+ amplitudes ($\Sigma$) of the POD decomposition.
157
+
158
+ Example 2: Memory Saving option
159
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
160
+
161
+ For the Memory Saving option, MODULO decomposes $D$ in `N_partitions`, defined
162
+ by the user (refer to `examples/ex_04_Memory_Saving.py`).
163
+
164
+ .. code-block:: python
165
+
166
+ import os
167
+ import numpy as np
168
+ from modulo_vki import ModuloVKI
169
+ from modulo_vki.utils.read_db import ReadData
170
+
171
+ # --- 1. User-defined settings ---
172
+ # Define the path to your data and the file naming convention.
173
+ FOLDER = 'path/to/your/snapshot_data'
174
+ FILE_ROOT_NAME = 'Res' # The base name, e.g., 'Res' for 'Res00001.dat'
175
+ n_t = 100 # The total number of snapshots (time steps) to process.
176
+
177
+ # --- 2. Data format parameters ---
178
+ # Specify how to read your text-based snapshot files.
179
+ H = 1 # H: Number of header lines to skip
180
+ F = 0 # F: Number of footer lines to skip
181
+ C = 0 # C: Number of initial columns to skip
182
+
183
+ # --- 3. Determine data dimensions from a sample file ---
184
+ # To understand the structure, we load the first snapshot.
185
+ first_snapshot_file = os.path.join(FOLDER, f"{FILE_ROOT_NAME}00001.dat")
186
+ Dat = np.genfromtxt(first_snapshot_file, skip_header=H, skip_footer=F)
187
+
188
+ # N: Number of components per point (e.g., 2 for 2D velocity u,v)
189
+ N = Dat.shape[1]
190
+ # nxny: Number of spatial points in the mesh
191
+ nxny = Dat.shape[0]
192
+ # N_T: Total number of snapshots (aliased from n_t for clarity)
193
+ N_T = n_t
194
+
195
+ # --- 4. Process the dataset into partitions on disk ---
196
+ # The ReadData utility reads all snapshots and chunks the snapshot matrix.
197
+
198
+ D = ReadData._data_processing(
199
+ D=None, # We start with no data in memory
200
+ FOLDER_IN=FOLDER,
201
+ filename=f'{FILE_ROOT_NAME}%05d', # File pattern for snapshot files
202
+ N=N, # Number of components per point
203
+ N_S=N * nxny, # Total size of a single snapshot vector
204
+ N_T=N_T, # Total number of snapshots
205
+ h=H, f=F, c=C, # Header, footer, and column skip parameters
206
+ N_PARTITIONS=10, # The dataset will be split into 10 chunks
207
+ MR=False, # Mean-removal flag
208
+ FOLDER_OUT=os.path.join('.', 'MODULO_tmp') # Where to save temp files
209
+ )
210
+
211
+ # --- 5. Initialize ModuloVKI and compute the POD ---
212
+ # Initialize the object, passing the number of partitions. D must be set to None
213
+ # MODULO will look for the partitions in FOLDER_OUT/MODULO_tmp
214
+ m = ModuloVKI(None, N_PARTITIONS=10, FOLDER_OUT=FOLDER_OUT)
215
+
216
+ # The POD method will now automatically read the data from the partitioned files.
217
+ phi_POD, Sigma_POD, psi_POD = m.POD()
218
+
219
+ print("POD computation complete.")
220
+
221
+ Example 3: non-uniform grid
222
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
223
+
224
+ If you are dealing with non-uniform grid (e.g. output of a Computational Fluid Dynamic (CFD) simulation),
225
+ you can use the weighted inner product formulation (refer to `examples/ex_05_nonUniform_POD.py`).
226
+
227
+ .. code-block:: python
228
+
229
+ from modulo_vki import ModuloVKI
230
+ import numpy as np
231
+
232
+ # Create a random dataset
233
+ D = np.random.rand(100, 1000)
234
+
235
+ # Get the area of the grid
236
+ a_dataSet = gridData.compute_cell_sizes()
237
+ area = a_dataSet['Area']
238
+
239
+ # Compute weights
240
+ areaTot = np.sum(area)
241
+ weights = area/areaTot # sum should be equal to 1
242
+
243
+ # Initialize the ModuloVKI object
244
+ m = ModuloVKI(D, weights=weights)
245
+
246
+ # Compute the POD decomposition
247
+ phi_POD, Sigma_POD, psi_POD = m.POD()
248
+
249
+ Community guidelines
250
+ ---------------------
251
+
252
+ Contributing to MODULO
253
+ ^^^^^^^^^^^^^^^^^^^^^^^
254
+ We welcome contributions to MODULO.
255
+
256
+ It is recommended to perform a shallow clone of the repository to avoid downloading the entire history of the project:
257
+
258
+ .. code-block:: bash
259
+
260
+ $ git clone --depth 1 https://github.com/mendezVKI/MODULO.git
261
+
262
+ This will download only the latest version of the repository, which is sufficient for contributing to the project, and will save
263
+ you time and disk space.
264
+
265
+ To create a new feature, please submit a pull request, specifying the proposed changes and
266
+ providing an example of how to use the new feature (that will be included in the `examples/` folder).
267
+
268
+ The pull request will be reviewed by the MODULO team before being merged into the main branch, and your contribution duly acknowledged.
269
+
270
+ Report bugs
271
+ ^^^^^^^^^^^^
272
+ If you find a bug, or you encounter unexpected behaviour, please open an issue on the MODULO GitHub repository.
273
+
274
+ Ask for help
275
+ ^^^^^^^^^^^^
276
+ If you have troubles using MODULO, or you need help with a specific decomposition, please open an issue on the MODULO GitHub repository.
277
+
278
+ Citation
279
+ --------
280
+
281
+ If you use MODULO in your research, please cite it as follows:
282
+
283
+ Poletti, R., Schena, L., Ninni, D., Mendez, M. A. (2024).
284
+ *MODULO: A Python toolbox for data-driven modal decomposition*.
285
+ Journal of Open Source Software, 9(102), 6753. https://doi.org/10.21105/joss.06753
286
+
287
+ .. code-block:: text
288
+
289
+ @article{Poletti2024,
290
+ doi = {10.21105/joss.06753},
291
+ url = {https://doi.org/10.21105/joss.06753},
292
+ year = {2024},
293
+ publisher = {The Open Journal},
294
+ volume = {9},
295
+ number = {102},
296
+ pages = {6753},
297
+ author = {R. Poletti and L. Schena and D. Ninni and M. A. Mendez},
298
+ title = {MODULO: A Python toolbox for data-driven modal decomposition},
299
+ journal = {Journal of Open Source Software}
300
+ }
301
+
302
+ and
303
+
304
+ Ninni, D., & Mendez, M. A. (2020).
305
+ *MODULO: A software for Multiscale Proper Orthogonal Decomposition of data*.
306
+ SoftwareX, 12, 100622. https://doi.org/10.1016/j.softx.2020.100622
307
+
308
+ .. code-block:: text
309
+
310
+ @article{ninni2020modulo,
311
+ title={MODULO: A software for Multiscale Proper Orthogonal Decomposition of data},
312
+ author={Ninni, Davide and Mendez, Miguel A},
313
+ journal={SoftwareX},
314
+ volume={12},
315
+ pages={100622},
316
+ year={2020},
317
+ publisher={Elsevier}
318
+ }
319
+
320
+
321
+ References
322
+ ----------
323
+
324
+ - Mendez, Miguel Alfonso. "Statistical Treatment, Fourier and Modal Decomposition." arXiv preprint arXiv:2201.03847 (2022).
325
+ - Mendez, M. A. (2023) "Generalized and Multiscale Modal Analysis". In : Mendez M.A., Ianiro, A., Noack, B.R., Brunton, S. L. (Eds),
326
+ "Data-Driven Fluid Mechanics: Combining First Principles and Machine Learning". Cambridge University Press, 2023:153-181.
327
+ https://doi.org/10.1017/9781108896214.013. The pre-print is available at https://arxiv.org/abs/2208.12630.
328
+ - Ninni, Davide, and Miguel A. Mendez. "MODULO: A software for Multiscale Proper Orthogonal Decomposition of data." SoftwareX 12 (2020): 100622.
329
+ - Poletti, Romain, Schena, Lorenzo, Ninni, David, and Mendez, Miguel A. "Modulo: A python toolbox for data-driven modal decomposition". Journal of Open Source Software (2024), 9(102), 6753.
330
+ - Mendez, Miguel A. "Linear and nonlinear dimensionality reduction from fluid mechanics to machine learning." Measurement Science and Technology 34.4 (2023): 042001.
331
+ - Briggs, William L., and Van Emden Henson. The DFT: an owner's manual for the discrete Fourier transform. Society for Industrial and Applied Mathematics, 1995.
332
+ - Berkooz, Gal, Philip Holmes, and John L. Lumley. "The proper orthogonal decomposition in the analysis of turbulent flows." Annual review of fluid mechanics 25.1 (1993): 539-575.
333
+ - Sirovich, Lawrence. "Turbulence and the dynamics of coherent structures. III. Dynamics and scaling." Quarterly of Applied mathematics 45.3 (1987): 583-590.
334
+ - Mendez, M. A., M. Balabane, and J-M. Buchlin. "Multi-scale proper orthogonal decomposition of complex fluid flows." Journal of Fluid Mechanics 870 (2019): 988-1036.
335
+ - Schmid, Peter J. "Dynamic mode decomposition of numerical and experimental data." Journal of fluid mechanics 656 (2010): 5-28.
336
+ - Sieber, Moritz, C. Oliver Paschereit, and Kilian Oberleithner. "Spectral proper orthogonal decomposition." Journal of Fluid Mechanics 792 (2016): 798-828.
337
+ - Towne, Aaron, Oliver T. Schmidt, and Tim Colonius. "Spectral proper orthogonal decomposition and its relationship to dynamic mode decomposition and resolvent analysis." Journal of Fluid Mechanics 847 (2018): 821-867.
338
+ - Mika, Sebastian, et al. "Kernel PCA and de-noising in feature spaces." Advances in neural information processing systems 11 (1998).
339
+
340
+ Related projects
341
+ ----------------
342
+ MODULO encapsulates a wide range of decomposition techniques, but not all of them. We refer to the project below for an additional set of decomposition techniques:
343
+
344
+ - ModRed, https://github.com/belson17/modred
345
+
346
+ There are also decomposition-specific projects, some of which are listed below:
347
+
348
+ - Rogowski, Marcin, Brandon CY Yeung, Oliver T. Schmidt, Romit Maulik, Lisandro Dalcin, Matteo Parsani, and Gianmarco Mengaldo. "Unlocking massively parallel spectral proper orthogonal decompositions in the PySPOD package." Computer Physics Communications 302 (2024): 109246.
349
+ - Lario, A., Maulik, R., Schmidt, O.T., Rozza, G. and Mengaldo, G., 2022. Neural-network learning of SPOD latent dynamics. Journal of Computational Physics, 468, p.111475.
350
+ - Ichinaga, Andreuzzi, Demo, Tezzele, Lapo, Rozza, Brunton, Kutz. PyDMD: A Python package for robust dynamic mode decomposition. arXiv preprint, 2024.
351
+ - Rogowski, Marcin, et al. "Unlocking massively parallel spectral proper orthogonal decompositions in the PySPOD package." Computer Physics Communications 302 (2024): 109246.
352
+
353
+
354
+
355
+
356
+
357
+
@@ -1,5 +1,5 @@
1
1
  modulo_vki/__init__.py,sha256=AOjmeFjHj69m45iZzfTHM6-SLUelgKdGeu3VdSg9hIo,39
2
- modulo_vki/modulo.py,sha256=OYMLteELmAHyhfByCoy2Vqg4h7bUMsgbmIDF7jUXf3A,38261
2
+ modulo_vki/modulo.py,sha256=XbPyzd5sugYHtgKsPZ220BoWT0L3iqi-JDYXlcFTu0g,38478
3
3
  modulo_vki/modulo_old.py,sha256=3r_BBYQfbmZWGDyPukyJTVYVVcAVuEE0CmREEJkzsxU,59413
4
4
  modulo_vki/core/__init__.py,sha256=y9mIqtmSg3o8TXMqFxoiMCoMSle6mK0LBrvNJCVM1Zg,226
5
5
  modulo_vki/core/_dft.py,sha256=W98vC4HR1fivZjYRQXrFKV7RBa-O3RSRwq-nCKoxqjQ,4374
@@ -11,16 +11,16 @@ modulo_vki/core/_pod_space.py,sha256=A3dfv4Nzs9fx3qwOdlJR5HwyyfI-QcVer8P83xqa_C4
11
11
  modulo_vki/core/_pod_time.py,sha256=JtiFGYFV-tBKTWHWHW8zynMoLt2q8bD1bd1LP9pyvjo,2169
12
12
  modulo_vki/core/_spod_s.py,sha256=rxXSsNdSTLv3sjvlUErw3xjHk0eF8H7IkSJr5nMQ8Vo,4149
13
13
  modulo_vki/core/_spod_t.py,sha256=csftCPRSqs-OghQa8l0mRDL7cy5eXXSCnW8O4pnXTCY,3866
14
- modulo_vki/core/spatial_structures.py,sha256=65xh3zD3ekjRYUeRd2KcOYzPurpua7qDf0AysY-X8hE,14712
14
+ modulo_vki/core/spatial_structures.py,sha256=XRdhcZM0TdUW0PRaRKU8BU3u74H36WGEIx1YHLjrPs4,14620
15
15
  modulo_vki/core/temporal_structures.py,sha256=0DQEdE9ssTnnfIC86VZPsNlym6fsjRAboPHHnv-9CI4,10645
16
16
  modulo_vki/core/utils.py,sha256=Ac9Im9knlbZRByP6Qgv-LCDt5zEC8PbyidqXzVdeYtQ,17889
17
17
  modulo_vki/utils/__init__.py,sha256=F5yy5R19dONK9oaBEpKzylorVJNcjT2kiJ5Og-ZX1ek,94
18
18
  modulo_vki/utils/_plots.py,sha256=m43t08cVq-TY0BW0YPqT71hN-54hBphIYKZEn8Kw16E,1453
19
19
  modulo_vki/utils/_utils.py,sha256=WFD7nwjSzVHpevVwTEvMdjAmcbeqwoXT9M48tIIniJw,14355
20
- modulo_vki/utils/others.py,sha256=26ES5EmsLhwkvcXTwNhDMkblGrxoWepX5c9TXeLTRWg,17336
20
+ modulo_vki/utils/others.py,sha256=9yZzD0_rZIOWYjV2Hbi74N5oXEYct7o5h9ZjNkmxHPw,17338
21
21
  modulo_vki/utils/read_db.py,sha256=lJFauxJxS0_mYoxrbn-43UqZjOkr-qb9f6RTUq4IxZU,15149
22
- modulo_vki-2.1.2.dist-info/licenses/LICENSE,sha256=5TivriXFErrYrJgBq3M72kHNHqtSiCft3xESM1zHc0k,1091
23
- modulo_vki-2.1.2.dist-info/METADATA,sha256=dCTKzUK0d91uWzg-CoySY5towOn3-ZhExDPXmLF7w-g,14816
24
- modulo_vki-2.1.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
25
- modulo_vki-2.1.2.dist-info/top_level.txt,sha256=4PA4AmafKU6M7us7gvt_Q976Khx3qjNUEThRRM5zxeA,11
26
- modulo_vki-2.1.2.dist-info/RECORD,,
22
+ modulo_vki-2.1.5.dist-info/licenses/LICENSE,sha256=5TivriXFErrYrJgBq3M72kHNHqtSiCft3xESM1zHc0k,1091
23
+ modulo_vki-2.1.5.dist-info/METADATA,sha256=J0fY2NItK7F6s1XfraHXgbRKjjxa5EIMstXUUoFs7ns,16857
24
+ modulo_vki-2.1.5.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
25
+ modulo_vki-2.1.5.dist-info/top_level.txt,sha256=4PA4AmafKU6M7us7gvt_Q976Khx3qjNUEThRRM5zxeA,11
26
+ modulo_vki-2.1.5.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.9.0)
2
+ Generator: setuptools (80.10.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5