.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/plot_filters.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_gallery_plot_filters.py: Filters examples ================ .. GENERATED FROM PYTHON SOURCE LINES 6-53 .. image:: /gallery/images/sphx_glr_plot_filters_001.png :alt: plot filters :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out Out: .. code-block:: none Warning in dyadlength: n != 2^J | .. code-block:: default import pandas as pd import toto from toto.filters import despike_phasespace3d,lanczos_filter,bandpass_filter import matplotlib.pyplot as plt import numpy as np # Create a panda timeseries of elevation n = 86400 signal = np.random.normal(0, 0.5, n) \ + np.sin(np.linspace(0, 5*np.pi, n))**2 signal[60000:60005]=5 signal[30000:30005]=4 timestamp= pd.date_range("2018-01-01", periods=n, freq="60s") df = pd.DataFrame({'time':timestamp,'signal':signal}).set_index('time') ## Apply a despike_phasespace3d df['phasespace3d']=despike_phasespace3d.despike_phasespace3d( df['signal'].copy()) ## Interpolate the gap df['phasespace3d']=df['phasespace3d'].interpolate() ## Apply a lanczos_filter df['lanczos_filter']=lanczos_filter.lanczos_filter( df['phasespace3d'].copy(),\ args={'window':30, 'Type':'lanczos lowpas 1st order'}) ## Apply a bandpass filter df['bandpass']=bandpass_filter.bandpass_filter( df['phasespace3d'].copy(),\ args={'lower cut-off (s)':3600*30, 'upper cut-off (s)':24*3600*30}) # Plot the results fig, ax = plt.subplots(1) ax.plot(df.index,df['signal'],label='raw') ax.plot(df.index,df['phasespace3d'],label='phasespace3d') ax.plot(df.index,df['lanczos_filter'],label='lanczos_filter') ax.plot(df.index,df['bandpass'],label='bandpass') ax.legend() #ax.set_xlim(df.index[1000],df.index[2000]) fig.autofmt_xdate() plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 3.521 seconds) .. _sphx_glr_download_gallery_plot_filters.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_filters.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_filters.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_