slmsuite.hardware.cameraslms.CameraSLM#

class CameraSLM(cam, slm, mag=1)[source]#

Bases: _Picklable

Base class for an SLM with camera feedback.

cam#

Instance of Camera which interfaces with a camera. This camera is used to provide closed-loop feedback to an SLM for calibration and holography.

Type:

Camera

slm#

Instance of SLM which interfaces with a phase display.

Type:

SLM

name#

Stores cam.name + '-' + slm.name.

Type:

str

mag#

Magnification of the camera relative to an experiment plane. For instance, mag = 10 could refer to the use of a 10x objective (with appropriate imaging lensing) between the experiment plane and the camera. In this case, the images apparent on the camera are 10x larger than the true objects at the experiment plane.

Type:

float

Methods

pickle

Returns a dictionary containing selected attributes of this class.

plot

Plots the provided phase and image for the child hardware on a pair of subplot axes.

save

Saves the dictionary returned from pickle() to a file like "path/name_id.h5".

__init__(cam, slm, mag=1)[source]#

Initialize an SLM linked to a camera, with given magnification between the camera and experiment planes.

Parameters:
  • cam (Camera) – Instance of Camera which interfaces with a camera. This camera is used to provide closed-loop feedback to an SLM for calibration and holography.

  • slm (SLM) – Instance of SLM which interfaces with a phase display.

  • mag (float) –

    Magnification of the camera relative to an experiment plane. For instance, mag = 10 could refer to the use of a 10x objective (with appropriate imaging lensing) between the experiment plane and the camera. In this case, the images apparent on the camera are ten times larger than the true objects at the experiment plane.

    Note

    This magnification is currently isotropic. In the future, anisotropy between the camera and experiment planes could be implemented.

plot(phase=None, image=None, slm_limits=None, cam_limits=None, title='', axs=None, cbar=True, **kwargs)[source]#

Plots the provided phase and image for the child hardware on a pair of subplot axes.

Parameters:
  • phase (ndarray OR None) –

    Phase to be plotted. If None, grabs the last written phase from the SLM.

    Important

    Writes this phase to the SLM if image is None.

  • image (ndarray OR None) – Image to be plotted. If None, grabs an image from the camera.

  • slm_limits (None OR float OR [[float, float], [float, float]]) – Scales the limits by a given factor or uses the passed limits directly.

  • cam_limits (None OR float OR [[float, float], [float, float]]) – Scales the limits by a given factor or uses the passed limits directly.

  • title (str) – Super title for the axes.

  • ax ((matplotlib.pyplot.axis, matplotlib.pyplot.axis) OR None) – Axes to plot upon.

  • cbar (bool) – Also plot a colorbar.

  • **kwargs – Passed to set_phase()

Returns:

Axes of the plotted phase and image.

Return type:

(matplotlib.pyplot.axis, matplotlib.pyplot.axis)

pickle(attributes=True, metadata=True)[source]#

Returns a dictionary containing selected attributes of this class.

Parameters:
  • attributes (bool OR list of str) – If False, pickles only baseline attributes, usually single floats. If True, also pickles ‘heavy’ attributes such as large images and calibrations. If list of str, pickles the keys in the given list. By default, the chosen attributes should be things that can be written to .h5 files: scalars and lists of scalars.

  • metadata (bool) – If True, package the dictionary as the "__meta__" value of a superdictionary which also contains: "__version__", the current slmsuite version, "__time__", the time formatted as a date string, and "__timestamp__", the time formatting as a floating point timestamp. This information is used as standard metadata for calibrations and saving.

save(path='.', name=None, **kwargs)[source]#

Saves the dictionary returned from pickle() to a file like "path/name_id.h5".

Parameters:
  • path (str) – Path to directory to save in. Default is current directory.

  • name (str OR None) – Name of the save file. If None, will use name + '-pickle'.

  • **kwargs – Passed to pickle() to customize how and what data is saved.

Returns:

The file path that the pickled data was saved to.

Return type:

str