pylablib.devices.Andor package

Submodules

pylablib.devices.Andor.AndorSDK2 module

class pylablib.devices.Andor.AndorSDK2.LibraryController(lib)[source]

Bases: pylablib.devices.utils.load_lib.LibraryController

close(opid)[source]

Mark device closing.

Return tuple (close_result, uninit_result) with the results of the closing and the shutdown. If library does not need to be shut down yet, set uninit_result=None

open()[source]

Mark device opening.

Return tuple (init_result, open_result, opid) with the results of the initialization and the opening, and the opening ID which should afterwards be used for closing. If library is already initialized, set init_result=None

preinit()[source]

Pre-initialize the library, if it hasn’t been done already

shutdown()[source]

Close all opened connections and shutdown the library

temp_open()[source]

Context for temporarily opening a new device connection

pylablib.devices.Andor.AndorSDK2.restart_lib()[source]
pylablib.devices.Andor.AndorSDK2.get_cameras_number()[source]

Get number of connected Andor cameras

class pylablib.devices.Andor.AndorSDK2.TDeviceInfo(controller_model, head_model, serial_number)

Bases: tuple

controller_model
count()

Return number of occurrences of value.

head_model
index()

Return first index of value.

Raises ValueError if the value is not present.

serial_number
class pylablib.devices.Andor.AndorSDK2.TCycleTimings(exposure, accum_cycle_time, kinetic_cycle_time)

Bases: tuple

accum_cycle_time
count()

Return number of occurrences of value.

exposure
index()

Return first index of value.

Raises ValueError if the value is not present.

kinetic_cycle_time
class pylablib.devices.Andor.AndorSDK2.TAcqProgress(frames_done, cycles_done)

Bases: tuple

count()

Return number of occurrences of value.

cycles_done
frames_done
index()

Return first index of value.

Raises ValueError if the value is not present.

class pylablib.devices.Andor.AndorSDK2.AndorSDK2Camera(idx=0, ini_path='', temperature=None, fan_mode='off', amp_mode=None)[source]

Bases: pylablib.devices.interface.camera.IBinROICamera, pylablib.devices.interface.camera.IExposureCamera

Andor SDK2 camera.

Due to the library features, the camera needs to set up all of the parameters to some default values upon connection. Most of these parameters are chosen as reasonable defaults: full ROI, minimal exposure time, closed shutter, internal trigger, fastest recommended verticals shift speed, no EMCCD gain. However, some should be supplied during the connection: temperature setpoint (where appropriate), fan mode, and amplifier mode; while there is still a possibility to have default values of these parameters, they might not be appropriate in some settings, and frequently need to be changed.

Caution: the manufacturer DLL is designed such that if the camera is not closed on the program termination, the allocated resources are never released. If this happens, these resources are blocked until the complete OS restart.

Parameters:
  • idx (int) – camera index (use get_cameras_number() to get the total number of connected cameras)
  • ini_path (str) – path to .ini file, if required by the camera
  • temperature – initial temperature setpoint (in C); can also be None (select the bottom 20% of the whole range), or "off" (turn the cooler off and set the maximal of the whole range)
  • fan_mode – initial fan mode
  • amp_mode – initial amplifier mode (a tuple like the one returned by get_amp_mode()); can also be None, which selects the slowest, smallest gain mode
Error

alias of pylablib.devices.Andor.base.AndorError

TimeoutError

alias of pylablib.devices.Andor.base.AndorTimeoutError

open()[source]

Open connection to the camera

close()[source]

Close connection to the camera

is_opened()[source]

Check if the device is connected

get_device_info()[source]

Get camera device info.

Return tuple (controller_mode, head_model, serial_number).

get_status()[source]

Get camera status.

Return either "idle" (no acquisition), "acquiring" (acquisition in progress) or "temp_cycle" (temperature cycle in progress).

acquisition_in_progress()[source]

Check if acquisition is in progress

get_capabilities()[source]

Get camera capabilities.

For description of the structure, see Andor SDK manual.

get_pixel_size()[source]

Get camera pixel size (in m)

is_cooler_on()[source]

Check if the cooler is on

set_cooler(on=True)[source]

Set the cooler on or off

get_temperature_status()[source]

Get temperature status.

