Skip to main content

Lossy compression tools for smooth data series

Project description

Lossy compression tools for smooth data series. WIP

  • Free software: MIT license

Installation

pip install limesqueezer

You can also install the in-development version with:

pip install https://github.com/limespy/limesqueezer/archive/master.zip

Documentation

Examples

limesqueezer uses numpy ndarrays types for input and output. The package itself with author-recommended abbreviation. Rest of documentation uses this abbreviation.

import numpy as np
import limesqueezer as  ls

You have some data from system of equations For example, let’s take 100 000 datapoints along some function

input_x = np.linspace(0, 1, int(1e5))
input_y = np.sin(6 * input_x * input_x)

Now you want to compress it with maximum absolute error being 1e-3.

Or maybe you have some generator-like thing that gives out numbers. E.g. some simulation step Here you use the context manager “Stream” Initialise with first values, here I am just going to use the first

Block

To simplify the interface, the package has beem made callable.

output_x, output_y = ls(input_x, input_y, tol = 1e-3)

You can also use

output_x, output_y = ls.compress(input_x, input_y, tol = 1e-3)

if that is more comfortable for you.

Stream

example_x0, example_y0 = input_x[0], input_y[0]
generator = zip(input_x[1:], input_y[1:])

The context manager for stream data is called ‘Stream’.

with ls.Stream(example_x0, example_y0, tol = 1e-3) as record:
    for example_x_value, example_y_value in generator:
        record(example_x_value, example_y_value)

Using record.x or record.y in the with statement block results in attribute error, as those attributes are generated only when the record is closed.

If you want to access the data fed to the record, you can use

x_compressed, y_compressed = record.xc, record.yc

to access the already compressed data and

x_buffered, y_buffered = record.xb, record.yb

to access the buffered data that is waiting more values or closing of the record to be compressed.

A side mote: In English language the word ‘record’ can be either verb or noun and since it performs this double role of both taking in data and being storage of the data, it is a fitting name for the object

output_x, output_y = record.x, record.y
print(record.state)
print(record.__str__)

Changelog

1.0.10 (2021-11-30)

  • Cleaned documentation

1.0.9 (2022-04-03)

  • Block and stream compression are much more uniform

  • Restructuring

  • Tests

  • Profiling

1.0.8 (2022-03-20)

  • Step-by-step style ploting of the compression.

1.0.3 (2021-11-30)

  • First release on PyPI.

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

limesqueezer-1.0.10.tar.gz (293.7 kB view hashes)

Uploaded Source

Built Distribution

limesqueezer-1.0.10-py2.py3-none-any.whl (23.2 kB view hashes)

Uploaded Python 2 Python 3

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