pyUTSAlgorithms
Unevenly Spaced Time Series Algorithms
Unevenly Spaced Time Series (UTS) algorithms for moving averages, rolling operators, and peak detection. This repository provides a comprehensive set of tools to handle time series where observations are not recorded at regular intervals.
This library started as a conversion of the C++ code from andreas50/utsAlgorithms. It has since been expanded with additional algorithms specifically designed for unevenly spaced data.
Features
- Exponential Moving Averages (EMA): Supports
last,next, andlinearinterpolation schemes for numerical stability in UTS. - Simple Moving Averages (SMA): Efficient rolling window averages for uneven grids using
last,next, andlinearinterpolation. - Gradient Computation: Central first and second-order derivatives, and arbitrary order derivatives via Fornberg's algorithm.
- Peak and Valley Detection:
- Basic peak/valley identification.
- Significant peaks based on Z-score, Kneedle algorithm, or peak prominence.
- Rolling Operators: Generic rolling statistics (mean, variance, max, min, product, etc.) on unevenly spaced time intervals.
- Thresholding & Z-Score: Specialized utilities (like ISODATA) for data analysis and noise reduction in UTS.
Quick Start
import numpy as np
import uts.ema as ema
# Sample unevenly spaced data: (time, value)
data = np.array([
[0.0, 10.0],
[1.5, 12.0],
[2.1, 11.0],
[4.5, 15.0],
[5.0, 14.0]
])
# Compute EMA with a tau (time constant) of 1.0 using linear interpolation
results = ema.linear(data, tau=1.0)
print("Original Data:\n", data)
print("EMA Results:\n", results)
Running Unit Tests
Several unit tests were written to validate corner cases and ensure accuracy. The unit tests use the standard unittest framework.
python -m unittest
Documentation
The library is documented using Google-style docstrings. Detailed API documentation is available here.
To generate the documentation locally:
pip install pdoc
pdoc --math -d google -o docs src/uts
Installation
From PyPI
Install the latest version directly from PyPI:
pip install pyUTSAlgorithms
From Source
To install the library locally:
python3 -m venv venv
source venv/bin/activate
pip install --upgrade pip
pip install .
Authors
- Mário Antunes - mariolpantunes
License
This project is licensed under the MIT License - see the LICENSE file for details.
MIT License
Copyright (c) 2020 Mário Antunes
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Metadata
Release files for pyUTSAlgorithms 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| pyutsalgorithms-0.2.1.tar.gz | 15.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pyutsalgorithms-0.2.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 30.6 kB
Release files / pyutsalgorithms-0.2.1.tar.gz
| Download URL | pyutsalgorithms-0.2.1.tar.gz |
|---|---|
| Size | 15.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cf628becc03a5d2c6326bcf9931ada86b2ecc0843f68470a27a0ab288d76f908
|
|
BLAKE2b-256 checksum How to use checksums |
eefc5e8feaa5148b11119420e8f053771e3a5987ad72500f660cf9d263306448
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Release files / pyutsalgorithms-0.2.1-py3-none-any.whl
| Download URL | pyutsalgorithms-0.2.1-py3-none-any.whl |
|---|---|
| Size | 15.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
03f81d791737c3c73f0ea04767ab7769cc3d617bed81948201ef78529fc87d8d
|
|
BLAKE2b-256 checksum How to use checksums |
8e8bbb89d7fb29925d688c6dcefb91cfbf36c7840f15b2d08371785b726f968a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Security for pyUTSAlgorithms 0.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.