Can return "off" (cooler off), "not_reached" (cooling in progress), "not_stabilized" (reached but not stabilized yet), "stabilized" (completely stabilized) or "drifted".

get_temperature()[source]

Get the current camera temperature (in C)

set_temperature(temperature, enable_cooler=True)[source]

Change the temperature setpoint (in C).

If enable_cooler==True, turn the cooler on automatically.

get_temperature_setpoint()[source]

Get the temperature setpoint (in C)

get_temperature_range()[source]

Return the available range of temperatures (in C)

get_all_amp_modes()[source]

Get all available preamp modes.

Each preamp mode is characterized by an AD channel index, amplifier index, channel speed (horizontal scan speed) index and preamp gain index. Return list of tuples (channel, channel_bitdepth, oamp, oamp_kind, hsspeed, hsspeed_MHz, preamp, preamp_gain), where channel, oamp, hsspeed and preamp are indices, while channel_bitdepth, oamp_kind, hsspeed_MHz and preamp_gain are descriptions.

get_max_vsspeed()[source]

Get maximal recommended vertical scan speed

set_amp_mode(channel=None, oamp=None, hsspeed=None, preamp=None)[source]

Setup preamp mode.

Can specify AD channel index, amplifier index, channel speed (horizontal scan speed) index and preamp gain index. None (default) means leaving the current value.

get_amp_mode(full=True)[source]

Return the current amplifier mode.

If full==True, return a full description (e.g., actual preamp gain or channel name); otherwise, return just the essential indices information (enough to set the mode for this camera, but no explanations).

set_vsspeed(vsspeed)[source]

Set vertical scan speed index

get_channel()[source]

Get current channel index

get_channel_bitdepth(channel=None)[source]

Get channel bit depth corresponding to the given channel index (current by default)

get_oamp()[source]

Get current output amplifier index

get_oamp_desc(oamp=None)[source]

Get output amplifier kind corresponding to the given oamp index (current by default)

get_hsspeed()[source]

Get current horizontal speed index

get_hsspeed_frequency(hsspeed=None)[source]

Get horizontal scan frequency (in Hz) corresponding to the given hsspeed index (current by default)

get_preamp()[source]

Get current preamp index

get_preamp_gain(preamp=None)[source]

Get preamp gain corresponding to the given preamp index (current by default)

get_vsspeed()[source]

Get current vertical speed index

get_vsspeed_period(vsspeed=None)[source]

Get vertical scan period corresponding to the given vsspeed index (current by default)

get_EMCCD_gain()[source]

Get current EMCCD gain.

Return tuple (gain, advanced).

set_EMCCD_gain(gain, advanced=None)[source]

Set EMCCD gain.

Gain goes up to 300 if advanced==False or higher if advanced==True (in this mode the sensor can be permanently damaged by strong light).

init_amp_mode(mode=None)[source]

Initialize the camera channel, frequencies and amp settings to some default mode.

If mode is supplied, use this mode; otherwise, use the slowest, lowest gain mode (the first one returned by get_all_amp_modes()). Also set the maximal recommended vertical shift speed and no EMCCD gain.

get_min_shutter_times()[source]

Get minimal shutter opening and closing times

setup_shutter(mode, ttl_mode=0, open_time=None, close_time=None)[source]

Setup shutter.

mode can be "auto", "open" or "closed", ttl_mode can be 0 (low is open) or 1 (high is open), open_time and close_time specify opening and closing times (required to calculate the minimal exposure times). By default, these time are minimal allowed times.

get_shutter_parameters()[source]

Return shutter parameters as a tuple (mode, ttl_mode, open_time, close_time)

get_shutter()[source]

Get shutter state ("auto", "open", or "closed")

set_fan_mode(mode)[source]

Set fan mode.

Can be "full", "low" or "off".

get_fan_mode()[source]

Return fan mode ("full", "low", or "off")

read_in_aux_port(port)[source]

Get state at a given auxiliary port

set_out_aux_port(port, state)[source]

Set state at a given auxiliary port

set_trigger_mode(mode)[source]

Set trigger mode.

Can be "int" (internal), "ext" (external), "ext_start" (external start), "ext_exp" (external exposure), "ext_fvb_em" (external FVB EM), "software" (software trigger) or "ext_charge_shift" (external charge shifting).

For description, see Andor SDK manual.

get_trigger_mode()[source]

