.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/numerical_calculus/plot_sliding_window_integration.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_numerical_calculus_plot_sliding_window_integration.py: ========================== Sliding window integration ========================== In this example a synthetic time series is generated with a certain skewness (to make it more interesting) and a use the sliding window integration with a integrand rate of 1 hour. In other words, carry out a sliding window integration of the data over 1 hour periods. .. GENERATED FROM PYTHON SOURCE LINES 12-38 .. image-sg:: /auto_examples/numerical_calculus/images/sphx_glr_plot_sliding_window_integration_001.png :alt: Sliding window integration with matching integrand rate and window :srcset: /auto_examples/numerical_calculus/images/sphx_glr_plot_sliding_window_integration_001.png :class: sphx-glr-single-img .. code-block:: default import matplotlib.pyplot as plt import numpy as np import pandas as pd from indsl.ts_utils.numerical_calculus import sliding_window_integration np.random.seed(1337) datapoints = 5000 x = np.random.randn(datapoints) y = np.zeros(len(x)) y[0] = x[0] + 100 # initial synthetic start for i in range(1, len(x)): y[i] = y[i - 1] + (x[i] + 0.0025) # and skew it upwards series = pd.Series(y, index=pd.date_range(start="2000", periods=datapoints, freq="10s")) result = sliding_window_integration(series, pd.Timedelta("1h")) plt.figure(1, figsize=[9, 7]) plt.plot(result, label="Cumulative moving window result, with matching units to raw time series data") plt.plot(series, alpha=0.6, label="Raw timeseries data") plt.legend() plt.ylabel("[-]/h") plt.title("Sliding window integration with matching integrand rate and window") _ = plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 4.154 seconds) .. _sphx_glr_download_auto_examples_numerical_calculus_plot_sliding_window_integration.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_sliding_window_integration.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_sliding_window_integration.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_