Introduction to the Python Seismic Imaging Toolbox (PySIT)
Russell J. Hewett
Department of Mathematics, Massachusetts Institute of Technology
Python is write once, run everywhere
Construct experiments in Python scripting environment + version control
################ CARTOON (doesn't run...yet) ###############
# Setup a physical problem and acquisition
M, M0, mesh, domain = marmousi2(scale='mini')
shots = equispaced_acquisition(mesh, domain, nshots=5, nrecs=50)
# Setup solver
solver = ConstantDensityAcousticWave(mesh, trange=(0.0, 3.0))
# Populate synthetic data
generate_seismic_data(shots, solver, base_model)
# Define objective function
objective = TemporalLeastSquares(solver)
# Define optimization algorithm
invalg = LBFGS(objective)
# Run inversion for 5 steps
result = invalg(shots, initial_value, 5, line_search='backtrack')
# Visualize results
vis.plot(result.C, mesh)
\[\;\;\;\;\;\;\;\;\;\;\;\;\;\;\Updownarrow\]
\[\;\;\;\;\;\;\;\;\;\;\;\;\;\;\Updownarrow\]
\[\;\;\;\;\;\;\;\;\;\;\;\;\;\;\Updownarrow\]
Gradient Descent
Limited Memory BFGS (L-BFGS)
(Gauss-Newton via Krylov)
Implements
Wave: Time-domain Constant Density Acoustics
Helmholtz: Frequency-domain Constant Density Acoustics
################ CARTOON (doesn't run...yet) ###############
# Setup a physical problem and acquisition
M, M0, mesh, domain = marmousi2(scale='mini')
shots = equispaced_acquisition(mesh, domain, nshots=5, nrecs=50)
# Setup solver
solver = ConstantDensityAcousticWave(mesh, trange=(0.0, 3.0))
# Populate synthetic data
generate_seismic_data(shots, solver, base_model)
# Define objective function
objective = TemporalLeastSquares(solver)
# Define optimization algorithm
invalg = LBFGS(objective)
# Run inversion for 5 steps
result = invalg(shots, initial_value, 5, line_search='backtrack')
# Visualize results
vis.plot(result.C, mesh)
################ CARTOON (doesn't run...yet) ###############
# Setup a physical problem and acquisition
M, M0, mesh, domain = marmousi2(scale='mini')
shots = equispaced_acquisition(mesh, domain, nshots=5, nrecs=50)
# Setup solver
solver = ConstantDensityAcousticWaveLOD(mesh, trange=(0.0, 3.0))
# Populate synthetic data
generate_seismic_data(shots, solver, base_model)
# Define objective function
objective = TemporalLeastSquares(solver)
# Define optimization algorithm
invalg = LBFGS(objective)
# Run inversion for 5 steps
result = invalg(shots, initial_value, 5, line_search='backtrack')
# Visualize results
vis.plot(result.C, mesh)
Start an ipython interpreter: ipython --pylab
import numpy as np
import matplotlib.pyplot as plt
import pysit # from pysit import *
from pysit.gallery import horizontal_reflector
# Define a boundary condition object
bcx = pysit.PML(0.1, 100)
# bcx = Dirichlet()
bcz = pysit.PML(0.1, 100)
# Configure the domain in PHYSICAL paramters
x_config = (0.1, 1.0, bcx, bcx)
z_config = (0.1, 0.8, bcz, bcz)
# Define the PHYSICAL domain based on the parameters
domain = pysit.RectangularDomain( x_config, z_config )
# Define the COMPUTATIONAL mesh based on the domain
mesh = pysit.CartesianMesh(domain, 90, 70)
# Create our demo model
C, C0 = horizontal_reflector(mesh, reflector_position=[0.45, 0.65],
reflector_scaling = [1.0, 1.0], base_speed = 1.0,)
pysit.vis.plot(C0, mesh, axis=plt.subplot(1,2,1), clim=(C.min(),C.max()));
plt.colorbar();
pysit.vis.plot(C, mesh, axis=plt.subplot(1,2,2))
plt.colorbar();
# Extract some useful parameters
zmin = domain.z.lbound
zmax = domain.z.rbound
zdepth = zmin + (1./9.)*zmax
shots = pysit.equispaced_acquisition(mesh,
pysit.RickerWavelet(10.0),
sources=1,
source_depth=zdepth,
receivers='max',
receiver_depth=zdepth)
print shots
solver = pysit.ConstantDensityAcousticWave(mesh,
formulation='scalar',
model_parameters={'C': C},
spatial_accuracy_order=2,
trange=(0.0,3.0),
use_cpp_acceleration=True)
wavefields = []
base_model = solver.ModelParameters(mesh,{'C': C})
pysit.generate_seismic_data(shots, solver, base_model, wavefields=wavefields)
pysit.vis.display_seismogram(shots[0], cmap='gray', clim=(-0.01,0.01))
objective = pysit.TemporalLeastSquares(solver)
invalg = pysit.LBFGS(objective)
initial_value = solver.ModelParameters(mesh,{'C': C0})
sc = {'residual_length_frequency' : 1,
'objective_frequency' : 1,
'gradient_frequency' : 1,
'run_time_frequency' : 1,
}
nsteps = 1
result = invalg(shots, initial_value, nsteps, line_search='backtrack',
status_configuration=sc, verbose=True);
nsteps = 15
result = invalg(shots, initial_value, nsteps, line_search='backtrack',
status_configuration=sc);
pysit.pysit.vis.plot(result.C, mesh);
obj_vals = np.array([v for k,v in invalg.objective_history.items()])
plt.figure()
plt.semilogy(obj_vals, linewidth=2);
clim = C.min(),C.max()
plt.figure()
plt.subplot(3,1,1)
pysit.vis.plot(C0, mesh, clim=clim, cmap='gray')
plt.title('Initial Model')
plt.xticks([])
plt.subplot(3,1,2)
pysit.vis.plot(C, mesh, clim=clim, cmap='gray')
plt.title('True Model')
plt.xticks([])
plt.subplot(3,1,3)
pysit.vis.plot(result.C, mesh, clim=clim, cmap='gray')
plt.title('Reconstruction');