Python Presets and Scaling Up

Part 12, Part 12: The Modeling Lab

Learning objectives

  • Reproduce the course's engines in real Python
  • Copy and run a convolutional, an FD, and a rock-physics preset
  • Know when to leave the browser for a numerical runtime
  • Meet the industry-scale codes: Devito, SPECFEM, Madagascar

The Same Physics, in Real Code

The Modeling Lab runs the cheap engines in the browser for instant feedback. The heavy engines, the full wave equation and elastic gathers, belong in a real numerical runtime. This section closes that gap. It gives you three self-contained Python programs, real runnable code, not pseudocode, that reproduce the course's engines in numpy: a convolutional synthetic, a small 2D acoustic finite-difference wavefield, and the Hudson crack-to-HTI mapping.

Copy one into the Python Playground under Tools, or into your own environment, run it, and change it. Nothing in them is new; they are the exact algorithms you have been driving with sliders, now written out so you can extend them beyond what a browser slider allows.

Python presets and scaling upConvolutional synthetic (build a section)import numpy as npz = np.r_[...] # impedance logrc[1:] = (z[1:]-z[:-1])/(z[1:]+z[:-1])trace = np.convolve(rc, ricker(30), 'same')Copy codeDevitoFD stencils compiled to fast CSPECFEM3Dspectral-element 3D wave equationMadagascarreproducible SEG-Y imagingThree real numpy programs reproduce the course engines (convolution, acoustic FD, Hudson HTI). Copy, run, and scale up to Devito, SPECFEM, or Madagascar via SEG-Y.

Beyond the Laptop

When a numpy loop is no longer enough, the path continues to dedicated codes. Devito compiles finite-difference stencils to fast C for full acoustic and elastic propagation and inversion, the natural step up from the FD preset. SPECFEM3D is a spectral-element solver for the full 3D wave equation on realistic meshes, the research standard. Madagascar is a reproducible processing and imaging package that reads and writes the very SEG-Y files you exported from the Lab.

The important point is that the path is continuous. The same physics scales from a browser slider to a numpy preset to Devito to SPECFEM, and SEG-Y files carry your models between every stage. You have not been learning a toy; you have been learning the real forward problem, at the scale where it starts. The final section sizes the jump, estimating the cost of a full run, and looks ahead to where the course goes next.

This page is prerendered for SEO and accessibility. The interactive widgets above hydrate on JavaScript load.