{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# 2D Linear Inversion of Crosswell Tomography Data " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "from geoscilabs.inversion.TomographyInversion import TomographyInversionApp\n", "import matplotlib.pyplot as plt\n", "from ipywidgets import interact, IntSlider" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Purpose\n", "\n", "From the Linear inversion notebook (1D), we learned important apsects about the linear inversion. \n", "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. \n", "In this notebook, we explore these multidimensional aspects of the linear inversion by using 2D traveltime croswell tomography example. \n", "\n", "## Outline\n", "This notebook includes four steps:\n", "- Step1: Generate a velocity model\n", "- Step2: Simulate traveltime data and add noise\n", "- Step3: Run $l_2$ inversion" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Step1: Generate a velocity model\n", "\n", "Here we set up a velocity model using a following app. Controlling parameters of the app are:\n", "\n", "- `set mesh`: use active **only** when you want to change the 2D mesh\n", "- `add block`: use active when you want to add block (if not stay inactive)\n", "- `model type`: background or block\n", "- `show grid?`: show grid of the mesh\n", "\n", "- `v0`: velocity of the background\n", "- `v1`: velocity of the block\n", "- `xc`: x center of the block\n", "- `yc`: y center of the block\n", "- `dx`: width of the block\n", "- `dy`: thickness of the block\n", "- `nx`: # of cells in x-direction (this is only active when `set_mesh=active`)\n", "- `ny`: # of cells in y-direction (this is only active when `set_mesh=active`)\n", "\n", "### Changing # of cells in $x$- or $z$- direction\n", "Related parameters for this task are: `set mesh`, `nx`, `ny`. \n", "Size of the 2D domain are fixed to 200m $\\times$ 400m, but the number of cells in each direction can be changed such that you can alter size of the cells in each direction. When you change either `nx` or `ny` make sure you choose `set mesh=active` otherwise `set mesh=inactive`. Note that once mesh setup is changed, velocity model is reset to a background value (`v0`). \n", "\n", "### Changing a parameter of a single block\n", "Although you can change the location, size, and velocity of the block there are few rules that you need to follow to do so. \n", "\n", "1. If you want to change the parameter of the block: first set `add block=active` then change parameters of the block (`v1`, `xc`, `zc`, `dx`, `dy`)\n", "\n", "2. Once you changed the parameters, make sure first choose `model type=background` then change that to `model type=block`\n", "\n", "### Adding more blocks\n", "You can also add multiple blocks. To add a block follow below steps:\n", "\n", "1. Set `add block=inactive`, then change the parameter of the new block using: `v1`, `xc`, `zc`, `dx`, `dy`. Velocity model will not change, but you can see the white lines which illustrate boundary of the new block.\n", "\n", "2. Once you are happy with the new block, set `add block=active`, then velocity model will be updated with the new block that you have set. \n", "\n", "3. Repeat 1 and 2 if you want to add more blocks. \n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "scrolled": false }, "outputs": [], "source": [ "app = TomographyInversionApp()\n", "app.interact_plot_model()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Step2: Simulate travel time data and add noise\n", "\n", "Within this app, by using the velocity model set up, we simulate traveltime tomography data and add Gaussian noise. This syntehtic data set will be used in the following inversion module. Controlling parameters are:\n", "\n", "- `percent (%)`: percentage of the Gaussian noise\n", "- `floor (s)`: floor of the Gaussain noise\n", "- `random seed`: seed to generate random variables having normal distribution\n", "- `tx_rx_plane` or `histogram`: choice of the plotting data\n", "- `update`: this buttion is for the interactin between the first 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. \n" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "app.interact_data()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Step3: $l_2$ inversion\n", "\n", "- `maxIter`: maximum number of iteration\n", "- `m0`: initial model\n", "- `mref`: reference model\n", "- `percentage`: percent standard deviation for the uncertainty\n", "- `floor`: floor value for the uncertainty\n", "- `chifact`: chifactor for the target misfit\n", "- `beta0_ratio`: ratio to set the initial beta\n", "- `coolingFactor`: cooling factor to cool beta\n", "- `n_iter_per_beta`: # of interation for each beta value \n", "- `alpha_s`: $\\alpha_s$\n", "- `alpha_x`: $\\alpha_x$\n", "- `alpha_z`: $\\alpha_z$\n", "- `use_target`: use target misfit as a stopping criteria or not" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Step 3-1: Run inversion" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "model, pred, save = app.run_inversion(\n", " maxIter=20,\n", " m0=1./1000.,\n", " mref=1./1250.,\n", " percentage=0,\n", " floor=0.005,\n", " chifact=1,\n", " beta0_ratio=1e2,\n", " coolingFactor=2,\n", " n_iter_per_beta=1,\n", " alpha_s=1/(app.mesh_prop.hx.min())**2 * 1e4,\n", " alpha_x=1,\n", " alpha_z=1,\n", " use_target=True\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Step 3-2: Plot recovered model" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "app.interact_model_inversion(model, clim=None)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Step 3-3: Plot predicted data " ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "app.interact_data_inversion(pred)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Step 3-4: Plot misfit curves" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "save.plot_misfit_curves()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "app.plot_tikhonov_curves(save);" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.10" } }, "nbformat": 4, "nbformat_minor": 2 }