pyccapt.control.tdc_surface_concept package

Submodules

pyccapt.control.tdc_surface_concept.scTDC module

Copyright 2018, 2019, 2021 Surface Concept GmbH

This file is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This file is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this file. If not, see <https://www.gnu.org/licenses/>.


Python wrapper for a subset of the scTDC library built on pythons ctypes module. The class scTDClib holds the dynamically loaded library object and provides all low-level functions supported by this wrapper. Additionally, this module defines structures from the scTDC_types.h header file. The functions defined in the scTDC class aim to match the original scTDC C API as close as possible, except for a few cases where they have been changed for more convenient use (sc_get_err_msg, for example).

A higher-level API is defined in the Device and Pipe classes, which facilitates usage of 1D,2D,3D histogram pipes, statistics data, and time histograms of stand-alone TDCs.

A higher-level API for processing of event data is provided via the classes buffered_data_callbacks_pipe and usercallbacks_pipe. usercallbacks_pipe has been in existence for a longer time, but it suffers from a high number of callbacks into python code which makes it rather slow. It is still included for backwards compatibility. The buffered_data_callbacks_pipe improves the performance by buffering a user-defined number of events and invoking callbacks into python code after filling this buffer and optionally at the end of each measurement. The buffer size can be tuned large enough to reduce the number of callbacks into python code. The data offered in the callbacks are in the form of 1D numpy arrays — one array for one selected event data field — ready to be processed in vectorized mathematical operations. The buffered_data_callbacks_pipe requires scTDC1 library versions not older than 1.3010.0.

Following constants are defined for selecting which event data fields shall be buffered by the buffered_data_callbacks_pipe interface: SC_DATA_FIELD_SUBDEVICE, SC_DATA_FIELD_CHANNEL, SC_DATA_FIELD_START_COUNTER, SC_DATA_FIELD_TIME_TAG, SC_DATA_FIELD_DIF1, SC_DATA_FIELD_DIF2, SC_DATA_FIELD_TIME, SC_DATA_FIELD_MASTER_RST_COUNTER, SC_DATA_FIELD_ADC, SC_DATA_FIELD_SIGNAL1BIT.

Some remarks concerning low-level interfaces: * Following constants are defined for pipe types: TDC_HISTO, DLD_IMAGE_XY,

DLD_IMAGE_XT, DLD_IMAGE_YT, DLD_IMAGE_3D, DLD_SUM_HISTO, STATISTICS, TMSTAMP_TDC_HISTO, TDC_STATISTICS, DLD_STATISTICS, USER_CALLBACKS, DLD_IMAGE_XY_EXT, BUFFERED_DATA_CALLBACKS. These are to be used for the pipe_type parameter in sc_pipe_open2.

  • Following constants are defined for bit sizes: BS8, BS16, BS32, BS64. These are to be used for the depth field in the structures sc_pipe_dld_image_xyt_params_t, sc_pipe_tdc_histo_params_t.


Additions 2019-09-19 : structures for USER_CALLBACKS pipe Additions 2019-10-15 : higher-level Device and Pipe classes Additions 2020-05-14 : added wrapper for a separate library to save DLD

events to HDF5

Additions 2021-06-15added support for BUFFERED_DATA_CALLBACKS pipe

(requires scTDC1 library version >= 1.3010.0)

class pyccapt.control.tdc_surface_concept.scTDC.Device(inifilepath='tdc_gpx3.ini', autoinit=True, lib=None)[source]

Bases: object

Creates a Device object that will use the specified inifilepath during initialization. If autoinit==True, initialize the hardware immediately. lib can be specified to reuse an existing scTDClib object.

add_3d_pipe(depth, modulo, binning, roi)[source]

Adds a 3D pipe (x,y,time) with static buffer. Returns a tuple containing a non-negative pipe ID on success and the Pipe object — or negative error code and a string containing the error message. depth is either BS8, BS16, BS32, BS64 and determines the voxel bit width. modulo unequal zero applies a modulo operation to the time before sorting it into the 3D buffer. Note that the modulo value is in digital time units _times_ 32. binning is a triple specifying the binning in x, y, and time and each entry has to be a power of 2. roi is a triple of (offset,size) pairs specifying ranges in the x, y, and time axis. The 3D buffer is organized such that a point (x,y,time_slice) is addressed by x + y * size_x + time_slice * size_x * size_y. When getting a numpy array view/copy of the buffer, the ‘F’ (Fortran) indexing order can be chosen, such that the indices are intuitively ordered x, y, time.

