LiberTEM-dectris-rs
This is a Python package for efficiently receiving data from DECTRIS detectors with the zeromq interface. The low-level, high-frequency operations are performed in a background thread implemented in rust, and multiple frames are batched together for further processing in Python.
It is built for LiberTEM-live, but can also be used stand-alone.
Usage
import numpy as np
import libertem_dectris
from libertem_live.detectors.dectris.DEigerClient import DEigerClient
# trigger acquisition via the REST API, needs `libertem-live`
nimages = 256 * 256
ec = DEigerClient('localhost', 8910) # hostname and port of the DCU REST API
ec.setDetectorConfig('ntrigger', 1)
ec.setDetectorConfig('nimages', 1)
ec.setDetectorConfig('trigger_mode', 'exte')
ec.setDetectorConfig('ntrigger', nimages)
result = ec.sendDetectorCommand('arm')
sequence_id = result['sequence id']
conn = libertem_dectris.DectrisConnection(
uri="tcp://localhost:9999",
handle_path="/tmp/dectris_shm",
frame_stack_size=32,
num_slots=2000,
bytes_per_frame=512*512,
huge=False,
)
# as we have armed the detector above, we know the sequence number
# that we should expect:
# (in other cases, can also call
# `conn.start_passive` and `conn.wait_for_arm` to passively wait for
# the detector to be armed)
conn.start(sequence_id)
# any other process can use a `CamClient` to use data
# stored in the SHM:
cam_client = libertem_dectris.CamClient(conn.get_socket_path())
try:
while True:
# get at most `max_size` frames as a stack
# (might get less at the end of the acquisition)
stack_handle = conn.get_next_stack(max_size=32)
# if the receiver is idle, stack_handle will be None here:
if stack_handle is None:
break
# the expected shape and data type:
frame_shape = tuple(reversed(stack_handle.get_shape()))
dtype = np.dtype(stack_handle.get_pixel_type()).newbyteorder(
stack_handle.get_endianess()
)
# pre-allocate some memory for the pixel data:
# (would be pulled out of the loop in real code)
buf = np.zeros((len(stack_handle),) + frame_shape, dtype=dtype)
# decompress into the pre-allocated buffer
cam_client.decompress_frame_stack(stack_handle, out=buf)
# free up the shared memory slot for this frame stack:
cam_client.done(stack_handle)
# we can still use the decompressed data:
buf.sum()
finally:
conn.close() # clean up background thread etc.
cam_client.close()
Changelog
v0.3.2
- updated licensing metadata
- Be more resilient when synchronizing to the start of an acquisition (PR #111)
v0.3.1
frame_stack_sizeis not an upper limit- add parameter
max_latency_per_stackto control maximum latency
v0.3.0
- Support for recent Python versions
- Switch to abi3-py39
- Updated dependencies (pyO3 etc)
v0.2.13
- Updated dependencies and improved error handling
v0.2.12
- Refactored and unified interface - allows for more code sharing between crates
- Some robustness changes around adding timeout parameters for many top-level operations
v0.2.11
- Re-release for CI changes
v0.2.10
- Add functionality to generate mock data for sending via the simulator
- Add missing numpy dependency
- Make debug output a bit more reliable
v0.2.9
- Add more debug and trace output
v0.2.7
- Log more details in
DectrisConnection.log_shm_statsand change log level toINFO - Increase timeout for sending headers and frames
v0.2.4 - v0.2.6
- Updated examples and CI configuration
v0.2.3
- Add
env_logger: set environment variableLIBERTEM_DECTRIS_LOG_LEVELto e.g.'INFO'to enable logging - Improved error handling: raise an exception instead of panicing on serialization errors
- Ignore messages with mismatching series ID
- Add explicit checks for the correct
header_detaillevels - Move code into monorepo
v0.2.2
- Vendor
bitshuffleand addFrame.decompress_intomethod, PR #10
v0.2.1
- Catch frame ID mismatch, PR #9
v0.2.0
- Added
libertem_dectris.headerssubmodule that exports header classes - Added ways to create
libertem_dectris.Frameandlibertem_dectris.FrameStackobjects from Python, mostly useful for testing - Added binding to random port for the simulator
- Properly parametrize with zmq endpoint URI
- Fix many clippy complaints
v0.1.0
Initial release!
Metadata
Release files for libertem-dectris 0.3.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| libertem_dectris-0.3.2.tar.gz | 2.3 MB | Without provenance | Details for libertem_dectris-0.3.2.tar.gz |
Built distributions (wheels)
| File | Actions Reset | |||
|---|---|---|---|---|
| libertem_dectris-0.3.2-cp39-abi3-win_amd64.whl | CPython 3.9 | abi3 | Windows x86-64 | Details for libertem_dectris-0.3.2-cp39-abi3-win_amd64.whl |
| libertem_dectris-0.3.2-cp39-abi3-manylinux_2_28_x86_64.whl | CPython 3.9 | abi3 | Linux glibc 2.28+ x86-64 | Details for libertem_dectris-0.3.2-cp39-abi3-manylinux_2_28_x86_64.whl |
| libertem_dectris-0.3.2-cp39-abi3-macosx_11_0_x86_64.whl | CPython 3.9 | abi3 | macOS 11.0+ x86-64 | Details for libertem_dectris-0.3.2-cp39-abi3-macosx_11_0_x86_64.whl |
| libertem_dectris-0.3.2-cp39-abi3-macosx_11_0_arm64.whl | CPython 3.9 | abi3 | macOS 11.0+ ARM64 | Details for libertem_dectris-0.3.2-cp39-abi3-macosx_11_0_arm64.whl |
Total release size: 44.2 MB
Release files / libertem_dectris-0.3.2.tar.gz
| Download URL | libertem_dectris-0.3.2.tar.gz |
|---|---|
| Size | 2.3 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d0feb9a44c62b9e83ad7abb9933e90ad6f3803e938d29ced4896e89c24eea928
|
|
BLAKE2b-256 checksum How to use checksums |
c7f51d4d7b21cc5adebaa571f859a9190accc4449c288d86a08db3fba24964cf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.11.5
|
Release files / libertem_dectris-0.3.2-cp39-abi3-win_amd64.whl
| Download URL | libertem_dectris-0.3.2-cp39-abi3-win_amd64.whl |
|---|---|
| Size | 2.0 MB |
| Tags | CPython 3.9 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
18c09adf87faa5be8e6875cfb756e3154ff5c8d69e8fade714ae0e55c2e06ec5
|
|
BLAKE2b-256 checksum How to use checksums |
9a0ecffe4bedee1ff5f74e2ce0a9505122306dceaa38d676735790dc46333e72
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.11.5
|
Release files / libertem_dectris-0.3.2-cp39-abi3-manylinux_2_28_x86_64.whl
| Download URL | libertem_dectris-0.3.2-cp39-abi3-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 35.1 MB |
| Tags | CPython 3.9 Linux glibc 2.28+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
3ec645385cdbf262c17666749a09f1b6c4f4642dc040bc40c089f1a1ea7a42e3
|
|
BLAKE2b-256 checksum How to use checksums |
76fd7500e16362b56a33cd4943bb9e5480293b702893c3e2bc7cdb3382ed2bd6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.11.5
|
Release files / libertem_dectris-0.3.2-cp39-abi3-macosx_11_0_x86_64.whl
| Download URL | libertem_dectris-0.3.2-cp39-abi3-macosx_11_0_x86_64.whl |
|---|---|
| Size | 2.4 MB |
| Tags | CPython 3.9 abi3 macOS 11.0+ x86-64 |
|
SHA-256 checksum How to use checksums |
b11a353fed67dedd2a8a70a758958fd379dcf9ee55929bb9d2eeb345f0556881
|
|
BLAKE2b-256 checksum How to use checksums |
57ec536c854b005e9886668073350e44efe8fd6e8ec48913e78d15831414b55a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.11.5
|
Release files / libertem_dectris-0.3.2-cp39-abi3-macosx_11_0_arm64.whl
| Download URL | libertem_dectris-0.3.2-cp39-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 2.4 MB |
| Tags | CPython 3.9 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
51644f6e6808ea7b710871bff3e9da3d82ae3e036ac5423dfa017b8353ff27e6
|
|
BLAKE2b-256 checksum How to use checksums |
2026fec2db3b5c5118f929f38fe118f7edb43c21df7e046c5b9a225f0d999f61
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
maturin/1.11.5
|
Security for libertem-dectris 0.3.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.