Return trigger mode

get_trigger_level_limits()[source]

Get limits on the trigger level

setup_ext_trigger(level=None, invert=None, term_highZ=None)[source]

Setup external trigger (level, inversion, and high-Z termination).

Any None values are not changed. If any returned values are None, it means that this option is not supported.

get_ext_trigger_parameters()[source]

Return external trigger parameters (level, inversion, high-Z termination).

If any returned values are None, it means that this option is not supported.

send_software_trigger()[source]

Send software trigger signal

set_acquisition_mode(mode, setup_params=True)[source]

Set the acquisition mode.

Can be "single", "accum", "kinetic", "fast_kinetic" or "cont" (continuous). If setup_params==True, make sure that the last specified parameters for this mode are set up. For description of each mode, see Andor SDK manual and corresponding setup_*_mode functions.

get_acquisition_mode()[source]

Get the current acquisition mode

setup_accum_mode(num_acc, cycle_time_acc=0)[source]

Switch into the accum acquisition mode and set up its parameters.

num_acc is the number of accumulated frames, cycle_time_acc is the acquisition period (by default the minimal possible based on exposure and transfer time).

get_accum_mode_parameters()[source]

Return accum acquisition mode parameters (num_acc, cycle_time_acc)

setup_kinetic_mode(num_cycle, cycle_time=0.0, num_acc=1, cycle_time_acc=0, num_prescan=0)[source]

Switch into the kinetic acquisition mode and set up its parameters.

num_cycle is the number of kinetic cycles frames, cycle_time is the acquisition period between accum frames, num_accum is the number of accumulated frames, cycle_time_acc is the accum acquisition period, num_prescan is the number of prescans.

get_kinetic_mode_parameters()[source]

Return kinetic acquisition mode parameters (num_cycle, cycle_time, num_acc, cycle_time_acc, num_prescan)

setup_fast_kinetic_mode(num_acc, cycle_time_acc=0.0)[source]

Switch into the fast kinetic acquisition mode and set up its parameters.

num_acc is the number of accumulated frames, cycle_time_acc is the acquisition period (by default the minimal possible based on exposure and transfer time).

get_fast_kinetic_mode_parameters()[source]

Return fast kinetic acquisition mode parameters (num_acc, cycle_time_acc)

setup_cont_mode(cycle_time=0)[source]

Switch into the continuous acquisition mode and set up its parameters.

cycle_time is the acquisition period (by default the minimal possible based on exposure and transfer time).

get_cont_mode_parameters()[source]

Return continuous acquisition mode parameters cycle_time

set_exposure(exposure)[source]

Set camera exposure

get_exposure()[source]

Get current exposure

set_frame_period(frame_period)[source]

Set frame acquisition period for the continuous mode

enable_frame_transfer_mode(enable=True)[source]

Enable frame transfer mode.

For description, see Andor SDK manual.

is_frame_transfer_enabled()[source]

Return whether the frame transfer mode is enabled

get_cycle_timings()[source]

Get acquisition timing.

Return tuple (exposure, accum_cycle_time, kinetic_cycle_time). In continuous mode, the relevant cycle time is kinetic_cycle_time.

get_frame_timings()[source]

Get acquisition timing.

Return tuple (exposure, frame_period). Frame period is the rate of frame generation, not of internal frame acquisition (e.g., in accumulator or kinetic mode this is the rate of generating a single accumulated frame, which is num_acc times larger than the internal frame period).

get_readout_time()[source]

Get frame readout time

get_keepclean_time()[source]

Get sensor keep-clean time

set_read_mode(mode)[source]

Set camera read mode.

Can be "fvb" (average all image vertically and return it as one row), "single_track" (read a single row or several rows averaged together), "multi_track" (read multiple rows or averaged sets of rows), "random_track" (read several arbitrary lines), or "image" (read a whole image or its rectangular part).

get_read_mode()[source]

Get the current read mode

setup_single_track_mode(center=0, width=1)[source]

Switch into the singe-track read mode and set up its parameters.

center and width specify selection of the rows to be averaged together.

get_single_track_mode_parameters()[source]

Return singe-track read mode parameters (center, width)

setup_multi_track_mode(number=1, height=1, offset=1)[source]

Switch into the multi-track read mode and set up its parameters.

