PF: Gravity: Laguna del Maule Bouguer GravityΒΆ

This notebook illustrates the SimPEG code used to invert Bouguer gravity data collected at Laguna del Maule volcanic field, Chile. Refer to Miller et al 2016 EPSL for full details.

We run the inversion in two steps. Firstly creating a L2 model and then applying an Lp norm to produce a compact model.

Craig Miller

  • ../../../_images/sphx_glr_plot_laguna_del_maule_inversion_001.png
  • ../../../_images/sphx_glr_plot_laguna_del_maule_inversion_002.png
  • ../../../_images/sphx_glr_plot_laguna_del_maule_inversion_003.png

Out:

overwriting /Users/lindseyjh/git/simpeg/simpeg/examples/04-grav/Chile_GRAV_4_Miller.tar.gz
Downloading https://storage.googleapis.com/simpeg/Chile_GRAV_4_Miller/Chile_GRAV_4_Miller.tar.gz
   saved to: /Users/lindseyjh/git/simpeg/simpeg/examples/04-grav/Chile_GRAV_4_Miller.tar.gz
Download completed!
Begin calculation of distance weighting for R= 3.0
Done 0.0 %
Done 10.0 %
Done 20.0 %
Done 30.0 %
Done 40.0 %
Done 50.0 %
Done 60.0 %
Done 70.0 %
Done 80.0 %
Done 90.0 %
Done 100% ...distance weighting completed!!

SimPEG.DataMisfit.l2_DataMisfit assigning default eps of 1e-5 * ||dobs||
Begin calculation of forward operator: z
Done 0.0 %
Done 10.0 %
Done 20.0 %
Done 30.0 %
Done 40.0 %
Done 50.0 %
Done 60.0 %
Done 70.0 %
Done 80.0 %
Done 90.0 %
Done 100% ...forward operator completed!!


    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
=============================== Projected GNCG ===============================
  #     beta     phi_d     phi_m       f      |proj(x-g)-x|  LS    Comment
-----------------------------------------------------------------------------
x0 has any nan: 0
   0  2.01e+01  1.30e+06  1.85e+01  1.30e+06    1.95e+02      0
   1  1.01e+01  1.24e+06  1.53e+03  1.25e+06    1.83e+02      0
   2  5.03e+00  1.18e+06  5.41e+03  1.21e+06    1.80e+02      0   Skip BFGS
   3  2.52e+00  1.10e+06  1.82e+04  1.14e+06    1.75e+02      0   Skip BFGS
   4  1.26e+00  9.63e+05  5.77e+04  1.04e+06    1.69e+02      0   Skip BFGS
   5  6.29e-01  7.74e+05  1.67e+05  8.80e+05    1.61e+02      0   Skip BFGS
   6  3.14e-01  5.52e+05  4.23e+05  6.85e+05    1.53e+02      0   Skip BFGS
   7  1.57e-01  3.46e+05  8.91e+05  4.86e+05    1.46e+02      0   Skip BFGS
   8  7.86e-02  1.95e+05  1.56e+06  3.18e+05    1.42e+02      0   Skip BFGS
   9  3.93e-02  1.04e+05  2.38e+06  1.97e+05    1.39e+02      0   Skip BFGS
  10  1.97e-02  5.31e+04  3.28e+06  1.18e+05    1.36e+02      0   Skip BFGS
  11  9.83e-03  2.69e+04  4.20e+06  6.82e+04    1.32e+02      0   Skip BFGS
  12  4.91e-03  1.39e+04  5.11e+06  3.91e+04    1.25e+02      0   Skip BFGS
  13  2.46e-03  7.40e+03  6.04e+06  2.22e+04    1.15e+02      0   Skip BFGS
  14  1.23e-03  3.91e+03  7.03e+06  1.25e+04    1.02e+02      0   Skip BFGS
  15  6.14e-04  1.98e+03  8.12e+06  6.97e+03    8.78e+01      0   Skip BFGS
  16  3.07e-04  9.39e+02  9.31e+06  3.80e+03    7.18e+01      0   Skip BFGS
  17  1.54e-04  4.06e+02  1.05e+07  2.02e+03    6.14e+01      0   Skip BFGS
  18  7.68e-05  1.63e+02  1.16e+07  1.05e+03    4.56e+01      0   Skip BFGS
