volcapy.synthetic package

Submodules

volcapy.synthetic.build_synth_data module

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.

volcapy.synthetic.grid module

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.

volcapy.synthetic.reconstruct module

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.

volcapy.synthetic.reconstruct.main(out_folder, lambda0, sigma0)[source]
volcapy.synthetic.reconstruct.prelude()[source]

volcapy.synthetic.temp module

volcapy.synthetic.test_voxel module

volcapy.synthetic.test_voxel.MakeVoxel()[source]

A voxel is a representation of a regular grid in 3-D space.

volcapy.synthetic.train module

volcapy.synthetic.try_vtk_str_grid module

volcapy.synthetic.vtkutils module

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

Module contents