number is the number of rows (or row sets) to read, height is number of one row set (1 for a single row), offset is the distance between the row sets. Return a tuple (number, height, offset, top, gap), where top is the offset of the first row from the top, and gap is the gap between the tracks.

get_multi_track_mode_parameters()[source]

Return multi-track read mode parameters (number, height, offset)

setup_random_track_mode(tracks=None)[source]

Switch into the random-track read mode and set up its parameters.

tracks is a list of tuples (start, stop) specifying track span (start are inclusive, stop are exclusive, starting from 0). Note that it does not affect the current read mode, which should be set using set_read_mode().

get_random_track_mode_parameters()[source]

Return random-track read mode parameters, i.e., the list of track positions

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

Switch into the image read mode and set up its parameters.

hstart and hend specify horizontal image extent, vstart and vend specify vertical image extent (start are inclusive, stop are exclusive, starting from 0), hbin and vbin specify binning. By default, all non-supplied parameters take extreme values.

get_image_mode_parameters()[source]

Return image read mode parameters, (hstart, hend, vstart, vend, hbin, vbin)

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)[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).

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.

setup_acquisition(mode=None, nframes=None)[source]

Setup acquisition.

Any non-specified acquisition parameters are assumed to be the same as previously set (or default, if not explicitly set before). Return the new acquisition parameters.

clear_acquisition()[source]

Clear acquisition settings

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

get_acquisition_progress()[source]

Get acquisition progress.

Return tuple (frames_done, acc_done) with the number of full transferred frames and the number of acquired sub-frames in the current accumulation cycle.

get_buffer_size()[source]

Get the size of the image ring buffer

FrameTransferError

alias of pylablib.devices.interface.camera.DefaultFrameTransferError

class NoParameterCaller(device, kind)

Bases: object

Class to simplify calling functions without a parameter

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_frame_period()

Get frame period (time between two consecutive frames in the internal trigger mode)

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.

pylablib.devices.Andor.AndorSDK3 module

class pylablib.devices.Andor.AndorSDK3.LibraryController(lib)[source]

Bases: pylablib.devices.utils.load_lib.LibraryController

close(opid)[source]

Mark device closing.

Return tuple (close_result, uninit_result) with the results of the closing and the shutdown. If library does not need to be shut down yet, set uninit_result=None

open()[source]

Mark device opening.

Return tuple (init_result, open_result, opid) with the results of the initialization and the opening, and the opening ID which should afterwards be used for closing. If library is already initialized, set init_result=None

preinit()[source]

Pre-initialize the library, if it hasn’t been done already

shutdown()[source]

Close all opened connections and shutdown the library

temp_open()[source]

Context for temporarily opening a new device connection

pylablib.devices.Andor.AndorSDK3.restart_lib()[source]
pylablib.devices.Andor.AndorSDK3.get_cameras_number()[source]

Get number of connected Andor cameras

class pylablib.devices.Andor.AndorSDK3.AndorSDK3Attribute(handle, name, kind='auto')[source]

Bases: object

Andor SDK3 camera attribute.

Allows to query and set values and get additional information. Usually created automatically by a Andor SDK3 camera instance, but could also be created manually.

Parameters:
  • handle – Andor SDK3 camera handle
  • pid – attribute id
  • kind – attribute kind; can be "float", "int", "str", "bool", "enum", or "comm" (command); can also be "auto" (default), in which case it is obtained from the stored feature table; newer features might be missing, in which case kind needs to be supplied explicitly, or it raises an error
name

attribute name

kind

attribute kind; can be "float", "int", "str", "bool", "enum", or "comm" (command)

implemented

whether attribute is implemented

Type:bool
readable

whether attribute is readable

Type:bool
writable

whether attribute is writable

Type:bool
min

minimal attribute value (if applicable)

Type:float or int
max

maximal attribute value (if applicable)

Type:float or int
ivalues

list of possible integer values for enum attributes

values

list of possible text values for enum attributes

labels

dict {label: index} which shows all possible values of an enumerated attribute and their corresponding numerical values

ilabels

dict {index: label} which shows labels corresponding to numerical values of an enumerated attribute

is_command

whether attribute is a command (same as kind=="comm")

Type:bool
update_properties()[source]

Update all attribute properties: implemented, readable, writable, limits

get_value(enum_as_str=True, not_implemented_error=True, default=None)[source]

