Skip to content

Commit 5d1db19

Browse files
authored
Merge pull request #29 from dynamicslab/cleanup-and-fixes
Cleanup and fixes
2 parents a849cdb + 518146e commit 5d1db19

17 files changed

+1665
-1094
lines changed

.github/workflows/release.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- name: Checkout source
13-
uses: actions/checkout@v1
13+
uses: actions/checkout@v4
1414
- name: Set up Python
15-
uses: actions/setup-python@v1
15+
uses: actions/setup-python@v5
1616
with:
17-
python-version: 3.7
17+
python-version: 3.11
1818
- name: Install dependencies
1919
run: pip install wheel
2020
- name: Build package

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ repos:
44
rev: v5.0.0
55
hooks:
66
- id: check-added-large-files
7-
args: ["--maxkb=775"]
7+
args: ["--maxkb=900"]
88
- id: check-merge-conflict
99
- repo: https://github.com/PyCQA/isort
1010
rev: 5.12.0

README.rst

Lines changed: 42 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ the PySensors approach to reconstruction problems and Brunton et al.
2121
literature review along with examples and additional tips for
2222
using PySensors effectively.
2323

24+
The diagram below shows current Pysensors capabilities.
25+
26+
.. figure:: docs/figures/pysensors-capabilities.jpeg
27+
:align: center
28+
:alt: A diagram showing current pysensors capabilities.
29+
:figclass: align-center
2430

2531
Reconstruction
2632
^^^^^^^^^^^^^^
@@ -43,12 +49,18 @@ feed them to a ``SSPOR`` instance with 10 sensors, and
4349
model = pysensors.reconstruction.SSPOR(n_sensors=10)
4450
model.fit(data)
4551
46-
Use the ``predict`` method to reconstruct a new function sampled at the chosen sensor locations:
52+
Use the ``predict`` method to reconstruct a new function sampled at the chosen sensor locations. There are two methods of reconstruction using ``predict``: ``Unregularized Reconstruction`` and ``Regularized Reconstruction``.
53+
4754

4855
.. code-block:: python
4956
5057
f = numpy.abs(x[model.selected_sensors]**2 - 0.5)
51-
f_pred = model.predict(f)
58+
# Unregularized reconstruction can be used using the method ``unregularized``
59+
f_pred_unregularized = model.predict(f, method='unregularized')
60+
# Regularized reconstruction, on the other hand is the default method for predict. It also requires other parameters like prior and noise
61+
f_pred_regularized = model.predict(f, prior, noise)
62+
63+
See `reconstruction comparison example <https://python-sensors.readthedocs.io/en/latest/examples/reconstruction_comparison.html>`__ for more information on the methods of reconstruction.
5264

5365
.. figure:: docs/figures/vandermonde.png
5466
:align: center
@@ -77,6 +89,8 @@ Three strategies to deal with constraints are currently developed:
7789

7890
* ``predetermined`` - A number of sensor locations are predetermined and the aim is to optimize the rest.
7991

92+
* ``distance constrained`` - Enforces a minimum distance 'r' between selected sensors.
93+
8094
.. code-block:: python
8195
8296
optimizer_exact = ps.optimizers.GQR()
@@ -89,24 +103,10 @@ Three strategies to deal with constraints are currently developed:
89103
We have further provided functions to compute the sensors in the constrained regions. For example if the user provides the center and radius of a circular
90104
constrained region, the constraints in utils compute the constrained sensor indices. Direct constraint plotting capabilities have also been developed.
91105

92-
The constrained shapes currently implemented are:
93-
94-
* ``Circle``
95-
96-
* ``Cylinder``
97-
98-
* ``Line``
99-
100-
* ``Parabola``
106+
The constrained shapes currently implemented are: ``Circle``, ``Cylinder``, ``Line``, ``Parabola``, ``Ellipse``, ``Polygon``.
107+
A user can also define their own constraints using ``UserDefinedConstraints``, this type of constraint has the ability to take in either a function or a .py file which contains a functional definition of the constrained region.
101108

102-
* ``Ellipse``
103-
104-
* ``Polygon``
105-
106-
* ``UserDefinedConstraints``
107-
108-
- This type of constraint has the ability to take in either a function from the user or a
109-
.py file which contains a functional definition of the constrained region.
109+
See `this example <https://python-sensors.readthedocs.io/en/latest/examples/Olivetti_constrained_sensing.html>`__ for more information.
110110

111111
Classification
112112
^^^^^^^^^^^^^^
@@ -126,7 +126,7 @@ Bases
126126
^^^^^
127127
The basis in which measurement data are represented can have a dramatic
128128
effect on performance. PySensors implements the three bases most commonly
129-
used for sparse sensor placement: raw measurements, SVD/POD/PCA modes, and random projections. Bases can be easily incorporated into ``SSPOR`` and ``SSPOC`` classes:
129+
used for sparse sensor placement: raw measurements, SVD/POD/PCA modes, and random projections. A user can also define their own custom basis. Bases can be easily incorporated into ``SSPOR`` and ``SSPOC`` classes:
130130

