Smooth real-time data streams like eye tracking or sensor input with this lightweight package.
📋 Overview
SmoothiePy is a Python library designed for smoothing real-time data streams with minimal latency. It provides a collection of filters and smoothers that can be applied to one-dimensional and two-dimensional data, making it ideal for applications such as:
- Eye tracking and gaze analysis
- Sensor data processing
- Motion tracking
- Financial data analysis
- Time series preprocessing
- Signal processing
The library is built with a focus on flexibility, performance, and ease of use, allowing you to quickly implement sophisticated data smoothing pipelines.
🚀 Installation
pip install smoothiepy
SmoothiePy requires Python 3.10 or later.
🏁 Quick Start
Here's a simple example of how to use SmoothiePy to smooth a data stream:
from smoothiepy import SmootherBuilder, ExponentialMovingAverageFilter1D
# Create a smoother with an exponential moving average filter
smoother = (
SmootherBuilder()
.one_dimensional()
.continuous()
.attach_filter(ExponentialMovingAverageFilter1D(alpha=0.2))
.build()
)
# Process data points
smoother.add(20.0)
print(f"Smoothed value: {smoother.get()}")
smoother.add(60.0)
print(f"Smoothed value: {smoother.get()}")
# Alternatively, use add_and_get to add a value and get the result in one step
smoothed_value = smoother.add_and_get(3.0)
print(f"Smoothed value: {smoothed_value}")
✨ Features
Available Filters
SmoothiePy provides a variety of filters:
One-Dimensional Filters
- Offset Filter: Adds a constant offset to the data
- Simple Moving Average: Computes the arithmetic mean over a window
- Weighted Moving Average: Applies linearly decreasing weights
- Gaussian Average: Applies a Gaussian weighting function
- Median Average: Computes the median of values in a window
- Exponential Moving Average: Applies exponential weighting
- Cumulative Moving Average: Computes the cumulative average
- Fixation Smooth Filter: Sort of Deadband filter. Specialized for fixation-like data (e.g., eye tracking)
- Multi-Pass Moving Average: Applies multiple passes of a specified moving average type
Two-Dimensional Filters
Each 1D filter is also available in a 2D version, allowing you to smooth data in two dimensions (e.g., x-y coordinates).
Many more filters are work in progress, including advanced filters like Kalman filters and more complex multidimensional filters.
Builder Pattern
SmoothiePy uses a builder pattern to create smoothers, making it easy to configure and chain multiple filters:
from smoothiepy import SmootherBuilder, SimpleMovingAverageFilter1D, GaussianAverageFilter1D
# Create a smoother with multiple filters
smoother = (
SmootherBuilder()
.one_dimensional()
.continuous()
.attach_filter(SimpleMovingAverageFilter1D(window_size=5))
.attach_filter(GaussianAverageFilter1D(window_size=3, std_dev=1.0))
.build()
)
📚 Documentation
For detailed documentation, visit the GitHub Wiki. Work in progress...
API Reference
1D Filters
OffsetFilter1D: Adds a constant offsetSimpleMovingAverageFilter1D: Simple arithmetic meanWeightedMovingAverageFilter1D: Linearly decreasing weightsGaussianAverageFilter1D: Gaussian weighting functionMedianAverageFilter1D: Median of valuesExponentialMovingAverageFilter1D: Exponential weightingCumulativeMovingAverageFilter1D: Cumulative averageFixationSmoothFilter1D: For fixation-like dataMultiPassMovingAverage1D: Multiple passes of a specified filter
2D Filters
OffsetFilter2D: Adds a constant offset in 2DSimpleMovingAverageFilter2D: Simple arithmetic mean in 2DWeightedMovingAverageFilter2D: Linearly decreasing weights in 2DGaussianAverageFilter2D: Gaussian weighting function in 2DMedianAverageFilter2D: Median of values in 2DExponentialMovingAverageFilter2D: Exponential weighting in 2DCumulativeMovingAverageFilter2D: Cumulative average in 2DFixationSmoothFilter2D: For fixation-like data in 2DMultiPassMovingAverage2D: Multiple passes of a specified filter in 2D
Builder
SmootherBuilder: Entry point for creating smoothers
📄 License
This project is licensed under the GNU Lesser General Public License v3.0 (LGPL-3.0) — see the LICENSE file in the git repo for details.
📬 Contact
Timo Seyfarth - timo@seyfarth.dev
Release files for smoothiepy 0.1.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 | |
|---|---|---|---|
| smoothiepy-0.1.1.tar.gz | 20.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| smoothiepy-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 39.3 kB
Release files / smoothiepy-0.1.1.tar.gz
| Download URL | smoothiepy-0.1.1.tar.gz |
|---|---|
| Size | 20.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
631737f875a157cbe28d84fe0fd06dfae8e900292122a59865d9adbebab0ea67
|
|
BLAKE2b-256 checksum How to use checksums |
504637cba68d3b45b86c144470d092d835ba10ab368157e992b74ffdf6ca8b2d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
pdm/2.25.4 CPython/3.10.18 Linux/6.11.0-1015-azure
|
Release files / smoothiepy-0.1.1-py3-none-any.whl
| Download URL | smoothiepy-0.1.1-py3-none-any.whl |
|---|---|
| Size | 18.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fd58455329a7ab78721840c7732aeb1a8779d5c55d7e0e3bcbc90c295e02ad67
|
|
BLAKE2b-256 checksum How to use checksums |
af98ad9c2ed6a3a6a70fefffc1925eeb7bd0db822cb8886d7bac8c20285cdc8a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
pdm/2.25.4 CPython/3.10.18 Linux/6.11.0-1015-azure
|