contrast.detectors package¶
Module contents¶
Provides the Detector base class, base classes that bring other
functionality, as well as derived detector subclasses.
Does not automatically load hardware-specific submodules or classes as these might have special dependencies that aren’t available everywhere.
Submodules¶
contrast.detectors.Detector module¶
- class contrast.detectors.Detector.Detector(*args, **kwargs)[source]¶
Bases:
GadgetBase class representing any device which can be read out to produce recordable data.
- classmethod get_active()[source]¶
Returns a DetectorGroup instance containing the currently active
Detectorinstances.
- class contrast.detectors.Detector.TriggerSource(*args, **kwargs)[source]¶
Bases:
DetectorA TriggerSource is a device which follows the
DetectorAPI, but which does not produce data. It can be seen as a lightweightDetectorsubclass, where some of the methods are not mandatory.
- class contrast.detectors.Detector.LiveDetector[source]¶
Bases:
objectAbstract class to define the interface of live detectors, which can run continuously with no synchronization or data capture.
- class contrast.detectors.Detector.SoftwareLiveDetector[source]¶
Bases:
LiveDetectorImplements a software live mode, where detectors that do not provide a monitoring mode get started repeatedly from a background thread.
- class contrast.detectors.Detector.TriggeredDetector[source]¶
Bases:
objectDefines the API for detectors that optionally accept hardware triggers.
- class contrast.detectors.Detector.BurstDetector[source]¶
Bases:
objectDefines the API for detectors that optionally run in burst mode, so that an autonomous train of measurements is made for one arm/start command.
Defines three attributes:
burst_n: the number of autonomous measurements
burst_latency: the time between measurements
burst_acqtime: an optional parameter which (if not None) overrides the value received via the prepare() method.
- class contrast.detectors.Detector.DetectorGroup(*args)[source]¶
Bases:
objectCollection of
Detectorobjects to be acquired together, in a scan for example. Convenience class to call prepare, arm, busy etc in shorthand. Provides some safe measures too.- Parameters:
*args – Sequence of
Detectorinstances
- class contrast.detectors.Detector.LsDet[source]¶
Bases:
objectThis class generates the macro `lsdet`
List available detectors.
- class contrast.detectors.Detector.LsTrig[source]¶
Bases:
objectThis class generates the macro `lstrig`
List available trigger sources.
- class contrast.detectors.Detector.StartLive(*args)[source]¶
Bases:
objectThis class generates the macro `startlive`
Starts software live mode on listed eligible detectors. If none are listed, all active and eligible detectors are started.
startlive [<det1> ... <detN> <exposure time>]
- class contrast.detectors.Detector.StopLive(*args)[source]¶
Bases:
objectThis class generates the macro `stoplive`
Stops software live mode on listed eligible detectors. If no arguments are given, all active live detectors are stopped.
stoplive [<det1> ... <detN>]
contrast.detectors.Dummies module¶
- class contrast.detectors.Dummies.DummyDetector(name=None)[source]¶
Bases:
Detector,SoftwareLiveDetectorDummy detector which returns a single number.
- class contrast.detectors.Dummies.Dummy1dDetector(name=None)[source]¶
Bases:
DummyDetectorDummy detector which returns a 1d vector.
- class contrast.detectors.Dummies.DummyWritingDetector(name=None)[source]¶
Bases:
DummyDetectorHdf5 writing detector which puts sequential frames in separate files.
- class contrast.detectors.Dummies.DummyWritingDetector2(name=None)[source]¶
Bases:
DummyDetectorHdf5 writing detector which puts sequential frames in a big array.
- class contrast.detectors.Dummies.DummyDictDetector(name=None)[source]¶
Bases:
DummyDetectorIllustrates how multi-channel detectors can return dict values.
contrast.detectors.Pseudo module¶
- contrast.detectors.Pseudo.get_dict_recursive(dct, key)[source]¶
Helper function to get the value corresponding to path/to/key from a nested dict.
- class contrast.detectors.Pseudo.PseudoDetector(variables, expression, *args, **kwargs)[source]¶
Bases:
DetectorDerived detector which transforms signals from other Detector objects. Defines a dict of variables corresponding to detector labels, and one or more expressions to apply to these.
Variables can be of the form detector/sub/value, where “detector” is interpreted as the basic gadget, and “sub/value” are components keys into the value dictionary.
If ‘expressions’ is a string, the detector will return a single value, if it’s a dict, the detector will return a corresponding dict of results.
Example:
r = PseudoDetector(variables={'x':'npointbuff/x', 'y':npointbuff/y'}, expressions={'r':np.sqrt(x**2+y**2)'}, name='r'')
contrast.detectors.Eiger module¶
- class contrast.detectors.Eiger.Eiger(name=None, host='b-nanomax-eiger-dc-1.maxiv.lu.se', api_version='1.8.0', use_image_appendix=False, hdf_path='entry/instrument/Eiger/data', hw_trig_min_latency=1e-07)[source]¶
Bases:
Detector,SoftwareLiveDetector,TriggeredDetector,BurstDetectorProvides a direct interface to the Dectris Eiger server.
Class to interact directly with the Eiger Simplon API.
- property max_count_rate¶
Maximum count rate according to the server
- property compression¶
Whether bitshuffle compression is enabled
- property energy¶
Operating energy in keV
- property mask_applied¶
Whether to apply the mask
- property pixel_splitting¶
Whether to use virtual pixel splitting
- property threshold¶
Energy threshold for the counters
- class contrast.detectors.Eiger.EigerTango(device_name, name=None, hdf_path='entry/instrument/Eiger/data', rotation=0, hw_trig_min_latency=1e-07)[source]¶
Bases:
Detector,SoftwareLiveDetector,TriggeredDetector,BurstDetectorProvides a direct interface to the Dectris Eiger server via a Tango Server.
Class to interact directly with the Eiger Simplon API.
- property max_count_rate¶
Maximum count rate according to the server
- property energy¶
Operating energy in eV
- property mask_applied¶
Whether to apply the mask
- property pixel_splitting¶
Whether to use virtual pixel splitting
- property threshold¶
Energy threshold for the counters
- property rotation¶
Rotation of detector frame. Uses numpy.rot90() notation.
- class contrast.detectors.Eiger.SelunTango(device_name, name=None, hdf_path='entry/instrument/Eiger/data', rotation=0, hw_trig_min_latency=1e-07)[source]¶
Bases:
EigerTangoProvides a direct interface to the Dectris SELUN server via a Tango Server.
Class to interact directly with the Eiger Simplon API.
- property OnDetectorBinning¶
On Detector binning. Options: ‘1x1’ - 190x190 pixels at max. 30 kHz ‘2x2’ - 94x94 pixels at up to 120 kHz
contrast.detectors.Merlin module¶
- class contrast.detectors.Merlin.Merlin(name=None, host='b-nanomax-controlroom-cc-2', port=8000, hw_trig_min_latency=0.00164)[source]¶
Bases:
Detector,SoftwareLiveDetector,TriggeredDetector,BurstDetectorProvides an interface to the Merlin detector streaming manager,
https://github.com/maxiv-science/merlin-streamer
- property gapless¶
Whether to use the continuous alternating-counter mode
- property energy¶
Operating photon energy
contrast.detectors.Xspress3 module¶
- class contrast.detectors.Xspress3.Xspress3(device='staff/alebjo/xspress3', name=None, hw_trig_min_latency=1e-07)[source]¶
Bases:
Detector,SoftwareLiveDetector,TriggeredDetector,BurstDetectorProvides an interface to the Xspress3 streaming manager,
contrast.detectors.Pilatus module¶
- class contrast.detectors.Pilatus.Pilatus2(hostname, name=None, hw_trig_min_latency=0.003)[source]¶
Bases:
Detector,SoftwareLiveDetector,TriggeredDetector,BurstDetectorProvides an interface to the Pilatus streaming manager,
https://github.com/maxiv-science/pilatus-streamer https://gitlab.maxiv.lu.se/nanomax-beamline/streaming-receiver
This class talks socket directly to the camserver.
- property energy¶
Operating energy
- class contrast.detectors.Pilatus.Pilatus3(device_name, hw_trig_min_latency=0.00095, hdf_path='entry/instrument/Pilatus3/data', **kwargs)[source]¶
Bases:
Detector,LiveDetector,TriggeredDetector,BurstDetectorProvides an interface to the MAX IV Pilatus Tango DS,
https://gitlab.maxiv.lu.se/kits-maxiv/dev-pilatus https://github.com/maxiv-science/pilatus-streamer https://gitlab.maxiv.lu.se/nanomax-beamline/streaming-receiver
There’s no soft trigger on this detector. Also, the DS seems not to have HW triggered burst mode exposed.
- property energy¶
Operating energy in eV
contrast.detectors.Andor3 module¶
- class contrast.detectors.Andor3.Andor3(device='zyla/test/1', name=None)[source]¶
Bases:
Detector,SoftwareLiveDetector,BurstDetectorProvides an interface to the Andor3 Zyla streaming manager,
https://github.com/maxiv-science/andor-streamer
Note: hw trigger not yet implemented.
contrast.detectors.AlbaEM module¶
This module contains an interface to the Alba electrometer, as well as a contrast Detector class representing it.
Requires the “STREAMING” mode now available as standard firmware.
For the old school data-polling version, see LegacyAlbaEM.py.
- class contrast.detectors.AlbaEM.Stream(host, port, debug=False)[source]¶
Bases:
ThreadServer which receives the electrometer stream.
- class contrast.detectors.AlbaEM.Electrometer(host='b-nanomax-em2-2', port=5025, trig_source='DIO_1', streaming=False, stream_host=None, stream_port=22003)[source]¶
Bases:
objectInterface to a 4-channel Alba electrometer.
- class contrast.detectors.AlbaEM.AlbaEM(name=None, debug=False, hw_trig_min_latency=0.0004, **kwargs)[source]¶
Bases:
Detector,LiveDetector,TriggeredDetector,BurstDetectorContrast interface to the alba EM.
The specifics of the EM enables these four cases, each of which causes a different triggering and readout behaviour below:
HW triggered expecting one trigger per SW step -> arm at the top
HW triggered expecting hw_trig_n triggers per SW step -> arm on every sw step
Burst mode, burst_n > 1, uses a special EM command
Software triggered mode, -> arm at the top
Note that the electrometer itself (as of SW version 2.0.04) does not allow for triggered burst acquisition, as reflected in the code.
contrast.detectors.PandaBox module¶
- class contrast.detectors.PandaBox.PandaBox(name=None, host='172.16.126.101', ctrl_port=8888, data_port=8889, bitblock='BITS1', debug=False)[source]¶
Bases:
Detector,TriggeredDetector,BurstDetectorBasic class for treating a PandaBox as a detector, capable of operating in burst mode (thereby acting as a time-based trigger source).
The PandaBox is infinitely configurable, and this class assumes that:
the PCAP block is used,
the PULSE1 block is used to control the number of acquired points and their timing, and
flickering the “A” bit causes a trigger.
contrast.detectors.AdLink module¶
- class contrast.detectors.AdLink.AdLinkAnalogInput(name=None, device=None)[source]¶
Bases:
Detector,TriggeredDetectorInterface to the AdLink Tango device exposing one analog input.
contrast.detectors.DG645 module¶
- class contrast.detectors.DG645.StanfordTriggerSource(name=None, device_name=None)[source]¶
Bases:
TriggerSource,BurstDetectorClass representing the DG645 as a simple source for hardware triggers. All channels are fired with the requested high time.
contrast.detectors.Lima module¶
- class contrast.detectors.Lima.LimaDetector(name=None, lima_device=None, det_device=None)[source]¶
Bases:
Detector,SoftwareLiveDetector,TriggeredDetector,BurstDetectorLima base class.
Lima is sometimes very slow to finish writing data, which is why this gadget has a ‘hybrid mode’, where Lima is started only once, and sequential arm/start calls to this gadget only increment counters. The busy state is set based on Lima’s last_image_acquired compared to these counters, and does not reflect the state of the Lima device.
- class contrast.detectors.Lima.LimaPilatus(*args, **kwargs)[source]¶
Bases:
LimaDetectorPilatus specific LimaDetector.
- class contrast.detectors.Lima.LimaMerlin(*args, **kwargs)[source]¶
Bases:
LimaDetectorMerlin specific LimaDetector.
- class contrast.detectors.Lima.LimaAndor(*args, **kwargs)[source]¶
Bases:
LimaDetectorAndor specific LimaDetector.
- class contrast.detectors.Lima.LimaXspress3(*args, **kwargs)[source]¶
Bases:
LimaDetectorXspress3 specific LimaDetector.
- class contrast.detectors.Lima.Lima_hybrid_on(*args)[source]¶
Bases:
objectThis class generates the macro `lima_hybrid_on`
Turn on ‘hybrid triggering’ for the specified Lima device, or for all Lima devices if nothing is specified.
- class contrast.detectors.Lima.Lima_hybrid_off(*args)[source]¶
Bases:
Lima_hybrid_onThis class generates the macro `lima_hybrid_off`
Turn on ‘hybrid triggering’ for the specified Lima device, or for all Lima devices if nothing is specified.
contrast.detectors.Ni6602 module¶
- class contrast.detectors.Ni6602.Ni6602CounterCard(name=None, device=None)[source]¶
Bases:
Detector,LiveDetector,TriggeredDetectorInterface to the Ni6602 Tango device exposing counters.
contrast.detectors.TangoAttributeDetector module¶
Provides a Detector interface to Tango attributes, so that anything can be monitored during scans.