.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "api/gallery/seismology/plot_03_omori_aftershock_decay.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code or to run this example in your browser via JupyterLite. .. rst-class:: sphx-glr-example-title .. _sphx_glr_api_gallery_seismology_plot_03_omori_aftershock_decay.py: Omori's aftershock decay (1894) =============================== Fusakichi Omori counted the aftershocks of the 1891 Nobi earthquake and found that their rate fell as 1/(t + c). Tokuji Utsu later generalized the exponent to p, usually close to 1. On log-log axes the rate is flat for t << c and has slope -p for t >> c. The parameters here are synthetic. .. GENERATED FROM PYTHON SOURCE LINES 10-36 .. image-sg:: /api/gallery/seismology/images/sphx_glr_plot_03_omori_aftershock_decay_001.png :alt: Aftershock rate decays as a power law :srcset: /api/gallery/seismology/images/sphx_glr_plot_03_omori_aftershock_decay_001.png :class: sphx-glr-single-img .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from earthsciencekit.seismology import omori_rate from earthsciencekit.units import convert day = convert(1, "day", "s") time = np.logspace(-3, 3, 300) * day c, k = 0.05 * day, 200.0 fig, ax = plt.subplots() for p in [0.9, 1.0, 1.2]: rate = omori_rate(k * day ** (p - 1), c, p, time) * day ax.loglog(time / day, rate, label=f"p = {p}") late = time > 100 * c slope = np.polyfit(np.log(time[late] + c), np.log(rate[late]), 1)[0] assert np.isclose(slope, -p) # Omori's original law integrates to a logarithm: N(T) = K ln(1 + T / c). t = np.linspace(0, 30 * day, 30001) count = np.trapezoid(omori_rate(k, c, 1.0, t), t) assert np.isclose(count, k * np.log1p(30 * day / c), rtol=1e-4) ax.set(xlabel="time after main shock [day]", ylabel="aftershocks per day", title="Aftershock rate decays as a power law") ax.legend() plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.232 seconds) .. _sphx_glr_download_api_gallery_seismology_plot_03_omori_aftershock_decay.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: lite-badge .. image:: images/jupyterlite_badge_logo.svg :target: ../../../lite/lab/index.html?path=api/gallery/seismology/plot_03_omori_aftershock_decay.ipynb :alt: Launch JupyterLite :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_03_omori_aftershock_decay.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_03_omori_aftershock_decay.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_03_omori_aftershock_decay.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_