Skip to main content

Recreate time-series from averaged data

Project description

Traffic Weaver

Create semi-synthetic time-series based on averaged data.

documentation

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.

Signal processing

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

traffic_weaver-1.0.0a1-py3-none-any.whl (22.8 kB view details)

Uploaded Python 3

File details

Details for the file traffic_weaver-1.0.0a1-py3-none-any.whl.

File metadata

File hashes

Hashes for traffic_weaver-1.0.0a1-py3-none-any.whl
Algorithm Hash digest
SHA256 18bc2da40ae192b3bdb758198faf9cdaa7498fd71709fc485ca9293340ebfbd8
MD5 0d614999212f28ba4501146217b7ec6e
BLAKE2b-256 8349e4efcd29e6a8c98f723c2f7ecd02e99604116ad73aaf859a842580c08ea6

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page