.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "api/gallery/seismology/plot_12_ricker_wavelet.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_12_ricker_wavelet.py: Ricker's wavelet (1953) ======================= Norman Ricker studied how a sharp seismic pulse changes shape as it travels through absorbing rock and proposed the "Mexican hat" pulse as its stable form. The wavelet has unit peak, zero mean, zero crossings at ±1/(sqrt(2) pi f) and an amplitude spectrum that peaks at f. .. GENERATED FROM PYTHON SOURCE LINES 10-35 .. image-sg:: /api/gallery/seismology/images/sphx_glr_plot_12_ricker_wavelet_001.png :alt: Ricker wavelet, Spectrum peaks at f :srcset: /api/gallery/seismology/images/sphx_glr_plot_12_ricker_wavelet_001.png :class: sphx-glr-single-img .. code-block:: Python import matplotlib.pyplot as plt import numpy as np from earthsciencekit.seismology import ricker_wavelet dt = 1e-4 time = np.arange(-0.5, 0.5, dt) fig, axes = plt.subplots(1, 2, figsize=(10, 3.5)) for f in [10, 20, 40]: pulse = ricker_wavelet(time, f) assert np.isclose(ricker_wavelet(1 / (np.sqrt(2) * np.pi * f), f), 0, atol=1e-15) assert abs(pulse.sum() * dt) < 1e-10 spectrum = np.abs(np.fft.rfft(pulse)) freq = np.fft.rfftfreq(time.size, dt) assert abs(freq[np.argmax(spectrum)] - f) <= freq[1] axes[0].plot(time, pulse, label=f"{f} Hz") axes[1].plot(freq, spectrum / spectrum.max(), label=f"{f} Hz") axes[0].set(xlim=(-0.1, 0.1), xlabel="time [s]", ylabel="amplitude", title="Ricker wavelet") axes[1].set(xlim=(0, 100), xlabel="frequency [Hz]", ylabel="normalized spectrum", title="Spectrum peaks at f") for ax in axes: ax.legend() fig.tight_layout() plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.234 seconds) .. _sphx_glr_download_api_gallery_seismology_plot_12_ricker_wavelet.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_12_ricker_wavelet.ipynb :alt: Launch JupyterLite :width: 150 px .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_12_ricker_wavelet.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_12_ricker_wavelet.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_12_ricker_wavelet.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_