harrymd / PyLayeredModel

Python wrappers for the CPS and Rftn libraries for layered models in seismology

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PyLayeredModel

What it is

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.

What's included

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 and slegn96;
    • Sensitivity kernels using srfker96.
  • Receiver functions, using trftn96 ;

Additionally, one wrapper is provided for Rftn, which calculates:

  • The Earth-response function, using respknt.

Software requirements

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.

Getting started

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.

Examples

1. Dispersion

2. Eigenfunctions and sensitivity kernels

3. More sensitivity kernels

4. Receiver functions

5. Earth-response functions

Future work

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.

Similar packages

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 of subprocess, 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:

Credit

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.

About

Python wrappers for the CPS and Rftn libraries for layered models in seismology


Languages

Language:Python 98.6%Language:Shell 1.4%