Skip to content

Commit cd7a266

Browse files
authored
Merge pull request #33 from MathEXLab/readthedocs
docs: Fix Read The Docs
2 parents 55c77d6 + 2d712e9 commit cd7a266

File tree

9 files changed

+119
-156
lines changed

9 files changed

+119
-156
lines changed

docs/source/Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?=
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = .
9+
BUILDDIR = _build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/source/conf.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,24 @@ def pkg_version():
2828
here = os.path.dirname(__file__)
2929
pardir = [os.path.pardir] * 2
3030
topdir = os.path.join(here, *pardir)
31-
srcdir = os.path.join(topdir, 'PySPOD')
32-
with open(os.path.join(srcdir, 'pyspod', '__init__.py')) as f:
31+
with open(os.path.join(topdir, 'pyspod', '__init__.py')) as f:
3332
m = re.search(r"__version__\s*=\s*'(.*)'", f.read())
3433
return m.groups()[0]
3534

3635
project = 'PySPOD: Python SPOD'
37-
package = project.lower()
38-
author = "Gianmarco Mengaldo, Lisandro Dalcin, Romit Maulik, Andrea Lario"
36+
package = 'pyspod'
37+
author = ', '.join([
38+
'Gianmarco Mengaldo',
39+
'Marcin Rogowski',
40+
'Lisandro Dalcin',
41+
'Romit Maulik',
42+
'Andrea Lario',
43+
])
3944
copyright = f'{_today.year}, {author}'
4045

4146
release = pkg_version()
4247
version = release.rsplit('.', 1)[0]
4348

44-
release = pkg_version()
45-
version = release.rsplit('.', 1)[0]
46-
47-
4849

4950
# -- General configuration ---------------------------------------------------
5051

@@ -118,7 +119,7 @@ def _setup_numpy_typing():
118119

119120
# This is also used if you do content translation via gettext catalogs.
120121
# Usually you set "language" from the command line for these cases.
121-
language = None
122+
# language = 'en'
122123

123124
# There are two options for replacing |today|: either, you set today to some
124125
# non-false value, then it is used:
@@ -169,16 +170,17 @@ def _setup_numpy_typing():
169170

170171
# The theme to use for HTML and HTML Help pages. See the documentation for
171172
# a list of builtin themes.
172-
#html_theme = 'bizstyle'
173-
html_theme = "sphinx_rtd_theme"
173+
html_theme = (
174+
'sphinx_rtd_theme' if 'sphinx_rtd_theme' in extensions else 'default'
175+
)
174176

175177
# Theme options are theme-specific and customize the look and feel of a theme
176178
# further. For a list of options available for each theme, see the
177179
# documentation.
178180
#html_theme_options = {}
179181

180182
# Add any paths that contain custom themes here, relative to this directory.
181-
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
183+
#html_theme_path = []
182184

183185
# The name for this set of Sphinx documents. If None, it defaults to
184186
# "<project> v<release> documentation".

docs/source/index.rst

Lines changed: 54 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -12,69 +12,11 @@ Welcome to PySPOD's documentation!
1212

1313

1414

