[ Skip to content]

Science and Engineering at The University of Edinburgh

Dr Andrew Bell

Volcanology, seismology, and natural hazards

Python codes for modelling seismicity and deformation data

On this page I'm providing Python scripts to simulate and fit strain and seismicity data associated with "acceleration-to-failure" processes. If you plan to use these scripts as part of publication, please reference Bell et al. 2011 (GRL).

NEW!!! - Updated in June 2013 to include maximum-likelihood forecasting methods from Bell et al. 2013 (GJI). here



Data simulation:

Here are two Python scripts to generate:

  1. Earthquake or AE data as a heterogeneous Poisson process, with a power-law or exponential acceleration in mean rate and with magnitudes distributed according to the Gutenberg-Richter distribution
  2. Strain data with a Gaussian measurement uncertainty, with a power-law acceleration in mean rate

Two example data files are also provided.

  1. Python script for generating and plotting synthetic earthquake/AE data
  2. Python script for generating and plotting synthetic strain data
  1. .dat file containing simulated strain data
  2. .dat file containing simulated earthquakes data
[Simulated strain] [Simulated earthquakes]

Retrospective data analysis:

Here are Python scripts to fit power-law accelerations to failure in strain and earthquake/AE data using different methods (parameter confidence intervals to follow):

  1. To strain data using a GLM routine with log-link function and Gaussian errors (uses scikits.statsmodels)
  2. To strain data by minimizing the least-squares resdiuals between model and data (uses scipy.optimize)
  3. To earthquake/AE data using a GLM routine with log-link function and Poisson errors (uses scikits.statsmodels)
  4. To earthquake/AE data using by minimizing Ogata's log-likelihood function (uses scipy.optimize)
  1. Python script for fitting power-law to strain using GLM
  2. Python script for fitting power-law to strain by minimizing LS
  3. Python script for fitting power-law to earthquake rates using GLM
  4. Python script for fitting power-law to earthquake occurrence times using Ogata's method
[Ogata_quakefit] [GLM_Strainfit]

Bayesian model comparison:

Information criterion are a pragmatic tool for comparing the performance of models, taking model complexity into account. Here I provide a code for using the Akaike information criterion (AIC) for comparing a power-law and exponential model for accelerating rates of earthquakes (using Ogata's maximum likelihood method to fit the models). The preferred model is the one with the lower AIC; see Bell et al. 2011 (GJI) for examples. Note that rigorous model comparison requires calculation of the Bayesian "evidence" (see Toussaint, 2011, for discussion).

  1. Python script for comparing power-law and exponential models for accelerating rates of earthquakes using AIC
[PL-Exp Comparison]

Forecasting:

Bell et al. 2013 (GJI) outlines maximum-likelihood methods for fitting and forecasting accelerating rates of earthquakes.

  1. Python script for fitting power-law, exponential and constant rate models using MLE in "pseudo-prospective mode"
[ML forecasting]

About Python:

These scripts are written in Python. Python is a general-purpose, readable, high-level programming language. It is open source, with community development. NumPy is an extension to Python that allows operation on multi-dimensional arrays and matrices. SciPy is a library of mathematical tools. Matplotlib is a plotting library. Together these components provide a free, open source alternative to Matlab.

For windows users I recommend the Pythonxy distribution of Python, based on Qt and Spyder.

Some of these scripts use the Statsmodels module, and the Optimize module of SciPy.



References

  1. Bell, A.F., M. Naylor, M.J. Heap and I.G. Main, Forecasting volcanic eruptions and other material failure phenomena: an evaluation of the failure forecast method, Geophys. Res. Lett., 38, L15304, doi:10.1029/2011GL048155 (2011).
  2. Bell, A.F., J. Greenhough, M.J. Heap and I.G. Main, Challenges for forecasting based on accelerating rates of earthquakes at volcanoes and laboratory analogues, Geophys. J. Int., 185, 2, doi:10.1111/j.1365-246X.2011.04982.x, (2011).
  3. Toussaint, U. v., Bayesian inference in physics, Rev. Mod. Phys., 83, doi:10.1103/RevModPhys.83.943, (2011).
  4. Ogata, Y., Statistical analysis of seismicity: updated version (SASeis2006), Computer Science Monographs, 33 (2006).
© School of GeoSciences --- Privacy & Cookies --- Last modified: 25 Jun, 2013 --- Page contact: