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.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 Distribution
Built Distribution
File details
Details for the file traffic_weaver-1.1.0a1.tar.gz
.
File metadata
- Download URL: traffic_weaver-1.1.0a1.tar.gz
- Upload date:
- Size: 20.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 06e1fa2a07cffb53960a59cdc417781e4e917d8b79f51c738e4fec4fcc7654cb |
|
MD5 | fc9d5c5f3c2f4a416ad625560059aebb |
|
BLAKE2b-256 | 95682c2e11c719ba2675b5dbe45cda7cbc0911649373301f1a2594b3e10d5c52 |
File details
Details for the file traffic_weaver-1.1.0a1-py3-none-any.whl
.
File metadata
- Download URL: traffic_weaver-1.1.0a1-py3-none-any.whl
- Upload date:
- Size: 22.0 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 | e85644c0e9a8fa5070b1a0199965f7a4c9b9a6f1be86ca9502d4d62e27f12d2a |
|
MD5 | b871554ae3591561ff2cb0aaac1ae99c |
|
BLAKE2b-256 | e3bec0890a444c09c8c795c8e7d3a95d93040c8c388ff250173eddb7ff90ed28 |