pygeoinf 1.2.7__tar.gz → 1.2.9__tar.gz

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.
Files changed (28) hide show
  1. {pygeoinf-1.2.7 → pygeoinf-1.2.9}/PKG-INFO +41 -23
  2. {pygeoinf-1.2.7 → pygeoinf-1.2.9}/README.md +39 -20
  3. {pygeoinf-1.2.7 → pygeoinf-1.2.9}/pygeoinf/__init__.py +9 -1
  4. {pygeoinf-1.2.7 → pygeoinf-1.2.9}/pygeoinf/gaussian_measure.py +24 -35
  5. {pygeoinf-1.2.7 → pygeoinf-1.2.9}/pygeoinf/linear_operators.py +659 -173
  6. {pygeoinf-1.2.7 → pygeoinf-1.2.9}/pygeoinf/linear_solvers.py +39 -7
  7. {pygeoinf-1.2.7 → pygeoinf-1.2.9}/pygeoinf/random_matrix.py +114 -0
  8. {pygeoinf-1.2.7 → pygeoinf-1.2.9}/pygeoinf/symmetric_space/sphere.py +10 -4
  9. {pygeoinf-1.2.7 → pygeoinf-1.2.9}/pyproject.toml +7 -16
  10. {pygeoinf-1.2.7 → pygeoinf-1.2.9}/LICENSE +0 -0
  11. {pygeoinf-1.2.7 → pygeoinf-1.2.9}/pygeoinf/backus_gilbert.py +0 -0
  12. {pygeoinf-1.2.7 → pygeoinf-1.2.9}/pygeoinf/checks/hilbert_space.py +0 -0
  13. {pygeoinf-1.2.7 → pygeoinf-1.2.9}/pygeoinf/checks/linear_operators.py +0 -0
  14. {pygeoinf-1.2.7 → pygeoinf-1.2.9}/pygeoinf/checks/nonlinear_operators.py +0 -0
  15. {pygeoinf-1.2.7 → pygeoinf-1.2.9}/pygeoinf/direct_sum.py +0 -0
  16. {pygeoinf-1.2.7 → pygeoinf-1.2.9}/pygeoinf/forward_problem.py +0 -0
  17. {pygeoinf-1.2.7 → pygeoinf-1.2.9}/pygeoinf/hilbert_space.py +0 -0
  18. {pygeoinf-1.2.7 → pygeoinf-1.2.9}/pygeoinf/inversion.py +0 -0
  19. {pygeoinf-1.2.7 → pygeoinf-1.2.9}/pygeoinf/linear_bayesian.py +0 -0
  20. {pygeoinf-1.2.7 → pygeoinf-1.2.9}/pygeoinf/linear_forms.py +0 -0
  21. {pygeoinf-1.2.7 → pygeoinf-1.2.9}/pygeoinf/linear_optimisation.py +0 -0
  22. {pygeoinf-1.2.7 → pygeoinf-1.2.9}/pygeoinf/nonlinear_forms.py +0 -0
  23. {pygeoinf-1.2.7 → pygeoinf-1.2.9}/pygeoinf/nonlinear_operators.py +0 -0
  24. {pygeoinf-1.2.7 → pygeoinf-1.2.9}/pygeoinf/nonlinear_optimisation.py +0 -0
  25. {pygeoinf-1.2.7 → pygeoinf-1.2.9}/pygeoinf/parallel.py +0 -0
  26. {pygeoinf-1.2.7 → pygeoinf-1.2.9}/pygeoinf/symmetric_space/__init__.py +0 -0
  27. {pygeoinf-1.2.7 → pygeoinf-1.2.9}/pygeoinf/symmetric_space/circle.py +0 -0
  28. {pygeoinf-1.2.7 → pygeoinf-1.2.9}/pygeoinf/symmetric_space/symmetric_space.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: pygeoinf
3
- Version: 1.2.7
3
+ Version: 1.2.9
4
4
  Summary: A package for solving geophysical inference and inverse problems
