Seismic Straight Ray TomographyΒΆ

Example of a straight ray tomography inverse problem.

  • ../../../_images/sphx_glr_plot_seis_straight_ray_tomo_001.png
  • ../../../_images/sphx_glr_plot_seis_straight_ray_tomo_002.png
  • ../../../_images/sphx_glr_plot_seis_straight_ray_tomo_003.png

Out:

length: 1.1313708499
length: 0.707106781187
Using a seed of:  861
SimPEG.DataMisfit.l2_DataMisfit assigning default eps of 1e-5 * ||dobs||
SimPEG.InvProblem will set Regularization.mref to m0.

    SimPEG.InvProblem is setting bfgsH0 to the inverse of the eval2Deriv.
    ***Done using same Solver and solverOpts as the problem***
model has any nan: 0
============================ Inexact Gauss Newton ============================
  #     beta     phi_d     phi_m       f      |proj(x-g)-x|  LS    Comment
-----------------------------------------------------------------------------
x0 has any nan: 0
   0  4.38e+03  5.56e+02  0.00e+00  5.56e+02    2.78e+02      0
   1  4.38e+03  1.30e+02  2.38e-03  1.41e+02    1.04e+01      0
   2  4.38e+03  1.30e+02  2.46e-03  1.41e+02    3.18e-02      0   Skip BFGS
------------------------- STOP! -------------------------
1 : |fc-fOld| = 1.3372e-01 <= tolF*(1+|f0|) = 5.5723e+01
1 : |xc-x_last| = 3.3815e-02 <= tolX*(1+|x0|) = 3.1000e+00
1 : |proj(x-g)-x|    = 3.1776e-02 <= tolG          = 1.0000e-01
0 : |proj(x-g)-x|    = 3.1776e-02 <= 1e3*eps       = 1.0000e-02
0 : maxIter   =      40    <= iter          =      2
------------------------- DONE! -------------------------

from SimPEG import Utils
from SimPEG import Mesh
from SimPEG import Maps
from SimPEG import Survey
from SimPEG import Regularization
from SimPEG import DataMisfit
from SimPEG import Optimization
from SimPEG import InvProblem
from SimPEG import Directives
from SimPEG import Inversion

from SimPEG.SEIS import StraightRay

import numpy as np
import scipy.sparse as sp
import matplotlib.pyplot as plt


def run(plotIt=False):

    O = np.r_[-1.2, -1.]
    D = np.r_[10., 10.]
    x = np.r_[0., 1.]
    y = np.r_[0., 1.]
    print('length:', StraightRay.lengthInCell(O, D, x, y, plotIt=plotIt))
    O = np.r_[0, -1.]
    D = np.r_[1., 1.]*1.5
    print('length:', StraightRay.lengthInCell(O, D, x*2, y*2, plotIt=plotIt))

    nC = 20
    M = Mesh.TensorMesh([nC, nC])
    y = np.linspace(0., 1., nC/2)
    rlocs = np.c_[y*0+M.vectorCCx[-1], y]
    rx = StraightRay.Rx(rlocs, None)

    srcList = [
        StraightRay.Src(loc=np.r_[M.vectorCCx[0], yi], rxList=[rx])
        for yi in y
    ]

    survey = StraightRay.Survey(srcList)
    problem = StraightRay.Problem(M, slownessMap=Maps.IdentityMap(M))
    problem.pair(survey)

    s = Utils.mkvc(Utils.ModelBuilder.randomModel(M.vnC)) + 1.
    survey.dobs = survey.dpred(s)
    survey.std = 0.01

    # Create an optimization program

    reg = Regularization.Tikhonov(M)
    dmis = DataMisfit.l2_DataMisfit(survey)
    opt = Optimization.InexactGaussNewton(maxIter=40)
    opt.remember('xc')
    invProb = InvProblem.BaseInvProblem(dmis, reg, opt)
    beta = Directives.BetaSchedule()
    betaest = Directives.BetaEstimate_ByEig()
    inv = Inversion.BaseInversion(invProb, directiveList=[beta, betaest])

    # Start the inversion with a model of zeros, and run the inversion
    m0 = np.ones(M.nC)*1.5
    mopt = inv.run(m0)

    if plotIt is True:
        fig, ax = plt.subplots(1, 2, figsize=(8, 4))
        ax[1].plot(survey.dobs)
        ax[1].plot(survey.dpred(m0), 's')
        ax[1].plot(survey.dpred(mopt), 'o')
        ax[1].legend(['dobs', 'starting dpred', 'dpred'])
        M.plotImage(s, ax=ax[0])
        survey.plot(ax=ax[0])
        ax[0].set_title('survey')

        plt.tight_layout()

    if plotIt is True:
        fig, ax = plt.subplots(1, 3, figsize=(12, 4))
        plt.colorbar(M.plotImage(m0, ax=ax[0])[0], ax=ax[0])
        plt.colorbar(M.plotImage(mopt, ax=ax[1])[0], ax=ax[1])
        plt.colorbar(M.plotImage(s, ax=ax[2])[0], ax=ax[2])

        ax[0].set_title('Starting Model')
        ax[1].set_title('Recovered Model')
        ax[2].set_title('True Model')

        plt.tight_layout()

if __name__ == '__main__':
    run(plotIt=True)
    plt.show()

Total running time of the script: ( 0 minutes 5.218 seconds)

Generated by Sphinx-Gallery