.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/filter/plot_wavelet_filter.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_filter_plot_wavelet_filter.py: ================================================== Noise removal and trending with the Wavelet filter ================================================== Example of filtering to remove noise from time series data using the Wavelet filter. We use data from volumetric flow rate (m3/h) sensor with non-uniform sampling frequency measuring measuring flow into a compressor. In the figure below it can be observed how applying different wavelet type filters can help remove some of the noise (fluctuations) from the data and such provide a more smooth an easily interpretable signal. Applying different type wavelets (db[1-20], sym[2-20] or coif[1-5]) will provide different results, but generally one will find that the lower numbered wavelets let more noise through while higher value wavelets results in a smoother signal. The same applies to wavelet decomposition level. The lower the number the more similar the result will be to the original data. Zero or negative numbers will fail and typically one will not want to choose a value higher than 6. .. GENERATED FROM PYTHON SOURCE LINES 20-62 .. image-sg:: /auto_examples/filter/images/sphx_glr_plot_wavelet_filter_001.png :alt: Noise removal effect using different type wavelets and wavelet decomposition levels :srcset: /auto_examples/filter/images/sphx_glr_plot_wavelet_filter_001.png :class: sphx-glr-single-img .. code-block:: default import os import matplotlib.pyplot as plt import pandas as pd from indsl.filter import wavelet_filter base_path = "" if __name__ == "__main__" else os.path.dirname(__file__) data = pd.read_csv(os.path.join(base_path, "../../datasets/data/vol_flow_rate_m3h.csv"), index_col=0) data = data.squeeze() data.index = pd.to_datetime(data.index) # TODO: Create load_flowrate_data method from above # Apply the filter with different settings and plot the results plt.figure(1, figsize=[9, 7]) # RAW data plt.plot(data, color="lightblue", label="RAW") # Filter applied using 'db6' wavelet and a level of 2 plt.plot( wavelet_filter(data, level=2, wavelet="db8"), color="black", linewidth=1, label="db8, level 2", ) # Filter applied using sym4 wavelet, and a level of 3 plt.plot( wavelet_filter(data, level=3, wavelet="sym4"), color="red", linewidth=1, ls="--", label="sym4, level=3", ) plt.ylabel("Vol. Flow (m3/h)") plt.title("Noise removal effect using different type wavelets and wavelet decomposition levels") _ = plt.legend(loc=2) plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 27.907 seconds) .. _sphx_glr_download_auto_examples_filter_plot_wavelet_filter.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_wavelet_filter.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_wavelet_filter.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_