Get current value.

If enum_as_str==True, return enum values as strings; otherwise, return as indices. If not_implemented_error==True and the feature is not implemented, raise AndorError; otherwise, return default if it is not implemented.

set_value(value, not_implemented_error=True)[source]

Set current value.

If not_implemented_error==True and the feature is not implemented, raise AndorError; otherwise, do nothing.

call_command()[source]

Execute the given command

get_range(enum_as_str=True)[source]

Get allowed range of the given value.

For "int" or "float" values return tuple (min, max) (inclusive); for "enum" return list of possible values (if enum_as_str==True, return list of string values, otherwise return list of indices). For all other value kinds return None.

update_limits()[source]

Update minimal and maximal attribute limits and return tuple (min, max)

truncate_value(value)[source]

Limit value to lie within the allowed range

class pylablib.devices.Andor.AndorSDK3.TDeviceInfo(camera_name, camera_model, serial_number, firmware_version, software_version)

Bases: tuple

camera_model
camera_name
count()

Return number of occurrences of value.

firmware_version
index()

Return first index of value.

Raises ValueError if the value is not present.

serial_number
software_version
class pylablib.devices.Andor.AndorSDK3.TMissedFramesStatus(skipped, overflows)

Bases: tuple

count()

Return number of occurrences of value.

index()

Return first index of value.

Raises ValueError if the value is not present.

overflows
skipped
class pylablib.devices.Andor.AndorSDK3.TFrameInfo(frame_index, timestamp_dev, size, pixeltype, stride)

Bases: tuple

count()

Return number of occurrences of value.

frame_index
index()

Return first index of value.

Raises ValueError if the value is not present.

pixeltype
size
stride
timestamp_dev
class pylablib.devices.Andor.AndorSDK3.AndorSDK3Camera(idx=0)[source]

Bases: pylablib.devices.interface.camera.IBinROICamera, pylablib.devices.interface.camera.IExposureCamera, pylablib.devices.interface.camera.IAttributeCamera

Andor SDK3 camera.

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

alias of pylablib.devices.Andor.base.AndorError

TimeoutError

alias of pylablib.devices.Andor.base.AndorTimeoutError

FrameTransferError

alias of pylablib.devices.Andor.base.AndorFrameTransferError

open()[source]

Open connection to the camera

close()[source]

Close connection to the camera

is_opened()[source]

Check if the device is connected

add_attribute(name, kind)[source]

Add a new attribute which is not currently present in the dictionary.

kind can be "float", "int", "str", "bool", "enum", or "comm" (command).

get_attribute(name, update_properties=False, error_on_missing=True)[source]

Get the camera attribute with the given name.

If update_properties==True, automatically update all attribute properties.

get_attribute_value(name, enum_as_str=True, update_properties=False, error_on_missing=True, default=None)[source]

Get value of an attribute with the given name.

If update_properties==True, automatically update all attribute properties before settings. If the value doesn’t exist or can not be read and error_on_missing==True, raise error; otherwise, return default. If default is not None, assume that error_on_missing==False.

set_attribute_value(name, value, update_properties=True, error_on_missing=True)[source]

Set value of an attribute with the given name.

If the value doesn’t exist or can not be written and error_on_missing==True, raise error; otherwise, do nothing. If update_properties==True, automatically update all attribute properties before settings.

get_all_attribute_values(root='', enum_as_str=True, update_properties=False)[source]

Get values of all attributes.

If update_properties==True, automatically update all attribute properties before settings.

set_all_attribute_values(settings, update_properties=True)[source]

Set values of all attribute in the given dictionary.

If update_properties==True, automatically update all attribute properties before settings.

call_command(name)[source]

Execute the given command

get_device_info()[source]

Get camera info.

Return tuple (camera_name, camera_model, serial_number, firmware_version, software_version).

get_trigger_mode()[source]

Get trigger mode.

Can be "int" (internal), "ext" (external), "software" (software trigger),
"ext_start" (external start), or "ext_exp" (external exposure).
set_trigger_mode(mode)[source]

Set trigger mode.

Can be "int" (internal), "ext" (external), or "software" (software trigger).

get_shutter()[source]

Get current shutter mode

set_shutter(mode)[source]

Set trigger mode.

Can be "open", "closed", or "auto".

