PyLayeredModel is a collection of Python wrappers for a small subset of the seismological codes found in the Fortran packages Computer Programs in Seismology (CPS; Herrmann 2013) and Rftn. This subset of programs performs calculations relating to transversely-isotropic Earth models (consisting of stacks of internally homogeneous layers). The wrappers may allow you to work more quickly with these Fortran-based codes, which are usually manipulated using bash shell scripts. The compiled Fortran routines are called via the Python core module subprocess
.
Currently, wrappers are written to calculate the following properties using CPS:
- For Rayleigh and Love waves:
- Phase and group speed dispersion, using
sdisp96
; - Eigenfunctions and sensitivity kernels, using
sregn96
andslegn96
; - Sensitivity kernels using
srfker96
.
- Phase and group speed dispersion, using
- Receiver functions, using
trftn96
;
Additionally, one wrapper is provided for Rftn, which calculates:
- The Earth-response function, using
respknt
.
For Earth-response functions, you need to compile respknt
from Rftn. For all of the other programs, you need to compile CPS. Follow the compilation instructions given in the links above.
To run this Python code, you need to have Python3 installed with the NumPy library. To work with Earth-response functions and receiver functions, you will also need the ObsPy library, which we use to handle the SAC files. For plotting, you will need Matplotlib. We recommend using Anaconda to assemble these Python libraries.
Compile Fortran programs and Python modules you need, based on the section above. Clone this project from GitHub, navigate to the base directory, and try
python3 examples.py 1
where 1
means the first example. You should get something like the figures shown in the next section. Look at the scripts in examples.py
to see how to build your own models.
We only add something if we need it for our research, and no additions are planned at this time. Please feel free to request features, report bugs, or make contributions.
Other wrappers for CPS in Python:
- CPSPy Dispersion, kernels and possibly more.
- CPyS A Python and bash wrapper for inversion of receiver functions and surface waves using CPS.
- Geopy Wrapper for CPS
sacfmt96
, eigenfunction routines,srfker96
, as well as some format manipulations, plotting, and a variety of other seismological tasks not related to CPS wrappers. - pysurf96 Dispersion calculations, wrapped using
f2py
instead ofsubprocess
, so it should be faster than PyLayeredModel. - srfpython 'Compute, display and invert 1-D models'.
A Python library calculating dispersion from scratch, including radial anisotropy:
A different Fortran library offering similar calculations:
If you use any of the CPS codes in published research, you must cite Herrmann (2013). If you use respknt
from Rftn, you must cite Randall (1994). If you found these Python wrappers helpful, please mention the PyLayeredModel GitHub page in your acknowledgement section.