# Crosswell Tomography Inversion 2D

# 2D Linear Inversion of Crosswell Tomography Data¶

```
import numpy as np
from geoscilabs.inversion.TomographyInversion import TomographyInversionApp
import matplotlib.pyplot as plt
from ipywidgets import interact, IntSlider
%matplotlib inline
```

# Purpose¶

From the Linear inversion notebook (1D), we learned important apsects about the linear inversion. However, real world geophysical inverse problem are not often 1D, but multidimensional (2D or 3D), and this extension of dimension allows us to put more apriori (or geologic) information through the regularization term. In this notebook, we explore these multidimensional aspects of the linear inversion by using 2D traveltime croswell tomography example.

## Outline¶

This notebook includes three steps:

- Step 1: Generate a velocity model
- Step 2: Simulate traveltime data and add noise
- Step 3: Run $l_2$ inversion

## Step 1: Generate a velocity model¶

Here we set up a velocity model using a following app. Controlling parameters of the app are:

`set mesh`

: use active**only**when you want to change the 2D mesh`add block`

: use active when you want to add block (if not stay inactive)`model type`

: background or block`show grid?`

: show grid of the mesh`v0`

: velocity of the background`v1`

: velocity of the block`xc`

: x center of the block`yc`

: y center of the block`dx`

: width of the block`dz`

: thickness of the block`nx`

: # of cells in x-direction (this is only active when`set_mesh=active`

)`ny`

: # of cells in y-direction (this is only active when`set_mesh=active`

)

Re-running the following cell will reset the app to the default parameters.

### Changing # of cells in $x$- or $z$- direction¶

Adjustable parameters: `set mesh`

, `nx`

, `ny`

The 2D domain is fixed at 200m $\times$ 400m. The number of cells in each direction can be changed which alters the size of cells in each direction. To change either `nx`

or `ny`

:

- Set
`set mesh=active`

. This will change the view to the background model`v0`

. - Adjust
`nx`

and or`ny`

using the sliders. The size of the cells is diplayed above the model. - When finished adjusting the mesh set
`set mesh=inactive`

.

### Changing the background model¶

Adjustable parameters: `model type`

, `v0`

To change the value of the constant background velocity model:

- Set
`model type=background`

. This will change the view to the background model`v0`

. - Adjust
`v0`

using the slider. - When finished ajusting set
`model type=block`

### Changing the parameters of a single block¶

Adjustable parameters: `add block`

, `model type`

, `v1`

, `xc`

, `zc`

, `dx`

, `dz`

To change the parameters of a single block model (default):

- Set
`add block=active`

. - Adjust
`v1`

,`xc`

,`zc`

,`dx`

,`dz`

using the sliders. The original block settings will remain in view. - When finished ajusting set
`model type=background`

- To confirm the parameter changes and veiw the current block, set
`model type=block`

### Adding more blocks¶

Adjustable parameters: `add block`

, `v1`

, `xc`

, `zc`

, `dx`

, `dz`

The model can contain multiple blocks. To add new blocks to the model:

- Set
`add block=inactive`

- Adjust the parameters of the new block
`v1`

,`xc`

,`zc`

,`dx`

,`dz`

. The velocity model will not change yet. The white boundary of the new block serves as a preview. - When finished adjusting the new block parameters set
`add block=active`

. The velocity model will be updated with the new block. - Repeat Steps 1-3 to add more blocks.

The parameters of the blocks in a multi-block model cannot be changed once the block has been added. Attempting to adjust the parameters after the block has been added to the model (following the directions in the previous section "Changing the parameters of a single block") will remove all previous blocks. A single block model with the current block is created.

```
app = TomographyInversionApp()
app.interact_plot_model()
```

## Step 2: Simulate travel time data and add noise¶

Within this app, by using the velocity model set up above, we simulate traveltime tomography data and add Gaussian noise. This syntehtic data set will be used in the following inversion module. Controlling parameters are:

`percent (%)`

: percentage of the Gaussian noise`floor (s)`

: floor of the Gaussain noise`random seed`

: seed to generate random variables having normal distribution`tx_rx_plane`

or`histogram`

: data display options`update`

: this buttion is for the interaction with the Step 1 app. If the velocity model is changed by altering the first app, you can simply click`update`

to run simulation again with the updated velocity model.

`app.interact_data()`

## Step 3: $l_2$ inversion¶

Here we invert the data generated in Step 2 and explore the results. Step 3 is divided into four sections:

- Step 3.1: Run inversion
- Step 3.2: Plot recovered model
- Step 3.3: Plot predicted data
- Step 3.4: Plot misfit curves

### Step 3.1: Run inversion¶

The inversion, run in the cell below, requires the following input parameters, each of which can be adjusted:

`maxIter`

: maximum number of iterations`m0`

: initial model`mref`

: reference model`percentage`

: percent standard deviation for the uncertainty`floor`

: floor value for the uncertainty`chifact`

: chifactor for the target misfit`beta0_ratio`

: ratio to set the initial beta`coolingFactor`

: cooling factor to cool beta`n_iter_per_beta`

: # of interations for each beta value`alpha_s`

: $\alpha_s$`alpha_x`

: $\alpha_x$`alpha_z`

: $\alpha_z$`use_target`

: use target misfit as a stopping criteria or not

```
model, pred, save = app.run_inversion(
maxIter=20,
m0=1./1000.,
mref=1./1000.,
percentage=0,
floor=0.01,
chifact=0.1,
beta0_ratio=1e2,
coolingFactor=2,
n_iter_per_beta=1,
alpha_s=1/(app.mesh_prop.hx.min())**2,
alpha_x=1,
alpha_z=1,
use_target=True
)
```

### Step 3.2: Plot recovered model¶

The app below displays the:

- Recovered model from the inversion in Step 3.1 (left)
- True model generated in Step 1 (right)

The model view is changed using:

`ii`

: each iteration of the inversion (`ii`

=0 is the initial model`m0`

)`fixed`

: when selected the colorbar of both plots have the same fixed limits

`app.interact_model_inversion(model, clim=None)`

### Step 3.3: Plot predicted data¶

The app below displays the:

- Obversed data calculated in Step 2 (left)
- Predicted data from the inversion in Step 3.1 (center)
- Normalized misfit between the observed and predicted data (right)

The predicted data and normalized misfit view is changed using:

`ii`

: each iteration of the inversion (`ii`

=0 is the initial model`m0`

)`fixed`

: when selected the colorbar of both data plots have the same fixed limits

`app.interact_data_inversion(pred)`

### Step 3.4: Plot misfit curves¶

- Plot of the data misfit and model norm values as functions of inversion iteration
- Tikhonov curves with the optimal values indicated by the star
- Data misfit as a function of trade-off parameter $\beta$
- Model norm as a function of trade-off parameter $\beta$
- Data misfit versus model norm

`app.plot_tikhonov_curves(save);`