add_end_of_measurement_callback(cb)[source]

Adds a callback function for the end of measurement, the callback function needs to accept one argument which indicates the reason for callback. Notification via callback is useful if you want to use do_measurement(…) with synchronous=False, for example in GUIs that need to be responsive during measurement. This functions returns a non-negative ID for the callback that can be used for later removal, or -1 on error (that would be a bug, though).

add_statistics_pipe()[source]

Adds a pipe for statistics data (what is shown in rate meters). The statistics data is only updated at the end of each measurement. Returns a tuple with a non-negative pipe ID and the Pipe object in case of success — or a negative error code and a string containing the error message in case of error.

add_t_pipe(depth, modulo, binning, roi)[source]

Adds a 1D time histogram pipe, integrated over a rectangular region in the (x,y) plane (for delay-line detectors) with static buffer. Returns a tuple containing a non-negative pipe ID on success and the Pipe object — or negative error code and a string containing the error message. depth is either BS8, BS16, BS32, BS64 and determines the bit width of the intensity entries. modulo unequal zero applies a modulo operation to the time before sorting it into the 1D array. Note that the modulo value is in digital time units _times_ 32. binning is a triple specifying the binning in x, y, and time and each entry has to be a power of 2. roi is a triple of (offset,size) pairs specifying ranges in the x, y, and time axis. The buffer is a 1D array of the intensity values for all resolved time bins. The binning in x and y has an influence only on the x and y units in the roi. The x and y parts in the roi specify the integration ranges, such that only events inside the x and y ranges are inserted into the data buffer.

add_tdc_histo_pipe(depth, channel, modulo, binning, offset, size)[source]

Adds a pipe for time histograms from a stand-alone TDC. Returns a tuple containing a non-negative pipe ID on success and the Pipe object — or negative error code and a string containing the error message. depth is either BS8, BS16, BS32, BS64 and determines the bit width of the histogram values. The channel parameter selects a channel of the TDC, or accepts all channels if channel==-1. modulo unequal zero applies a modulo operation to the time before sorting it into the 1D array. Note that the modulo value is in digital time units _times_ 32. Binning is an integer number and has to be a power of 2. offset and size specify the range of the time axis. The size is equal to the number of entries in the histogram. The original time value is first transformed by modulo, then by binning, then the offset is subtracted and in the last step it is clipped to the size value followed by insertion into the histogram.

add_xt_pipe(depth, modulo, binning, roi)[source]

Adds a 2D pipe (x,t) with static buffer. Returns a tuple containing a non-negative pipe ID on success and the Pipe object — or negative error code and a string containing the error message. depth is either BS8, BS16, BS32, BS64 and determines the voxel bit width. modulo unequal zero applies a modulo operation to the time before sorting it into the 2D buffer. Note that the modulo value is in digital time units _times_ 32. binning is a triple specifying the binning in x, y, and time and each entry has to be a power of 2. roi is a triple of (offset,size) pairs specifying ranges in the x, y, and time axis. The 2D buffer is organized such that a point (x,time) is addressed by x + time * size_x. When getting a numpy array view/copy of the buffer, the ‘F’ (Fortran) indexing order can be chosen, such that the indices are intuitively ordered x, time. The binning in y has an influence only on the y units in the roi. The y part in the roi specifies the integration range, such that only events inside this y range are inserted into the data buffer.

add_xy_pipe(depth, modulo, binning, roi)[source]