Convergence with smooth l2-norm regularization: Start IRLS steps...
L[p qx qy qz]-norm : [ 0.  1.  1.  1.  2.]
eps_p: 0.214371529687 eps_q: 0.0356115870052
Regularization decrease: 1.994e+00
  19  7.68e-05  6.13e+01  1.25e+07  1.02e+03    3.62e+01      0   Skip BFGS
  20  7.68e-05  5.15e+01  1.23e+07  9.98e+02    4.59e+01      0
  21  7.68e-05  5.53e+01  1.22e+07  9.90e+02    3.17e+01      0
  22  7.68e-05  4.98e+01  1.22e+07  9.85e+02    3.99e+01      0
  23  7.68e-05  5.31e+01  1.21e+07  9.81e+02    2.42e+01      0
Regularization decrease: 5.698e-02
  24  1.47e-04  5.00e+01  1.21e+07  1.82e+03    5.91e+01      0
  25  1.47e-04  1.45e+02  1.12e+07  1.78e+03    1.13e+02      0
  26  1.47e-04  1.19e+02  1.13e+07  1.78e+03    1.68e+02      0
  27  1.47e-04  1.38e+02  1.11e+07  1.77e+03    2.93e+01      0
  28  1.47e-04  1.24e+02  1.12e+07  1.77e+03    5.70e+01      0
Regularization decrease: 8.320e-02
  29  1.04e-04  1.35e+02  1.12e+07  1.30e+03    3.51e+01      0
  30  1.04e-04  8.13e+01  1.16e+07  1.29e+03    4.02e+01      0
  31  1.04e-04  9.37e+01  1.15e+07  1.29e+03    1.15e+02      0
  32  1.04e-04  8.17e+01  1.16e+07  1.29e+03    1.90e+01      0
  33  1.04e-04  8.36e+01  1.16e+07  1.29e+03    3.40e+01      2
Regularization decrease: 9.397e-03
Minimum decrease in regularization. End of IRLS
------------------------- STOP! -------------------------
1 : |fc-fOld| = 0.0000e+00 <= tolF*(1+|f0|) = 1.3022e+05
0 : |xc-x_last| = 1.0121e+00 <= tolX*(1+|x0|) = 1.0381e-01
0 : |proj(x-g)-x|    = 3.3993e+01 <= tolG          = 1.0000e-01
0 : |proj(x-g)-x|    = 3.3993e+01 <= 1e3*eps       = 1.0000e-02
0 : maxIter   =     150    <= iter          =     34
------------------------- DONE! -------------------------

import os
import shutil
import tarfile
import SimPEG.PF as PF
from SimPEG import Maps, Regularization, Optimization, DataMisfit,\
                   InvProblem, Directives, Inversion
from SimPEG.Utils.io_utils import download
import matplotlib.pyplot as plt
import numpy as np