5
5
  License: BSD-3-Clause
6
6
  Author: David Al-Attar and Dan Heathcote
@@ -10,12 +10,11 @@ Classifier: Programming Language :: Python :: 3
10
10
  Classifier: Programming Language :: Python :: 3.11
11
11
  Classifier: Programming Language :: Python :: 3.12
12
12
  Classifier: Programming Language :: Python :: 3.13
13
- Requires-Dist: Cartopy (>=0.23.0,<0.24.0)
13
+ Provides-Extra: sphere
14
14
  Requires-Dist: joblib (>=1.5.2,<2.0.0)
15
15
  Requires-Dist: matplotlib (>=3.0.0)
16
16
  Requires-Dist: numpy (>=1.26.0)
17
17
  Requires-Dist: pyqt6 (>=6.0.0)
18
- Requires-Dist: pyshtools (>=4.0.0)
19
18
  Requires-Dist: scipy (>=1.16.1)
20
19
  Description-Content-Type: text/markdown
21
20
 
@@ -47,16 +46,31 @@ The library is built on a few key concepts:
47
46
  * **Optimisation Methods**: Includes Tikhonov-regularized least-squares and minimum-norm solutions.
48
47
  * **Probabilistic Modelling**: Define priors and noise models using `GaussianMeasure` objects on abstract spaces.
49
48
  * **Randomized Algorithms**: Utilizes randomized SVD and Cholesky decompositions for efficient low-rank approximations of large operators.
49
+ * **Specialized Operator Variants**: Efficient implementations for `DiagonalSparseMatrixLinearOperator` and `NormalSumOperator`.
50
50
  * **Application-Specific Spaces**: Provides concrete `HilbertSpace` implementations for functions on a **line**, **circle**, and the **two-sphere**.
51
51
  * **High-Quality Visualisation**: Built-in plotting methods for functions on symmetric spaces, including map projections via `cartopy`.
52
52
 
53
+ ## Advanced Features
54
+
55
+ * **Block Operators**: Construct complex operators from smaller components using `BlockLinearOperator`, `ColumnLinearOperator`, and `RowLinearOperator`. This is ideal for coupled inverse problems.
56
+ * **Parallelisation**: Many expensive operations are parallelized with `joblib`, including dense matrix construction and randomized algorithms.
57
+
53
58
  ## Installation
54
59
 
55
- The package can be installed directly using pip:
60
+ The package can be installed directly using pip. By default, this will perform a minimal installation.
56
61
 
57
62
  ```bash
63
+ # Minimal installation
58
64
  pip install pygeoinf
59
65
  ```
66
+
67
+ To include the functionality for functions on the sphere, you can install the `sphere` extra. This provides support for `pyshtools` and `Cartopy`.
68
+
69
+ ```bash
70
+ # Installation with sphere-related features
71
+ pip install pygeoinf[sphere]
72
+ ```
73
+
60
74
  For development, you can clone the repository and install using Poetry:
61
75
 
62
76
  ```bash
@@ -65,21 +79,15 @@ cd pygeoinf
65
79
  poetry install
66
80
  ```
67
81
 
68
- You can install the optional dependencies for running tests, building documentation, or running the tutorials by using the --with flag.
82
+ You can install all optional dependencies for development—including tools for running the test suite,
83
+ building the documentation, and running the Jupyter tutorials—by using the ```--with``` flag and specifying the ```dev``` group.
69
84
 
70
85
  ```bash
71
- # To install dependencies for running the test suite
72
- poetry install --with tests
86
+ # Install all development dependencies (for tests, docs, and tutorials)
87
+ poetry install --with dev
88
+ ```
73
89
 
74
- # To install dependencies for building the documentation
75
- poetry install --with docs
76
90
 
