Skip to main content

A package to perfom real-time operations on time series data streams.

Project description

#Time Series Analysis and Signal Processing Library

Overview

This library offers a comprehensive suite of tools for time series analysis and signal processing, leveraging the power of NumPy and Numba for high performance computations. It includes functionalities for datetime manipulation, signal generation, buffer updates, moving averages, and much more. Designed for researchers and engineers working in data analysis, finance, or signal processing, this library streamlines complex numerical computations and analyses.

Features

  • Datetime Conversion: Convert between numpy.datetime64 objects and seconds since the Unix epoch.
  • Signal Generation: Create sinusoidal signals with specified parameters.
  • Buffer Management: Efficiently manage data buffers with functions to update, tick, and perform operations on buffered data.
  • Moving Averages: Calculate various forms of moving averages, including Exponential Moving Average (EMA) and Normalized EMA (NEMA).
  • Difference and Slope Calculations: Compute differences, slopes, and logarithmic returns from sequential data points.
  • Statistical Functions: Implementations of z-score, mean squared displacement (MSD), and correlation calculations.
  • Linear Regression: Perform linear regression on data points to find relationships between variables.
  • Outlier Detection: Identify outliers based on value differences, slope, and other criteria.
  • Data Downsampling: Reduce data resolution while preserving the integrity of the original signal.

Installation

To use this library, ensure that you have Python installed on your system along with the numpy and numba packages. You can install these dependencies using pip:

pip install numpy numba realtime_operator

Usage

Importing the Library

import numpy as np
import numba as nb
import realtime_operator.compression as compression
import realtime_operator.single_operator as single_operator
import realtime_operator.alignment as alignment

Converting Datetimes

dt64 = np.datetime64('2024-01-01 08:00:00')
seconds = to_utc_seconds(dt64)
print(f"UTC Seconds: {seconds}")

dt64_back = from_utc_seconds(seconds)
print(f"Back to Datetime: {dt64_back}")

Generating a Sinusoidal Signal

n = 100  # Number of points
step = 1  # Step size
amplitude = 1.0  # Amplitude of the sinusoid
shift = 0  # Phase shift
frequency = 0.1  # Frequency of the sinusoid

times, values = create_sinusoid(n, step, amplitude, shift, frequency)

Updating a Buffer and Calculating EMA

buffer = np.zeros(10)  # Example buffer
increment = 5

original_value = update_buffer(buffer, increment)
print(f"Original value: {original_value}")

tau = 10.0  # Time constant for EMA
inter = 0  # Interpolation method
t = 1.0  # Current time
z = 2.0  # Current value

time, ema_value = ema(tau, inter, buffer, t, z)
print(f"EMA Value: {ema_value}")

Performing Linear Regression

tau = 10.0
inter = 0
n = 100
buffer = np.zeros((15, 3))  # Example buffer setup
t = 1.0
x = np.random.rand(100)
y = 2.0 * x + np.random.normal(size=100)  # Generating a simple linear relationship with noise

beta = linear_regression(tau, inter, n, buffer.flatten(), t, x, y)
print(f"Beta Value: {beta}")

Contributions

Contributions to this library are welcome. Please ensure that any pull requests or issues adhere to the project's coding standards and provide tests for new functionalities.

License

This library is licensed under the MIT License. See the LICENSE file for more details.

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

realtime_operator-0.3.3.tar.gz (14.9 kB view details)

Uploaded Source

Built Distribution

realtime_operator-0.3.3-py3-none-any.whl (12.4 kB view details)

Uploaded Python 3

File details

Details for the file realtime_operator-0.3.3.tar.gz.

File metadata

  • Download URL: realtime_operator-0.3.3.tar.gz
  • Upload date:
  • Size: 14.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for realtime_operator-0.3.3.tar.gz
Algorithm Hash digest
SHA256 f21c7e926e4788589883452ce770b2d4a88a96517f574fe74c2ca2fca12ba75f
MD5 6f0257d806eb77436bd806311546a62e
BLAKE2b-256 098b457001c325241650706f0f6558491b48fa60bc2803aa47184bfb8912d0c4

See more details on using hashes here.

File details

Details for the file realtime_operator-0.3.3-py3-none-any.whl.

File metadata

File hashes

Hashes for realtime_operator-0.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 39a03eab0f1843ecbb8c115fda87d5d505260504d4b495e0966f852cdd5dc45e
MD5 698f5b68f4cae1ef479c6217c8343a0c
BLAKE2b-256 52db429e1ff23bc39195126110237d9be8f54d8c9ffbd4bc87bafece11b5415b

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