Skip to main content

A Python interface for the TRPX compression algorithm

Project description

Pyterse python package

Next generation TERSE/PROLIX diffraction data compression algorithm

The pyterse python package provides Python bindings for the C++ TERSE/PROLIX(TRPX) compression algorithm scheme (https://github.com/senikm/trpx).

Prerequisites

Before using pyterse, ensure your data meets these requirements:

  • Signed or unsigned integral type data
  • Grayscale data
  • Preferably has high dynamic range

Installation

Create a virtual environment:

conda create -n pyterse python pip numpy pillow

Install the package:

pip install pyterse

Usage guide

Basic operations

Creating a Terse object

There are multiple ways to create a Terse object:

import pyterse

# Empty constructor
terse = pyterse.Terse()

# From NumPy array
terse = pyterse.Terse(data)  # data can be nD NumPy array or slice

# With custom compression mode
terse = pyterse.Terse(data, pyterse.TerseMode.SIGNED)  # Available modes: SIGNED, UNSIGNED, SMALL_UNSIGNED, DEFAULT

Inserting and managing data

Add data to an existing Terse object:

# Append data at the end
terse.push_back(data)  # Data must match existing shape (terse.dim())

# Insert at specific position
terse.insert(pos, data)  # pos is the frame index

File operations

Save and load compressed data:

# Save to file
terse.save('filename.trpx')

# Load from file
loaded_terse = pyterse.Terse.load('filename.trpx')

Data Decompression

Decompress data:

# Decompress all data
decompressed_data = terse.prolix()

# Decompress specific frame
frame = terse.at(0)
decompressed_frame = frame.prolix()

Metadata Management

# Set metadata for a frame
terse.set_metadata(frame, "metadata string")

# Get metadata from a frame
metadata = terse.metadata(frame)

Utility Methods

# Data information
terse.size()              # Number of elements per frame
terse.dim()               # Dimensions of one frame
terse.number_of_frames()  # Number of frames
terse.number_of_bytes()   # Size in bytes of compressed data
terse.bits_per_val()      # Bits used per value
terse.is_signed()         # Whether data is signed

# Data management
terse.erase(pos)          # Remove frame at position
terse.shrink_to_fit()     # Optimize memory usage

# Compression settings
terse.set_block_size(size)  # Set compression block size (before adding frames)
terse.set_fast(bool)        # Toggle fast compression mode
terse.set_small(bool)       # Toggle small data optimization
terse.set_dop(value)        # Set degree of parallelism (0.0 to 1.0)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pyterse-0.1.5-cp311-cp311-win_amd64.whl (316.1 kB view details)

Uploaded CPython 3.11Windows x86-64

pyterse-0.1.5-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

pyterse-0.1.5-cp311-cp311-macosx_11_0_arm64.whl (510.3 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

pyterse-0.1.5-cp310-cp310-win_amd64.whl (315.6 kB view details)

Uploaded CPython 3.10Windows x86-64

pyterse-0.1.5-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

pyterse-0.1.5-cp310-cp310-macosx_11_0_arm64.whl (508.9 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

pyterse-0.1.5-cp39-cp39-win_amd64.whl (313.4 kB view details)

Uploaded CPython 3.9Windows x86-64

pyterse-0.1.5-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

pyterse-0.1.5-cp39-cp39-macosx_11_0_arm64.whl (509.0 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

File details

Details for the file pyterse-0.1.5-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: pyterse-0.1.5-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 316.1 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for pyterse-0.1.5-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 49778ee47f47ae9d9128445a61019e6c5fb846c000e644c8f17cfee371f7afc5
MD5 f7c80fc32f0f893e4c507073f64d8d5e
BLAKE2b-256 8e93b3498e0c297b6f0d92ea9d99a97b57fcc654f096b498b6b035f97b1b81f3

See more details on using hashes here.

File details

Details for the file pyterse-0.1.5-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyterse-0.1.5-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7c178b3964d89a92206a0b007461b509e27dac30611b1bf46854a6b711f8a2b2
MD5 90e4766020cafbd2e2fd4314112a664b
BLAKE2b-256 67763cf17fae39110b56f1c0ea1a75d7e93d0f8a6a0618411490d6d7968c37c8

See more details on using hashes here.

File details

Details for the file pyterse-0.1.5-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyterse-0.1.5-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e06b5fb4ad351787824c59d4b3d26f9dbc3c23f651e8eb7fe71c8dda01357919
MD5 cbe74066e5903d1db9a3e839a7df2ac8
BLAKE2b-256 2bde0cc2013b088cb8e9e1002f2311fe27ac4bda76fd7389e70c8363fc77ded0

See more details on using hashes here.

File details

Details for the file pyterse-0.1.5-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: pyterse-0.1.5-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 315.6 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for pyterse-0.1.5-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 49f6a99e31a57aeeaa0cfc221ab44dbfa559dfb7b8cb2f1afa71c1e2b3cf64a4
MD5 db5519ff31354782d62a785d902d838d
BLAKE2b-256 638b8b4df8fdb4b5cd1c481cdd3b8395aaf525662c1480bd6af59508bcc8b072

See more details on using hashes here.

File details

Details for the file pyterse-0.1.5-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyterse-0.1.5-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 e5d7017f583877e890c4a36c4468f4a70cf21c235abe57b26f20a792f002b091
MD5 a411b5b1e5b14562539a0f415917c1ef
BLAKE2b-256 d0d7ec7d8b86b89ab8d8ce63306976a3ce230847588b4bdf1357d1292c31fa7b

See more details on using hashes here.

File details

Details for the file pyterse-0.1.5-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyterse-0.1.5-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 240facdec83b464fb2312fbcc952fb0c4733a6ecf5743c01a6e4351850844842
MD5 5b07742c7c24decb9788dc43c9ac5857
BLAKE2b-256 d3624c1bd20bdec51d80392b354c236d0ea448febd192aadafc33b3f100b27c8

See more details on using hashes here.

File details

Details for the file pyterse-0.1.5-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: pyterse-0.1.5-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 313.4 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for pyterse-0.1.5-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 47e58929bf2b8d4e34fd484171f2885d885dcd34de222e5d3a3942ac51fc8a20
MD5 16eb254672971234d8bd9204eea50fdd
BLAKE2b-256 cea7633e13b073a8003b4947c561af3f5bd271ddbaf97d0be9636377194ddd19

See more details on using hashes here.

File details

Details for the file pyterse-0.1.5-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyterse-0.1.5-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 bff98da23210cdf4c25faab362ed2ec9c14bf5e60b83af97cbf0683cf2eb3066
MD5 fd56af6feaad89edbae99f4f9d10c96d
BLAKE2b-256 42403ae0b15724a19fc7dc75ae25712b78d3c29e729474b738981c541b20ef5c

See more details on using hashes here.

File details

Details for the file pyterse-0.1.5-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyterse-0.1.5-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b26c5cbbb46aea7577e4f2344b3521a2725333cc333240ed84d6fdc83f77d9ae
MD5 5c14fa44e8cc06d4c122764b0902a687
BLAKE2b-256 228c49e3737b25663695904d12f48d4a3fafa95a91e1000f98b53d6aaf1e1fba

See more details on using hashes here.

Supported by

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