No project description provided
Project description
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.
Decoding of compressed frames is not (yet) handled in this package, but may be added later.
Usage
import libertem_dectris
from libertem_live.detectors.dectris.DEigerClient import DEigerClient
# trigger acquisition via the REST API, needs `libertem-live`
nimages = 512 * 512
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']
frames = libertem_dectris.FrameChunkedIterator(uri="tcp://localhost:9999")
# start to receive data for the given series
# (can be called multiple times on the same `FrameChunkedIterator` instance)
frames.start(series=sequence_id)
try:
while True:
# get at most `max_size` frames as a stack
# (might get less at the end of the acquisition)
stack = frames.get_next_stack(max_size=32)
for i in range(len(stack)):
frame = stack[i]
# do something with the frame; compression
# is not handled in this module (yet)
image_data_bytes = frame.get_image_data()
shape = frame.get_shape()
encoding = frame.get_encoding()
frame_id = frame.get_frame_id()
if len(stack) == 0:
break
finally:
frames.close() # clean up background thread etc.
Changelog
v0.2.1
- Catch frame ID mismatch, PR #9
v0.2.0
- Added
libertem_dectris.headers
submodule that exports header classes - Added ways to create
libertem_dectris.Frame
andlibertem_dectris.FrameStack
objects 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!
Development
This package is using pyo3 with
maturin to create the Python bindings. First, make sure
maturin
is installed in your Python environment:
(venv) $ pip install maturin
Then, after each change to the rust code, run maturin develop -r
to build and
install a new version of the wheel.
Release
- update changelog above
- bump version in Cargo.toml if not already bumped, and push
- create a release from the GitHub UI, creating a new tag vX.Y.Z
- done!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for libertem_dectris-0.2.1-cp37-abi3-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2a3324862d1d66e836351154b943cb93f54893cce06a575900fff4217d7923b3 |
|
MD5 | 11065cc164c455d33d34e91e3f965af9 |
|
BLAKE2b-256 | d8c232b887f2e0d08f4b102c62df1e24ea84747f9aac2e3e4773b7be4d6ef0e8 |
Hashes for libertem_dectris-0.2.1-cp37-abi3-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 246cecf134d05148571f9bf91449958e7e36d48f2fb6103fc3312230b1bb33a9 |
|
MD5 | 92453e71ade5139137f93ba141f32e29 |
|
BLAKE2b-256 | 478d34c198fb7e497a2ccbf1502b539ebdfd3340edd146e2efbec9a0ecbc42b9 |
Hashes for libertem_dectris-0.2.1-cp37-abi3-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8ab53f665ab2ffa8ea3fb1debdcccfc3446eea9032a1c34a968fcf0932123a3c |
|
MD5 | fcc970caa62c780a1b178ac2b7314cdb |
|
BLAKE2b-256 | 4084029e381a5da214d93157d9f13513b67ee89dd8b4d2f9c01f2ad0b637d55f |