77
- # To install dependencies for running the Jupyter tutorials
78
- poetry install --with tutorials
79
-
80
- # You can also combine them
81
- poetry install --with tests,docs,tutorials
82
- ```
83
91
 
84
92
  ## Documentation
85
93
 
@@ -240,20 +248,30 @@ The output of the above script will look similar to the following figure:
240
248
  * NumPy
241
249
  * SciPy
242
250
  * Matplotlib
243
- * pyshtools (for `sphere.py`)
244
- * Cartopy (for plotting in `sphere.py`)
251
+ * joblib
245
252
 
246
- ## Future Plans
253
+ ### Optional (`sphere`)
254
+
255
+ * pyshtools
256
+ * Cartopy
257
+
258
+ ## Recent Updates
247
259
 
248
- `pygeoinf` is under active development. Future work will focus on expanding the library's capabilities to address a broader range of geophysical problems. Key areas for development include:
260
+ `pygeoinf` is under active development, and recent updates have expanded its capabilities to address a broader range of geophysical problems. Key improvements include:
249
261
 
250
- * **Generalised Backus-Gilbert Methods**: Implementation of a generalised Backus-Gilbert framework for linear inference problems, building on the work of [Al-Attar(2021)](https://arxiv.org/abs/2104.12256). The focus will be on constructing direct estimates of specific properties of interest (i.e., linear functionals of the model) from data, without needing to first solve for the full model itself.
262
+ * **Non-Linear Inverse Problems**: The library now supports non-linear inverse problems through the `NonLinearOperator` and `NonLinearForm` classes. This allows you to define and solve problems where the relationship between model parameters and data is non-linear. The framework includes support for Fréchet derivatives, enabling the use of gradient-based optimisation methods.
263
+
264
+ * **Advanced Optimisation Algorithms**: To complement the non-linear framework, `pygeoinf` now includes a suite of optimisation algorithms. You can use the custom `GradientDescent` solver or leverage the power of SciPy's optimization library with methods like 'BFGS', 'L-BFGS-B', and 'Newton-CG'. Derivative-free methods such as 'Powell' and 'Nelder-Mead' are also supported for problems where gradients are unavailable.
265
+
266
+ * **Backus-Gilbert Methods**: The foundations for the Backus-Gilbert method have been implemented. While this feature is still evolving, the core components are in place for you to begin exploring this powerful inference technique.
267
+
268
+ ## Future Plans
251
269
 
252
- * **Non-linear Optimisation**: Extension of the current optimisation framework to handle non-linear inverse problems. This will involve creating a general interface where users can provide their own non-linear forward mapping, a misfit functional, and methods for computing gradients (and optionally Hessians) for use in gradient-based optimisation algorithms.
270
+ Future development will focus on the following areas:
253
271
 
254
- * **Non-linear Bayesian Inference**: Development of methods for non-linear Bayesian problems. Planned approaches include linearizing the problem around the maximum a posteriori (MAP) solution to estimate posterior uncertainty, and using this linearization to construct efficient proposal distributions for Markov chain Monte Carlo (MCMC) sampling methods.
272
+ * **Non-linear Bayesian Inference**: We plan to develop methods for non-linear Bayesian problems, including techniques for linearizing the problem around the maximum a posteriori (MAP) solution to estimate posterior uncertainty. This will also involve constructing efficient proposal distributions for Markov chain Monte Carlo (MCMC) sampling methods.
255
273
 
256
- * **New Geophysical Hilbert Spaces**: Addition of further `HilbertSpace` implementations tailored to specific geophysical applications. A primary focus will be on creating spaces for functions defined within a **spherical annulus** (spherical shell), which is essential for problems in global seismology and mantle tomography.
274
+ * **New Geophysical Hilbert Spaces**: We will be adding more `HilbertSpace` implementations for specific geophysical applications. A key focus will be on creating spaces for functions defined within a **spherical annulus** (spherical shell), which is crucial for problems in global seismology and mantle tomography.
257
275
 
258
276
 
259
277
  ## Contributing
@@ -26,16 +26,31 @@ The library is built on a few key concepts:
26
26
  * **Optimisation Methods**: Includes Tikhonov-regularized least-squares and minimum-norm solutions.
27
27
  * **Probabilistic Modelling**: Define priors and noise models using `GaussianMeasure` objects on abstract spaces.
28
28
  * **Randomized Algorithms**: Utilizes randomized SVD and Cholesky decompositions for efficient low-rank approximations of large operators.
29
+ * **Specialized Operator Variants**: Efficient implementations for `DiagonalSparseMatrixLinearOperator` and `NormalSumOperator`.
29
30
  * **Application-Specific Spaces**: Provides concrete `HilbertSpace` implementations for functions on a **line**, **circle**, and the **two-sphere**.
30
31
  * **High-Quality Visualisation**: Built-in plotting methods for functions on symmetric spaces, including map projections via `cartopy`.
31
32
 
33
+ ## Advanced Features
34
+
35
+ * **Block Operators**: Construct complex operators from smaller components using `BlockLinearOperator`, `ColumnLinearOperator`, and `RowLinearOperator`. This is ideal for coupled inverse problems.
36
+ * **Parallelisation**: Many expensive operations are parallelized with `joblib`, including dense matrix construction and randomized algorithms.
37
+
32
38
  ## Installation
33
39
 
34
- The package can be installed directly using pip:
40
+ The package can be installed directly using pip. By default, this will perform a minimal installation.
35
41
 
36
42
  ```bash
