Tutorials
Practical guides for FWI workflows
Every example uses the same composable pattern:
- Load model with
load_model() - Create
Datasetfrom SEG-Y or Zarr - Instantiate
DevitoPhysicswith desired configuration - Run optimizer with
optimizer.fwi()or custom loop
This section collects battle-tested patterns you can adapt to your own survey.
For rugged topography workflows, pair these tutorials with the dedicated Immersed Boundary Support guide.
Getting Started
| Page | Scenario | Highlights |
|---|---|---|
| Basic Workflow | Full-batch inversion using all shots | Clean API, gradient verification, simple FWI |
| Stochastic Batches | Mini-batch optimization for large datasets | Shot sampling, reproducibility, logging |
| Multi-Parameter | VTI inversion (vp, epsilon, delta) |
Multi-parameter bounds, gradient inspection |
| Continuation | Multi-scale workflow | Sequential filtering, frequency continuation |
FWI Tutorials
| Notebook | Dataset | Highlights |
|---|---|---|
| Overthrust FWI | Overthrust | FWI with gradient verification and QC |
| BP94 FWI | BP1994 | SEG-Y loading, synthetic vs observed QC |
| Immersed Boundary BP94 | BP1994 | Signed-distance-function topography and immersed-boundary conditions |
| Reflection FWI, BP94 | BP1994 | Velocity and the scalar reflectivity (log impedance) |
| Reflection FWI, Marmousi2 | Marmousi2 | Velocity and the scalar reflectivity (log impedance) |
Misfits & Optimization
| Notebook | Topic | Highlights |
|---|---|---|
| Envelope Misfit | Misfits | Hilbert transform, cycle-skip robust misfit |
| Constrained Optimization | Optimizers | SPG vs PQN comparison, bound constraints |
| Denoising with Bregman | Regularization | Wavelet sparsity, linearized Bregman iterations |
| Laplacian Gradient Smoothing | Gradient processing | Custom gradient step and between-band model smoother |
Data & Preprocessing
| Notebook | Topic | Highlights |
|---|---|---|
| Preprocessing (Marmousi) | Preprocessing | SEG-Y loading, filtering, sampling |
| Despiking Noise Bursts | Preprocessing | Custom step, step order, observed-only target, effect on FWI |
Parallel Computing with Dask
| Notebook | Environment | Highlights |
|---|---|---|
| Dask Local | Local | Multi-worker parallelization |
| Dask Local with SEG-Y | Local | Parallel SEG-Y processing |
| Dask Azure | Azure | Cloud-based parallel FWI |
| Dask Azure TTI RTM | Azure | TTI RTM on Azure cluster |
| SEAM on Azure | Azure | End to end: model on blob, shots written on the worker, RTM |
| Dask AWS | AWS | EC2 cluster, shots and model on S3 |
Each page contains runnable Python code with explanations of key concepts.
Common Setup Pattern
from devitohorizon.data import Dataset
from devitohorizon.model import load_model
from devitohorizon.physics import DevitoPhysics
from devitohorizon.optimization import SPG
# Load model
model0 = load_model("models/init.h5", nbl=40, space_order=16)
# Load data
dataset = Dataset.from_segy("data/shots.segy")
# Create physics
physics = DevitoPhysics(
nbl=40,
space_order=16,
parameters=('m',),
misfit='l2',
)
# Run optimization
optimizer = SPG(maxiter=10, ftol=1e-6, verbose=True)
model_opt, f_opt, result = optimizer.fwi(
physics=physics,
dataset=dataset,
model0=model0,
bounds={'vp': (1.5, 5.0)},
)Once you understand this basic pattern, you can mix and match the advanced patterns documented in the following pages.
Example Workflows
RTM/Migration (No Optimization)
# Compute RTM image directly
image = physics.image(dataset)Custom Optimization Loop
# Manual control over everything
model = model0.copy()
for iteration in range(20):
# Sample mini-batch
batch = dataset.sample(8)
# Compute objective and gradient
f, g_dict = physics.objective(batch, model)
# Apply custom update
alpha = 0.1 / (1 + 0.1 * iteration) # Decaying step size
for param in g_dict:
model[param] -= alpha * g_dict[param]
print(f"Iter {iteration}: f={f:.6e}")Parallel Execution with Dask
from dask.distributed import Client
from devitohorizon.scheduler import create_scheduler
client = Client(n_workers=4, threads_per_worker=2)
scheduler = create_scheduler(client)
# Same optimizer.fwi() call, now parallelized
model_opt, f_opt, result = optimizer.fwi(
physics=physics,
dataset=dataset,
model0=model0,
bounds={'vp': (1.5, 5.0)},
scheduler=scheduler, # Enable parallelization
)Next Steps
Browse the individual example pages for detailed walkthroughs of each workflow pattern.