.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/detect/plot_oscillation_detection.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_detect_plot_oscillation_detection.py: =============================== Oscillation detection using linear predictive coding =============================== Identifies if a signal contains one or more oscillatory components. Based on the paper by Sharma et. al. [#]_. .. GENERATED FROM PYTHON SOURCE LINES 9-53 .. rst-class:: sphx-glr-horizontal * .. image-sg:: /auto_examples/detect/images/sphx_glr_plot_oscillation_detection_001.png :alt: Signal, Power Spectral Density, LPC Roots in z-plane :srcset: /auto_examples/detect/images/sphx_glr_plot_oscillation_detection_001.png :class: sphx-glr-multi-img * .. image-sg:: /auto_examples/detect/images/sphx_glr_plot_oscillation_detection_002.png :alt: Correlation coefficient, Normalized FFT magnitude spectrum, Power Spectral Density :srcset: /auto_examples/detect/images/sphx_glr_plot_oscillation_detection_002.png :class: sphx-glr-multi-img * .. image-sg:: /auto_examples/detect/images/sphx_glr_plot_oscillation_detection_003.png :alt: frequency regions where oscillation detected :srcset: /auto_examples/detect/images/sphx_glr_plot_oscillation_detection_003.png :class: sphx-glr-multi-img .. rst-class:: sphx-glr-script-out .. code-block:: none /Users/vebjorngilberg/Documents/work/cognite/repos/indsl/indsl/detect/oscillation_detector.py:580: UserWarning: The figure layout has changed to tight fig.tight_layout() | .. code-block:: default import os import matplotlib.pyplot as plt import numpy as np import pandas as pd from indsl.detect.oscillation_detector import helper_oscillation_detector, oscillation_detector # brownian noise wave signal base_path = "" if __name__ == "__main__" else os.path.dirname(__file__) data = pd.read_csv(os.path.join(base_path, "../../datasets/data/brownian_noise_wave.csv"), index_col=0).squeeze( "columns" ) # convert str to datetime data.index = pd.to_datetime(data.index) # call oscillation detector function results = oscillation_detector(data) # output dictionary dict_output = helper_oscillation_detector(data) # plot the results fig, ax = plt.subplots(1, 1, figsize=[10, 5]) ax.plot( results.index, results.values, color="blue", linestyle="dashed", linewidth=1, markersize=1, marker=".", ) ax.set_xlabel("freq (Hz)") ax.set_ylabel("detection (1: detected, 0: no detection)") ax.set_title("frequency regions where oscillation detected") ax.plot(results.index[np.where(results.values == 1)], 1, "go", markersize=8, alpha=0.5) plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.941 seconds) .. _sphx_glr_download_auto_examples_detect_plot_oscillation_detection.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_oscillation_detection.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_oscillation_detection.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_