43
+ # Minimal installation
37
44
  pip install pygeoinf
38
45
  ```
46
+
47
+ To include the functionality for functions on the sphere, you can install the `sphere` extra. This provides support for `pyshtools` and `Cartopy`.
48
+
49
+ ```bash
50
+ # Installation with sphere-related features
51
+ pip install pygeoinf[sphere]
52
+ ```
53
+
39
54
  For development, you can clone the repository and install using Poetry:
40
55
 
41
56
  ```bash
@@ -44,21 +59,15 @@ cd pygeoinf
44
59
  poetry install
45
60
  ```
46
61
 
47
- You can install the optional dependencies for running tests, building documentation, or running the tutorials by using the --with flag.
62
+ You can install all optional dependencies for development—including tools for running the test suite,
63
+ building the documentation, and running the Jupyter tutorials—by using the ```--with``` flag and specifying the ```dev``` group.
48
64
 
49
65
  ```bash
50
- # To install dependencies for running the test suite
51
- poetry install --with tests
66
+ # Install all development dependencies (for tests, docs, and tutorials)
67
+ poetry install --with dev
68
+ ```
52
69
 
53
- # To install dependencies for building the documentation
54
- poetry install --with docs
55
70
 
56
- # To install dependencies for running the Jupyter tutorials
57
- poetry install --with tutorials
58
-
59
- # You can also combine them
60
- poetry install --with tests,docs,tutorials
61
- ```
62
71
 
63
72
  ## Documentation
64
73
 
@@ -219,20 +228,30 @@ The output of the above script will look similar to the following figure:
219
228
  * NumPy
220
229
  * SciPy
221
230
  * Matplotlib
222
- * pyshtools (for `sphere.py`)
223
- * Cartopy (for plotting in `sphere.py`)
231
+ * joblib
224
232
 
225
- ## Future Plans
233
+ ### Optional (`sphere`)
234
+
235
+ * pyshtools
236
+ * Cartopy
237
+
238
+ ## Recent Updates
226
239
 
227
- `pygeoinf` is under active development. Future work will focus on expanding the library's capabilities to address a broader range of geophysical problems. Key areas for development include:
240
+ `pygeoinf` is under active development, and recent updates have expanded its capabilities to address a broader range of geophysical problems. Key improvements include:
228
241
 
