Prism API

This module provides the main interface for controlling and collecting data from Prism hardware.

Classes

class Prism(memory_map_fpath=None, timeout=None)[source]

Object for controlling and collecting data from Prism hardware.

This class provides a Python interface to the Prism hardware system, allowing control of various parameters and collection of measurement data.

The hardware controller is communicated with through a shared memory. The shared memory layout is defined by a JSON file that specifies the memory map configuration including data source locations and sizes. By default this file is located in a system-specific temp directory, but can be overridden by passing an explicit path. This location should not need to be modified.

Variables:
  • memory_map (Dict) – The loaded memory map configuration

  • measurements (Dict) – Dictionary of measurement data structures

  • dofs (Dict) – Dictionary of degree of freedom (DOF) data structures

__init__(memory_map_fpath=None, timeout=None)[source]

Initialize the Prism hardware interface.

Parameters:
  • memory_map_fpath (Optional[str]) – Path to the memory map JSON file. If None, defaults to a system-specific temp directory location. Should not need to be modified under normal circumstances.

  • timeout (Optional[float]) – Default timeout in seconds for blocking operations. If None, operations will block indefinitely.

Raises:

PrismConnectionError – If the shared memory cannot be opened or the memory map file is invalid.

close()[source]

Clean up resources and close the shared memory connection.

Return type:

None

get_measurement_types()[source]

Get available measurement types.

Return type:

Tuple[Measurement, ...]

Returns:

Tuple of Measurement objects without data.

get_measurement_keys()[source]

Get available measurement keys.

Return type:

Tuple[str, ...]

Returns:

Tuple of measurement keys.

get_last_measurement(meas_key)[source]

Get the most recent measurement data.

Parameters:

meas_key (str) – Measurement type key.

Return type:

Measurement

Returns:

Measurement object containing the most recent measurement data.

Raises:

PrismParameterError – If the measurement type key is invalid or is a camera.

single_measure(meas_key, timeout=None)[source]

Perform a single measurement and wait for completion.

Parameters:
  • meas_key (str) – Measurement type key.

  • timeout (Optional[float]) – Timeout in seconds. If None, uses the default timeout.

Return type:

Measurement

Returns:

Measurement object containing the measurement data.

Raises:
start_running_measure(meas_key)[source]

Start continuous measurement collection.

Parameters:

meas_key (str) – Measurement type key.

Raises:

PrismParameterError – If the measurement type is invalid.

Return type:

None

stop_running_measure(meas_key)[source]

Stop continuous measurement collection.

Parameters:

meas_key (str) – Measurement type key.

Raises:

PrismParameterError – If the measurement type is invalid.

Return type:

None

get_all_parameters(list_read_only=False)[source]

Get information about available parameters.

Parameters:

list_read_only (bool) – If True the returned collection will include read-only parameters (those whose name contains the marker "*RO*"). If False (default) read-only parameters are excluded so that only parameters that can be set by set_parameter() are returned.

Returns:

A tuple of prismapi.core.Parameter instances matching the filter criterion.

Return type:

Tuple[Parameter, …]

set_parameter(param_key, value, timeout=None)[source]

Set a parameter value and optionally wait for it to take effect.

Parameters:
  • param_key (str) – Key of the parameter to set.

  • value (Any) – New value for the parameter.

  • timeout (Optional[float]) – Timeout in seconds. If None, does not block.

Raises:
Return type:

None

get_parameter(param_key)[source]

Get the current value of a parameter.

Parameters:

param_key (str) – Key of the parameter.

Return type:

Parameter

Returns:

Current value of the parameter.

Raises:

PrismParameterError – If the parameter key is invalid.

image_bed()[source]

Capture an image from the bed camera.

Return type:

ndarray

Returns:

Numpy array containing the image data.

Raises:
pl_image()[source]

Capture an image from the PL camera.

Return type:

ndarray

Returns:

Numpy array containing the image data.

Raises:
move(x, y, timeout=None)[source]

Move the bed to the specified position.

Parameters:
  • x (float) – X position in millimeters.

  • y (float) – Y position in millimeters.

  • timeout (Optional[float]) – Timeout in seconds. If None, uses the default timeout.

Raises:
Return type:

None

wait_for_new_data(meas_key, timeout=None)[source]

Wait for new data to be available for a measurement.

Parameters:
  • meas_key (str) – Key of the measurement type.

  • timeout (Optional[float]) – Timeout in seconds. If None, blocks indefinitely.

Raises:
Return type:

None

get_next_measurement(meas_key, timeout=None)[source]

Get the next measurement from the measurement queue.

Parameters:
  • meas_key (str) – Key of the measurement type.

  • timeout (Optional[float]) – Timeout in seconds. If None, blocks indefinitely.

Return type:

Measurement

Returns:

Measurement object containing the next measurement data.

Raises:
class Parameter(name, key, value, units, min, max)[source]

Bases: object

A class representing a parameter with a value and constraints.

This class stores information about a parameter including its name, value, units, and valid range.

Variables:
  • name (str) – The display name of the parameter.

  • key (str) – The unique identifier/key for the parameter.

  • value (float) – The current value of the parameter.

  • units (str) – The units of measurement for the parameter.

  • min (float) – The minimum allowed value for the parameter.

  • max (float) – The maximum allowed value for the parameter.

name: str
key: str
value: float
units: str
min: float
max: float
__str__()[source]

Return a string representation of the parameter.

Returns:

A formatted string showing the parameter name, value, units, and range.

Return type:

str

class Measurement(name, key, x_data, y_data, x_units, y_units, start_time, finish_time)[source]

Bases: object

A class representing a measurement with x and y data points.

This class stores measurement data including the data points, units, and timing information.

Variables:
  • name (str) – The display name of the measurement.

  • key (str) – The unique identifier/key for the measurement.

  • x_data (ndarray | None) – The x-axis data points.

  • y_data (ndarray | None) – The y-axis data points.

  • x_units (str) – The units for the x-axis data.

  • y_units (str) – The units for the y-axis data.

  • start_time (float | None) – The timestamp when the measurement started.

  • finish_time (float | None) – The timestamp when the measurement finished.

name: str
key: str
x_data: ndarray | None
y_data: ndarray | None
x_units: str
y_units: str
start_time: float | None
finish_time: float | None
__str__()[source]

Return a string representation of the measurement.

Returns:

A formatted string showing the measurement name and units.

Return type:

str

Exceptions

class PrismError[source]

Bases: Exception

Base exception class for Prism API errors.

class PrismConnectionError[source]

Bases: PrismError

Raised when there are issues connecting to the Prism hardware.

class PrismParameterError[source]

Bases: PrismError

Raised when there are issues with parameter operations.

class PrismTimeoutError[source]

Bases: PrismError

Raised when a timeout occurs.