Educational Software

The following is a collection of simple educational codes, mostly in the form of Jupyter notebooks. They are intended to illustrate basic concepts in geophysics and in inverse theory. Most codes are licensed under a external pageCreative Commons Attribution 4.0 International License: You are free to share and adapt the codes as long as you give appropriate credit to this website and to the author of the codes, Andreas Fichtner.

1. Fundamentals of Geophysics

This is a collection of Jupyter notebooks covering basic topics in geophysics. They are the same as the computer exercises in the external pageFundamentals of Geophysics textbook by William Lowrie and Andreas Fichtner.

DownloadEuler pole rotation of tectonic plates (IPYNB, 11 KB) [Rotation of tectonic plates, represented as many points with fixed mutual distance, across the surface of a sphere.]

DownloadGravity of an extended body (IPYNB, 8 KB) [Numerical calculation of the gravitational attraction caused by an arbitrary 2D density distribution.]

DownloadTides and Roche limit (IPYNB, 4 KB) [Tidal acceleration at the surface of a planet in relation to the planet's self gravitation.]

DownloadFourier series (IPYNB, 5 KB) [Illustration of Fourier analysis and synthesis, the Gibbs phenomenon, and filtering.]

DownloadGravity corrections (IPYNB, 9 KB) [Numerical illustration of elevation and topography corrections in 2D.]

DownloadCreep mechanisms (IPYNB, 6 KB) [Realistic examples of dislocation and diffusion creep in olivine, and their dependence of pressure, temperature and grain size.]

DownloadFinite-difference approximation of the wave equation (IPYNB, 7 KB) [Finite-difference simulation of wave propagation in 1D.]

DownloadReflections at dipping interface (IPYNB, 3 KB) [Modelling and inversion of seismic wave reflections from a dipping interface below the surface.]

DownloadOrigin time and location (IPYNB, 6 KB) [Estimation of the origin time and the location of an earthquake.]

DownloadConcordia-discordia (IPYNB, 3 KB) [Estimation of the age of a volcanic rock using the concordia-discordia diagram.]

DownloadHeat flow and age (IPYNB, 4 KB) [Real-data correlation of oceanic heatflow and ocean floor age.]

DownloadFour-electrode methods (IPYNB, 4 KB) [Numerical illustration of various four-electrode methods in geoelectricity.]

DownloadMagnetic anomalies (IPYNB, 4 KB) [Numerical calculation of magnetic anomalies caused by differently shaped bodies.]

DownloadApparent polar wander (IPYNB, 3 KB) [Calculation of virtual geomagnetic poles.]

 

2. Inverse Theory

2.1. Basic Concepts and Illustrations

DownloadBayes' table (IPYNB, 32 KB) [Thomas Bayes' thought experiment to illustrate the concept of a binomial distribution and of what is now known as Bayes' theorem.]

DownloadGauss coefficients (IPYNB, 14 KB) [Simple exercise to obtain the posterior distribution of the Gauss coefficients of the geomagnetic field using artificial magnetic data and a line search approach.]

DownloadGaussian samples (IPYNB, 3 KB) [Generation of random samples from a two-dimensional Gaussian with non-diagonal covariance using Cholesky decomposition.]

DownloadLine fitting in 1D (IPYNB, 36 KB) [Simple illustration of linear least squares and the concept of data covariance.]

2.2. Linear Inverse Problems

DownloadStraight-ray tomography (IPYNB, 407 KB) [Straight-ray tomography in 2D to illustrate basic concepts of linear least-squares inversion, such as prior and posterior covariances, smoothing, damping, over- and under-fitting, and resolution. The Downloadutils (ZIP, 14 KB) need to be located in the same directory as the Jupyter notebook.]

DownloadStraight-ray tomography - Subjectivity Experiment (IPYNB, 14 KB) [Synthetic experiment to assess the impact of subjective choices (data selection, regularisation, ...) in a simple straight-ray tomography. The sDownloadynthetic dataset needs to be located in the same directory as the Jupyter notebook.]

2.3. Nonlinear Optimisation Methods

DownloadNonlinear optimisation in 2D (IPYNB, 29 KB) [Collection of nonlinear optimisation methods applied to 2D test functions. Currently implemented methods are steepest descent, conjugate gradients (Fletcher-Reeves, Polak-Ribiere, Hestenes-Stiefel), Newton's method, BFGS, and L-BFGS. The Downloadtest functions (PY, 3 KB) (including their first and second derivatives) need to be located in the same directory as the Jupyter notebook.]

2.4. Markov-Chain Monte Carlo Methods & Nullspace Shuttles

DownloadHamiltonian Nullspace Shuttle (analytic 2D) (IPYNB, 221 KB) [Analytic example of the nonlinear Hamiltonian Nullspace Shuttle for a one-dimensional model space (2D phase space).]

DownloadHamiltonian Nullspace Shuttle (analytic 2D randomised) (IPYNB, 390 KB) [Randomised version of the 2D analytic Hamiltonian Nullspace shuttle where the misfit tolerance is interpreted as a random variable. The algorithm is nearly identical to Hamiltonian Monte Carlo.]

DownloadMetropolis-Hastings I (IPYNB, 13 KB) [Finding the time shift between two noisy time series using Metropolis-Hastings sampling and Simulated Annealing.]

DownloadMetropolis-Hastings II (IPYNB, 164 KB) [Illustration of Metropolis-Hastings sampling in two dimensions using local or global proposals.]

DownloadTransdimensional sampling - Naive (IPYNB, 11 KB) [Naive transdimensional sampling for polynomial fitting of variable degree. Fixed-dimensional posteriors are sampled individually, and their respective evidences are approximated explicitly from the samples.]

DownloadTransdimensional sampling - Reversible Jump (IPYNB, 9 KB) [Reversible-jump algorithm applied to polynomial fitting of variable degree.]

DownloadHamiltonian Monte Carlo for 2D analytical test functions with unit mass matrix (IPYNB, 11 KB) [Simplest possible HMC illustration. Requires Downloadinput file (PY, 1 KB) and Downloadtest functions (PY, 3 KB).]

DownloadHamiltonian Monte Carlo for 2D analytical test functions with adaptable mass matrix (IPYNB, 12 KB) [In contrast to the previous example, the mass matrix can be any positive definite matrix. Illustrates the influence of the mass matrix on convergence and sample independence. The same input and test function files are needed.]

DownloadHamiltonian Monte Carlo for 2D analytical test functions with autotuned mass matrix (IPYNB, 17 KB) [A nearly optimal mass matrix is found on-the-fly using a BFGS approximation of the local Hessian. Requires the same input and test function files as the two examples above.]

2.5. Adjoint Methods

DownloadForward and adjoint wave propagation in 1D (IPYNB, 18 KB) [Second-order finite-difference approximation of the 1D frequency-domain visco-elastic wave equation, including solutions of the forward and and discrete adjoint problems, as well as gradient accuracy tests (e.g., hockey-stick test).]

DownloadForward and adjoint wave propagation in 1D using logarithmic parameters (IPYNB, 23 KB) [This is the same as above, but instead of (complex-valued) velocities, logarithmic velocities are used. The important benefit is a reparameterisation from the Jeffreys parameter velocity to its inverse, slowness, does not change the functional form of probability densities.]

JavaScript has been disabled in your browser