a dash of

emg3d and 2019 roundup

07 January 2020

2019 was quite a busy year. I changed my job from the Mexican Petroleum Institute IMP to TU Delft already in 2018, but it was only this February when we finally moved physically to the Netherlands. Here a quick rundown of 2019 in terms of open-source things, mostly in Python and generally related to geophysics. As usual, most my open-source stuff can be found either on my GitHub or the GitHub of empymod.


The highlight this year was definitely the release of emg3d, released under the Apache License, Version 2.0. It is a three-dimensional electromagnetic modeller for geophysical exploration (controlled-source electromagnetics CSEM), written completely in Python. The core functionality is written in just-in-time (jit) compiled functions using numba. From the description of emg3d: «The modeller emg3d is a multigrid solver for 3D EM diffusion with tri-axial electrical anisotropy. The matrix-free solver can be used as main solver or as preconditioner for Krylov subspace methods, and the governing equations are discretized on a staggered Yee grid.» Multigrid methods scale linearly in both CPU and RAM usage, and as such you can run quite big models on standard computers, no need for huge clusters (see the manual for more in this regard). You can find emg3d and all information around it (manual, code, examples, benchmarks, and more) together with empymod at empymod.github.io:

Installation is easy using either pip

$ pip install emg3d

or conda

$ conda install -c conda-forge emg3d

Reference (open access):

Werthmüller, D., W. A. Mulder, and E. C. Slob, 2019, emg3d: A multigrid solver for 3D electromagnetic diffusion: Journal of Open Source Software, 4(39), 1463, 10.21105/joss.01463.


Not too much happened with regards to empymod. Some notable changes:

  • Our article A tool for designing digital filters for the Hankel and Fourier transforms in potential, diffusive, and wavefield modeling (featured in the 2018 roundup) got highlighted under Geophysics Bright Spots in The Leading Edge, see 10.1190/tle38050402.1.

  • Sphinx-Gallery is now used for the examples.

  • Besides wavenumber-frequency domain, space-frequency domain, and space-time domain you can now calculate EM responses in the space-Laplace domain.

  • There were many improvements for loops (TEMs), have a look at the examples.

  • empymod also moved from my own conda channel prisae to the channel conda-forge.


  • Scooby: I used to have a Versions() function at the end of my notebooks to keep track of what versions I was using for the main packages, what Python environment, the date and other info. I had that implemented in empymod and emg3d, and also brought it to SimPEG. Bane Sullivan expanded on my code and made a self-standing package out of it, scooby (available via pip and conda-forge). Here you can see scooby in action: scooby
    In a notebook it shows a nicely rendered html-table, in a console it prints a plain-text version of it.

  • It took some work, but with the help of Joseph Dellinger (BP), Ted Bakamjian (SEG), and Philipp Witte (Georgia Institute of Technology) we managed to get finally a proper open-source license attached to the SEG/EAGE Salt and Overthrust Models, and you can download it directly from the SEG wiki.

  • Cubic spline interpolation in three dimensions is not implemented in an easy, user-facing routine in SciPy. However, interpolating linearly can introduce significant errors with, for instance, electromagnetic responses that cover many orders of magnitude. I made some comparisons in this direction in 2D to show the importance: cubicspline-vs-linear-interpolation
    You can find the corresponding notebook here: Interpolation-Comparison-2D.ipynb.

    There is now 3D cubic spline interpolation included in emg3d using SciPy, see the function emg3d.utils._interp3d. It uses a combination of scipy.interpolate.interp1d and scipy.ndimage.map_coordinates to get it working with 3D data (credit to Joe Kington for helping with that).