cameras package
cameras.pco_server module
Provides access to PCO cameras.
- exception cameras.pco_server.PcoConfigError(msg='')
Bases:
ExceptionAn error raised by an issue with the configuration of a PCO camera
- __init__(msg='')
- exception cameras.pco_server.PcoRecordError(msg='')
Bases:
ExceptionAn error raised by an issue with recording an image with a PCO camera
- __init__(msg='')
- exception cameras.pco_server.PcoSaveError(msg='')
Bases:
ExceptionAn error raised by an issue with saving an image with a PCO camera
- __init__(msg='')
- class cameras.pco_server.PcoServer
Bases:
HardwareInterfaceServerProvides access to PCO cameras.
Uses a modified version of the PCO Python library, found in
cameras/lib/pco. For more information, refer to the PCO SDK and PCO Python library documentation.- available_images(self, c)
Returns the number of acquired images. Images with interframing count as one.
- Parameters:
c – Labrad context
- Returns:
Number of acquired images.
- Return type:
- callbacks = {}
- check_roi(self, c, xmin, ymin, xmax, ymax)
Checks that the roi defined by (xmin, ymin, xmax, ymax) is allowed for the currently selected camera.
Note that the camera pixels are 1-indexed in the PCO software.
- Parameters:
- Returns:
Bounds-checked roi (xmin, ymin, xmax, ymax)
- Return type:
- close_camera(self, c)
Close the PCO camera opened via
select_interface().- Parameters:
c – Labrad context
- fname_base = 'pixelfly_{}.npz'
- static get_camera_identifier(cam)
- Parameters:
cam (pco.Camera()) – A PCO camera object
- Returns:
Returns a string containing the camera type and serial number of the camera.
- Return type:
- get_capabilities(self, c)
Gets a description of the camera, including available image sizes, readout rates, etc.
- Parameters:
c – Labrad context
- Returns:
JSON-dumped camera description dictionary
- Return type:
- get_config(self, c)
Get the camera configuration opened via
select_interface().- Parameters:
c – Labrad context
- Returns:
JSON-dumped configuration dictionary
- Return type:
- get_fname(self, c)
Gets the filename to save the next image
- Parameters:
c – Labrad context
- Returns:
the filename to save the next image
- Return type:
- get_images(self, c)
Provides the images stored in the camera buffer, if any. If
record()has not been run, throws aPcoRecordError. If no images are available, returns empty metadata and image array.- Parameters:
c – Labrad context
roi ((int), optional) – A 4-tuple of integers (xmin, ymin, xmax, ymax) representing the bounds of the image to be saved. Defaults to None, in which case the whole image is saved.
- Returns:
A list of numpy arrays of the images.
- Return type:
([numpy array])
- get_interframing_enabled(self, c)
Checks whether interframing mode is enabled for the selected camera.
- Parameters:
c – Labrad context
- Returns:
whether interframing mode is enabled for the selected camera
- Return type:
- get_readout_rates(self, c)
Gets the possible readout rates for the selected camera, in pixels per second.
- Parameters:
c – Labrad context
- Returns:
the possible readout rates for the camera, in pixels per second
- Return type:
[int]
- get_status(self, c)
Gets the recording status of the current camera. Returns an empty JSON if recording is not initialized.
- Parameters:
c – Labrad context
- Returns:
JSON-dumped recording status
- Return type:
- get_trigger_modes(self, c)
Returns a list of the possible trigger modes for PCO cameras. Not all trigger modes may be compatible with the selected camera.
- Parameters:
c – Labrad context
- Returns:
a list of the possible trigger modes for PCO cameras.
- Return type:
[str]
- is_running(self, c)
Checks whether the selected camera is currently recording.
- Parameters:
c – Labrad context
- Returns:
whether the selected camera is currently recording
- Return type:
- n_images = 0
- name = '%LABRADNODE%_pco'
- path_base = 'K:/data/{}/Pixelfly/'
- pattern = 'pixelfly_(\\d+).npz'
- poll_for_images(c, path, n_images, roi, timeout, start_time)
- record_and_save(self, c, path, n_images=1, mode='sequence non blocking', roi=None, timeout=None)
Records and saves a series of images. Stops recording when done. Non-blocking, but must be stopped with
stop_record()if the configuration must be set before it completes.- Parameters:
c – Labrad context
path (str) – Path to saved images. The extension is automatically changed to “.npz”
n_images (int, optional) – The number of images to record and save. An image taken with interframing enabled will only count as one here, but will be saved as two images, one for each frame. Defaults to 1.
mode (str, optional) –
The recording mode; see PCO Python library documentation for options. Defaults to ‘sequence non blocking’.
roi ((int), optional) – A 4-tuple of integers (xmin, ymin, xmax, ymax) representing the bounds of the image to be saved. Defaults to None, in which case the whole image is saved.
timeout (float, optional) – The time, in seconds, before acquisition is cancelled and an error is thrown. Defaults to None.
- refresh_available_interfaces(self)
Fill
self.interfaceswith available connections using PCO dll
- save_images(self, c, path, n_images, roi)
Saves the latest
n_imageimages if available. Ifrecord()has not been run, throws aPcoRecordError. If fewer thann_imagehave been acquired, throws aPcoSaveError.The images are saved as a compressed npz file with fields “meta” containing a zero-dimensional array with a metadata dictionary (stored pickled) and a 3-dimensional integer ndarray “data” of dimension (n_images (*2 if interframing enabled), y dimension, x dimension) containing the images.
- Parameters:
c – Labrad context
path (str) – Path to saved images. The extension is automatically changed to “.npz”
n_images (int) – Number of images to save. An image taken with interframing enabled will only count as one here, but will be saved as two images, one for each frame.
roi ((int), optional) – A 4-tuple of integers (xmin, ymin, xmax, ymax) representing the bounds of the image to be saved. Defaults to None, in which case the whole image is saved.
- Returns:
Path to saved image
- Return type:
- saved = False
- set_binning(self, c, xbins, ybins=None)
Sets the selected camera’s binning mode.
- set_cam_config(c, key, val)
- set_exposure(self, c, exposure)
Sets the camera exposure. If the specified exposure is outside the camera’s exposure range, clips to the range and warns the user.
Note that if interframing is enabled, the provided exposure is only used for the first frame, while the second has an exposure of 74 ms (for the pixelfly camera).
- Parameters:
c – Labrad context
exposure (numeric) – Exposure in seconds.
- Returns:
the camera’s actual exposure setting in seconds.
- Return type:
- set_interframing_enabled(self, c, enable)
Sets whether interframing mode is enabled for the selected camera.
- set_readout_rate(self, c, readout)
Sets the readout rate for the selected camera, in pixels per second.
- Parameters:
c – Labrad context
readout (int) – the readout rates for the camera, in pixels per second. Must be one of the values returned by
get_readout_rates()
- Returns:
the camera’s actual readout rate, in pixels per second
- Return type:
- set_trigger_mode(self, c, mode)
Sets the trigger mode for the selected camera.
- Parameters:
c – Labrad context
mode (str) – The trigger mode for the camera. Must be one of the values returned by
get_trigger_modes(). Not all trigger modes work for all cameras.
- Returns:
the camera’s actual trigger mode
- Return type:
- start_record(self, c, n_images=1, mode='sequence non blocking')
Starts recording images on the selected camera.
- Parameters:
c – Labrad context
n_images (int, optional) – The number of images to return. Defaults to 1.
mode (str, optional) –
The recording mode; see PCO Python library documentation for options. Defaults to ‘sequence non blocking’.
- stopServer(self)
Closes camera connections and shuts down the Labrad server.
- stop_record(self, c)
Stop recording on the current camera.
- Parameters:
c – Labrad context