Synthetic Volcano Creation

This module provides functionalities to build synthetic volcanoes and run inversion on them.

The goal is to build a synthetic topography with some user defined matter density field inside it. One can then compute the gravity field that such an artificial volcano would generate and treat is as artificial observations in an inverse problem.

The advantage of such artificial observations compared to real data is that one has the access to the ground truth (the synthetic matter density field). One can thus us this data to check the implementation of different inversion methodologies.

On a more informal level, one can use this artificial data to get intuition about the different covariance kernels, by comparing how the inversion results for different kernels differ for various ground thruth (sharp edges, long range structures, …).

We next provide a detailed description of how to work with synthetic volcanoes, strating with the static part (the data that is usually kept fixed among different experiments).

Building an artificial volcano

  • The main data characterizing an artificial volcano is a topography. A topography is a collection of contiguous 3-dimensional cells defining a discretization of a given domain (the volcano). For simplicity, we here use a cone discretized into uniform cubic cells.

  • Once a topography has been defined, one has to chose the locations at which the measurements of the gravity field will be performed. We do this by picking \(n_{obs}\) locations at random on the surface of the topography. Here surface means the upper boundary of the cone, i.e. there will be no measurements below the cone. Note also that we add a small offset between the surface and the measurement location to avoid singularities in the forwarded operator.

  • Once topography and measurement locations have been defined, the forward operator can be computed using the Banerjee formula.

Generating data from an artificial volcano

  • Once the static data has been defined, one has to specify a matter density field inside the topography, i.e. to assign a density to each cell.

  • Finally, the observations (gravity field) generated by tha matter density field can be computed using the forward operator.


We can thus summarize the workflow for working with synthetic volcanoes.

  1. Create an artificial topography.

  2. Place data measurement sites around the topography.

  3. Compute the forward operator relating the cells in the topography to the measurement sites.

  4. Define a matter density field inside the topography (see build_synth_data.py).

  5. Using the forward, compute the data observations generated by the density field.

  6. Train a gaussian process model on the generated data (see train.py).

  7. Use the gausian process as a prior in bayesian inversion (see reconstruct.py).

  8. Compare the inversion results with the true (synthetic) matter density field.


A detailed description of each submodule is provided below.

build_synth_data

This code generates a synthetic volcano and corresponding dataset. The generated forward operator, inversion grid, data sites coordinates, etc … will be stored as numpy array files (.npy).

See the documentation of the main function below for more information on the outputs.

volcapy.synthetic.build_synth_data.main()[source]
Returns
F_synth.npy:

The forward operator

reg_coords_synth.npy:

A regular grid, stored as a n_cells * n_dims array.

volcano_inds_synth.npy:

A list specifying the indices (in the regular grid) that correspond to volcano cells.

data_coords_synth.npy:

Coordinates of the data sites.

data_values_synth.npy:

(Computed) value of the data measurements.

density_synth.npy:

The matter density inside the synthetic volcano. Note tha this is on the regular grid, with zeros for cells outside the volcano.

grid

This submodule contains functions for building artificial irregular grids (topographies) when building synthetic volcanoes.

It can also generate data measurement site on the surface of the topography (sites placed at random) and compute the forward operator associated to the topography/data sites.

volcapy.synthetic.grid.build_cone(coords)[source]

Given a cubic grid, turn it into a cone.

Parameters
coords: ndarray

Array of size n_cells * 3. Contains the coordinates of the center of each cell.

Returns
ndarray

1 dimensional array containing indices of cells belonging to the cone.

volcapy.synthetic.grid.build_cube(nr_x, res_x, nr_y, res_y, nr_z, res_z)[source]

Builds a regular gridded cube.

Parameters
nr_x: int

Number of cells in x-dimension.

res_x: float

Size of cell along x_dimension.

nr_y: int
res_y: float
nr_z: int
res_z: float
Returns
ndarray

Array of size n_cells * 3. Contains the coordinates of the center of each cell.

volcapy.synthetic.grid.build_random_cone(coords, nx, ny, nz)[source]

Given a cubic grid, turn it into a cone.

Parameters
coords: ndarray

Array of size n_cells * 3. Contains the coordinates of the center of each cell.

nx: int

Number of cells along x-dimension.

ny: int
nz: int
Returns
ndarray

1 dimensional array containing indices of cells belonging to the cone.

volcapy.synthetic.grid.compute_forward(coords, res_x, res_y, res_z, data_coords)[source]

Compute the forward operator associated to a given topography/irregular grid. In the end, it only need a list of cells.

Parameters
coords: ndarray

Cells centroid coordinates, size n_cell * n_dims.

res_x: float

Length of a cell in x-direction (meters).

res_y_float
res_z: float
data_coords: ndarray

List of data measurements coordinates, size n_data * n_dims.

Returns
ndarray

Forward operator, size n_data * n_cells.

volcapy.synthetic.grid.coords_from_meshgrid(meshgrid)[source]

Inverse operation of the above.

volcapy.synthetic.grid.generate_regular_surface_datapoints(xl, xh, nx, yl, yh, ny, zl, zh, nz, offset)[source]

Put regularly spaced measurement points on the surface of a cube. Note that there will always be measurement sites at the endpoints of the cube. We need an offset because measerements cannot be directly on the endpoints of a cell because of division by zero in the Bannerjee formula.

Parameters
xl: float

Lower x-coordinate of the cube.

xh: float

Higher x-coordinate of the cube.

nx: int

Number of measurments in x-dimension.

yl: float
yh: float
ny: int
zl: float
zh: float
nz: int
offset: float

Displace the measurements sites by an offset outside of the cube to avoid division by zero.

Returns
ndarray

Coordinates of the measurement sites, size n_data * n_dims.

volcapy.synthetic.grid.meshgrid_from_coords(coords, nx, ny, nz)[source]

Turns a list of coordinates (in regular grid) into a meshgrid.

vtkutils

Utilities to convert inversion data to VTK format for 3d visualization.

volcapy.synthetic.vtkutils.ndarray_to_vtk(data, res_x, res_y, res_z, filename)[source]

Save data to vtk format.

THIS IS THE ONE THAT WORKS WITH REAL DATA.

Parameters
data: ndarray

1D array.

filename: string
volcapy.synthetic.vtkutils.save_vtk(data, shape, res_x, res_y, res_z, filename)[source]

Save data to vtk format.

THIS ONLY WORKS FOR SYNTHETIC DATA. REAL DATA HAS TO BE TRANSPOSED.

Parameters
data: ndarray

1D array.

shape: (int, int, int)
filename: string

train

reconstruct

This script runs the inversion on the synthetic dataset created using build_synth_data. Note that hyperparameters have to be manually specified, so one should run train before in order to determine the optimal hyperparameters.