131131
.. code-block:: python
132132
@@ -141,7 +141,7 @@ Installation
141141

142142
Dependencies
143143
^^^^^^^^^^^^
144-
The high-level dependencies for PySensors are Linux or macOS and Python 3.6-3.8. ``pip`` is also recommended as is makes managing PySensors' other dependencies much easier. You can install it by following the instructions `here <https://packaging.python.org/tutorials/installing-packages/#ensure-you-can-run-pip-from-the-command-line>`__.
144+
The high-level dependencies for PySensors are Linux or macOS and Python 3.9-3.12. ``pip`` is also recommended as is makes managing PySensors' other dependencies much easier. You can install it by following the instructions `here <https://packaging.python.org/tutorials/installing-packages/#ensure-you-can-run-pip-from-the-command-line>`__.
145145

146146
PySensors has not been tested on Windows.
147147

@@ -191,10 +191,24 @@ The primary PySensors objects are the ``SSPOR`` and ``SSPOC`` classes, which are
191191

192192
- ``Identity`` - use raw measurement data
193193
- ``SVD`` - efficiently compute first k left singular vectors
194-
- ``RandomProjection`` - Gaussian random projections of measurements
194+
- ``RandomProjection`` - gaussian random projections of measurements
195+
- ``CustomBasis`` - user defined bases ranging from DMD modes to Chebyshev polynomials
195196

197+
* ``optimizers`` - submodule implementing different optimizers to fit data
198+
199+
- ``QR`` - greedy QR optimizer
200+
- ``CCQR`` - greedy cost constrained QR optimizer
201+
- ``GQR`` - general QR optimizer
202+
- ``TPGR`` - two point greedy optmizer
196203
* Convenience functions to aid in the analysis of error as number of sensors or basis modes are varied
197204

205+
The diagram below outlines a flow chart of how a user can utilize pysensors.
206+
207+
.. figure:: docs/figures/pysensors-methods.jpeg
208+
:align: center
209+
:alt: A flow chart of pysensors methods.
210+
:figclass: align-center
211+
198212
Documentation
199213
-------------
200214
PySensors has a `documentation site <https://python-sensors.readthedocs.io/en/latest/index.html>`__ hosted by readthedocs.
@@ -300,12 +314,15 @@ References
300314
(2018): 2642-2656.
301315
`[DOI] <https://doi.org/10.1109/JSEN.2018.2887044>`__
302316

303-
- Karnik, Niharika, Mohammad G. Abdo, Carlos E. Estrada-Perez, Jun Soo Yoo,
304-
Joshua J. Cogliati, Richard S. Skifton, Pattrick Calderoni, Steven L. Brunton, and Krithika Manohar.
305-
"Constrained Optimization of Sensor Plcaement for Nuclear Digital Twins" IEEE Sensors Journal 24, no. 9
317+
- Karnik, Niharika, Mohammad G. Abdo, Carlos E. Estrada-Perez, Jun Soo Yoo, Joshua J. Cogliati, Richard S. Skifton, Pattrick Calderoni, Steven L. Brunton, and Krithika Manohar.
318+
"Constrained Optimization of Sensor Placement for Nuclear Digital Twins" IEEE Sensors Journal 24, no. 9
306319
(2024): 15501 - 15516.
307320
`[DOI] <https://doi.org/10.1109/JSEN.2024.3368875>`__
308321

322+
- Klishin, Andrei A., J. Nathan Kutz, Krithika Manohar
323+
"Data-Induced Interations of Sparse Sensors" (2023)
324+
`[DOI] <https://doi.org/10.48550/arXiv.2307.11838>`__
325+
309326
.. |Build| image:: https://github.com/dynamicslab/pysensors/actions/workflows/main.yml/badge.svg?branch=master
310327
:target: https://github.com/dynamicslab/pysensors/actions?query=workflow%3ACI
311328

628 KB
Loading
874 KB
Loading

examples/OPTI-TWIST_constrained_sensing.ipynb

Lines changed: 74 additions & 122 deletions
Large diffs are not rendered by default.

examples/Olivetti_constrained_sensing.ipynb

Lines changed: 330 additions & 290 deletions
Large diffs are not rendered by default.

examples/README.rst

Lines changed: 0 additions & 58 deletions
This file was deleted.

examples/basis_comparison.ipynb

Lines changed: 43 additions & 25 deletions
Large diffs are not rendered by default.

examples/index.rst

Lines changed: 67 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,71 @@
11
PySensors Examples
22
==================
33

