pylablib.devices.PCO package

Submodules

pylablib.devices.PCO.SC2 module

pylablib.devices.PCO.SC2.list_cameras(cam_interface=None)[source]

List camera connections (interface kind and camera index).

If cam_interface is supplied, it defines one of camera interfaces to check (e.g., "usb3" or "clhs"). Otherwise, check all interfaces.

pylablib.devices.PCO.SC2.get_cameras_number(cam_interface=None)[source]

Get the total number of connected PCOSC2 cameras.

If cam_interface is supplied, it defines one of camera interfaces to check (e.g., "usb3" or "clhs"). Otherwise, check all interfaces.

pylablib.devices.PCO.SC2.reset_api()[source]

Reset API.

All cameras must be closed; otherwise, the prompt to reboot will appear.

class pylablib.devices.PCO.SC2.TDeviceInfo(model, interface, sensor, serial_number)

Bases: tuple

interface
model
sensor
serial_number
class pylablib.devices.PCO.SC2.TCameraStatus(status, warnings, errors)

Bases: tuple

errors
status
warnings
class pylablib.devices.PCO.SC2.TInternalBufferStatus(scheduled, scheduled_max, overruns)

Bases: tuple

overruns
scheduled
scheduled_max
class pylablib.devices.PCO.SC2.TFrameInfo(frame_index)

Bases: tuple

frame_index
class pylablib.devices.PCO.SC2.PCOSC2Camera(idx=0, cam_interface=None, reboot_on_fail=True)[source]

Bases: IBinROICamera, IExposureCamera

PCO SC2 camera.

Parameters:
  • idx (int) – camera index (use get_cameras_number() to get the total number of connected cameras)

  • cam_interface – camera interface; if it is None, get the first available connected camera (in this case idx is ignored); if not, then value of idx is used to connect to a particular camera (interfaces and indices can be obtain from list_cameras())

  • reboot_on_fail (bool) – if True and the camera raised an error during initialization (but after opening), reboot the camera and try to connect again useful when the camera is in a broken state (e.g., wrong ROI or pixel clock settings)

Error = <Mock name='mock.PCOSC2Error' id='139946311400336'>
TimeoutError = <Mock spec='str' id='139946316459728'>
open()[source]

Open connection to the camera

close()[source]

Close connection to the camera

is_opened()[source]

Check if the device is connected

reboot(wait=True)[source]

Reboot the camera.

If wait==True, wait for the recommended time (10 seconds) after reboot for the camera to fully restart; attempt to open the camera before that can lead to an error.

get_full_camera_data()[source]

Get a dictionary the all camera data available through the SDK

update_full_data()[source]

Update internal full camera data settings.

Takes some time (about 50ms), so more specific function are preferable for specific parameters.

get_device_info()[source]

Get camera model data.

Return tuple (model, interface, sensor, serial_number).

get_capabilities()[source]

Get camera capabilities.

For description of the capabilities, see PCO SC2 manual.

get_camera_status(full=False)[source]

Get camera status.

If full==True, return current camera status as a set of enabled status states; otherwise, return tuple (status, warnings, errors) with additional information about warnings and error.

get_temperature()[source]

Get the current camera temperature

Return tuple (CCD, cam, power) with temperatures of the sensor, camera, and power supply respectively.

get_conversion_factor()[source]

Get camera conversion factor (electrons per pixel value)

get_trigger_mode()[source]

Get current trigger mode (see set_trigger_mode() for description)

set_trigger_mode(mode)[source]

Set trigger mode.

