Solve various inverse problems!
-
Install poetry as a package manager (https://python-poetry.org/docs/#installation)
-
Download the source code from GitHub:
$ git clone https://github.com/ATMO-IUP-UHEI/pyinverse.git
-
Install
numbaandllvmliteeither manually or create a conda environment using the provided file:$ conda env create -f conda-environment.yaml
-
Open the directory and install with poetry:
cd pyinverse poetry install
import numpy as np
from pyinverse.loss import Bayesian
from pyinverse.solver import BayesianAnalytical
# Define your inverse problem
y = np.array([1.2, 2.3, 1.8]) # measurements
K = np.array([[1, 0], [0, 1], [1, 1]]) # forward model
x_prior = np.array([1.0, 1.0]) # prior state
cov_prior = np.eye(2) # prior covariance
cov_y = 0.1 * np.eye(3) # measurement covariance
# Set up Bayesian inversion
loss = Bayesian(y, cov_y, K, x_prior, cov_prior)
solver = BayesianAnalytical(loss)
# Solve for posterior state
x_post = solver.x_posterior
cov_post = solver.cov_posteriorInterested in contributing? Check out the contributing guidelines. Please note that this project is released with a Code of Conduct. By contributing to this project, you agree to abide by its terms.
pyinverse was created by Robert Maiwald and Christopher Lüken-Winkels. It is licensed under the terms of the MIT license.
pyinverse was created with cookiecutter and the py-pkgs-cookiecutter template.