You are on page 1of 16

PySIT: Seismic Imaging Toolbox for Python

Russell J. Hewett and Laurent Demanet

EAGE 2016, Vienna

Russell J. Hewett (TOTAL E&P USA and MIT) PySIT 1 / 14


Who we are

I Earth Resources Laboratory (ERL): https://erlweb.mit.edu


I Imaging and Computing group: http://math.mit.edu/icg
I Main developer: Russell Hewett (Total)

Russell J. Hewett (TOTAL E&P USA and MIT) PySIT 2 / 14


PySIT: Origin & Motivations
Needed flexible platform for research on. . .
I Wave Equation Solvers
I Objective Functions
I Optimization

. . . in the context of FWI

Why Python?
I Cross-platform, portability
I Community
I Not MATLAB ($$)
I Open parallel libraries
I General fan of the language

Russell J. Hewett (TOTAL E&P USA and MIT) PySIT 3 / 14


PySIT: Python Seismic Imaging Toolbox

Pedagogical and research platform for seismic inversion

Rapid prototyping new imaging algorithms


I Easy to learn
I Maximize student and intern productivity
I Reproducible research

Russell J. Hewett (TOTAL E&P USA and MIT) PySIT 4 / 14


PySIT: Python Seismic Imaging Toolbox

http://www.pysit.org

Open source under BSD license


I Permissive license
I No legal concerns for industrial use

Open development model


I Version control with Git
I Source code hosted on GitHub
I Explicitly provide mechanisms for handling proprietary research

Russell J. Hewett (TOTAL E&P USA and MIT) PySIT 5 / 14


Community Dependencies
NumPy [www.numpy.org]
I Core N-D array package

SciPy [www.scipy.org]
I Fundamental library for scientific computing

Matplotlib [www.matplotlib.org]
I Plotting and visualization

ObsPy [www.obspy.org]
I Python framework for seismology
I Data reading, writing, and processing

mpi4py [mpi4py.scipy.org]
I MPI wrapper for Python

Russell J. Hewett (TOTAL E&P USA and MIT) PySIT 6 / 14


PySIT is a research tool

Local solvers for salt boundary inversion in FWI


I Willemsen et al. (GJI ‘16)

Microseismic Event Estimation via FWI


I Minkoff et al. (SEG ‘15)

Hessian approximations
I Stochastic approximation of FWI Hessian (Willemsen et al.)
I Matrix probing of FWI Inverse Hessian (Hewett et al.)

Uncertainty quantification
I Non-gaussianity of the FWI posterior (Li et al.)

Russell J. Hewett (TOTAL E&P USA and MIT) PySIT 7 / 14


PySIT is also a Pedagogical Tool

Exercise: 1D full waveform inversion


I Introduces FWI to interns, graduate students, and postdocs
I Achieves a functional FWI in a few hours
I Motivates and teaches both design and structure of PySIT
I Is part of PySIT’s documentation

Russell J. Hewett (TOTAL E&P USA and MIT) PySIT 8 / 14


PySIT is also a Pedagogical Tool

Exercise: 1D full waveform inversion


I Introduces FWI to interns, graduate students, and postdocs
I Achieves a functional FWI in a few hours
I Motivates and teaches both design and structure of PySIT
I Is part of PySIT’s documentation

Case study: MSRI – Mathematics of Seismic Imaging


I Two weeks and ∼ 40 math graduate students
I No imaging experience, moderate programming experience
I Start with 1D exercise . . .
I . . . end with blind 2D inversion problem using PySIT

Russell J. Hewett (TOTAL E&P USA and MIT) PySIT 8 / 14


PySIT is also a Pedagogical Tool

Exercise: 1D full waveform inversion


I Introduces FWI to interns, graduate students, and postdocs
I Achieves a functional FWI in a few hours
I Motivates and teaches both design and structure of PySIT
I Is part of PySIT’s documentation

Case study: MSRI – Mathematics of Seismic Imaging


I Two weeks and ∼ 40 math graduate students
I No imaging experience, moderate programming experience
I Start with 1D exercise . . .
I . . . end with blind 2D inversion problem using PySIT on their laptops

