Skip to main content

pygeoinf: A Python Library for Geophysical Inference

Build Status PyPI version License: BSD-3-Clause Documentation Status

pygeoinf is a Python library for solving geophysical inference and inverse problems in a coordinate-free, abstract framework. It leverages the mathematics of Hilbert spaces to provide a robust and flexible foundation for Bayesian and optimisation-based inference.

Overview

The core philosophy of pygeoinf is to separate the abstract mathematical structure of an inverse problem from its concrete numerical implementation. Instead of manipulating NumPy arrays directly, you work with high-level objects like HilbertSpace, LinearOperator, and GaussianMeasure. This allows you to write code that is more readable, less error-prone, and closer to the underlying mathematics.

The library is built on a few key concepts:

  • HilbertSpace: The foundational class. It represents a vector space with an inner product, but it abstracts away the specific representation of vectors (e.g., NumPy arrays, pyshtools grids).
  • LinearOperator: Represents linear mappings between Hilbert spaces. These are the workhorses of the library, supporting composition, adjoints, and matrix representations.
  • GaussianMeasure: Generalizes the multivariate normal distribution to abstract Hilbert spaces, providing a way to define priors and noise models.
  • ForwardProblem: Encapsulates the mathematical model d = A(u) + e, linking the unknown model u to the observed data d.
  • Inversion Classes: High-level classes like LinearBayesianInversion and LinearLeastSquaresInversion provide ready-to-use algorithms for solving the inverse problem.

Key Features

  • Abstract Coordinate-Free Formulation: Write elegant code that mirrors the mathematics of inverse problems.
  • Bayesian Inference: Solve inverse problems in a probabilistic framework to obtain posterior distributions over models.
  • Optimisation Methods: Includes Tikhonov-regularized least-squares and minimum-norm solutions.
  • Extensive Solver Suite: Choose from direct factorisations or matrix-free iterative solvers (e.g., CG, MINRES, LSQR, BiCGStab, FCG) designed for abstract vectors.
  • Coupled Systems: Effortlessly build block matrices and direct sum spaces using HilbertSpaceDirectSum for joint inversions.
  • Geometric Constraints: Constrain your inversions using affine subspaces, bounds, and convex sublevel sets.
  • Probabilistic Modelling: Define priors and noise models using GaussianMeasure objects on abstract spaces.
  • Randomized Algorithms: Utilizes randomized SVD and Cholesky decompositions for efficient low-rank approximations of large operators.
  • Specialized Operator Variants: Efficient implementations for SparseMatrixLinearOperator and DiagonalSparseMatrixLinearOperator
  • Application-Specific Spaces: Provides concrete HilbertSpace implementations for functions on a line, circle, and the two-sphere.
  • High-Quality Visualisation: Built-in plotting methods for functions on symmetric spaces, now featuring multi-dimensional corner plots for joint posterior distributions.

Advanced Features

  • Block Operators: Construct complex operators from smaller components using BlockLinearOperator, ColumnLinearOperator, and RowLinearOperator. This is ideal for coupled inverse problems.
  • Parallelisation: Many expensive operations are parallelized with joblib, including dense matrix construction and randomized algorithms.

Installation

The package can be installed directly using pip. By default, this will perform a minimal installation.

    # Minimal installation
    pip install pygeoinf

To include the functionality for functions on the sphere, you can install the sphere extra. This provides support for pyshtools and Cartopy.

    # Installation with sphere-related features
    pip install pygeoinf[sphere]

For development, you can clone the repository and install using Poetry:

    git clone https://github.com/da380/pygeoinf.git
    cd pygeoinf
    poetry install

You can install all optional dependencies for development—including tools for running the test suite, building the documentation, and running the Jupyter tutorials—by using the --with flag and specifying the dev group.

    # Install all development dependencies (for tests, docs, and tutorials)
    poetry install --with dev

Documentation

The full documentation for the library, including the API reference and tutorials, is available at pygeoinf.readthedocs.io.

Tutorials

You can run the interactive tutorials directly in Google Colab to get started with the core concepts of the library.

