.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/seismicity_rate.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_seismicity_rate.py: Modeling of seismicity ====================== This example shows how to translate stressing rate to seismicity rate using the function :func:`bruces.modeling.seismicity_rate`. Modeled seismicity rate can then be used to generate a magnitude-time distribution using the function :func:`bruces.modeling.magnitude_time`. This example starts by generating a synthetic stressing rate with an instantaneous 1000 fold increase after 2 years followed by a 10 fold decrease after another 2 years. The free parameter :math:`a \sigma` of the rate-and-state model is arbitrarily set to 0.15. Note that :func:`bruces.modeling.seismicity_rate` outputs the seismicity rate :math:`r` relative to the background seismicity rate :math:`r_0`. Modeling the magnitude-time distribution requires the actual seismicity rate :math:`r \times r_0`. Here, we assume that :math:`r_0` = 1 event/year. .. GENERATED FROM PYTHON SOURCE LINES 12-55 .. image-sg:: /examples/images/sphx_glr_seismicity_rate_001.png :alt: seismicity rate :srcset: /examples/images/sphx_glr_seismicity_rate_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none (0.0, 10.0) | .. code-block:: default import bruces import numpy as np import matplotlib.pyplot as plt # Define stressing rate stress_ini = 1.0e-3 times = np.linspace(0.0, 10.0, 201) stress = np.ones(201) * stress_ini stress[times > 2.0] = stress_ini * 1.0e3 stress[times > 4.0] = stress_ini * 1.0e2 # Model relative seismicity rate rates = bruces.modeling.seismicity_rate( times=times, stress=stress, stress_ini=stress_ini, asigma=0.15, ) # Model magnitude-time distribution magnitudes = bruces.modeling.magnitude_time( times=times, rates=rates, m_bounds=[0.0, 2.0], seed=0, ) # Plot fig, ax = plt.subplots(2, 1, sharex=True) ax[0].semilogy(times, stress / stress_ini, label="Stress") ax[0].semilogy(times, rates, label="Seismicity") ax[0].set_ylabel("Rate") ax[0].legend(frameon=False) for t, m in zip(times, magnitudes): if len(m): ax[1].scatter([t] * len(m), m, color="black", alpha=0.2) ax[1].set_xlabel("Time (year)") ax[1].set_ylabel("Magnitude") ax[1].set_xlim(times.min(), times.max()) .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 6.178 seconds) .. _sphx_glr_download_examples_seismicity_rate.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: seismicity_rate.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: seismicity_rate.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_