Adds a 2D pipe (x,y) with static buffer. Returns a tuple containing a non-negative pipe ID on success and the Pipe object — or negative error code and a string containing the error message. depth is either BS8, BS16, BS32, BS64 and determines the voxel bit width. modulo unequal zero has the effect that the time value is transformed by the modulo operation and the transformed value is checked whether it is within the specified integration range, given in the third element of the roi parameter. Note that the modulo value is in digital time units _times_ 32. binning is a triple specifying the binning in x, y, and time and each entry has to be a power of 2. roi is a triple of (offset,size) pairs specifying ranges in the x, y, and time axis. The 2D buffer is organized such that a point (x,y) is addressed by x + y * size_x. When getting a numpy array view/copy of the buffer, the ‘F’ (Fortran) indexing order can be chosen, such that the indices are intuitively ordered x, y. The binning in time has an influence only on the time units in the roi. The time part in the roi specifies the integration range, such that only events inside this time range are inserted into the data buffer.

add_yt_pipe(depth, modulo, binning, roi)[source]

Adds a 2D pipe (y,t) with static buffer. Returns a tuple containing a non-negative pipe ID on success and the Pipe object — or negative error code and a string containing the error message. depth is either BS8, BS16, BS32, BS64 and determines the voxel bit width. modulo unequal zero applies a modulo operation to the time before sorting it into the 2D buffer. Note that the modulo value is in digital time units _times_ 32. binning is a triple specifying the binning in x, y, and time and each entry has to be a power of 2. roi is a triple of (offset,size) pairs specifying ranges in the x, y, and time axis. The 2D buffer is organized such that a point (y,time) is addressed by y + time * size_y. When getting a numpy array view/copy of the buffer, the ‘F’ (Fortran) indexing order can be chosen, such that the indices are intuitively ordered y, time. The binning in x has an influence only on the x units in the roi. The x part in the roi specifies the integration range, such that only events inside this x range are inserted into the data buffer.

deinitialize()[source]

Deinitialize the hardware. Returns a tuple, containing an error code and a human-readable error message (zero and empty string in case of success).

do_measurement(time_ms=100, synchronous=False)[source]

Perform a measurement. If synchronous is True, block until the measurement has finished. Returns a tuple (0, “”) in case of success, or a negative error code and a string with the error message.

hdf5_close()[source]

Writes the remaining, internally buffered events and closes the HDF5 file. (Technical remark: Internally, this also involves termination of a thread and deregistration of a USER_CALLBACKS pipe). Returns (True, “”) if successful or (False, error_message)

hdf5_disable()[source]

Disconnects the HDF5 streamer instance from this Device. Does not return anything

hdf5_enable()[source]

Attempts to load the scTDC_hdf5 library which implements event streaming to HDF5 files. This should be called only once with an initialized Device. Returns (True, “”) if HDF5 is enabled or (False, error_message)

hdf5_lib_version()[source]
hdf5_open(filepath, comment, data_selection)[source]

Opens an HDF5 file and activates streaming. Comment is a string that will be included as the ‘/user_comment’ attribute in the HDF5 file. data_selection is an instance of the HDF5DataSelection class and specifies the selection of data fields from DLD events to be included in the HDF5 file (as separate 1D datasets such that in each dataset, the first event is represented by the first element of the dataset and so on). (Technical remark: Internally, this involves creation of a thread and registration of a USER_CALLBACKS pipe, done by the scTDC_hdf5 library.) Returns (True, “”) if successful or (False, error_message)

initialize()[source]

Initialize the hardware. Returns a tuple, containing an error code and a human-readable error message (zero and empty string in case of success).

interrupt_measurement()[source]

Interrupt a measurement that was started with synchronous=False. Returns a tuple (0, “”) in case of success, or a negative error code and a string with the error message.

is_initialized()[source]

Returns True, if the device is initialized

remove_end_of_measurement_callback(id_of_cb)[source]

Removes a previously added callback function for the end of measurement by its ID. This function returns 0 on success, or -1 if the id_of_cb is unknown.

remove_pipe(pipeid)[source]

Remove a pipe specified by the pipe ID as returned in the first entry of a tuple by all add_XXX_pipe functions. Note that deinitialize will remove all pipes, as well.

class pyccapt.control.tdc_surface_concept.scTDC.HDF5DataSelection(value=0)[source]

Bases: object

add(value)[source]
remove(value)[source]
ADC = 256
CHANNEL = 8
MASTER_RESET_CTR = 128
SIGNALBIT = 512
STARTCTR = 1
SUBDEVICE = 4
TIME = 16
TIMETAG = 2
X = 32
Y = 64
class pyccapt.control.tdc_surface_concept.scTDC.Pipe(typestr, par, parent)[source]

