Recreate time-series from averaged data
Project description
Traffic Weaver
Create semi-synthetic time-series based on averaged data.
Description
General scope of Traffic Weaver is to read averaged time series averaged and to create semi-synthetic signal with finner granularity that after averaging matches the original signal provided. Following tools are applied to recreate the signal.
- Oversampling with a given strategy
- Stretched to match the integral of the original time series
- Smoothing
- Repeating
- Applying trend
- Adding noise
Below figure illustrates the processing example. Based on provided original averaged time series (a), signal is n-times oversampled with predefined strategy how to approximate intermediate points (b). Next, it is stretched to match integral of the original function (c). Further, it can be smoothened with spline function (d). Signal can be repeated several times (e) to apply certain long-term trend (f). Finally, noise can be introduced to signal (g). (h) presents averaged two periods of created signal to show that they match the original signal.
Getting Started
Installation
Install package with pip.
pip install traffic_weaver
Minimal processing example
from traffic_weaver import Weaver
from traffic_weaver.datasets import load_mobile_video
from traffic_weaver.utils import add_one_sample
import matplotlib.pyplot as plt
# load exemplary dataset
x, y = load_mobile_video()
# add one sample to the end as file contains averaged values for time intervals
x, y = add_one_sample(x, y, make_periodic=True)
wv = Weaver(x, y)
# plot original time series
fig, axes = plt.subplots()
axes.plot(*wv.get(), drawstyle='steps-post')
plt.show()
# process time series
wv.oversample(10).integral_match().smooth(s=0.2).repeat(4).trend(
lambda x: 0.5 * x).noise(snr=60)
# plot modified time series
fig, axes = plt.subplots()
axes.plot(*wv.get())
plt.show()
# get time series processed data
x, y = wv.get()
# or get them as a spline function to sample any arbitrary point
f = wv.to_function()
# get value at 0.5
yi = f(0.5)
License
This project is licensed under the MIT License - see the LICENSE.md file for details
Acknowledgments
TBD
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
File details
Details for the file traffic_weaver-1.0.0a1-py3-none-any.whl
.
File metadata
- Download URL: traffic_weaver-1.0.0a1-py3-none-any.whl
- Upload date:
- Size: 22.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 18bc2da40ae192b3bdb758198faf9cdaa7498fd71709fc485ca9293340ebfbd8 |
|
MD5 | 0d614999212f28ba4501146217b7ec6e |
|
BLAKE2b-256 | 8349e4efcd29e6a8c98f723c2f7ecd02e99604116ad73aaf859a842580c08ea6 |