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

# Dimensions of one frame
terse.dim()
 
# Data information
terse.size              # Number of elements per 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.7-cp311-cp311-win_amd64.whl (573.7 kB view details)

Uploaded CPython 3.11Windows x86-64

pyterse-0.1.7-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (1.6 MB view details)

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

pyterse-0.1.7-cp311-cp311-macosx_11_0_arm64.whl (1.2 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

pyterse-0.1.7-cp310-cp310-win_amd64.whl (573.1 kB view details)

Uploaded CPython 3.10Windows x86-64

pyterse-0.1.7-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (1.6 MB view details)

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

pyterse-0.1.7-cp310-cp310-macosx_11_0_arm64.whl (1.1 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

pyterse-0.1.7-cp39-cp39-win_amd64.whl (577.4 kB view details)

Uploaded CPython 3.9Windows x86-64

pyterse-0.1.7-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (1.6 MB view details)

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

pyterse-0.1.7-cp39-cp39-macosx_11_0_arm64.whl (1.1 MB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

File details

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

File metadata

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

File hashes

Hashes for pyterse-0.1.7-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 289df0efb3e1569794309684f5b17582afebcb1529cae94c44bd2cb8242e8a26
MD5 8c44cf3ced593d4b233ef80e15e45cb5
BLAKE2b-256 9ed9e7f47e682cdaf14c93734cf205ad41cd5f177fce127e4ea66e94edd73aeb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyterse-0.1.7-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 04288236aacfd03a79e35229fb6f01d799ad5f8b84bbb773803429c9515bb0d5
MD5 a535721c1ccde1048208655f03267bb2
BLAKE2b-256 f8090012d679fa20dba001959a2aa1d48f1c772d4a4fac20fa89fb422b05f77b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyterse-0.1.7-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fb88474aec07a09d4385abe0ac48765afffc82bd1cc92d2786b5ce990e1949b8
MD5 eec09ac66d6c8919a6a26e29f610b201
BLAKE2b-256 f5d12a988121481e013ba074cef768ce13cc2ffd3cd412396379e5735a9689f3

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for pyterse-0.1.7-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 9d485bcda596a616863b8e54c5fc9a896b76dbb80db539c4db6dd5939aa19759
MD5 2e753f069739454091e1a5e9d3c99fd3
BLAKE2b-256 dc29e4f9cb0bd5b013290e6fcd8da04866f97722657dbe40878550b504676d14

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyterse-0.1.7-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7927cffaed804157186f87ee82a34d0ab0c570ee1aeb38007a26f2fd4699ccee
MD5 f7aa83e299bd9a313271f1a58191c824
BLAKE2b-256 ba0abb287252a46638f5e59aa2d0567706d2691c119ef55a845a7f648a4e576f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyterse-0.1.7-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 79ed9535793ccb2c73d8072998e9908a6a7ce180a518156defe8b74e1a5f2541
MD5 d35c4a6f7bc1667ed40f5e219df4df3b
BLAKE2b-256 45b94180624440ea8134d47e0a2d40cab9067a2d8d57b4a031ffef181e314839

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for pyterse-0.1.7-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 e4ba91e5b4b13bfd161c01bdbc46a9761ae3f1ed39cba7917ad200f7c3710e17
MD5 3150dd9b39eddaf08583ecd2a2a10525
BLAKE2b-256 da86eec6cacd069be4e30bd8ade6abab55faba9c76395768571421b726865a53

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyterse-0.1.7-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 76453eccaeb911c2a9ce7839c4452990d65b5626e1251c0acc23cb1e902154b6
MD5 c5d361be8cf50d2ac4ca81e62827cb40
BLAKE2b-256 e21349b48a1e8e035025595014ee144e6c10cec25b13f3bb5dadcb48548a32c9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyterse-0.1.7-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f2ff5cec6d5ce10545ab2c887c4ce2c075cf7ec62d218c998a903df82607996f
MD5 fbc1c19c28fb70e327fda6e9ab5b1b41
BLAKE2b-256 c5503dba1f3085b3f4b79960b67fffef014923118abd1f04ba7af7a3a3c8cc90

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