.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "api/gallery/seismology/plot_13_knopoff_q.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_13_knopoff_q.py: Knopoff's Q (1964) ================== Leon Knopoff reviewed the evidence that rocks dissipate a nearly constant fraction of wave energy per cycle, whatever the frequency. With a constant quality factor Q, amplitude decays as exp(-pi f t / Q), so high frequencies die first. The log ratio of two spectra is then a straight line in frequency whose slope gives Q, the spectral-ratio method. .. GENERATED FROM PYTHON SOURCE LINES 11-36 .. image-sg:: /api/gallery/seismology/images/sphx_glr_plot_13_knopoff_q_001.png :alt: Constant Q = 200, Spectral ratio recovers Q = 200 :srcset: /api/gallery/seismology/images/sphx_glr_plot_13_knopoff_q_001.png :class: sphx-glr-single-img .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from earthsciencekit.seismology import attenuated_amplitude Q = 200.0 frequency = np.linspace(0.5, 20, 100) near, far = 5.0, 50.0 log_ratio = np.log(attenuated_amplitude(1, frequency, far, Q) / attenuated_amplitude(1, frequency, near, Q)) slope = np.polyfit(frequency, log_ratio, 1)[0] Q_hat = -np.pi * (far - near) / slope assert np.isclose(Q_hat, Q) travel = np.linspace(0, 60, 200) fig, axes = plt.subplots(1, 2, figsize=(10, 3.5)) for f in [1, 5, 20]: axes[0].plot(travel, attenuated_amplitude(1, f, travel, Q), label=f"{f} Hz") axes[0].set(xlabel="travel time [s]", ylabel="relative amplitude", title=f"Constant Q = {Q:.0f}") axes[0].legend() axes[1].plot(frequency, log_ratio) axes[1].set(xlabel="frequency [Hz]", ylabel="ln(A far / A near)", title=f"Spectral ratio recovers Q = {Q_hat:.0f}") fig.tight_layout() plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.210 seconds) .. _sphx_glr_download_api_gallery_seismology_plot_13_knopoff_q.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_13_knopoff_q.ipynb :alt: Launch JupyterLite :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_13_knopoff_q.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_13_knopoff_q.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_13_knopoff_q.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_