Tutorial Name Link to Colab
Tutorial 1 - A first example Open In Colab
Tutorial 2 - Hilbert spaces Open In Colab
Tutorial 3 - Dual spaces Open In Colab
Tutorial 4 - Linear operators Open In Colab
Tutorial 5 - Linear solvers Open In Colab
Tutorial 6 - Gaussian measures Open In Colab
Tutorial 7 - Minimum norm inversions Open In Colab
Tutorial 8 - Bayesian inversions Open In Colab
Tutorial 9 - Direct sums Open In Colab
Tutorial 10 - Symmetric spaces Open In Colab

Contributing

Contributions are welcome! If you would like to contribute, please feel free to fork the repository, make your changes, and submit a pull request. For major changes, please open an issue first to discuss what you would like to change.

License

This project is licensed under the BSD-3-Clause License - see the LICENSE file for details.

Release files for pygeoinf 1.8.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pygeoinf 1.8.5
File Size Uploaded
pygeoinf-1.8.5.tar.gz 263.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pygeoinf 1.8.5
File Interpreter ABI Platform
pygeoinf-1.8.5-py3-none-any.whl Python 3 none any Details

Total release size: 558.2 kB

Release files / pygeoinf-1.8.5.tar.gz

Download URL pygeoinf-1.8.5.tar.gz
Size 263.4 kB
Tags Source
SHA-256 checksum
How to use checksums
47221424fb76b2ddff5c890933f13eddafb13a3e1a5dbc0566cfd1ddd897b936
BLAKE2b-256 checksum
How to use checksums
6b2d62128fb492b7e71ecbeac7dcb40336245bbb555a20cc9d1e51e1d92e04de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.1 CPython/3.12.13 Linux/6.17.0-1020-azure

Release files / pygeoinf-1.8.5-py3-none-any.whl

Download URL pygeoinf-1.8.5-py3-none-any.whl
Size 294.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
993cb118bba965d3498243db4f199722c72dffc7f430ef71868726ababa0fb82
BLAKE2b-256 checksum
How to use checksums
56c0b373141679fb0a93b862b541026915740ecd96e433e4fbb424504caa8e76
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.1 CPython/3.12.13 Linux/6.17.0-1020-azure

Release history Release notifications | RSS feed

1.8.9

2 release files

1.8.8

2 release files

1.8.7

2 release files

1.8.6

2 release files

This release

1.8.5 This release

2 release files

1.8.4

2 release files

1.8.3

2 release files

1.8.2

2 release files

1.8.1

2 release files

1.8.0

2 release files

1.7.9

2 release files

1.7.8

2 release files

1.7.7

2 release files

1.7.6

2 release files

1.7.5

2 release files

1.7.4

2 release files

1.7.3

2 release files

1.7.2

2 release files

1.7.1

2 release files

1.7.0

2 release files

1.6.9

2 release files

1.6.8

2 release files

1.6.7

2 release files

1.6.6

2 release files

1.6.5

2 release files

1.6.4

2 release files

1.6.3

2 release files

1.6.2

2 release files

1.6.1

2 release files

1.6.0

2 release files

1.5.9

2 release files

1.5.8

2 release files

1.5.7

2 release files

1.5.6

2 release files

1.5.5

2 release files

1.5.4

2 release files

1.5.3

2 release files

1.5.2

2 release files

1.5.1

2 release files

1.5.0

2 release files

1.4.9

2 release files

1.4.8

2 release files

1.4.7

2 release files

1.4.6

2 release files

1.4.5

2 release files

1.4.4

2 release files

1.4.3

2 release files

1.4.2

2 release files

1.4.1

2 release files

1.4.0

2 release files

1.3.9

2 release files

1.3.8

2 release files

1.3.7

2 release files

1.3.6

2 release files

1.3.5

2 release files

1.3.4

2 release files

1.3.3

2 release files

1.3.2

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.9

2 release files

1.2.8

2 release files

1.2.7

2 release files

1.2.6

2 release files

1.2.5

2 release files

1.2.4

2 release files

1.2.3

2 release files

1.2.2

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.9

2 release files

1.1.8

2 release files

1.1.7

2 release files

1.1.6

2 release files

1.1.5

2 release files

1.1.4

2 release files

1.1.3

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.9

2 release files

1.0.8

2 release files

1.0.7

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.1.4

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page