Bases: object

Pipe objects are used to let the scTDC library construct 1D, 2D, 3D histograms from DLD events occuring during measurements, or to collect statistics data after measurements. They are preferably created via the Device object and its add_XXX_pipe functions.

Constructs a pipe object. typestr must be one of ‘3d’, ‘xy’, ‘xt’, ‘yt’, ‘t’, ‘stat’. par is of the sc_pipe_dld_image_xyt_params_t type, or in case of typestr==’stat’, of the sc_pipe_statistics_params_t type. parent must be a Device object. Creates the data buffer and opens the pipe in the scTDC library for the parent device.

clear()[source]

Set all voxels of the data buffer to zero

close()[source]

Closes the pipe such that no events are sorted into the data buffer anymore. The data buffer remains unchanged. In that sense, closing acts more like setting the pipe inactive and you can reopen it, later. The data buffer can only be garbage-collected after deleting the pipe object via the parent device and discarding all other references to the Pipe object, as well.

get_buffer_copy()[source]

For 1D, 2D, 3D pipes, returns a numpy array of a copy of the data buffer. The indexing is in Fortran order, i.e. x, y, time. If the pipe is a statistics pipe, return a copy of the statistics_t object.

get_buffer_view()[source]

For 1D, 2D, 3D pipes, returns a numpy array of the data buffer, constructed without copying. As a consequence, changes to the data buffer, made by the scTDC library after getting the buffer view, will be visible to the numpy array returned from this function. The indexing is in Fortran order, i.e. x, y, time. If the pipe is a statistics pipe, return the statistics_t object which may be modified subsequently by the scTDC.

is_open()[source]