Russell J. Hewett (TOTAL E&P USA and MIT) PySIT 8 / 14


Partial List of Features

Dimension independent inversion: 1D, 2D, and 3D


Solvers
I Scalar acoustic wave equation
– Matrix (numpy) and matrix-free (C++) implementations
– Leap frog and ODE timestepping
– Arbitrary spatial accuracy
I + Variable density solvers
I Helmholtz equation
– Sparse, direct LU with SuperLU + PETSc wrappers
Objective Functions
I Temporal least-squares
I Frequency least-squares
Optimization Algorithms
I Gradient descent, Gauss-Newton, L-BFGS
Visualization
Parallelism (MPI + OpenMP), PMLs, gallery problems, and more
Russell J. Hewett (TOTAL E&P USA and MIT) PySIT 9 / 14
Let the Mathematics Define the API

modeling = T e m p o r a l M o d e l i n g ( solver )

u = F(m) ⇔ L(m)u = f
modeling . forward_model ( shot , m , ...)

δL
δu = Fm0 δm ⇔ L(m0 ) = − [δm]u0
δm
modeling . l i n e a r _ f o r w a r d _ m o d e l ( shot , m0 , dm , ...)

δL
δm = − < q, δm u0 >
δm = Fm∗ 0 S ∗ r ⇔
s.t. L (m0 )q = S ∗ r

modeling . adjoint_model ( shot , m0 , r , ...)

Russell J. Hewett (TOTAL E&P USA and MIT) PySIT 10 / 14


Let the Mathematics Define the API

objective = T e m p o r a l L e a s t S q u a r e s ( solver )

J(m) = 1
2 ||d − F(m)||22
objective . evaluate ( shots , m , ...)

∇J(m0 ) = − Fm∗ 0 (d − F(m0 ))


objective . co m p u t e _ g r a d i e n t ( shots , m0 , ...)

D2 Jδm = Fm∗ 0 Fm0 δm− < D2 Fδm, d − F(m0 ) >


objective . apply_hessian ( shots , m0 , dm , ...)

Russell J. Hewett (TOTAL E&P USA and MIT) PySIT 11 / 14


A Cartoon Example
from pysit import *
hidden_text

# Setup a p h y s i c a l problem and a c q u i s i t i o n


true_model , initial_model , mesh , domain = marmousi2 ()

wavelet = RickerWavelet (10.0)


shots = e q u i s p a c e d _ a c q u i s i t i o n ( mesh , wavelet , nshots =5 , nrecs =50)

# Setup solver
solver = C o n s t a n t D e n s i t y A c o u s t i c W a v e ( mesh , trange =(0.0 , 3.0))

# P o p u l a t e s y n t h e t i c data
g e n e r a t e _ s e i s m i c _ d a t a ( shots , solver , true_model )

# Define o b j e c t i v e f u n c t i o n
objective = T e m p o r a l L e a s t S q u a r e s ( solver )

# Define o p t i m i z a t i o n a l g o r i t h m
invalg = LBFGS ( objective )

# Run i n v e r s i o n for 5 i t e r a t i o n s
result = invalg ( shots , initial_value , 5)

# V i s u a l i z e results
vis . plot ( result .C , mesh )
Russell J. Hewett (TOTAL E&P USA and MIT) PySIT 12 / 14
FWI Results with PySIT

0
20
40
60
80
100
120
140
0 100 200 300 400 500
0
20
40
60
80
100
120
140
0 100 200 300 400 500
0
20
40
60
80
100
120
140
0 100 200 300 400 500

Russell J. Hewett (TOTAL E&P USA and MIT) PySIT 13 / 14


What does the future hold?

I Optimization toward a simpler, more powerful, dependable tool:


I New features: UQ, hDG, maybe elastic / anisotropic, maybe AD
I Speed up: encapsulate more C++, maybe switch to Julia
I Bridge gap between academic research and industrial application
I Better installer

I Library dependencies can be painful: how to minimize the need for


TLC?

http://www.pysit.org

Russell J. Hewett (TOTAL E&P USA and MIT) PySIT 14 / 14

You might also like