15-
* The **GitHub repository** of this package can be found at `PySPOD <https://github.com/mathe-lab/PySPOD>`_ along installation instructions, and how to get started.
16-
17-
* **Tutorials** can be found at `PySPOD-Tutorials <https://github.com/mathe-lab/PySPOD/tree/main/tutorials>`_
18-
19-
* The package uses `github actions`_ for **continuous integration**.
20-
21-
22-
23-
Summary
24-
==================
25-
26-
The `PySPOD` library is organized following an abstract factory
27-
design pattern, where we define a base class in `spod_base.py`,
28-
called `SPOD_Base` :ref:`SPOD base class`, that implements functions
29-
and parameters available to all derived classes. In addition, it
30-
implements two abstract functions, `fit()` and `predict()` which
31-
implementation must be provided by the derived classes.
32-
33-
The classes derived from the base class are the following:
34-
- `SPOD_low_storage` (implemented in `spod_low_storage.py`) :ref:`SPOD low storage`
35-
- `SPOD_low_ram` (implemented in `spod_low_ram.py`) :ref:`SPOD low ram`
36-
- `SPOD_streaming` (implemented in `spod_streaming.py`) :ref:`SPOD streaming`
37-
38-
These derived classes contain the actual implementation
39-
of three different different versions of SPOD algorithms
40-
that mainly differ in terms of I/O requirements, RAM usage
41-
and speed. The `SPOD_low_storage` implements an algorithm
42-
that is intended when we have enough RAM to perform a given
43-
a analysis and it is generally faster, requiring a small
44-
amount of I/O operations, the `SPOD_low_ram` require extensive
45-
I/O operations but allows to run analyses when RAM is not
46-
sufficient, and the `SPOD_streaming` is a streaming version
47-
SPOD (generally slower).
48-
49-
`SPOD_low_storage` and `SPOD_low_ram` implements the algorithms
50-
that were proposed in `(Schmidt et al. 2019) <https://doi.org/10.1175/MWR-D-18-0337.1>`_.
51-
See also `(Towne et al. 2017) <https://doi.org/10.1017/jfm.2018.283>`_.
52-
`SPOD_streaming` instead implements the streaming version proposed
53-
in `(Schmidt & Towne 2019) <https://doi.org/10.1016/j.cpc.2018.11.009>`_.
54-
55-
**It should be noted that the design pattern chosen allows for the
56-
easy addition of derived classes that can implement a new versions
57-
of the SPOD approach.**
58-
59-
Additionally to these modules, we provide utilities to compute the
60-
weights that are typically required in SPOD computations. The implementation
61-
is currently limited to 2D and 3D longitude-latitude grids for geophysical
62-
applications. It is possible to implement any weighthing function that
63-
could be required for different applications. These weighting are implemented
64-
in `weights.py` :ref:`Weights`. For additional details regarding the usage
65-
of weights in the context of SPOD, one can refer to `(Schmidt & Colonius 2020)
66-
<https://doi.org/10.2514/1.J058809>`_.
67-
68-
We finally also provide some post-processing capabilities to visualize
69-
the results. These are implemented in `postproc.py` :ref:`Postprocessing
70-
module`.
71-
The functions in post-processing can be accessed directly from the base
72-
class, and in particular from the `SPOD object` returned by the `fit()`
73-
function. They can also be accessed separately from the base class, as
74-
the post-processing module constitutes a standalone module. In practice,
75-
once you run an analysis, you can load the results at a later stage and
76-
use the post-processing module to visualize the results or you can implement
77-
you own viasuliazation tools, that best suit your needs.
15+
* The **GitHub repository** of this package can be found at `PySPOD <https://github.com/MathEXLab/PySPOD>`_ along installation instructions, and how to get started.
16+
17+
* **Tutorials** can be found at `PySPOD-Tutorials <https://github.com/MathEXLab/PySPOD/tree/main/tutorials>`_
18+
19+
* The package uses `GitHub Actions <https://github.com/MathEXLab/PySPOD/actions>`_ for **continuous integration**.
7820

7921

8022

@@ -86,85 +28,71 @@ Indices and table
8628

8729

8830

89-
SPOD main modules
90-
=================
91-
92-
The SPOD main modules constitutes the backbone of the `PySPOD` library.
93-
They are constituted by the base class:
94-
95-
- `SPOD_Base` (implemented in `spod_base.py`) :ref:`SPOD base class`
96-
97-
along with its derived classes:
98-
99-
- `SPOD_low_storage` (implemented in `spod_low_storage.py`) :ref:`SPOD low storage`
100-
- `SPOD_low_ram` (implemented in `spod_low_ram.py`) :ref:`SPOD low ram`
101-
- `SPOD_streaming` (implemented in `spod_streaming.py`) :ref:`SPOD streaming`
31+
SPOD module
32+
===========
10233

103-
SPOD base class
104-
---------------
34+
SPOD base
35+
---------
10536

106-
The **SPOD base class** is intended to hold functions that are shared
107-
by all derived classes. It follows an abstract factory design pattern.
37+
.. automodule:: pyspod.spod.base
38+
:members: Base
10839

109-
.. automodule:: pyspod.spod_base
110-
:members: SPOD_Base
11140

112-
SPOD low storage
113-
----------------
41+
SPOD standard
42+
-------------
11443

115-
.. automodule:: pyspod.spod_low_storage
116-
:members: SPOD_low_storage
44+
.. automodule:: pyspod.spod.standard
45+
:members: Standard
11746

118-
SPOD low ram
119-
------------
120-
121-
.. automodule:: pyspod.spod_low_ram
122-
:members: SPOD_low_ram
12347

12448
SPOD streaming
125-
----------------
49+
--------------
12650

127-
.. automodule:: pyspod.spod_streaming
128-
:members: SPOD_streaming
51+
.. automodule:: pyspod.spod.streaming
52+
:members: Streaming
12953

13054

55+
SPOD utils
56+
----------
13157

132-
Weights
133-
=======
58+
.. automodule:: pyspod.spod.utils
59+
:members:
60+
check_orthogonality,
61+
compute_coeffs_op,
62+
compute_coeffs_conv,
63+
compute_reconstruction
13464

135-
SPOD typically requires a set of spatial weights to compute
136-
the needed inner product. In the module `weights`, we implement
137-
a set of weights used for longitude-latitude grids, for both
138-
2D and 3D problems. You can implement your own weights in this
139-
module, or pass a set of weights you have precomputed as a parameter
140-
to the SPOD base class.
14165