Returns True if the pipe is active in the scTDC library (i.e. the library will access the data buffer and increment voxels on incoming events.

reopen(force=False)[source]

Open a pipe with previous parameters, if currently not open. Use force=True, if the pipe had not been explicitly closed, but the device had been deinitialized, causing an implicit destruction of the pipe (implicit desctruction only happens through low-level API calls, whereas Device.deinitialize will close all pipe objects and delete its references to them).

class pyccapt.control.tdc_surface_concept.scTDC.buffered_data_callbacks_pipe(lib, dev_desc, data_field_selection=64, max_buffered_data_len=65536, dld_events=True)[source]

Bases: object

Base class for using the “BUFFERED_DATA_CALLBACKS” interface. Requires scTDC1 library version >= 1.3010.0. In comparison to the USER_CALLBACKS pipe, this pipe reduces the number of callbacks into python, buffering a higher number of events within the library before invoking the callbacks. The on_data callback receives a dictionary containing 1D numpy arrays where the size of these arrays can be as large as specified by the max_buffered_data_len parameter. To use this interface, write a class that derives from this class and override the methods

on_data, on_end_of_meas

Parameters:
  • lib (scTDClib) – a scTDClib object.

  • dev_desc (int) – device descriptor as returned by sc_tdc_init_inifile(…).

  • data_field_selection (int, optional) – a ‘bitwise or’ combination of SC_DATA_FIELD_xyz constants. The default is SC_DATA_FIELD_TIME.

  • max_buffered_data_len (int, optional) – The number of events that are buffered before invoking the on_data callback. Less events can also be received in the on_data callback, when the user chooses to return True from the on_end_of_meas callback. The default is (1<<16).

  • dld_events (bool, optional) – if True, receive DLD events. If False, receive TDC events. Depending on the configuration in the tdc_gpx3.ini file, only one type of events may be available. The default is True.

Return type:

None.

close()[source]

Close the pipe.

Return type:

None.

on_data(data)[source]

Override this method to process the data.

Parameters:

data (dict) –

A dictionary containing several numpy arrays. The selection of arrays depends on the data_field_selection value used during initialization of the class. The key names in this dictionary, that are always present, are:

event_index, data_len

Keywords related to regular event data are:

subdevice, channel, start_counter, time_tag, dif1, dif2, time, master_rst_counter, adc, signal1bit

Keywords related to indexing arrays are:

som_indices, ms_indices. These contain event indices where the start of a measurement happened, or a millisecond count up happened.

Return type:

None.

on_end_of_meas()[source]

Override this method to trigger actions at the end of the measurement. Do not call methods that start the next measurement from this callback. This cannot succeed. Use a signalling mechanism into your main thread, instead.

Returns:

True indicates that the pipe should transfer the remaining buffered events immediately after returning from this callback. False indicates that the pipe may continue buffering the next measurements until the max_buffered_data_len threshold is reached.

Return type:

bool

start_measurement(time_ms, retries=3)[source]

Start a measurement ‘in the background’, i.e. don’t wait for it to finish.

Parameters:
  • time_ms (int) – the duration of the measurement in milliseconds.

  • retries (int) – in an asynchronous scheme of measurement sequences, trying to start the next measurement can occasionally result in a “NOT READY” error. Often some thread of the scTDC1 library just needs a few more cycles to reach the “idle” state again, where the start of the next measurement will be accepted. The retries parameter specifies how many retries with 0.001 s sleeps in between will be made before giving up.

Returns:

0 on success or a negative error code.

Return type:

int

start_measurement_sync(time_ms)[source]

Start a measurement and wait until it is finished.

Parameters:

time_ms (int) – the duration of the measurement in milliseconds.

Returns:

0 on success or a negative error code.

Return type:

int

class pyccapt.control.tdc_surface_concept.scTDC.dld_event_t[source]

Bases: Structure

adc

Structure/Union member

channel

Structure/Union member

dif1

Structure/Union member

dif2

Structure/Union member

master_rst_counter

Structure/Union member

signal1bit

Structure/Union member

start_counter

Structure/Union member

subdevice

Structure/Union member

sum

Structure/Union member

time_tag

Structure/Union member

class pyccapt.control.tdc_surface_concept.scTDC.roi_t[source]

Bases: Structure

offset

Structure/Union member

size

Structure/Union member

class pyccapt.control.tdc_surface_concept.scTDC.sc3d_t[source]

Bases: Structure

time

Structure/Union member

x

Structure/Union member

y

Structure/Union member

class pyccapt.control.tdc_surface_concept.scTDC.sc3du_t[source]

Bases: Structure

time

Structure/Union member

x

Structure/Union member

y

Structure/Union member

class pyccapt.control.tdc_surface_concept.scTDC.scTDC_hdf5lib[source]

Bases: object

loads the shared library scTDC_hdf5

cfg_comment(objID, comment)[source]
cfg_outfile(objID, filepath)[source]
version()[source]
class pyccapt.control.tdc_surface_concept.scTDC.scTDClib[source]

Bases: object

loads the shared library

sc_get_err_msg(errcode)[source]

Returns an error message to the given error code (signed integer)

sc_pipe_close2(dev_desc, pipe_handle)[source]

Close a pipe. dev_desc is the device descriptor. pipe_handle is the pipe handle as returned by sc_pipe_open2. Returns 0 on success, or negative error code.

sc_pipe_open2(dev_desc, pipe_type, pipe_params)[source]

Open a pipe. dev_desc is the device descriptor. Here is a table of which pipe_type requires which type of pipe_params: DLD_IMAGE_XY : sc_pipe_dld_image_xyt_params_t DLD_IMAGE_XT : sc_pipe_dld_image_xyt_params_t DLD_IMAGE_YT : sc_pipe_dld_image_xyt_params_t DLD_IMAGE_3D : sc_pipe_dld_image_xyt_params_t DLD_SUM_HISTO : sc_pipe_dld_image_xyt_params_t TDC_HISTO : sc_pipe_tdc_histo_params_t STATISTICS : sc_pipe_statistics_params_t This python function expects a structure object for pipe_params. Do not pass a pointer-to-structure here. ctypes.addressof(pipe_params) is already internally performed for the call of the C function. /// Support for other pipe types is a TODO item /// Returns an integer containing either the pipe handle (non-negative), or, in case of failure, an error code (negative number)

sc_pipe_read2(dev_desc, pipe_handle, timeout)[source]

Read a pipe. dev_desc is the device descriptor. pipe_handle is the pipe handle as returned by sc_pipe_open2. timeout is the timeout after which the function returns when no data is available. Returns a tuple containing the return code and a ctypes.POINTER to the databuffer.

sc_tdc_deinit2(dev_desc)[source]

Deinitialize the hardware for the given device descriptor which was retrieved from sc_tdc_init_inifile. Returns 0 on success or negative error code.

sc_tdc_get_statistics2(dev_desc)[source]

This function is deprecated! Use the statistics pipe, instead. This function is kept for older scTDC library versions.

sc_tdc_get_status2(dev_desc)[source]

Get status. Returns 0 (idle), 1 (exposure), or negative error codes

sc_tdc_init_inifile(inifile_path='tdc_gpx3.ini')[source]

Initializes the hardware and loads the initial settings reading it from the specified ini file. Returns an integer, containing a non-negative device iterator on success, or, a negative error code in case of failure. The device descriptor is needed for almost all other functions.

sc_tdc_interrupt2(dev_desc)[source]

Interrupts a measurement asynchronously (non-blocking)

sc_tdc_set_complete_callback2(dev_desc, privptr, callback)[source]

Set a measurement complete callback

sc_tdc_start_measure2(dev_desc, exposure_ms)[source]

Start a measurement (asynchronously/non-blocking) for the hardware indicated by the device descriptor with the given exposure time in milliseconds. Returns 0 on success, or negative error code.

class pyccapt.control.tdc_surface_concept.scTDC.sc_pipe_buf_callback_args[source]

Bases: Structure

adc

Structure/Union member

channel

Structure/Union member

data_len

Structure/Union member

dif1

Structure/Union member

dif2

Structure/Union member

event_index

Structure/Union member

master_rst_counter

Structure/Union member

ms_indices

Structure/Union member

ms_indices_len

Structure/Union member

reserved

Structure/Union member

signal1bit

Structure/Union member

som_indices

Structure/Union member

som_indices_len

Structure/Union member

start_counter

Structure/Union member

subdevice

Structure/Union member

time

Structure/Union member

time_tag

Structure/Union member

class pyccapt.control.tdc_surface_concept.scTDC.sc_pipe_buf_callbacks_params_t[source]

Bases: Structure

data

Structure/Union member

data_field_selection

Structure/Union member

dld_events

Structure/Union member

end_of_measurement

Structure/Union member

max_buffered_data_len

Structure/Union member

priv

Structure/Union member

reserved

Structure/Union member

version

Structure/Union member

class pyccapt.control.tdc_surface_concept.scTDC.sc_pipe_callback_params_t[source]

Bases: Structure

callbacks

Structure/Union member

class pyccapt.control.tdc_surface_concept.scTDC.sc_pipe_callbacks[source]

Bases: Structure

dld_event

Structure/Union member

end_of_measure

Structure/Union member

millisecond_countup

Structure/Union member

priv

Structure/Union member

start_of_measure

Structure/Union member

statistics

Structure/Union member

tdc_event

Structure/Union member

class pyccapt.control.tdc_surface_concept.scTDC.sc_pipe_dld_image_xyt_params_t[source]

Bases: Structure

accumulation_ms

Structure/Union member

allocator_cb

Structure/Union member

allocator_owner

Structure/Union member

binning

Structure/Union member

channel

Structure/Union member

depth

Structure/Union member

modulo

Structure/Union member

roi

Structure/Union member

class pyccapt.control.tdc_surface_concept.scTDC.sc_pipe_statistics_params_t[source]

Bases: Structure

allocator_cb

Structure/Union member

allocator_owner

Structure/Union member

class pyccapt.control.tdc_surface_concept.scTDC.sc_pipe_tdc_histo_params_t[source]

Bases: Structure

accumulation_ms

Structure/Union member

allocator_cb

Structure/Union member

allocator_owner

Structure/Union member

binning

Structure/Union member

channel

Structure/Union member

depth

Structure/Union member

modulo

Structure/Union member

offset

Structure/Union member

size

Structure/Union member

class pyccapt.control.tdc_surface_concept.scTDC.statistics_t[source]

Bases: Structure

counters

Structure/Union member

counts_read

Structure/Union member

counts_received

Structure/Union member

events_found

Structure/Union member

events_in_roi

Structure/Union member

events_received

Structure/Union member

reserved

Structure/Union member

class pyccapt.control.tdc_surface_concept.scTDC.tdc_event_t[source]

Bases: Structure

channel

Structure/Union member

sign_counter

Structure/Union member

start_counter

Structure/Union member

subdevice

Structure/Union member

time_data

Structure/Union member

time_tag

Structure/Union member

class pyccapt.control.tdc_surface_concept.scTDC.usercallbacks_pipe(lib, dev_desc)[source]

Bases: object

Base class for user implementations of the “USER_CALLBACKS” interface. Derive from this class and override some or all of the methods

on_start_of_meas, on_end_of_meas, on_millisecond, on_statistics, on_tdc_event, on_dld_event

The lib argument in the constructor expects a scTDClib object. The dev_desc argument in the constructor expects the device descriptor as returned by sc_tdc_init_inifile(…).

close()[source]
do_measurement(time_ms)[source]
on_dld_event(dld_events, nr_dld_events)[source]
on_end_of_meas()[source]
on_millisecond()[source]
on_start_of_meas()[source]
on_statistics(stats)[source]
on_tdc_event(tdc_events, nr_tdc_events)[source]
pyccapt.control.tdc_surface_concept.scTDC.copy_statistics(s)[source]

pyccapt.control.tdc_surface_concept.tdc_surface_concept module

class pyccapt.control.tdc_surface_concept.tdc_surface_concept.BufDataCB4(lib, dev_desc, data_field_selection, dld_events, max_buffered_data_len=500000)[source]

Bases: buffered_data_callbacks_pipe

The class inherits from python wrapper module scTDC and class: buffered_data_callbacks_pipe

Initialize the base class: scTDC.buffered_data_callbacks_pipe

Parameters:
  • lib (scTDClib) – A scTDClib object.

  • dev_desc (int) – Device descriptor as returned by sc_tdc_init_inifile(…).

  • data_field_selection (int) – A ‘bitwise or’ combination of SC_DATA_FIELD_xyz constants.

  • dld_events (bool) – True to receive DLD events, False to receive TDC events.

  • max_buffered_data_len (int) – Number of events buffered before invoking callbacks.

on_data(d)[source]
This class method function:
  1. Makes a deep copy of numpy arrays in d

  2. Inserts basic values by simple assignment

  3. Inserts numpy arrays using the copy method of the source array

Parameters:

d (dict) – Data dictionary.

Returns:

None

on_end_of_meas()[source]

This class method sets end_of_meas to True.

Returns:

True (bool)

pyccapt.control.tdc_surface_concept.tdc_surface_concept.errorcheck(device, bufdatacb, bufdatacb_raw, retcode)[source]

This function checks return codes for errors and does cleanup.

Parameters:
  • retcode (int) – Return code.

  • bufdatacb (BufDataCB4) – A BufDataCB4 object.

  • bufdatacb_raw (BufDataCB4) – A BufDataCB4 object.

  • device (scTDC.Device) – A scTDC.Device object.

Returns:

0 if success return code or return code > 0, -1 if return code is error code or less than 0.

Return type:

int

pyccapt.control.tdc_surface_concept.tdc_surface_concept.experiment_measure(variables, x_plot, y_plot, t_plot, main_v_dc_plot, stop_event)[source]
pyccapt.control.tdc_surface_concept.tdc_surface_concept.load_and_concatenate_chunks(path, chunk_id)[source]
pyccapt.control.tdc_surface_concept.tdc_surface_concept.run_experiment_measure(variables, x_plot, y_plot, t_plot, main_v_dc_plot, stop_event)[source]

Measurement function: This function is called in a process to read data from the queue.

Parameters:
  • variables (share_variables.Variables) – A share_variables.Variables object.

  • x_plot (multiprocessing.Array) – A multiprocessing.Array object.

  • y_plot (multiprocessing.Array) – A multiprocessing.Array object.

  • t_plot (multiprocessing.Array) – A multiprocessing.Array object.

  • main_v_dc_plot (multiprocessing.Array) – A multiprocessing.Array object.

  • stop_event (multiprocessing.Event) – A multiprocessing.Event object.

Returns:

Return code.

Return type:

int

pyccapt.control.tdc_surface_concept.tdc_surface_concept.save_chunk_worker(save_queue)[source]

Module contents