229
- * **Generalised Backus-Gilbert Methods**: Implementation of a generalised Backus-Gilbert framework for linear inference problems, building on the work of [Al-Attar(2021)](https://arxiv.org/abs/2104.12256). The focus will be on constructing direct estimates of specific properties of interest (i.e., linear functionals of the model) from data, without needing to first solve for the full model itself.
242
+ * **Non-Linear Inverse Problems**: The library now supports non-linear inverse problems through the `NonLinearOperator` and `NonLinearForm` classes. This allows you to define and solve problems where the relationship between model parameters and data is non-linear. The framework includes support for Fréchet derivatives, enabling the use of gradient-based optimisation methods.
243
+
244
+ * **Advanced Optimisation Algorithms**: To complement the non-linear framework, `pygeoinf` now includes a suite of optimisation algorithms. You can use the custom `GradientDescent` solver or leverage the power of SciPy's optimization library with methods like 'BFGS', 'L-BFGS-B', and 'Newton-CG'. Derivative-free methods such as 'Powell' and 'Nelder-Mead' are also supported for problems where gradients are unavailable.
245
+
246
+ * **Backus-Gilbert Methods**: The foundations for the Backus-Gilbert method have been implemented. While this feature is still evolving, the core components are in place for you to begin exploring this powerful inference technique.
247
+
248
+ ## Future Plans
230
249
 
231
- * **Non-linear Optimisation**: Extension of the current optimisation framework to handle non-linear inverse problems. This will involve creating a general interface where users can provide their own non-linear forward mapping, a misfit functional, and methods for computing gradients (and optionally Hessians) for use in gradient-based optimisation algorithms.
250
+ Future development will focus on the following areas:
232
251
 
233
- * **Non-linear Bayesian Inference**: Development of methods for non-linear Bayesian problems. Planned approaches include linearizing the problem around the maximum a posteriori (MAP) solution to estimate posterior uncertainty, and using this linearization to construct efficient proposal distributions for Markov chain Monte Carlo (MCMC) sampling methods.
252
+ * **Non-linear Bayesian Inference**: We plan to develop methods for non-linear Bayesian problems, including techniques for linearizing the problem around the maximum a posteriori (MAP) solution to estimate posterior uncertainty. This will also involve constructing efficient proposal distributions for Markov chain Monte Carlo (MCMC) sampling methods.
234
253
 
235
- * **New Geophysical Hilbert Spaces**: Addition of further `HilbertSpace` implementations tailored to specific geophysical applications. A primary focus will be on creating spaces for functions defined within a **spherical annulus** (spherical shell), which is essential for problems in global seismology and mantle tomography.
254
+ * **New Geophysical Hilbert Spaces**: We will be adding more `HilbertSpace` implementations for specific geophysical applications. A key focus will be on creating spaces for functions defined within a **spherical annulus** (spherical shell), which is crucial for problems in global seismology and mantle tomography.
236
255
 
237
256
 
238
257
  ## Contributing
@@ -9,6 +9,7 @@ from .random_matrix import (
9
9
  random_svd,
10
10
  random_eig,
11
11
  random_cholesky,
12
+ random_diagonal,
12
13
  )
13
14
 
14
15
  from .hilbert_space import (
@@ -32,7 +33,14 @@ from .linear_forms import (
32
33
 
33
34
  from .nonlinear_operators import NonLinearOperator
34
35
 
35
- from .linear_operators import LinearOperator, DiagonalLinearOperator, NormalSumOperator
36
+ from .linear_operators import (
37
+ LinearOperator,
38
+ MatrixLinearOperator,
39
+ DenseMatrixLinearOperator,
40
+ SparseMatrixLinearOperator,
41
+ DiagonalSparseMatrixLinearOperator,
42
+ NormalSumOperator,
43
+ )
36
44
 
37
45
 
38
46
  from .gaussian_measure import (
@@ -28,11 +28,11 @@ from scipy.sparse import diags
28
28
  from scipy.stats import multivariate_normal
29
29
 
30
30
 
31
- from .hilbert_space import EuclideanSpace, HilbertModule
31
+ from .hilbert_space import EuclideanSpace, HilbertModule, Vector
32
32
 
33
33
  from .linear_operators import (
34
34
  LinearOperator,
35
- DiagonalLinearOperator,
35
+ DiagonalSparseMatrixLinearOperator,
36
36
  )
37
37
 
38
38
  from .direct_sum import (
@@ -40,17 +40,6 @@ from .direct_sum import (
40
40
  )
41
41
 
42
42
 
43
- # This block only runs for type checkers, not at runtime, to prevent
44
- # circular import errors while still allowing type hints.
45
- if TYPE_CHECKING:
46
- from .hilbert_space import HilbertSpace, EuclideanSpace
47
- from .operators import LinearOperator, DiagonalLinearOperator
48
- from .direct_sum import BlockDiagonalLinearOperator
49
-
50
- # Define a generic type for vectors in a Hilbert space
51
- Vector = TypeVar("Vector")
52
-
53
-
54
43
  class GaussianMeasure:
55
44
  """
56
45
  Represents a Gaussian measure on a Hilbert space.
@@ -76,29 +65,29 @@ class GaussianMeasure:
76
65
  inverse_covariance_factor: LinearOperator = None,
77
66
  ) -> None:
78
67
  """
79
- Initializes the GaussianMeasure.
68
+ Initializes the GaussianMeasure.
80
69
 
81
70
  The measure can be defined in several ways, primarily by providing
82
- either a covariance operator or a covariance factor.
83
-
84
- Args:
85
- covariance (LinearOperator, optional): A self-adjoint and positive
86
- semi-definite linear operator on the domain.
87
- covariance_factor (LinearOperator, optional): A linear operator L
88
- such that the covariance C = L @ L*.
89
- expectation (vector, optional): The expectation (mean) of the
90
- measure. Defaults to the zero vector of the space.
91
- sample (callable, optional): A function that returns a random
92
- sample from the measure. If a `covariance_factor` is given,
93
- a default sampler is created.
94
- inverse_covariance (LinearOperator, optional): The inverse of the
95
- covariance operator (the precision operator).
96
- inverse_covariance_factor (LinearOperator, optional): A factor Li
97
- of the inverse covariance, such that C_inv = Li.T @ Li.
98
-
99
- Raises:
100
- ValueError: If neither `covariance` nor `covariance_factor`
101
- is provided.
71
+ either a covariance operator or a covariance factor.
72
+
73
+ Args:
74
+ covariance (LinearOperator, optional): A self-adjoint and positive
75
+ semi-definite linear operator on the domain.
76
+ covariance_factor (LinearOperator, optional): A linear operator L
77
+ such that the covariance C = L @ L*.
78
+ expectation (vector, optional): The expectation (mean) of the
79
+ measure. Defaults to the zero vector of the space.
80
+ sample (callable, optional): A function that returns a random
81
+ sample from the measure. If a `covariance_factor` is given,
82
+ a default sampler is created.
83
+ inverse_covariance (LinearOperator, optional): The inverse of the
84
+ covariance operator (the precision operator).
85
+ inverse_covariance_factor (LinearOperator, optional): A factor Li
86
+ of the inverse covariance, such that C_inv = Li.T @ Li.
87
+
88
+ Raises:
89
+ ValueError: If neither `covariance` nor `covariance_factor`
90
+ is provided.
102
91
  """
103
92
  if covariance is None and covariance_factor is None:
104
93
  raise ValueError(
@@ -186,7 +175,7 @@ class GaussianMeasure:
186
175
  "Standard deviation vector does not have the correct length"
187
176
  )
188
177
  euclidean = EuclideanSpace(domain.dim)
189
- covariance_factor = DiagonalLinearOperator(
178
+ covariance_factor = DiagonalSparseMatrixLinearOperator.from_diagonal_values(
190
179
  euclidean, domain, standard_deviations
191
180
  )
192
181
  return GaussianMeasure(