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.6-cp311-cp311-win_amd64.whl (577.5 kB view details)

Uploaded CPython 3.11Windows x86-64

pyterse-0.1.6-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.6-cp311-cp311-macosx_11_0_arm64.whl (1.1 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

pyterse-0.1.6-cp310-cp310-win_amd64.whl (576.8 kB view details)

Uploaded CPython 3.10Windows x86-64

pyterse-0.1.6-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.6-cp310-cp310-macosx_11_0_arm64.whl (1.1 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

pyterse-0.1.6-cp39-cp39-win_amd64.whl (574.7 kB view details)

Uploaded CPython 3.9Windows x86-64

pyterse-0.1.6-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.6-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.6-cp311-cp311-win_amd64.whl.

File metadata

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

File hashes

Hashes for pyterse-0.1.6-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 1a23d2a400ead87838605c805e678758b5dc6710c71988862319d48d9f34b516
MD5 c5349a6559e78b61079da69c7deb6bb0
BLAKE2b-256 26d2c55ce7f81c4c24d39d7556c77ddc22ba6d4be8422b5b3abf6b7859da9556

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyterse-0.1.6-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 31d400541c24866c80f587fa1385dd83f7c627030aeeab9a6ed7ef87a6e39616
MD5 7c0a445f455a0abf14cec2fa8cfe9c6c
BLAKE2b-256 62a5aec03fdb3ac79b0a8d985256a6109ed27ed89084812531b551fc12f75166

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyterse-0.1.6-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c1d553b869869c364784ff3b6fb142134462e368fcc7a3dc8fa815309325ac8d
MD5 31243c2ad3195976e08329c9ab584075
BLAKE2b-256 c7a8a2b71ab8d98694c9fb880f9861ecd1cd30a93a39d3e0d6971e07f45453e4

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for pyterse-0.1.6-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 dbf4a5408e18a5176b889d3354f931991cd7705e94f20991d6fb7dc525c47430
MD5 cea093b9e818cc2f2b08fe898529a0b5
BLAKE2b-256 2e9b02cfeee65b64fdce7c7fbd11253c5f7e6c4c5ddd8be80a61724246860043

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyterse-0.1.6-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3c12323c1eb4abb4cf882a7bb967e52b35dace75aa922ddce74672c59fd5eca7
MD5 819edddc205f0d4e98edbe8d226abc83
BLAKE2b-256 fc45ccfd58857fd4f842e19957e4c665f9423771ee908fdc5374aa323b705b9d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyterse-0.1.6-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 17854cd9f18361fcc2646ec0b08e3fbb38b6e8a45b6b46b48feb57a9a510cbca
MD5 3b6daf5f1f8b38ba18141997d02bebdc
BLAKE2b-256 5a34172d364caeba1963d1a4ec898af041c3020db459d1e14645d27cea851ae4

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for pyterse-0.1.6-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 e550171f1d3247db8be977f07711d4b7085d51f318a16ed1c65b0c2be6f849bd
MD5 282b2e4e02a771e2a8a26235b47b8f61
BLAKE2b-256 f159440f0fdccbe88ab71c2085bace0108834a9fdd8d8dba40ba98695ffd177f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyterse-0.1.6-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0de045f0204d05759094ccfe56e8dda46e6d0d6547eda45b96da09a05aa97dc4
MD5 715cfc4c68bf5c9f397dfe0be65eb403
BLAKE2b-256 5b84d35c6a49e8f63f36aca95a462506f0e7b2b859aef2ef3a63d8cb347269ae

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyterse-0.1.6-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2fe9f7065b2cdfccf70104db56ff5bde892a3124fecf5a581aeac8bdf59848c1
MD5 a5692bcfd3a54c836c529c7306f1ef4b
BLAKE2b-256 a6653ba9c502c12241bd78e15cf814f65d0f072116f228f99deb3a2e944a07dc

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