4+
This directory provides examples of how to use `PySensors` objects to solve sensor placement problems.
5+
`PySensors` was designed to be completely compatible with `scikit-learn`.
6+
7+
`PySensors Overview <./pysensors_overview.ipynb>`__
8+
---------------------------------------------------
9+
This notebook gives an overview of most of the different tools available in `PySensors`. It's a good place to start to get a quick idea of what the package is capable of.
10+
11+
.. toctree::
12+
:hidden:
13+
:maxdepth: 1
14+
15+
pysensors_overview
16+
17+
`Classification <./classification.ipynb>`__
18+
-------------------------------------------
19+
This notebook showcases the use of `SSPOC` class (Sparse Sensor Placement Optimization for Classification) to choose sparse sets of sensors for *classification* problems.
20+
21+
.. toctree::
22+
:hidden:
23+
:maxdepth: 1
24+
25+
classification
26+
27+
Reconstruction
28+
--------------
29+
These notebooks show how the `SSPOR` class (Sparse Sensor Placement Optimization for Reconstruction) can be used with different optimizers.
30+
The default optimizer for `SSPOR` is `QR`, which uses QR pivoting to select sensors in unconstrained problems.
31+
`GQR` (General QR) optimizer provides a more intrusive approach into the `QR` pivoting procedure to take into account spatial constraints. The `General QR Optimizer for Spatial Constraints <./spatial_constrained_qr.ipynb>`__ and `Functional Constraints for Olivetti Faces <./Olivetti_constrained_sensing.ipynb>`__ notebooks provide a detailed account of unconstrained and constrained sensor placement.
32+
`CCQR` (Cost Constrained QR) optimizer can be used to place sparse sensors when there are variable costs associated with different locations. The `Cost Constrained QR <./cost_constrained_qr.ipynb>`__ notebook showcases the `CCQR` optimizer.
33+
`TPGR` (Two Point GReedy) optimizer uses a thermodynamic approach to sensor placement that maps the complete landscape of sensor interactions induced by the training data and places sensors such that the marginal energy of each next placed sensor is minimized. The `TPGR <./two_point_greedy.ipynb>`__ notebook goes into detail about the optimizer and the one-point and two-point enery landscape computation. The `TPGR` optimizer requires prior and noise.
34+
35+
There are two methods used for reconstruction: `Unregularized Reconstruction`, which uses the Moore-Penrose Pseudoinverse method, and `Regularized Reconstruction`, that uses a maximal likelihood reconstructor that requires a prior and noise.
36+
The `Reconstruction Comparison <./reconstruction_comparison.ipynb>`__ notebook compares these two methods using the `TPGR` optimizer. It also shows a comparison between `TPGR` and `QR` optimizers using both of the reconstruction methods.
37+
38+
.. toctree::
39+
:hidden:
40+
:maxdepth: 1
41+
42+
spatial_constrained_qr
43+
Olivetti_constrained_sensing
44+
cost_constrained_qr
45+
two_point_greedy
46+
reconstruction_comparison
47+
48+
Basis
49+
-----
50+
The `Basis Comparison <./basis_comparison.ipynb>`__ notebook compares the different basis options implemented in `PySensors` on a simple problem.
51+
`Cross Validation<./cross_validation.ipynb>`__ is also performed with `scikit-learn` objects to optimize the number of sensors and/or basis modes.
52+
453
.. toctree::
5-
:maxdepth: 1
6-
:caption: Example Notebooks
7-
8-
pysensors_overview
9-
basis_comparison
10-
classification
11-
cost_constrained_qr
12-
cross_validation
13-
sea_surface_temperature
14-
reconstruction_comparison
15-
two_point_greedy
16-
polynomial_curve_fitting
17-
spatial_constrained_qr
18-
Olivetti_constrained_sensing
19-
OPTI-TWIST_constrained_sensing
54+
:hidden:
55+
:maxdepth: 1
56+
57+
basis_comparison
58+
cross_validation
59+
60+
Applications
61+
------------
62+
These notebooks showcase the sensor placement optimization methods on datasets ranging from `Sea Surface Temperature <./sea_surface_temperature.ipynb>`__ to predicting the temperature within a `Fuel Rod <./OPTI-TWIST_constrained_sensing.ipynb>`__ with spatially constrained sensors.
63+
The `Polynomial Curve Fitting <./polynomial_curve_fitting>`__ notebook demonstrates how to use PySensors to select sensor locations for polynomial interpolation using the monomial basis $1, x, x^2, x^3, \dots, x^k$.
64+
65+
.. toctree::
66+
:hidden:
67+
:maxdepth: 1
68+
69+
sea_surface_temperature
70+
polynomial_curve_fitting
71+
OPTI-TWIST_constrained_sensing

0 commit comments

Comments
 (0)