.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_auto_examples/plot_freq_calibration.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. .. rst-class:: sphx-glr-example-title .. _sphx_glr__auto_examples_plot_freq_calibration.py: Frequency-dependent calibration =============================== An example of how to use the frequency-dependent calibration functionality .. GENERATED FROM PYTHON SOURCE LINES 7-47 .. rst-class:: sphx-glr-horizontal * .. image-sg:: /_auto_examples/images/sphx_glr_plot_freq_calibration_001.png :alt: plot freq calibration :srcset: /_auto_examples/images/sphx_glr_plot_freq_calibration_001.png :class: sphx-glr-multi-img * .. image-sg:: /_auto_examples/images/sphx_glr_plot_freq_calibration_002.png :alt: Sensitivity of the RTSys hydrophone :srcset: /_auto_examples/images/sphx_glr_plot_freq_calibration_002.png :class: sphx-glr-multi-img * .. image-sg:: /_auto_examples/images/sphx_glr_plot_freq_calibration_003.png :alt: plot freq calibration :srcset: /_auto_examples/images/sphx_glr_plot_freq_calibration_003.png :class: sphx-glr-multi-img .. code-block:: Python import scipy.signal as sig import pathlib import pyhydrophone as pyhy import soundfile as sf import numpy as np import matplotlib.pyplot as plt rtsys_name = 'RTSys' rtsys_model = 'RESEA320' rtsys_serial_number = 2003001 rtsys_sens = -180 rtsys_preamp = 0 rtsys_vpp = 5 mode = 'lowpower' calibration_file = pathlib.Path("./../tests/test_data/rtsys/SN130.csv") rtsys = pyhy.RTSys(name=rtsys_name, model=rtsys_model, serial_number=rtsys_serial_number, sensitivity=rtsys_sens, preamp_gain=rtsys_preamp, Vpp=rtsys_vpp, mode=mode, calibration_file=calibration_file) wav_path = './../tests/test_data/rtsys/channelA_2021-10-11_13-11-09.wav' wav, fs = sf.read(wav_path) frequencies, spectrum = sig.welch(wav, nfft=1024, scaling='density', fs=fs) spectrum_db = 10 * np.log10(spectrum) spectrum_db_upa = spectrum_db + rtsys.end_to_end_calibration() frequency_increment = rtsys.freq_cal_inc(frequencies) spectrum_db_upa_corrected = spectrum_db_upa + frequency_increment['inc_value'] plt.figure() rtsys.freq_cal.plot('frequency', 'sensitivity') plt.ylabel('sensitivity [db re 1V/upa]') plt.title('Sensitivity of the RTSys hydrophone') plt.show() plt.figure() plt.plot(frequencies, spectrum_db_upa, label='not corrected') plt.plot(frequencies, spectrum_db_upa_corrected, label='corrected') plt.legend() plt.ylabel('Spectrum density [db re 1 upa**2/Hz]') plt.xlabel('Frequency [Hz]') plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.129 seconds) .. _sphx_glr_download__auto_examples_plot_freq_calibration.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_freq_calibration.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_freq_calibration.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_freq_calibration.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_