def run(plotIt=True, cleanAfterRun=True):

    # Start by downloading files from the remote repository
    # directory where the downloaded files are

    url = "https://storage.googleapis.com/simpeg/Chile_GRAV_4_Miller/Chile_GRAV_4_Miller.tar.gz"
    downloads = download(url, overwrite=True)
    basePath = downloads.split(".")[0]

    # unzip the tarfile
    tar = tarfile.open(downloads, "r")
    tar.extractall()
    tar.close()

    input_file = basePath + os.path.sep + 'LdM_input_file.inp'
    # %% User input
    # Plotting parameters, max and min densities in g/cc
    vmin = -0.6
    vmax = 0.6

    # weight exponent for default weighting
    wgtexp = 3.
    # %%
    # Read in the input file which included all parameters at once
    # (mesh, topo, model, survey, inv param, etc.)
    driver = PF.GravityDriver.GravityDriver_Inv(input_file)
    # %%
    # Now we need to create the survey and model information.

    # Access the mesh and survey information
    mesh = driver.mesh
    survey = driver.survey

    # define gravity survey locations
    rxLoc = survey.srcField.rxList[0].locs

    # define gravity data and errors
    d = survey.dobs
    wd = survey.std

    # Get the active cells
    active = driver.activeCells
    nC = len(active)  # Number of active cells

    # Create active map to go from reduce set to full
    activeMap = Maps.InjectActiveCells(mesh, active, -100)

    # Create static map
    static = driver.staticCells
    dynamic = driver.dynamicCells

    staticCells = Maps.InjectActiveCells(
        None, dynamic, driver.m0[static], nC=nC
    )
    mstart = driver.m0[dynamic]

    # Get index of the center
    midx = int(mesh.nCx/2)
    # %%
    # Now that we have a model and a survey we can build the linear system ...
    # Create the forward model operator
    prob = PF.Gravity.GravityIntegral(mesh, rhoMap=staticCells,
                                      actInd=active)
    prob.solverOpts['accuracyTol'] = 1e-4

    # Pair the survey and problem
    survey.pair(prob)

    # Apply depth weighting
    wr = PF.Magnetics.get_dist_wgt(mesh, rxLoc, active, wgtexp,
                                   np.min(mesh.hx)/4.)
    wr = wr**2.

    # %% Create inversion objects
    reg = Regularization.Sparse(mesh, indActive=active,
                                mapping=staticCells)
    reg.mref = driver.mref[dynamic]
    reg.cell_weights = wr * mesh.vol[active]
    reg.norms = driver.lpnorms

    # Specify how the optimization will proceed
    opt = Optimization.ProjectedGNCG(maxIter=150, lower=driver.bounds[0],
                                     upper=driver.bounds[1], maxIterLS=20,
                                     maxIterCG=20, tolCG=1e-3)

    # Define misfit function (obs-calc)
    dmis = DataMisfit.l2_DataMisfit(survey)
    dmis.W = 1./wd

    # create the default L2 inverse problem from the above objects
    invProb = InvProblem.BaseInvProblem(dmis, reg, opt)

    # Specify how the initial beta is found
    betaest = Directives.BetaEstimate_ByEig()

    # IRLS sets up the Lp inversion problem
    # Set the eps parameter parameter in Line 11 of the
    # input file based on the distribution of model (DEFAULT = 95th %ile)
    IRLS = Directives.Update_IRLS(f_min_change=1e-2, maxIRLSiter=20,
                                  minGNiter=5)

    # Preconditioning refreshing for each IRLS iteration
    update_Jacobi = Directives.Update_lin_PreCond()

    # Create combined the L2 and Lp problem
    inv = Inversion.BaseInversion(invProb,
                                  directiveList=[IRLS, update_Jacobi, betaest])

    # %%
    # Run L2 and Lp inversion
    mrec = inv.run(mstart)

    if cleanAfterRun:
        os.remove(downloads)
        shutil.rmtree(basePath)

    # %%
    if plotIt:
        # Plot observed data
        PF.Magnetics.plot_obs_2D(rxLoc, d, 'Observed Data')

        # %%
        # Write output model and data files and print misft stats.

        # reconstructing l2 model mesh with air cells and active dynamic cells
        L2out = activeMap * IRLS.l2model

        # reconstructing lp model mesh with air cells and active dynamic cells
        Lpout = activeMap*mrec

        # %%
        # Plot out sections and histograms of the smooth l2 model.
        # The ind= parameter is the slice of the model from top down.
        yslice = midx + 1
        L2out[L2out == -100] = np.nan  # set "air" to nan

        plt.figure(figsize=(10, 7))
        plt.suptitle('Smooth Inversion: Depth weight = ' + str(wgtexp))
        ax = plt.subplot(221)
        dat1 = mesh.plotSlice(L2out, ax=ax, normal='Z', ind=-16,
                              clim=(vmin, vmax), pcolorOpts={'cmap': 'bwr'})
        plt.plot(np.array([mesh.vectorCCx[0], mesh.vectorCCx[-1]]),
                 np.array([mesh.vectorCCy[yslice], mesh.vectorCCy[yslice]]),
                 c='gray', linestyle='--')
        plt.scatter(rxLoc[0:, 0], rxLoc[0:, 1], color='k', s=1)
        plt.title('Z: ' + str(mesh.vectorCCz[-16]) + ' m')
        plt.xlabel('Easting (m)')
        plt.ylabel('Northing (m)')
        plt.gca().set_aspect('equal', adjustable='box')
        cb = plt.colorbar(dat1[0], orientation="vertical",
                          ticks=np.linspace(vmin, vmax, 4))
        cb.set_label('Density (g/cc$^3$)')

        ax = plt.subplot(222)
        dat = mesh.plotSlice(L2out, ax=ax, normal='Z', ind=-27,
                             clim=(vmin, vmax), pcolorOpts={'cmap': 'bwr'})
        plt.plot(np.array([mesh.vectorCCx[0], mesh.vectorCCx[-1]]),
                 np.array([mesh.vectorCCy[yslice], mesh.vectorCCy[yslice]]),
                 c='gray', linestyle='--')
        plt.scatter(rxLoc[0:, 0], rxLoc[0:, 1], color='k', s=1)
        plt.title('Z: ' + str(mesh.vectorCCz[-27]) + ' m')
        plt.xlabel('Easting (m)')
        plt.ylabel('Northing (m)')
        plt.gca().set_aspect('equal', adjustable='box')
        cb = plt.colorbar(dat1[0], orientation="vertical",
                          ticks=np.linspace(vmin, vmax, 4))
        cb.set_label('Density (g/cc$^3$)')

        ax = plt.subplot(212)
        mesh.plotSlice(L2out, ax=ax, normal='Y', ind=yslice,
                       clim=(vmin, vmax), pcolorOpts={'cmap': 'bwr'})
        plt.title('Cross Section')
        plt.xlabel('Easting(m)')
        plt.ylabel('Elevation')
        plt.gca().set_aspect('equal', adjustable='box')
        cb = plt.colorbar(dat1[0], orientation="vertical",
                          ticks=np.linspace(vmin, vmax, 4), cmap='bwr')
        cb.set_label('Density (g/cc$^3$)')

        # %%
        # Make plots of Lp model
        yslice = midx + 1
        Lpout[Lpout == -100] = np.nan  # set "air" to nan

        plt.figure(figsize=(10, 7))
        plt.suptitle('Compact Inversion: Depth weight = ' + str(wgtexp) +
                     ': $\epsilon_p$ = ' + str(round(reg.eps_p, 1)) +
                     ': $\epsilon_q$ = ' + str(round(reg.eps_q, 2)))
        ax = plt.subplot(221)
        dat = mesh.plotSlice(Lpout, ax=ax, normal='Z', ind=-16,
                             clim=(vmin, vmax), pcolorOpts={'cmap': 'bwr'})
        plt.plot(np.array([mesh.vectorCCx[0], mesh.vectorCCx[-1]]),
                 np.array([mesh.vectorCCy[yslice], mesh.vectorCCy[yslice]]),
                 c='gray', linestyle='--')
        plt.scatter(rxLoc[0:, 0], rxLoc[0:, 1], color='k', s=1)
        plt.title('Z: ' + str(mesh.vectorCCz[-16]) + ' m')
        plt.xlabel('Easting (m)')
        plt.ylabel('Northing (m)')
        plt.gca().set_aspect('equal', adjustable='box')
        cb = plt.colorbar(dat[0], orientation="vertical",
                          ticks=np.linspace(vmin, vmax, 4))
        cb.set_label('Density (g/cc$^3$)')

        ax = plt.subplot(222)
        dat = mesh.plotSlice(Lpout, ax=ax, normal='Z', ind=-27,
                             clim=(vmin, vmax), pcolorOpts={'cmap': 'bwr'})
        plt.plot(np.array([mesh.vectorCCx[0], mesh.vectorCCx[-1]]),
                 np.array([mesh.vectorCCy[yslice], mesh.vectorCCy[yslice]]),
                 c='gray', linestyle='--')
        plt.scatter(rxLoc[0:, 0], rxLoc[0:, 1], color='k', s=1)
        plt.title('Z: ' + str(mesh.vectorCCz[-27]) + ' m')
        plt.xlabel('Easting (m)')
        plt.ylabel('Northing (m)')
        plt.gca().set_aspect('equal', adjustable='box')
        cb = plt.colorbar(dat[0], orientation="vertical",
                          ticks=np.linspace(vmin, vmax, 4))
        cb.set_label('Density (g/cc$^3$)')

        ax = plt.subplot(212)
        dat = mesh.plotSlice(Lpout, ax=ax, normal='Y', ind=yslice,
                             clim=(vmin, vmax), pcolorOpts={'cmap': 'bwr'})
        plt.title('Cross Section')
        plt.xlabel('Easting (m)')
        plt.ylabel('Elevation (m)')
        plt.gca().set_aspect('equal', adjustable='box')
        cb = plt.colorbar(dat[0], orientation="vertical",
                          ticks=np.linspace(vmin, vmax, 4))
        cb.set_label('Density (g/cc$^3$)')

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

Total running time of the script: ( 4 minutes 1.306 seconds)

Generated by Sphinx-Gallery