Can be "int" (internal), "software" (software), "ext" (external+software), "ext_exp" (external exposure), "ext_sync" (external PLL sync), "ext_exp_fast" (fast external exposure), "ext_cds" (external CDS control), "ext_exp_slow" (slow external exposure)`, or "ext_sync_hdsdi" (external synchronized SD/HDI).

For description, see PCO SDK manual.

send_software_trigger()[source]

Send software trigger signal

class ScheduleLooper[source]

Bases: object

Cython-based schedule loop manager.

Runs the loop function and provides callback storage.

loop(handle, nbuff, buffers, buffer_size, set_idx)[source]
reset()[source]
notify()[source]
class BufferManager(nbuff, size, metadata_size=0)[source]

Bases: object

Frame buffer managers.

Stores and accesses frame buffer and status arrays and buffer info.

get_buffer_ptr(n)[source]

Get address of n’th frame buffer

get_internal_buffer_status()[source]

Get the status of the internal smaller API buffer, showing the number of scheduled frames there, and the maximal number that can be scheduled

set_exposure(exposure)[source]

Set camera exposure

get_exposure()[source]

Get current exposure

set_frame_delay(frame_delay)[source]

Set camera frame delay

get_frame_delay()[source]

Get current frame delay

set_frame_period(frame_time=0, adjust_exposure=False)[source]

Set frame time (frame acquisition period).

If the time can’t be achieved even with zero frame delay and adjust_exposure==True, try to reduce the exposure to get the desired frame time; otherwise, keep the exposure the same.

get_frame_period()[source]

Get current frame time (frame acquisition period)

get_frame_timings()[source]

Get acquisition timing.

Return tuple (exposure, frame_period).

get_pixel_rate()[source]

Get camera pixel rate (in Hz)

get_available_pixel_rates()[source]

Get all available pixel rates

set_pixel_rate(rate=None)[source]

Set camera pixel rate (in Hz)

The rate is always rounded to the closest available. If rate is None, set the maximal possible rate.

setup_acquisition(nframes=100)[source]

Setup acquisition.

nframes determines number of size of the ring buffer (by default, 100).

start_acquisition(*args, **kwargs)[source]

Start acquisition.

Can take the same keyword parameters as :meth:``setup_acquisition. If the acquisition is not set up yet, set it up using the supplied parameters (use default of setup_acquisition(),if the parameter is None). Otherwise, if any supplied parameters are different from the current ones, change them and reset the acquisition.

stop_acquisition()[source]

Stop acquisition.

Clears buffers as well, so any readout afterwards is impossible.

acquisition_in_progress()[source]

Check if the acquisition is in progress

clear_acquisition()[source]

Clear acquisition settings

get_detector_size()[source]

Get camera detector size (in pixels) as a tuple (width, height)

get_roi()[source]

Get current ROI.

Return tuple (hstart, hend, vstart, vend, hbin, vbin). hstart and hend specify horizontal image extent, vstart and vend specify vertical image extent (start is inclusive, stop is exclusive, starting from 0), hbin and vbin specify binning.

set_roi(hstart=0, hend=None, vstart=0, vend=None, hbin=1, vbin=1, symmetric=False)[source]

Setup camera ROI.

hstart and hend specify horizontal image extent, vstart and vend specify vertical image extent (start is inclusive, stop is exclusive, starting from 0), hbin and vbin specify binning. By default, all non-supplied parameters take extreme values (0 for start, maximal for end, 1 for binning). If symmetric==True and camera requires symmetric ROI (see requires_symmetric_roi()), respect this symmetry in the resulting ROI; otherwise, try to use software ROI feature to set up the required ranges (note: while software ROI does affect the size of the read out frame, it does not change the readout time, which would be the same as with symmetric==True).

requires_symmetric_roi()[source]

Check if the camera requires horizontally or vertically symmetric ROI.

Return a tuple (horizontal, vertical). If True, one might still set up an asymmetric ROI for some cameras using the software ROI feature, but it does not affect camera readout rate

get_roi_limits(hbin=1, vbin=1)[source]

Get the minimal and maximal ROI parameters.

Return tuple (hlim, vlim), where each element is in turn a limit 5-tuple (min, max, pstep, sstep, maxbin) with, correspondingly, minimal and maximal size, position and size step, and the maximal binning. In some cameras, the step and the minimal size depend on the binning, which can be supplied.

enable_pixel_correction(enable=True)[source]

Enable or disable hotpixel correction

is_pixel_correction_enabled()[source]

Check if hotpixel correction is enabled

get_noise_filter_mode()[source]

Get the noise filter mode (for details, see set_noise_filter_mode())

set_noise_filter_mode(mode='on')[source]

Set the noise filter mode.

Can be "off", "on", or "on_hpc" (on + hot pixel correction).

set_status_line_mode(binary=True, text=False)[source]

Set status line mode.

binary determines if the binary line is present (it occupies first 14 pixels of the image). text determines if the text line is present (it is plane text timestamp, which takes first 8 rows and about 300 columns).

It is recommended to always have binary option on, since it is used to determine frame index for checking if there are any missing frames.

get_status_line_mode()[source]

Get status line mode.

Return tuple (binary, text) (see set_status_line_mode() for description)

get_bit_alignment()[source]

Get data bit alignment

Can be "LSB" (normal alignment) or "MSB" (if camera data is less than 16 bit, it is padded with zeros on the right to match 16 bit).

set_bit_alignment(mode)[source]

Get data bit alignment

Can be "LSB" (normal alignment) or "MSB" (if camera data is less than 16 bit, it is padded with zeros on the right to match 16 bit).

set_metadata_mode(mode=True)[source]

Set metadata mode

get_metadata_mode()[source]

Get metadata mode.

Return tuple (enabled, size, version)

get_double_image_mode()[source]

Check if the double image mode is active

set_double_image_mode(enable)[source]

Enable or disable the double image mode

FrameTransferError

alias of DefaultFrameTransferError

apply_settings(settings)

Apply the settings.

settings is the dict {name: value} of the device available settings. Non-applicable settings are ignored.

get_acquisition_parameters()

Get acquisition parameters.

Return dictionary {name: value}

get_data_dimensions()

Get readout data dimensions (in pixels) as a tuple (width, height); take indexing mode into account

get_device_variable(key)

Get the value of a settings, status, or full info parameter

get_frame_format()

Get format for the returned images.

Can be "list" (list of 2D arrays), "array" (a single 3D array), or "chunks" (list of 3D “chunk” arrays; supported for some cameras and provides the best performance).

get_frame_info_fields()

Get the names of frame info fields.

Applicable when frame info format (set by set_frame_info_format()) is "list" or "array".

get_frame_info_format()

Get format of the frame info.

Can be "namedtuple" (potentially nested named tuples; convenient to get particular values), "list" (flat list of values, with field names are given by get_frame_info_fields(); convenient for building a table), "array" (same as "list", but with a numpy array, which is easier to use for "chunks" frame format), or "dict" (flat dictionary with the same fields as the "list" format; more resilient to future format changes)

get_frame_info_period()

Get period of frame info acquisition.

Frame info might be skipped (set to None) except for frames which indices are divisible by period. Useful for certain cameras where acquiring frame info takes a lot of time and can reduce performance at higher frame rates. Note that this parameter can still be ignored (i.e., always set to 1) if the performance is not an issue for a given camera class.

get_frames_status()

Get acquisition and buffer status.

Return tuple (acquired, unread, skipped, size), where acquired is the total number of acquired frames, unread is the number of acquired but not read frames, skipped is the number of skipped (not read and then written over) frames, and buffer_size is the total buffer size (in frames).

get_full_info(include=0)

Get dict {name: value} containing full device information (including status and settings).

include specifies either a list of variables (only these variables are returned), a priority threshold (only values with the priority equal or higher are returned), or "all" (all available variables). Since the lowest priority is -10, setting include=-10 queries all available variables, which is equivalent to include="all".

get_full_status(include=0)

Get dict {name: value} containing the device status (including settings).

include specifies either a list of variables (only these variables are returned), a priority threshold (only values with the priority equal or higher are returned), or "all" (all available variables). Since the lowest priority is -10, setting include=-10 queries all available variables, which is equivalent to include="all".

get_image_indexing()

Get indexing for the returned images.

Can be "rct" (first index row, second index column, rows counted from the top), "rcb" (same as "rc", rows counted from the bottom), "xyt" (first index column, second index row, rows counted from the top), or "xyb" (same as "xyt", rows counted from the bottom)

get_new_images_range()

Get the range of the new images.

Return tuple (first, last) with images range (first inclusive). If no images are available, return None. If some images were in the buffer were overwritten, exclude them from the range.

get_settings(include=0)

Get dict {name: value} containing all the device settings.

include specifies either a list of variables (only these variables are returned), a priority threshold (only values with the priority equal or higher are returned), or "all" (all available variables). Since the lowest priority is -10, setting include=-10 queries all available variables, which is equivalent to include="all".

grab(nframes=1, frame_timeout=5.0, missing_frame='skip', return_info=False, buff_size=None)

Snap nframes images (with preset image read mode parameters)

buff_size determines buffer size (if None, use the default size). Timeout is specified for a single-frame acquisition, not for the whole acquisition time. missing_frame determines what to do with frames which have been lost: can be "none" (replacing them with None), "zero" (replacing them with zero-filled frame), or "skip" (skipping them, while still keeping total returned frames number to n). If return_info==True, return tuple (frames, infos), where infos is a list of frame info tuples (camera-dependent); if some frames are missing and missing_frame!="skip", the corresponding frame info is None.

is_acquisition_setup()

Check if acquisition is set up.

If the camera does not support separate acquisition setup, always return True.

pausing_acquisition(clear=None, stop=True, setup_after=None, start_after=True, combine_nested=True)

Context manager which temporarily pauses acquisition during execution of with block.

Useful for applying certain settings which can’t be changed during the acquisition. If clear==True, clear acquisition in addition to stopping (by default, use the class default specified as _clear_pausing_acquisition attribute). If stop==True, stop the acquisition (if clear==True, stop regardless). If setup_after==True, setup the acquisition after pause if necessary (None means setup only if clearing was required). If start_after==True, start the acquisition after pause if necessary (None means start only if stopping was required). If combine_nested==True, then any nested pausing_acquisition calls will stop/clear acquisition as necessary, but won’t setup/start it again until this pausing_acquisition call is complete.

Yields tuple (acq_in_progress, acq_params), which indicates whether acquisition is currently in progress, and what are the current acquisition parameters.

read_multiple_images(rng=None, peek=False, missing_frame='skip', return_info=False, return_rng=False)

Read multiple images specified by rng (by default, all un-read images).

If rng is specified, it is a tuple (first, last) with images range (first inclusive). If no new frames are available, return an empty list; if no acquisition is running, return None. If peek==True, return images but not mark them as read. missing_frame determines what to do with frames which are out of range (missing or lost): can be "none" (replacing them with None), "zero" (replacing them with zero-filled frame), or "skip" (skipping them). If return_info==True, return tuple (frames, infos), where infos is a list of frame info tuples (camera-dependent, by default, only the frame index); if some frames are missing and missing_frame!="skip", the corresponding frame info is None. if return_rng==True, return the range covered resulting frames; if missing_frame=="skip", the range can be smaller than the supplied rng if some frames are skipped.

read_newest_image(peek=False, return_info=False)

Read the newest un-read image.

If no un-read frames are available, return None. If peek==True, return the image but not mark it as read. If return_info==True, return tuple (frame, info), where info is an info tuples (camera-dependent, see read_multiple_images()).

read_oldest_image(peek=False, return_info=False)

Read the oldest un-read image.

If no un-read frames are available, return None. If peek==True, return the image but not mark it as read. If return_info==True, return tuple (frame, info), where info is an info tuples (camera-dependent, see read_multiple_images()).

set_device_variable(key, value)

Set the value of a settings parameter

set_frame_format(fmt)

Set format for the returned images.

Can be "list" (list of 2D arrays), "array" (a single 3D array), "chunks" (list of 3D “chunk” arrays; supported for some cameras and provides the best performance), or "try_chunks" (same as "chunks", but if chunks are not supported, set to "list" instead). If format is "chunks" and chunks are not supported by the camera, it results in one frame per chunk. Note that if the format is set to "array" or "chunks", the frame info format is also automatically set to "array". If the format is set to "chunks", then the image info is also returned in chunks form (list of 2D info arrays with the same length as the corresponding frame chunks).

set_frame_info_format(fmt, include_fields=None)

Set format of the frame info.

Can be "namedtuple" (potentially nested named tuples; convenient to get particular values), "list" (flat list of values, with field names are given by get_frame_info_fields(); convenient for building a table), "array" (same as "list", but with a numpy array, which is easier to use for "chunks" frame format), or "dict" (flat dictionary with the same fields as the "list" format; more resilient to future format changes) If include_fields is not None, it specifies the fields included for non-"tuple" formats; note that order or include_fields is ignored, and the resulting fields are always ordered same as in the original.

set_frame_info_period(period=1)

Set period of frame info acquisition.

Frame info might be skipped (set to None) except for frames which indices are divisible by period. Useful for certain cameras where acquiring frame info takes a lot of time and can reduce performance at higher frame rates. Note that this parameter can still be ignored (i.e., always set to 1) if the performance is not an issue for a given camera class.

set_image_indexing(indexing)

Set up indexing for the returned images.

Can be "rct" (first index row, second index column, rows counted from the top), "rcb" (same as "rc", rows counted from the bottom), "xyt" (first index column, second index row, rows counted from the top), or "xyb" (same as "xyt", rows counted from the bottom)

snap(timeout=5.0, return_info=False)

Snap a single frame

wait_for_frame(since='lastread', nframes=1, timeout=20.0, error_on_stopped=False)

Wait for one or several new camera frames.

since specifies the reference point for waiting to acquire nframes frames; can be “lastread”`` (from the last read frame), "lastwait" (wait for the last successful wait_for_frame() call), "now" (from the start of the current call), or "start" (from the acquisition start, i.e., wait until nframes frames have been acquired). timeout can be either a number, None (infinite timeout), or a tuple (timeout, frame_timeout), in which case the call times out if the total time exceeds timeout, or a single frame wait exceeds frame_timeout. If the call times out, raise TimeoutError. If error_on_stopped==True and the acquisition is not running, raise Error; otherwise, simply return False without waiting.

class pylablib.devices.PCO.SC2.TStatusLine(framestamp)

Bases: tuple

framestamp
pylablib.devices.PCO.SC2.get_status_line(frame)[source]

Get frame info from the binary status line.

Assume that the status line is present; if it isn’t, the returned frame info will be a random noise.

pylablib.devices.PCO.SC2.get_status_lines(frames)[source]

Get frame info from the binary status line.

frames can be 2D array (one frame), 3D array (stack of frames, first index is frame number), or list of 1D or 2D arrays. Assume that the status line is present; if it isn’t, the returned frame info will be a random noise. Return a 1D or 2D numpy array, where the first axis (if present) is the frame number, and the last is the status line entry.

class pylablib.devices.PCO.SC2.StatusLineChecker[source]

Bases: StatusLineChecker

get_framestamp(frames)[source]

Get framestamps from status lines in the given frames

check_indices(indices, step=1)[source]

Check if indices are consistent with the given step

Module contents