142-
.. automodule:: pyspod.weights
143-
:members: geo_weights_trapz_2D,
144-
geo_weights_trapz_3D,
145-
apply_normalization
66+
Utils module
67+
============
14668

14769

70+
Postprocessing
71+
--------------
14872

149-
Postprocessing module
150-
=====================
73+
.. automodule:: pyspod.utils.postproc
74+
:members:
75+
find_nearest_freq,
76+
find_nearest_coords,
77+
get_modes_at_freq,
78+
get_data_from_file,
79+
plot_eigs,
80+
plot_eigs_vs_frequency,
81+
plot_eigs_vs_period,
82+
plot_2d_modes_at_frequency,
83+
plot_3d_modes_slice_at_frequency,
84+
plot_mode_tracers,
85+
plot_2d_data,
86+
plot_data_tracers,
87+
generate_2d_data_video
15188

152-
The postproc module is intended to provide some limited
153-
support to post-process the data and results produced by **pyspod**.
154-
The key routines implemented are
15589

156-
.. automodule:: pyspod.utils.postproc
157-
:members: find_nearest_freq,
158-
find_nearest_coords,
159-
get_modes_at_freq,
160-
get_mode_from_file,
161-
plot_eigs,
162-
plot_eigs_vs_frequency,
163-
plot_eigs_vs_period,
164-
plot_2d_modes_at_frequency,
165-
plot_2d_mode_slice_vs_time,
166-
plot_3d_modes_slice_at_frequency,
167-
plot_mode_tracers,
168-
plot_2d_data,
169-
plot_data_tracers,
170-
generate_2d_data_video
90+
Weights
91+
--------------
92+
93+
.. automodule:: pyspod.utils.weights
94+
:members:
95+
geo_trapz_2D,
96+
geo_trapz_3D,
97+
custom,
98+
apply_normalization

pyspod/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
from .spod.standard import Standard as spod_standard
66
from .spod.streaming import Streaming as spod_streaming
77

8-
__version__ = "2.0.0"
8+
__version__ = '2.0.0'

pyspod/pod/base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ def xdim(self):
141141
Get the number of spatial dimensions of the data matrix.
142142
143143
:return: number of spatial dimensions of the data matrix.
144-
:rtype: tuple(int,)
144+
:rtype: tuple[int]
145145
'''
146146
return self._xdim
147147

@@ -152,7 +152,7 @@ def xshape(self):
152152
Get the spatial shape of the data matrix.
153153
154154
:return: spatial shape of the data matrix.
155-
:rtype: tuple(int,)
155+
:rtype: tuple[int]
156156
'''
157157
return self._xshape
158158

@@ -195,7 +195,7 @@ def weights(self):
195195
Get the weights used to compute the inner product.
196196
197197
:return: weight matrix used to compute the inner product.
198-
:rtype: np.ndarray
198+
:rtype: numpy.ndarray
199199
'''
200200
return self._weights
201201

pyspod/spod/base.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'''
22
Base module for the SPOD:
3-
- `fit` method must be implemented in inherited classes
3+
- The `Base.fit` method must be implemented in inherited classes
44
'''
55
from __future__ import division
66

@@ -123,6 +123,16 @@ def __init__(self, params, weights=None, comm=None):
123123
assert self._savefreq_disk2 == False, 'savefreq_disk2 and savefreq_disk cannot be both True'
124124

125125

126+
def fit(self, data_list, *args, **kwargs):
127+
'''
128+
Fit the data using SPOD.
129+
130+
:param list data_list: list containing data matrices for which
131+
to compute the SPOD.
132+
133+
'''
134+
raise NotImplementedError # pragma: no cover
135+
126136
# basic getters
127137
# --------------------------------------------------------------------------
128138

@@ -371,7 +381,7 @@ def weights(self):
371381
Get the weights used to compute the inner product.
372382
373383
:return: weight matrix used to compute the inner product.
374-
:rtype: np.ndarray
384+
:rtype: numpy.ndarray
375385
'''
376386
return self._weights
377387

pyspod/spod/standard.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class Standard(Base):
2323
Class that implements a distributed batch version of the
2424
Spectral Proper Orthogonal Decomposition algorithm to the input data.
2525
26-
The computation is performed on the `data` passed
26+
The computation is performed on the *data* passed
2727
to the `fit` method of the `Standard` class, derived
2828
from the `Base` class.
2929
'''

pyspod/spod/streaming.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class Streaming(Base):
1515
Class that implements a distributed streaming version of the
1616
Spectral Proper Orthogonal Decomposition algorithm to the input data.
1717
18-
The computation is performed on the `data` passed
18+
The computation is performed on the data passed
1919
to the `fit` method of the `Streaming` class, derived
2020
from the `Base` class.
2121
'''

0 commit comments

Comments
 (0)