Skip to main content

Time series synchronization and resample library.

Project description

What is syncing?

syncing is an useful library to synchronise and re-sample time series.

Synchronization is based on the fourier transform and the re-sampling is performed with a specific interpolation method.

Installation

To install it use (with root privileges):

$ pip install syncing

Or download the last git version and use (with root privileges):

$ python setup.py install

Install extras

Some additional functionality is enabled installing the following extras:

  • cli: enables the command line interface.

  • plot: enables to plot the model process and its workflow.

  • dev: installs all libraries plus the development libraries.

To install syncing and all extras (except development libraries), do:

$ pip install syncing[all]

Synchronising Laboratory Data

This example shows how to synchronise two data-sets obd and dyno (respectively they are the On-Board Diagnostics of a vehicle and Chassis dynamometer) with a reference signal ref. To achieve this we use the model syncing model to visualize the model:

>>> from syncing.model import dsp
>>> model = dsp.register()
>>> model.plot(view=False)
SiteMap(...)

[graph]

Tip: You can explore the diagram by clicking on it.

First of all, we generate synthetically the data-sets to feed the model:

>>> import numpy as np
>>> data_sets = {}
>>> time = np.arange(0, 150, .1)
>>> velocity = (1 + np.sin(time / 10)) * 60
>>> data_sets['ref'] = dict(
...     time=time,                                               # [10 Hz]
...     velocity=velocity / 3.6                                  # [m/s]
... )
>>> data_sets['obd'] = dict(
...     time=time[::10] + 12,                                    # 1 Hz
...     velocity=velocity[::10] + np.random.normal(0, 5, 150),   # [km/h]
...     engine_rpm=np.maximum(
...         np.random.normal(velocity[::10] * 3 + 600, 5), 800
...     )                                                        # [RPM]
... )
>>> data_sets['dyno'] = dict(
...     time=time + 6.66,                                        # 10 Hz
...     velocity=velocity + np.random.normal(0, 1, 1500)         # [km/h]
... )

To synchronize the data-sets and plot the workflow:

>>> from syncing.model import dsp
>>> sol = dsp(dict(
...     data=data_sets, x_label='time', y_label='velocity',
...     reference_name='ref', interpolation_method='cubic'
... ))
>>> sol.plot(view=False)
SiteMap(...)

[graph]

Finally, we can analyze the time shifts and the synchronized and re-sampled data-sets:

>>> import pandas as pd
>>> import schedula as sh
>>> pd.DataFrame(sol['shifts'], index=[0])
     obd  dyno
...
>>> df = pd.DataFrame(dict(sh.stack_nested_keys(sol['resampled'])))
>>> df.columns = df.columns.map('/'.join)
>>> df['ref/velocity'] *= 3.6
>>> ax = df.set_index('ref/time').plot(secondary_y='obd/engine_rpm')
>>> ax.set_ylabel('[km/h]'); ax.right_ax.set_ylabel('[RPM]')
Text(...)
setup-7c9t785u/pypi-1.*

Project details


Download files

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

Source Distribution

syncing-1.0.7.tar.gz (63.6 kB view details)

Uploaded Source

Built Distribution

syncing-1.0.7-py2.py3-none-any.whl (19.0 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file syncing-1.0.7.tar.gz.

File metadata

  • Download URL: syncing-1.0.7.tar.gz
  • Upload date:
  • Size: 63.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.9.1

File hashes

Hashes for syncing-1.0.7.tar.gz
Algorithm Hash digest
SHA256 9772461153e3fc3ab865e78da7b8e9e215ca762fda83a51baea0401513e67517
MD5 afd233e936459baba06b3d5cab89d19f
BLAKE2b-256 01e51d3269d84cfed9c0482ba5e0c5e57a5f98794d62c860d730ab1703be6312

See more details on using hashes here.

File details

Details for the file syncing-1.0.7-py2.py3-none-any.whl.

File metadata

  • Download URL: syncing-1.0.7-py2.py3-none-any.whl
  • Upload date:
  • Size: 19.0 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.9.1

File hashes

Hashes for syncing-1.0.7-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 bb33804c3c9be1a3b85e616ff5b6220022d820f27b6acb73e47d45e4444e83c0
MD5 5801796d70a7e0d3fcd080f803fc54a9
BLAKE2b-256 ed99496532fdc800a86f580aeca872b7106a4615d5135d291c1771bf2db5428f

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