is_cooler_on()[source]

Check if the cooler is on

set_cooler(on=True)[source]

Set the cooler on or off

get_temperature()[source]

Get the current camera temperature

get_temperature_setpoint()[source]

Get current temperature setpoint

set_temperature(temperature, enable_cooler=True)[source]

Change the temperature setpoint.

If enable_cooler==True, turn the cooler on automatically.

get_exposure()[source]

Get current exposure

set_exposure(exposure)[source]

Set camera exposure

get_frame_period()[source]

Get frame period (time between two consecutive frames in the internal trigger mode)

set_frame_period(frame_period)[source]

Set frame period (time between two consecutive frames in the internal trigger mode)

get_frame_timings()[source]

Get acquisition timing.

Return tuple (exposure, frame_period).

is_metadata_enabled()[source]

Check if the metadata enabled

enable_metadata(enable=True)[source]

Enable or disable metadata streaming

class BufferManager(cam)[source]

Bases: object

Buffer manager: stores, constantly reads and re-schedules buffers, keeps track of acquired frames and buffer overflow events

allocate_buffers(nbuff, size, queued_buffers=None)[source]

Allocate and queue buffers.

queued_buffers` specifies number of allocated buffers to keep queued at a given time (by default, all of them)

queue_buffer(queued_buffers)[source]

Queue extra buffers (only before any buffers are read)

deallocate_buffers()[source]

Deallocated buffers (flushing should be done manually)

reset()[source]

Reset counter (on frame acquisition)

read(idx)[source]

Return the oldest available acquired but not read buffer, and mark it as read

start_loop()[source]

Start buffer scheduling loop

stop_loop()[source]

Stop buffer scheduling loop

wait_for_frame(idx=None, timeout=None)[source]

Wait for a new frame acquisition

on_overflow()[source]

Process buffer overflow event

new_overflow()[source]
get_status()[source]

Get counter status: tuple (acquired, total_length)

setup_acquisition(mode='sequence', nframes=100)[source]

Setup acquisition.

mode can be either "snap" (single frame or a fixed number of frames) or "sequence" (continuous acquisition). nframes determines number of frames to acquire in the single mode, or size of the ring buffer in the "sequence" mode (by default, 100).

clear_acquisition()[source]

Clear acquisition settings

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

acquisition_in_progress()[source]

Check if acquisition is in progress

get_missed_frames_status()[source]

Get missed frames status.

Return tuple (skipped, overflows) with the number skipped frames (sent from camera to the PC, but not read and overwritten) and number of buffer overflows (events when the frame rate is too for the data transfer, so some unknown number of frames is skipped).

reset_overflows_counter()[source]

Reset buffer overflows counter

set_overflow_behavior(behavior)[source]

Choose the camera behavior if buffer overflow is encountered when waiting for a new frame.

Can be "error" (raise AndorFrameTransferError), "restart" (restart the acquisition), or "ignore" (ignore the overflow, which will cause the wait to time out).

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).

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

Set current ROI.

By default, all non-supplied parameters take extreme values. Binning is the same for both axes.

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.

Note that the minimal ROI size depends on the current (not just supplied) binning settings. For more accurate results, is it only after setting up the binning.

class NoParameterCaller(device, kind)

Bases: object

Class to simplify calling functions without a parameter

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_all_attributes(copy=False)

Return a dictionary of all available attributes.

If copy==True, copy the dictionary; otherwise, return the internal dictionary structure (should not be modified).

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_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.

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

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 TFrameInfo instances describing frame index and frame metadata, which contains timestamp, image size, pixel format, and row stride; 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.

pylablib.devices.Andor.atcore_features module

pylablib.devices.Andor.base module

exception pylablib.devices.Andor.base.AndorError[source]

Bases: pylablib.core.devio.base.DeviceError

Generic Andor error

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception pylablib.devices.Andor.base.AndorTimeoutError[source]

Bases: pylablib.devices.Andor.base.AndorError

Andor timeout error

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception pylablib.devices.Andor.base.AndorFrameTransferError[source]

Bases: pylablib.devices.Andor.base.AndorError

Andor frame transfer error

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception pylablib.devices.Andor.base.AndorNotSupportedError[source]

Bases: pylablib.devices.Andor.base.AndorError

Option not supported error

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

Module contents