API Reference#
Inv Dataset Accessor#
xarray.Dataset accessor for properties and methods for both gravity and model datasets.
A class which allows adding properties and methods as xarray dataset accessors. |
Model creation#
Create a topography grid (or provide your own) and convert it into an initial prism or tesseroid model for the inversion.
|
Create a grid of topography data from either the interpolation (with splines) of point data or creating a grid of constant value. |
|
Convert a topography grid into a model, which can be used as the starting model for an inversion. |
|
Find the minimum distance between each grid cell and the nearest point. |
Gravity data processing#
Process gravity data and prepare it for the inversion.
|
Convert a dataset of gravity data into the format needed for the inversion. |
Calculate the forward gravity of the model at each point of the gravity grid. |
Regional gravity misfit estimation.
Calculate the gravity misfit as the difference between dataset variables |
|
Calculate the gravity misfit as the difference between dataset variables |
|
Calculate the gravity misfit as the difference between dataset variables |
|
Calculate the gravity misfit as the difference between dataset variables |
|
Calculate the gravity misfit as the difference between dataset variables |
|
Calculate the gravity misfit as the difference between dataset variables |
|
This is a convenience function to wrap |
xarray.Dataset properties#
Properties of both the gravity and model xarray.Dataset can be accessed via the inv Accessor. For example, to return just the inner region of a dataset ds, use ds.inv.inner. These are intended to be used for both the the gravity and the model datasets.
return the dataframe representation of the xarray dataset without nans |
|
return the dataframe representation of the inner region of the xarray dataset without nans |
|
return the dataframe representation of the masked xarray dataset without nans |
|
return only the model elements with a non-nan mask value |
Inversion class#
Class for attributes and methods for performing a gravity inversion.
|
A class which holds the gravity dataset, the model dataset, inversion stopping criteria, parameters which control the inversion, and methods used to run the inversion and cross-validations. |
Function to run a full inversion workflow.
|
This function runs the full inversion workflow. |
Cross-Validation#
Split data (gravity and constraints) into training and test sets.
|
take a dataframe of coordinates and make all rows that fall on the data_spacing grid training points. |
Remove the test rows and the column denoting test points |
|
|
Split data into training or testing sets either using KFold (optional blocked) or LeaveOneOut methods. |
|
split data into training and testing sets randomly with a specified percentage of points to be in the test set set by test_size. |
convert a single dataframe with fold columns in the form fold_0, fold_1 etc. |
Calculate optimization and cross-validation scores.
|
Calculate the cross-validation score for fitting gravity data to equivalent sources. |
|
Evaluate the effectiveness of the gravity regional-residual separation. |
|
Find the score, represented by the root mean (or median) squared error (RMSE), between the testing gravity data, and the predict gravity data after an inversion. |
|
Find the score, represented by the root mean squared error (RMSE), between the constraint point elevation, and the inverted topography at the constraint points. |
Optimization#
Run optimization routines with optuna to find optimal parameters.
Routines for optimal regional field estimation parameters.
|
Run an Optuna optimization to find the optimal filter width for estimating the regional component of gravity misfit. |
|
Run an Optuna optimization to find the optimal trend order for estimating the regional component of gravity misfit. |
|
Run an Optuna optimization to find the optimal equivalent source parameters for estimating the regional component of gravity misfit. |
Run an Optuna optimization to find the optimal hyperparameters for the Constraint Point Minimization technique for estimating the regional component of gravity misfit. |
Routines for optimal interpolation parameters.
|
Use Optuna to find the optimal parameters for fitting equivalent sources to gravity data. |
|
Find the best damping parameter for a verde.SplineCV() fit. |
Routines for optimal inversion parameters.
|
Use Optuna to find the optimal damping regularization parameter for a gravity inversion. |
Run an Optuna optimization to find the optimal zref and or density contrast values for a gravity inversion. |
|
|
Perform an optimization for zref and density contrast values same as function optimize_inversion_zref_density_contrast, but pass a dataframe of constraint points and split_kwargs which are both passed split_test_train create K-folds of testing and training constraints. |
|
Run an optimization to find best buffer zone width. |
Uncertainty#
Monte Carlo simulations to estimate the spatially variable uncertainties for the inversion and data processing.
|
Run a series of inversions (N=runs), and save results of each inversion to pickle files starting with fname. |
|
Use the outputs of the function uncertainty.full_workflow_uncertainty_loop to calculate the cell-wise statistics of the inversion ensemble and plot the resulting mean and standard deviation of the ensemble. |
|
Given a dataframe with a data column and an uncertainty column, sample the data with a normal distribution within the uncertainty range. |
|
Create a stochastic ensemble of regional gravity anomalies by sampling the constraints, gravity, or parameters within their respective distributions and calculate the cell-wise (weighted) statistics of the ensemble. |
Plotting#
Plot gravity data.
plot observed gravity |
|
plot gravity anomalies |
|
plot gravity misfit and estimate regional and residual components |
Plot model.
|
Use |
|
show prism layers using PyVista |
Plot inversion results.
plot a graph of L2-norm and delta L2-norm vs iteration number. |
|
plot a dynamic graph of L2-norm and delta L2-norm vs iteration number. |
|
|
plot the initial and final topography grids from the inversion and their difference |
|
plot the initial and final misfit grids from the inversion and their difference |
|
plot the starting misfit, updated topography, and correction grids for a specified number of the iterations of an inversion |
|
DEPRECATED: use the Inversion class method plot_inversion_results instead |
Plot optimization and cross-validation results.
|
plot a scatter plot graph with x axis equal to parameter 1, y axis equal to parameter 2, and points colored by cross-validation scores. |
|
plot a scatter plot graph with x axis equal to parameter 1, y axis equal to parameter 2, and points colored by cross-validation scores. |
|
plot a graph of cross-validation scores vs hyperparameter values |
|
plot combined slice plots for optimizations. |
|
plot the results of an optuna optimization |
Plot parameter sampling and uncertainty results.
|
Plot the (weighted) standard deviation (uncertainty) and mean of the stochastic ensemble. |
|
With a dictionary of parameters and their sampled values, plot the individual distributions and or the 2D projections of the parameter pairs. |
|
Plots the samples projected on each 2D plane |
Other plotting functions.
|
Show the gravity edge effects and the percentage decay within the inner region and optionally a profile across the region. |