herosdevices.hardware.hamamatsu.dcam_camera¶
Implementation of the CameraTemplate for Hamamatsu DCAM cameras.
Also see the corresponding section in the documentation.
Module Contents¶
- herosdevices.hardware.hamamatsu.dcam_camera.dcamsdk4 = None¶
- herosdevices.hardware.hamamatsu.dcam_camera.EXAMPLE_CONFIG_DICT¶
- herosdevices.hardware.hamamatsu.dcam_camera.generate_dcam_error_dict() dict[source]¶
Get a dictionary that maps numerical error code against human-readable string.
- Returns:
Dictionary of error codes -> error descriptions
- herosdevices.hardware.hamamatsu.dcam_camera.get_prop_or_val(prop_str: str = 'DCAMPROP.TRIGGERSOURCE.SOFTWARE') int | float[source]¶
Get a dictionary that maps numerical error code against human-readable string.
- Parameters:
prop_str – Property of interest
- Returns:
Value of the property of interest
- herosdevices.hardware.hamamatsu.dcam_camera.validate_roi(val: int, binning: int = 1) int[source]¶
Calculate a valid ROI size of position with a given binning setting.
- Parameters:
val – ROI size or position value
binning – number of pixels to bin in one direction (1, 2, 4)
- Returns:
Valid ROI size or position correwcted with binning
- class herosdevices.hardware.hamamatsu.dcam_camera.DcamCompatibleCamera[source]¶
Bases:
herosdevices.core.templates.CameraTemplateCamera object for Hamamatsu DCAM cameras.
In particular, this code has been tested with the C15550-20UP.
- default_config_dict: dict¶
- set_property(prop: str, value: str) bool[source]¶
Set a single property on the device.
- Parameters:
prop – Property of interest
value – Target value
- Returns:
True if setting the property was successful
- Raises:
RuntimeError – last error in case the API call returned False
- get_property(prop: str) int | float | None[source]¶
Read a single property from the device and reports its value.
- Parameters:
prop – Property of interest
- Returns:
Value of the property
- Raises:
RuntimeError – last error in case the API call returned False
- get_propperty_dict(prop_dict: dict | None = None) dict[source]¶
Read a dictionary of properties and report their value.
- Parameters:
prop_dict – A dict of properties (as strings)
- Returns:
A dict oft property values
- Raises:
RuntimeError – last error in case the API call returned False
- get_temperature() dict[source]¶
Get cooling and temperature properties.
- Returns:
A dict of sensor temperature, cooler status
- Raises:
RuntimeError – last error in case the API call returned False
- get_acquisition_mode() dict[source]¶
Get SENSORMODE, READOUTSPEED and BINNING properties.
- Returns:
A dict of SENSORMODE, READOUTSPEED and BINNING
- Raises:
RuntimeError – last error in case the API call returned False
- get_timing_infos() dict[source]¶
Get trigger timing properties.
- Returns:
A dict of trigger timing properties
- Raises:
RuntimeError – last error in case the API call returned False
- get_camera¶
- supported_features() list[str]¶
Return the names of the camera helper features this class supports.
A feature is supported if the class overrides both its getter and its setter hook. If only one of the two is overridden, a warning is logged once per class and the feature is treated as unsupported.
- Returns:
sorted feature names, equal to the names of the corresponding properties
- property exposure_time: float | None¶
Exposure time in seconds. None if not set or not supported, see
supported_features().
- property roi_coordinates: tuple[int, int, int, int] | None¶
ROI as (x_offset, y_offset, width, height) in sensor pixels.
None if not set or not supported, see
supported_features().
- property binning: tuple[int, int] | None¶
Binning as (horizontal, vertical). None if not set or not supported, see
supported_features().
- property gain: float | None¶
Gain in the native unit of the driver, see Gain and frame rate.
The setter raises
ValueErrorfor NaN, infinity, booleans and non-numbers. The valid range is driver specific and checked by the driver. The getter returns None if not set or not supported, seesupported_features().
- property frame_rate: float | None¶
Frame rate limit in Hz, see Gain and frame rate.
Setting None removes the limit. Other values must be positive finite numbers, not booleans, otherwise the setter raises
ValueError. The getter returns None if the limit is removed, if no frame rate is configured and if the feature is not supported, seesupported_features().
- acquisition_running: bool = False¶
- payload_metadata: dict¶
- keep_device_open = True¶
- default_config: str¶
- get_device() collections.abc.Iterator[None]¶
Yield a device handle.
# use the device in a with statement with self.get_device() as camera: camera.do_something()
- open() Any¶
Open the device handler and assign it to self._device.
- teardown() None¶
Release the device handler and potentially de-initialize the API.
- start() bool¶
Fire a software trigger.
- Returns:
True if successful
- stop() bool¶
Abort the exposure and release queued buffers.
- Returns:
True if successful
- reset() None¶
Reset the device by aborting any ongoing exposure, closing and re-opening the handler.
- get_status() dict¶
Get a dict with the current device status.
- Returns:
A dict with the device status
- get_available_options() dict¶
Get all configurable options/features of the device.
- Returns:
Dict mapping option names to their properties (value, readable, writable, etc.).
- property config_dict: dict¶
Get a copy of the configuration dict.
- Returns:
Copy of the configuration dict
- update_configuration(new_config_dict: dict, merge: bool = True) None¶
Update the configuration dict with new configuration.
Each dict key corresponds a (new) configuration name. Each value is a dict with config property -> config value.
- Parameters:
new_config_dict – A dict of configurations where the keys are the configuration names
merge – If
True, the new dict is recursively merged with the current set config dict. IfFalsethe old configurations with the provided names (keys) are overwritten. In this case each new configuration, merged overdefault_config_dict, must contain all_required_config_keys.
- Raises:
ValueError – If
mergeisFalseand a required config key is missing. No configuration is changed.
- get_configuration() dict¶
Get the currently active configuration.
- Returns:
The currently active configuration.
- configure(config: str = '', metadata: dict | None = None) bool¶
Configure the device with the known configuration config.
To add a configuration to the device, use
update_configuration().- Parameters:
config – Key (name) of the configuration
metadata – Metadata that is merged into the current payload metadata dict which is send with every emitted
acquisition_dataevent.
- Returns:
False if the acquisition is running or if
_set_config()returned False, True otherwise. Exceptions raised by_set_config()are not caught.
- set_configuration¶
- update_payload_metadata(metadata: dict, merge: bool = True) None¶
Update metadata dict send with every emitted frame by the
acquisition_dataevent method.- Parameters:
metadata – Metadata that is merged into the current payload metadata dict which is send with every emitted
acquisition_dataevent.merge – If
True, the new dict is merged with the current set metadata dict. IfFalsethe old metadata is overwritten by the given dict.
- arm(metadata: dict | None = None, kill_running: bool = False) bool¶
Arm the device with the currently active configuration.
- Parameters:
metadata – Metadata that is merged into the current payload metadata dict which is send with every emitted
acquisition_dataevent.kill_running – If
Trueany running acquisition will be stopped. IfFalseand an acquisition isrunning (already)
raised. (an error will be)
- Returns:
True if arming was successful else False
- acquisition_data(frame: numpy.ndarray, metadata: dict | None = None) tuple¶
Event to emit new frames.
Note
The dtype of the frame is not changed here.
- Parameters:
frame – The frame payload data (for example an image or an scope trace)
metadata – The metadata which is passed along the payload. This argument takes precedence over the
payload_metadataattribute (for example set by theupdate_payload_metadatamethod) while merging the two dicts.
- Returns:
A tuple of image and metadata(-dict)
- acquisition_started(metadata: dict | None = None) dict¶
Event emitted when the acquisition thread starts.
- Returns:
A dict with acquisition metadata
- acquisition_stopped(metadata: dict | None = None) dict¶
Event emitted when the acquisition thread stops.
- Returns:
A dict with acquisition metadata