Python API — MiniPixCtrl
Initialization and connection
MiniPixCtrl(logger, log_level=None) requires a logger; None raises ValueError. log_level is stored but is not used to configure the logger in the supplied implementation. connect() -> bool calls pypixet.start() and selects pixet.devices()[0]. It returns False for an empty device list or FileDevice 0. Device information is logged, but no serial-number filtering is performed.
disconnect() attempts to stop an active acquisition and shuts down PIXet. connect() does not automatically configure mode, bias, or threshold.
Detector settings
Method |
Argument |
Implementation |
|---|---|---|
|
|
Maps to |
|
keV |
|
|
MHz |
|
|
V |
|
Each returns True on success and False on an SDK error. The class does not automatically reproduce the detector’s factory settings (10.0 MHz clock and a THL DAC value around 691 for 5 keV).
Acquisition API
acquire(count, sec, acquisition_type="frames", callback=None,
save_format=None, save_path=None)
acquire_frames(count, sec, callback=None, save_format=None, save_path=None)
acquire_integral(count, sec, callback=None, save_format=None, save_path=None)
count is the acquisition count passed to the SDK; sec is the exposure duration per acquisition. Only frames and integral are accepted. Calls are synchronous. For Frames, a completion event is used when a callback, TIFF, or HDF5 output is requested; otherwise frames are read after acquisition. Integral uses PIXet’s doSimpleIntegralAcquisition() and does not sum frames in Python. Its frame_count is the number of stored integrated images, not necessarily the requested count.
The return dictionary includes rc, acquisition_type, frame_count, frames, and saved_file. Each frame has name, width, height, data (a NumPy array), minimum, maximum, nonzero, and subframes. data is not a JSON-ready list.
Frame history, state, and stopping
Method |
Meaning |
|---|---|
|
Number of frames stored in Python |
|
Indexed Python history frame |
|
Shallow copy of the history list |
|
Latest frame or |
|
Clear Python history |
|
Frame count in the PIXet SDK |
|
All or one frame from the SDK |
|
Call |
|
SDK acquisition state |
|
State, requested/completed counts, history count, last error |
For Frames, state()["finished_count"] is the number of stored frames; after a successful Integral acquisition, it is set to the requested count. Do not confuse it with state()["frame_count"]. Thread-safety of stopping from another thread requires hardware testing.
Output and exceptions
Save formats are NONE, TIFF, HDF5, and PIXET_NATIVE (case-normalized); "PIXET NATIVE" is also accepted. TIFF writes individual frame_000001.tiff files. HDF5 appends to the frames dataset and flushes. Integral stores only the final image. PIXet-native output delegates to the SDK using PX_FTYPE_AUTODETECT; this class does not specify its internal format.
Invalid save formats or missing save paths raise ValueError; an unconnected device raises RuntimeError; SDK acquisition failures normally raise RuntimeError. Callback exceptions may propagate.
Source: supplied pixet_ctrl.py (unchanged).
For result data structures and timing, see Measurement result data.