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 details)

Uploaded Source

Built Distribution

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

Uploaded Python 2Python 3

File details

Details for the file limesqueezer-1.0.10.tar.gz.

File metadata

  • Download URL: limesqueezer-1.0.10.tar.gz
  • Upload date:
  • Size: 293.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.2

File hashes

Hashes for limesqueezer-1.0.10.tar.gz
Algorithm Hash digest
SHA256 7add9de7fbcf44df7895e9e8e0d6cc84bb5abc4430fd7f8d68a7426da85efb50
MD5 8bf77dcf546eaf0871be226320dbcf27
BLAKE2b-256 a9406c778cdbc8efc1686b12d3fb0d41486f0a713f86237efe7dd3ea37d5f987

See more details on using hashes here.

File details

Details for the file limesqueezer-1.0.10-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for limesqueezer-1.0.10-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 a7bc7a15efbd65e17d5ef0b5ec30569cccffb30fb0e087648f4237a821cd0171
MD5 eb4d00e81f584850b580d294745eaabf
BLAKE2b-256 f872f6861e624d0799fede87ced46196b9c7db9c2a5373148f6b89dde3a42a79

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page