trspectrometer.plugins.detector package

Module for management of detector devices.

A detector is a device which provides intensity values, often as a function of wavelength. These may be small form fibre spectrometers, or larger CCD or CMOS cameras attached to spectrographs. Single element detectors can be supported by returning a 1-element array of data, possibly also with an arbitrary wavelength label.

The implementation of the actual control of the hardware is abstracted from the software interface. The python pluginlib is used to find classes which implement and extend the Detector class and actually communicate with the detector device.

Detector plugin classes which are built-in are:

  • ZylaFixed, for an Andor Zyla sCMOS camera attached to a fixed spectrograph unit. It may support other Andor sCMOS cameras which use the SDK3 for communications with litle or no modifications. Support is provided using the andor3 python package

  • DummyDetector, which simulates the presence of a detector for demonstration or testing purposes.

To load the detector plugin module, ensure "detector" is present in the Configuration File’s load=[...] list inside the Plugins section. To configure the module to use a specific driver class, ensure a [[hardware.detector]] section is present such as the default:

# Detector configuration
# Each entry specifies a detector device
#   name (string) : Friendly name for the detector to use in the application
#   class (string) : Name of specific class to load to drive the detector
#   options (dict) : Dictionary containing key=value pairs to pass to the class init() method
[[hardware.detector]]
name = "Detector"
class = "DummyDetector"
options = {}

Multiple detector devices can be specified by including multiple [[hardware.detector]] sections. The double rectangular brackets around [[hardware.detector]] indicate that multiple sections are permitted. The same class type may be initialised multiple times with different values for its options. Acquisition methods may then select which detector entry to use.

class trspectrometer.plugins.detector.Detector(**kwargs)[source]

Bases: Plugin

Parent class of all detector class plugins.

Every detector driver class should derive from this parent, so that the automatic device class discovery can function.

close() None[source]

Close the connection to the device.

get_exposure() float[source]

Get the currently set exposure time, in seconds.

Returns:

Current exposure time.

get_exposure_limits()[source]

Get the minimum and maximum allowed exposure times, in seconds.

Returns:

Tuple of minimum and maximum allowed exposure times.

get_grating() Optional[str][source]

Get the grating currently in use.

If the grating is not selectable, then None may be returned.

Returns:

String describing the current grating.

get_gratings()[source]

List the gratings available for the detector.

If the grating in the detector is not changeable, then an empty tuple may be returned.

Returns:

Tuple of strings for available gratings.

get_max_value() Union[int, float][source]

Get the maximum value which may be returned for a pixel on the detector.

For example, for a 16-bit detector, the maximum value should be 2^16 or 65536.

Returns:

Maximum value allowed for a pixel.

get_pixel_wavelengths() Union[_SupportsArray[dtype[Any]], _NestedSequence[_SupportsArray[dtype[Any]]], bool, int, float, complex, str, bytes, _NestedSequence[Union[bool, int, float, complex, str, bytes]]][source]

Get an array containing the wavelength labels for each pixel in the acquired data.

Returns:

Wavelengths corresponding to data pixels.

get_triggermode() str[source]

Get the current acquisition triggering mode.

Returns:

Current triggering mode.

get_triggermodes()[source]

List the trigger modes available to the detector.

Returns:

Tuple of strings for available trigger modes.

get_wavelength() float[source]

Get the current central wavelength, in nanometres.

Returns:

Current central wavelength.

get_wavelength_limits()[source]

Get the minimum and maximum allowed values for the central wavelength selection, in nanometres.

Returns:

Tuple of minimum and maximum central wavelengths.

is_initialised() bool[source]

Test whether the detector hardware is present and initialised, and not in any error state.

register_acquisition_callback(callback: callable) None[source]

Register a function to receive notifications for completion of acquisition.

The callback method should take the form of acquisition_callback(data), where data is the data for the spectra as a 2D numpy array.

Parameters:

callback – Function to call on completion of acquisition.

register_spectrum_callback(callback: callable) None[source]

Register a function to receive notifications for acquisition data of a single spectra.

The callback method should take the form of spectrum_callback(data), where data is the data for the spectrum as a 1D numpy array.

Parameters:

callback – Function to call on each spectrum acquisition event.

set_exposure(time: float) None[source]

Set the desired exposure time, in seconds.

Parameters:

time – Desired exposure time.

set_grating(grating: str) None[source]

Set the grating for the detector.

Param:

String describing desired grating.

set_triggermode(mode: str) None[source]

Set a acquisition triggering mode.

The mode should be a value returned by get_trigger_modes().

Parameters:

mode – Triggering mode.

set_wavelength(central_wavelength: float) None[source]

Set the central wavelength, in nanometres.

Parameters:

central_wavelength – Desired central wavelength.

start(n: int = 0) None[source]

Begin acquisition of spectra.

The parameter n determines the number of spectra to acquire. If n is a positive integer then n spectra will be acquired, buffered, and passed to all functions subscribed to callbacks using register_acquisition_callback() at the conclusion of the acquisition process. In this case, the acquisition of an individual spectrum will not cause callbacks to the functions registered using register_spectrum_callback(). Alternatively, if n is zero or less (the default), then acquisition will continue indefinitely until the stop() method is called. Callbacks will be made to subscribers to register_spectrum_callback() on each spectrum acquisition event, but no callbacks will be made once the acquisition is stopped.

Parameters:

n – Number of spectra to acquire, or 0 to acquire indefinitely.

stop(wait: bool = False) None[source]

Stop any current acquisition process.

Parameters:

wait – Wait (block) until the acquisition finishes before returning.

unregister_acquisition_callback(callback: callable) None[source]

Unregister a function previously registered to receive acquisition callbacks using register_acquisition_callback().

Parameters:

callback – Function to unregister.

unregister_spectrum_callback(callback: callable) None[source]

Unregister a function previously registered to receive spectrum callbacks using register_spectrum_callback().

Parameters:

callback – Function to unregister.

description

Description of this detector device.

class trspectrometer.plugins.detector.DetectorStatusPanel(parent=None)[source]

Bases: QFrame

hideEvent(event)[source]

Handler for widget hide events.

refresh()[source]

Refresh the state of the hardware connection and update the panel’s display.

showEvent(event)[source]

Handler for widget show events.

devices_changed

Qt Signal to indicate the devices have changed in some way and the panel requires refreshing.

staticMetaObject = PySide6.QtCore.QMetaObject("DetectorStatusPanel" inherits "QFrame": Methods:   #34 type=Signal, signature=devices_changed() )
trspectrometer.plugins.detector.statuspanel

QWidget class type to use for displaying hardware status.

trspectrometer.plugins.detector.add_change_callback(callback_function)[source]

Register a function to be called when the devices are refreshed.

Parameters:

callback_function – Function to call when devices are refreshed.

trspectrometer.plugins.detector.close()[source]

Close any open detector devices.

trspectrometer.plugins.detector.init()[source]

Initialise the detector devices specified in the configuration file.

trspectrometer.plugins.detector.remove_change_callback(callback_function)[source]

Unregister a callback function added using add_change_callback().

Parameters:

callback_function – Function to unregister.

trspectrometer.plugins.detector.devices = [None]

List of instances of detector device classes. The number of entries in the list should correspond to the [[hardware.detector]] entries in the configuration file. If a device is missing or not initialised, a value of None should be used as a placeholder.

Submodules