Starters#
This set of examples is meant to be most basic and enable researchers create building blocks of the package in simplified settings.
Creators#
This modules contain essential functions to create simple functions to create/construct basic elements of the OED probcess, including creating error models, inverse problems, OED problems, utility functions, optimizers, etc. The functions created have oversimplified structure which is essential for unittesting and expose all elements of the problem at various complexities but all withing simplified settings such as spatiotemporal dimensionality and assumptions (linearity, Gaussianity, etc.)
Functions
Simulation model: toy linear time independent Observation operator: Identity Prior: Gaussian Noise: Gaussian Inversion: 3DVar (Filtering) invert for model parameter |
|
Simulation model: toy linear time dependent Observation operator: Identity Prior: Gaussian Noise: Gaussian Inversion: 4DVar (Smoothing) invert for model state (initial condition) |
|
Simulation model: toy linear time independent Observation operator: Power Prior: Gaussian Noise: Gaussian Inversion: 3DVar (Filtering) invert for model parameter |
|
Simulation model: toy linear time dependent (for smoothing) Observation operator: Power Prior: Gaussian Noise: Gaussian Inversion: 4DVar (Smoothing) invert for model state (initial condition) |
|
- create_toy_linear_time_independent_inverse_problem()[source]#
Simulation model: toy linear time independent Observation operator: Identity Prior: Gaussian Noise: Gaussian Inversion: 3DVar (Filtering) invert for model parameter
- Returns:
ip: the inverse problem
- create_toy_linear_time_dependent_inverse_problem()[source]#
Simulation model: toy linear time dependent Observation operator: Identity Prior: Gaussian Noise: Gaussian Inversion: 4DVar (Smoothing) invert for model state (initial condition)
- create_toy_nonlinear_time_independent_inverse_problem()[source]#
Simulation model: toy linear time independent Observation operator: Power Prior: Gaussian Noise: Gaussian Inversion: 3DVar (Filtering) invert for model parameter
Toy Linear Examples#
Functions
|
|
|
|
|
|
|
- get_base_output_dir()[source]#
Base output dir that enables modifying base output dir by changing pyoed settings class This is very helpful to globally steer output e.g., when running unittests.
Toy Nonlinear Examples#
Functions
|
|
|
Create an OED problem given an inverse problem and potententially solve it and plot results |
|
Given the inverse problem create and return a function that evaluates the log density (unnormalized) at a given parameter/state |
Given the inverse problem create and return a function that evaluates the gradient of the log density (unnormalized) at a given parameter/state |
|
|
Given the inverse pblem, generate samples from the posterior (given the underlying design) using HMC. |
- create_nonlinear_inverse_problem(state_size=3, dt=0.1, tspan=(0, 0.3), checkpoints=[0.1, 0.2, 0.3], solve_inverse_problem=True)[source]#
- create_oed_problem(inverse_problem=None, problem_is_linear=False, solve_oed_problem=False, plot_results=True)[source]#
Create an OED problem given an inverse problem and potententially solve it and plot results
- create_posterior_log_density(inverse_problem)[source]#
Given the inverse problem create and return a function that evaluates the log density (unnormalized) at a given parameter/state
- create_posterior_log_density_gradient(inverse_problem)[source]#
Given the inverse problem create and return a function that evaluates the gradient of the log density (unnormalized) at a given parameter/state
- sample_posterior(inverse_problem, sample_size, burn_in=100, mix_in=5, symplectic_integrator='3-stage', symplectic_integrator_stepsize=0.001, symplectic_integrator_num_steps=20, mass_matrix=0.1, random_seed=1011)[source]#
Given the inverse pblem, generate samples from the posterior (given the underlying design) using HMC. The posterior is formulated based on the current design in the inverse pblem.
Examples with a Toy Quark Model#
Functions
|
|
|
Given the inverse pblem, generate samples from the posterior (given the underlying design) using HMC. |
|
Create a heatmap from a numpy array and two lists of labels. |
|
A function to annotate a heatmap. |
- get_base_output_dir()[source]#
Base output dir that enables modifying base output dir by changing pyoed settings class This is very helpful to globally steer output e.g., when running unittests.
- create_toy_quark_inverse_problem(true_param=array([1., 0.5, 2.5, 0.25, 0.1, 3.]), x_grid=array([0.1, 0.11632653, 0.13265306, 0.14897959, 0.16530612, 0.18163265, 0.19795918, 0.21428571, 0.23061224, 0.24693878, 0.26326531, 0.27959184, 0.29591837, 0.3122449, 0.32857143, 0.34489796, 0.36122449, 0.37755102, 0.39387755, 0.41020408, 0.42653061, 0.44285714, 0.45918367, 0.4755102, 0.49183673, 0.50816327, 0.5244898, 0.54081633, 0.55714286, 0.57346939, 0.58979592, 0.60612245, 0.62244898, 0.63877551, 0.65510204, 0.67142857, 0.6877551, 0.70408163, 0.72040816, 0.73673469, 0.75306122, 0.76938776, 0.78571429, 0.80204082, 0.81836735, 0.83469388, 0.85102041, 0.86734694, 0.88367347, 0.9]), solve_inverse_problem=True, output_plots=True)[source]#
- sample_posterior(inverse_problem, sample_size, random_seed=1011)[source]#
Given the inverse pblem, generate samples from the posterior (given the underlying design) using HMC. The posterior is formulated based on the current design in the inverse pblem.
- heatmap(data, row_labels, col_labels, ax=None, cbar_kw=None, cbarlabel='', **kwargs)[source]#
Create a heatmap from a numpy array and two lists of labels.
- Parameters:
data – A 2D numpy array of shape (M, N).
row_labels – A list or array of length M with the labels for the rows.
col_labels – A list or array of length N with the labels for the columns.
ax – A matplotlib.axes.Axes instance to which the heatmap is plotted. If not provided, use current axes or create a new one. Optional.
cbar_kw – A dictionary with arguments to matplotlib.Figure.colorbar. Optional.
cbarlabel – The label for the colorbar. Optional.
**kwargs – All other arguments are forwarded to imshow.
- annotate_heatmap(im, data=None, valfmt='{x:.2f}', textcolors=('black', 'white'), threshold=None, **textkw)[source]#
A function to annotate a heatmap.
- Parameters:
im – The AxesImage to be labeled.
data – Data used to annotate. If None, the image’s data is used. Optional.
valfmt – The format of the annotations inside the heatmap. This should either use the string format method, e.g. “$ {x:.2f}”, or be a matplotlib.ticker.Formatter. Optional.
textcolors – A pair of colors. The first is used for values below a threshold, the second for those above. Optional.
threshold – Value in data units according to which the colors from textcolors are applied. If None (the default) uses the middle of the colormap as separation. Optional.
**kwargs – All other arguments are forwarded to each call to text used to create the text labels.