stresing 4.20.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- examples/continuous_measurement.py +46 -0
- examples/hooks.py +40 -0
- examples/nonblocking_measurement.py +34 -0
- examples/plot_rms.py +34 -0
- examples/raw_dll_call.py +32 -0
- examples/sec_sweep.py +132 -0
- examples/sensor_reset_sweep.py +132 -0
- examples/shutter.py +34 -0
- examples/simple_blocking_measurement.py +25 -0
- examples/stime_sweep.py +72 -0
- examples/stime_sweep_3blocks.py +91 -0
- stresing/ESLSCDLL.dll +0 -0
- stresing/__init__.py +2 -0
- stresing/core.py +794 -0
- stresing/hdf5.dll +0 -0
- stresing/lscpciej.dll +0 -0
- stresing/wdapi1400.dll +0 -0
- stresing-4.20.1.dist-info/METADATA +61 -0
- stresing-4.20.1.dist-info/RECORD +22 -0
- stresing-4.20.1.dist-info/WHEEL +5 -0
- stresing-4.20.1.dist-info/licenses/LICENSE +164 -0
- stresing-4.20.1.dist-info/top_level.txt +2 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
## @file: simple_blocking_measurement.py
|
|
2
|
+
# @brief: This script shows how to a continuous measurement.
|
|
3
|
+
# @details:
|
|
4
|
+
# @author: Florian Hahn
|
|
5
|
+
# @date: 15.07.2025
|
|
6
|
+
# @copyright: Copyright (c) 2025, Entwicklungsbüro Stresing. Released as public domain under the Unlicense.
|
|
7
|
+
|
|
8
|
+
import stresing
|
|
9
|
+
|
|
10
|
+
def measure_start_hook():
|
|
11
|
+
print("Measurement started")
|
|
12
|
+
|
|
13
|
+
def measure_done_hook():
|
|
14
|
+
print("Measurement done")
|
|
15
|
+
|
|
16
|
+
def block_start_hook(block_index: int):
|
|
17
|
+
print("Block " + str(block_index) + " started")
|
|
18
|
+
|
|
19
|
+
def block_done_hook(block_index: int):
|
|
20
|
+
print("Block " + str(block_index) + " done")
|
|
21
|
+
|
|
22
|
+
def all_blocks_done_hook(measurement_number: int):
|
|
23
|
+
print("All blocks done. Measurement number: " + str(measurement_number))
|
|
24
|
+
|
|
25
|
+
# Initialize the driver.
|
|
26
|
+
number_of_boards = stresing.init_driver()
|
|
27
|
+
# Set all settings that are needed for the measurement in config.ini. The file config.ini is also compatible with the exported settings of Escam. Settings that are not found in the file, will be left as default. You can find a description of all settings here: https://entwicklungsburo-stresing.github.io/structmeasurement__settings.html
|
|
28
|
+
stresing.load_config_file("config.ini")
|
|
29
|
+
# Set all hooks
|
|
30
|
+
measure_started_ref = stresing.set_measure_start_hook(measure_start_hook)
|
|
31
|
+
measure_done_ref = stresing.set_measure_done_hook(measure_done_hook)
|
|
32
|
+
block_started_ref = stresing.set_block_start_hook(block_start_hook)
|
|
33
|
+
block_done_ref = stresing.set_block_done_hook(block_done_hook)
|
|
34
|
+
all_blocks_done_ref = stresing.set_all_blocks_done_hook(all_blocks_done_hook)
|
|
35
|
+
stresing.settings.contiuous_measurement = 1
|
|
36
|
+
# Initialize the measurement.
|
|
37
|
+
stresing.init_measurement()
|
|
38
|
+
# Start the measurement non blocking.
|
|
39
|
+
stresing.start_measurement_nonblocking()
|
|
40
|
+
# Wait for 10 seconds
|
|
41
|
+
import time
|
|
42
|
+
time.sleep(10)
|
|
43
|
+
# Stop the measurement.
|
|
44
|
+
stresing.abort_measurement()
|
|
45
|
+
# Exit the driver
|
|
46
|
+
stresing.exit_driver()
|
examples/hooks.py
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
## @file: simple_blocking_measurement.py
|
|
2
|
+
# @brief: This script shows how to use hooks.
|
|
3
|
+
# @details:
|
|
4
|
+
# @author: Florian Hahn
|
|
5
|
+
# @date: 14.07.2025
|
|
6
|
+
# @copyright: Copyright (c) 2025, Entwicklungsbüro Stresing. Released as public domain under the Unlicense.
|
|
7
|
+
|
|
8
|
+
import stresing
|
|
9
|
+
|
|
10
|
+
def measure_start_hook():
|
|
11
|
+
print("Measurement started")
|
|
12
|
+
|
|
13
|
+
def measure_done_hook():
|
|
14
|
+
print("Measurement done")
|
|
15
|
+
|
|
16
|
+
def block_start_hook(block_index: int):
|
|
17
|
+
print("Block " + str(block_index) + " started")
|
|
18
|
+
|
|
19
|
+
def block_done_hook(block_index: int):
|
|
20
|
+
print("Block " + str(block_index) + " done")
|
|
21
|
+
|
|
22
|
+
def all_blocks_done_hook(measurement_number: int):
|
|
23
|
+
print("All blocks done. Measurement number: " + str(measurement_number))
|
|
24
|
+
|
|
25
|
+
# Initialize the driver.
|
|
26
|
+
number_of_boards = stresing.init_driver()
|
|
27
|
+
# Set all settings that are needed for the measurement in config.ini. The file config.ini is also compatible with the exported settings of Escam. Settings that are not found in the file, will be left as default. You can find a description of all settings here: https://entwicklungsburo-stresing.github.io/structmeasurement__settings.html
|
|
28
|
+
stresing.load_config_file("config.ini")
|
|
29
|
+
# Set all hooks. It is important to save the returned references to prevent them from being garbage collected.
|
|
30
|
+
measure_started_ref = stresing.set_measure_start_hook(measure_start_hook)
|
|
31
|
+
measure_done_ref = stresing.set_measure_done_hook(measure_done_hook)
|
|
32
|
+
block_started_ref = stresing.set_block_start_hook(block_start_hook)
|
|
33
|
+
block_done_ref = stresing.set_block_done_hook(block_done_hook)
|
|
34
|
+
all_blocks_done_ref = stresing.set_all_blocks_done_hook(all_blocks_done_hook)
|
|
35
|
+
# Initialize the measurement.
|
|
36
|
+
stresing.init_measurement()
|
|
37
|
+
# Start the measurement. This is the blocking call, which means it will return when the measurement is finished. This is done to ensure that no data access happens before all data is collected.
|
|
38
|
+
stresing.start_measurement_blocking()
|
|
39
|
+
# Exit the driver
|
|
40
|
+
stresing.exit_driver()
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
## @file: nonblocking_measurement.py
|
|
2
|
+
# @brief: This script shows how to operate the Stresing camera using the python module stresing.
|
|
3
|
+
# @details: This script initializes the camera, does one measurement, reads the data and plots the data. The data access happens after the complete measurement is done. This example is written for 1 camera on 1 PCIe board.
|
|
4
|
+
# @author: Florian Hahn
|
|
5
|
+
# @date: 13.10.2022
|
|
6
|
+
# @copyright: Copyright (c) 2025, Entwicklungsbüro Stresing. Released as public domain under the Unlicense.
|
|
7
|
+
|
|
8
|
+
import stresing
|
|
9
|
+
# matplotlib is used for the data plot
|
|
10
|
+
import matplotlib.pyplot as plt
|
|
11
|
+
import time
|
|
12
|
+
|
|
13
|
+
# Initialize the driver.
|
|
14
|
+
number_of_boards = stresing.init_driver()
|
|
15
|
+
# Set all settings that are needed for the measurement in config.ini. The file config.ini is also compatible with the exported settings of Escam. Settings that are not found in the file, will be left as default. You can find a description of all settings here: https://entwicklungsburo-stresing.github.io/structmeasurement__settings.html
|
|
16
|
+
stresing.load_config_file("config.ini")
|
|
17
|
+
# Initialize the measurement.
|
|
18
|
+
stresing.init_measurement()
|
|
19
|
+
# Start the measurement. This is the nonblocking call, which means it will return immediately.
|
|
20
|
+
stresing.start_measurement_nonblocking()
|
|
21
|
+
cur_sample = -2
|
|
22
|
+
cur_block = -2
|
|
23
|
+
# Always use board 0. There is only one PCIe board in this example script.
|
|
24
|
+
drvno = 0
|
|
25
|
+
while cur_sample < stresing.settings.nos-1 or cur_block < stresing.settings.nob-1:
|
|
26
|
+
(cur_sample, cur_block) = stresing.get_current_scan_number(drvno)
|
|
27
|
+
print("sample: "+str(cur_sample)+" block: "+str(cur_block))
|
|
28
|
+
time.sleep(1)
|
|
29
|
+
frame_buffer = stresing.copy_one_sample(drvno, 5, 0 ,0)
|
|
30
|
+
# Plot the frame
|
|
31
|
+
plt.plot(frame_buffer)
|
|
32
|
+
plt.show()
|
|
33
|
+
# Exit the driver
|
|
34
|
+
stresing.exit_driver()
|
examples/plot_rms.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
## @file: plot_rms.py
|
|
2
|
+
# @brief: This script does a sweep of the stime parameter.
|
|
3
|
+
# @details:
|
|
4
|
+
# @author: Florian Hahn
|
|
5
|
+
# @date: 25.02.2025
|
|
6
|
+
# @copyright: Copyright (c) 2025, Entwicklungsbüro Stresing. Released as public domain under the Unlicense.
|
|
7
|
+
|
|
8
|
+
# matplotlib is used for the data plot
|
|
9
|
+
import matplotlib.pyplot as plt
|
|
10
|
+
import stresing
|
|
11
|
+
|
|
12
|
+
# Initialize the driver and pass the created pointer to it. number_of_boards should show the number of detected PCIe boards after the next call.
|
|
13
|
+
stresing.init_driver()
|
|
14
|
+
# Set all settings that are needed for the measurement in config.ini. The file config.ini is also compatible with the exported settings of Escam. Settings that are not found in the file, will be left as default. You can find a description of all settings here: https://entwicklungsburo-stresing.github.io/structmeasurement__settings.html
|
|
15
|
+
stresing.load_config_file("config.ini")
|
|
16
|
+
# Initialize the measurement.
|
|
17
|
+
stresing.init_measurement()
|
|
18
|
+
# Number of data points of RMS values
|
|
19
|
+
measurement_cnt = 100
|
|
20
|
+
rms_pixel = 100
|
|
21
|
+
rms_list: list[float] = []
|
|
22
|
+
# Always use board 0. There is only one PCIe board in this example script.
|
|
23
|
+
drvno = 0
|
|
24
|
+
for i in range(measurement_cnt):
|
|
25
|
+
print("Measurement " + str(i+1) + " of " + str(measurement_cnt))
|
|
26
|
+
# Start the measurement. This is the blocking call, which means it will return when the measurement is finished. This is done to ensure that no data access happens before all data is collected.
|
|
27
|
+
stresing.start_measurement_blocking()
|
|
28
|
+
(mean, trms) = stresing.calc_trms(drvno, 10, stresing.settings.nos - 1, rms_pixel, 0)
|
|
29
|
+
rms_list.append(trms)
|
|
30
|
+
# Plot the frame
|
|
31
|
+
plt.plot(rms_list)
|
|
32
|
+
plt.show()
|
|
33
|
+
# Exit the driver
|
|
34
|
+
stresing.exit_driver()
|
examples/raw_dll_call.py
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
## @file: raw_dll_call.py
|
|
2
|
+
# @brief: This script shows how to directly call the DLL functions of ESLSCDLL.dll using the python module stresing.
|
|
3
|
+
# @author: Florian Hahn
|
|
4
|
+
# @date: 08.07.2025
|
|
5
|
+
# @copyright: Copyright (c) 2025, Entwicklungsbüro Stresing. Released as public domain under the Unlicense.
|
|
6
|
+
|
|
7
|
+
import stresing
|
|
8
|
+
import ctypes
|
|
9
|
+
from ctypes import c_uint32, POINTER
|
|
10
|
+
|
|
11
|
+
# Initialize the driver.
|
|
12
|
+
stresing.init_driver()
|
|
13
|
+
# Read the register S0Addr_EBST
|
|
14
|
+
# You can use every call you can find here in the documentation: https://entwicklungsburo-stresing.github.io/_e_s_l_s_c_d_l_l_8h.html
|
|
15
|
+
# Use board 0
|
|
16
|
+
drvno = 0
|
|
17
|
+
# data buffer
|
|
18
|
+
data = c_uint32(0)
|
|
19
|
+
# Address of the register S0Addr_EBST. You can find addresses of the PCIe card registers here: https://entwicklungsburo-stresing.github.io/enum__hardware_8h.html#a1532e8504727e103db7ec69af3330f15
|
|
20
|
+
address = 0x1C
|
|
21
|
+
stresing.dll.DLLreadRegisterS0_32.argtypes = [c_uint32, POINTER(c_uint32), c_uint32]
|
|
22
|
+
status = stresing.dll.DLLreadRegisterS0_32(c_uint32(0), ctypes.byref(data), c_uint32(address))
|
|
23
|
+
# Check the return status
|
|
24
|
+
if status != 0:
|
|
25
|
+
raise Exception(stresing.convert_error_code_to_msg(status))
|
|
26
|
+
# Print the read value
|
|
27
|
+
print(f"Value of S0Addr_EBST: {data.value}")
|
|
28
|
+
# Interprete the value as 4 charaters of ASCII
|
|
29
|
+
ascii_value = ''.join(chr((data.value >> (i * 8)) & 0xFF) for i in range(4))
|
|
30
|
+
print(f"Interpreted as ASCII: {ascii_value}")
|
|
31
|
+
# Exit the driver
|
|
32
|
+
stresing.exit_driver()
|
examples/sec_sweep.py
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
## @file: sec_sweep.py
|
|
2
|
+
# @brief: This script does a sweep of the parameter SEC.
|
|
3
|
+
# @details:
|
|
4
|
+
# @author: Florian Hahn
|
|
5
|
+
# @date: 30.07.2025
|
|
6
|
+
# @copyright: Copyright (c) 2025, Entwicklungsbüro Stresing. Released as public domain under the Unlicense.
|
|
7
|
+
|
|
8
|
+
# matplotlib is used for the data plot
|
|
9
|
+
import matplotlib.pyplot as plt
|
|
10
|
+
import stresing
|
|
11
|
+
|
|
12
|
+
# Always use board 0. There is only one PCIe board in this example script.
|
|
13
|
+
drvno = 0
|
|
14
|
+
# Initialize the driver and pass the created pointer to it. number_of_boards should show the number of detected PCIe boards after the next call.
|
|
15
|
+
stresing.init_driver()
|
|
16
|
+
# Set all settings that are needed for the measurement in config.ini. The file config.ini is also compatible with the exported settings of Escam. Settings that are not found in the file, will be left as default. You can find a description of all settings here: https://entwicklungsburo-stresing.github.io/structmeasurement__settings.html
|
|
17
|
+
stresing.load_config_file("config.ini")
|
|
18
|
+
stresing.settings.camera_settings[drvno].sensor_reset_or_hsir_ec = 0
|
|
19
|
+
stresing.settings.camera_settings[drvno].sec_in_10ns = 0
|
|
20
|
+
# create an empty list to store the data
|
|
21
|
+
list_x = []
|
|
22
|
+
list_y1 = []
|
|
23
|
+
list_y2 = []
|
|
24
|
+
list_y3 = []
|
|
25
|
+
list_y4 = []
|
|
26
|
+
# plot this pixel
|
|
27
|
+
pixel_plot = 588
|
|
28
|
+
# this is the reset time at which the sweep starts
|
|
29
|
+
start_value = stresing.settings.camera_settings[drvno].sec_in_10ns
|
|
30
|
+
# this is the exposure time at which the sweep stops
|
|
31
|
+
stop_value = 400
|
|
32
|
+
# this is the step size for the first measurements
|
|
33
|
+
step_size = 10
|
|
34
|
+
measurement_cnt = int((stop_value - start_value) / step_size)
|
|
35
|
+
|
|
36
|
+
print("Create a measurement with reset time 0")
|
|
37
|
+
# Initialize the measurement.
|
|
38
|
+
stresing.init_measurement()
|
|
39
|
+
# Start the measurement. This is the blocking call, which means it will return when the measurement is finished. This is done to ensure that no data access happens before all data is collected.
|
|
40
|
+
stresing.start_measurement_blocking()
|
|
41
|
+
# Get all the data in a 2D list
|
|
42
|
+
frame_buffer_2d = stresing.copy_all_data_2d(drvno)
|
|
43
|
+
# Drop the first 200 samples
|
|
44
|
+
frame_buffer_2d = frame_buffer_2d[200:]
|
|
45
|
+
# Calculate the 4 averages of every 4th row of frame_buffer_2d
|
|
46
|
+
import numpy as np
|
|
47
|
+
avg0 = np.mean([row for i, row in enumerate(frame_buffer_2d) if i % 4 == 0], axis=0)
|
|
48
|
+
avg1 = np.mean([row for i, row in enumerate(frame_buffer_2d) if i % 4 == 1], axis=0)
|
|
49
|
+
avg2 = np.mean([row for i, row in enumerate(frame_buffer_2d) if i % 4 == 2], axis=0)
|
|
50
|
+
avg3 = np.mean([row for i, row in enumerate(frame_buffer_2d) if i % 4 == 3], axis=0)
|
|
51
|
+
# plot the 4 averages
|
|
52
|
+
plt.figure(figsize=(10, 8))
|
|
53
|
+
plt.plot(avg0, label='On 1')
|
|
54
|
+
plt.plot(avg1, label='On 2')
|
|
55
|
+
plt.plot(avg2, label='Off 1')
|
|
56
|
+
plt.plot(avg3, label='Off 2')
|
|
57
|
+
plt.xlabel('Pixel')
|
|
58
|
+
plt.ylabel('Intensity')
|
|
59
|
+
plt.title('Average Intensity for each sample type for SEC time 0')
|
|
60
|
+
plt.legend()
|
|
61
|
+
plt.grid(True)
|
|
62
|
+
plt.tight_layout()
|
|
63
|
+
plt.show()
|
|
64
|
+
|
|
65
|
+
for i in range(measurement_cnt):
|
|
66
|
+
print("Measurement " + str(i + 1) + " of " + str(measurement_cnt) + ", sensor reset = " + str(stresing.settings.camera_settings[drvno].sec_in_10ns) + " (" + str(stresing.settings.camera_settings[drvno].sec_in_10ns * 10) +" ns)")
|
|
67
|
+
# Initialize the measurement.
|
|
68
|
+
stresing.init_measurement()
|
|
69
|
+
# Start the measurement. This is the blocking call, which means it will return when the measurement is finished. This is done to ensure that no data access happens before all data is collected.
|
|
70
|
+
stresing.start_measurement_blocking()
|
|
71
|
+
list_x.append(stresing.settings.camera_settings[drvno].sec_in_10ns * 10)
|
|
72
|
+
# Get all the data in a 2D list
|
|
73
|
+
frame_buffer_2d = stresing.copy_all_data_2d(drvno)
|
|
74
|
+
# Drop the first 200 samples
|
|
75
|
+
frame_buffer_2d = frame_buffer_2d[200:]
|
|
76
|
+
# Calculate the 4 averages of every 4th row of frame_buffer_2d
|
|
77
|
+
import numpy as np
|
|
78
|
+
avg0 = np.mean([row for i, row in enumerate(frame_buffer_2d) if i % 4 == 0], axis=0)
|
|
79
|
+
avg1 = np.mean([row for i, row in enumerate(frame_buffer_2d) if i % 4 == 1], axis=0)
|
|
80
|
+
avg2 = np.mean([row for i, row in enumerate(frame_buffer_2d) if i % 4 == 2], axis=0)
|
|
81
|
+
avg3 = np.mean([row for i, row in enumerate(frame_buffer_2d) if i % 4 == 3], axis=0)
|
|
82
|
+
list_y1.append(avg0[pixel_plot])
|
|
83
|
+
list_y2.append(avg1[pixel_plot])
|
|
84
|
+
list_y3.append(avg2[pixel_plot])
|
|
85
|
+
list_y4.append(avg3[pixel_plot])
|
|
86
|
+
stresing.settings.camera_settings[drvno].sec_in_10ns += step_size
|
|
87
|
+
|
|
88
|
+
# Plot all four lists as separate graphs in one figure
|
|
89
|
+
plt.figure(figsize=(10, 8))
|
|
90
|
+
plt.plot(list_x, list_y1, label='On 1')
|
|
91
|
+
plt.plot(list_x, list_y2, label='On 2')
|
|
92
|
+
plt.plot(list_x, list_y3, label='Off 1')
|
|
93
|
+
plt.plot(list_x, list_y4, label='Off 2')
|
|
94
|
+
plt.xlabel('sec in ns')
|
|
95
|
+
plt.ylabel('Intensity at pixel ' + str(pixel_plot))
|
|
96
|
+
plt.title('SEC Sweep - Pixel ' + str(pixel_plot))
|
|
97
|
+
plt.grid(True)
|
|
98
|
+
plt.legend()
|
|
99
|
+
plt.tight_layout()
|
|
100
|
+
plt.show()
|
|
101
|
+
|
|
102
|
+
print("Create a measurement with SEC time " + str(stresing.settings.camera_settings[drvno].sec_in_10ns * 10) + " ns")
|
|
103
|
+
# Initialize the measurement.
|
|
104
|
+
stresing.init_measurement()
|
|
105
|
+
# Start the measurement. This is the blocking call, which means it will return when the measurement is finished. This is done to ensure that no data access happens before all data is collected.
|
|
106
|
+
stresing.start_measurement_blocking()
|
|
107
|
+
# Get all the data in a 2D list
|
|
108
|
+
frame_buffer_2d = stresing.copy_all_data_2d(drvno)
|
|
109
|
+
# Drop the first 200 samples
|
|
110
|
+
frame_buffer_2d = frame_buffer_2d[200:]
|
|
111
|
+
# Calculate the 4 averages of every 4th row of frame_buffer_2d
|
|
112
|
+
import numpy as np
|
|
113
|
+
avg0 = np.mean([row for i, row in enumerate(frame_buffer_2d) if i % 4 == 0], axis=0)
|
|
114
|
+
avg1 = np.mean([row for i, row in enumerate(frame_buffer_2d) if i % 4 == 1], axis=0)
|
|
115
|
+
avg2 = np.mean([row for i, row in enumerate(frame_buffer_2d) if i % 4 == 2], axis=0)
|
|
116
|
+
avg3 = np.mean([row for i, row in enumerate(frame_buffer_2d) if i % 4 == 3], axis=0)
|
|
117
|
+
# plot the 4 averages
|
|
118
|
+
plt.figure(figsize=(10, 8))
|
|
119
|
+
plt.plot(avg0, label='On 1')
|
|
120
|
+
plt.plot(avg1, label='On 2')
|
|
121
|
+
plt.plot(avg2, label='Off 1')
|
|
122
|
+
plt.plot(avg3, label='Off 2')
|
|
123
|
+
plt.xlabel('Pixel')
|
|
124
|
+
plt.ylabel('Intensity')
|
|
125
|
+
plt.title('Average Intensity for each sample type for SEC time ' + str(stresing.settings.camera_settings[drvno].sec_in_10ns * 10) + ' ns')
|
|
126
|
+
plt.legend()
|
|
127
|
+
plt.grid(True)
|
|
128
|
+
plt.tight_layout()
|
|
129
|
+
plt.show()
|
|
130
|
+
|
|
131
|
+
# Exit the driver
|
|
132
|
+
stresing.exit_driver()
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
## @file: sensor_reset_sweep.py
|
|
2
|
+
# @brief: This script does a sweep of the parameter sensor reset.
|
|
3
|
+
# @details:
|
|
4
|
+
# @author: Florian Hahn
|
|
5
|
+
# @date: 25.06.2025
|
|
6
|
+
# @copyright: Copyright (c) 2025, Entwicklungsbüro Stresing. Released as public domain under the Unlicense.
|
|
7
|
+
|
|
8
|
+
# matplotlib is used for the data plot
|
|
9
|
+
import matplotlib.pyplot as plt
|
|
10
|
+
import stresing
|
|
11
|
+
|
|
12
|
+
# Always use board 0. There is only one PCIe board in this example script.
|
|
13
|
+
drvno = 0
|
|
14
|
+
# Initialize the driver and pass the created pointer to it. number_of_boards should show the number of detected PCIe boards after the next call.
|
|
15
|
+
stresing.init_driver()
|
|
16
|
+
# Set all settings that are needed for the measurement in config.ini. The file config.ini is also compatible with the exported settings of Escam. Settings that are not found in the file, will be left as default. You can find a description of all settings here: https://entwicklungsburo-stresing.github.io/structmeasurement__settings.html
|
|
17
|
+
stresing.load_config_file("config.ini")
|
|
18
|
+
stresing.settings.camera_settings[drvno].sensor_reset_or_hsir_ec = 0
|
|
19
|
+
stresing.settings.camera_settings[drvno].sec_in_10ns = 0
|
|
20
|
+
# create an empty list to store the data
|
|
21
|
+
list_x = []
|
|
22
|
+
list_y1 = []
|
|
23
|
+
list_y2 = []
|
|
24
|
+
list_y3 = []
|
|
25
|
+
list_y4 = []
|
|
26
|
+
# plot this pixel
|
|
27
|
+
pixel_plot = 506
|
|
28
|
+
# this is the reset time at which the sweep starts
|
|
29
|
+
start_value = stresing.settings.camera_settings[drvno].sensor_reset_or_hsir_ec
|
|
30
|
+
# this is the exposure time at which the sweep stops
|
|
31
|
+
stop_value = 11500
|
|
32
|
+
# this is the step size for the first measurements
|
|
33
|
+
step_size = 100
|
|
34
|
+
measurement_cnt = int((stop_value - start_value) / step_size)
|
|
35
|
+
|
|
36
|
+
print("Create a measurement with reset time 0")
|
|
37
|
+
# Initialize the measurement.
|
|
38
|
+
stresing.init_measurement()
|
|
39
|
+
# Start the measurement. This is the blocking call, which means it will return when the measurement is finished. This is done to ensure that no data access happens before all data is collected.
|
|
40
|
+
stresing.start_measurement_blocking()
|
|
41
|
+
# Get all the data in a 2D list
|
|
42
|
+
frame_buffer_2d = stresing.copy_all_data_2d(drvno)
|
|
43
|
+
# Drop the first 200 samples
|
|
44
|
+
frame_buffer_2d = frame_buffer_2d[200:]
|
|
45
|
+
# Calculate the 4 averages of every 4th row of frame_buffer_2d
|
|
46
|
+
import numpy as np
|
|
47
|
+
avg0 = np.mean([row for i, row in enumerate(frame_buffer_2d) if i % 4 == 0], axis=0)
|
|
48
|
+
avg1 = np.mean([row for i, row in enumerate(frame_buffer_2d) if i % 4 == 1], axis=0)
|
|
49
|
+
avg2 = np.mean([row for i, row in enumerate(frame_buffer_2d) if i % 4 == 2], axis=0)
|
|
50
|
+
avg3 = np.mean([row for i, row in enumerate(frame_buffer_2d) if i % 4 == 3], axis=0)
|
|
51
|
+
# plot the 4 averages
|
|
52
|
+
plt.figure(figsize=(10, 8))
|
|
53
|
+
plt.plot(avg0, label='On 1')
|
|
54
|
+
plt.plot(avg1, label='On 2')
|
|
55
|
+
plt.plot(avg2, label='Off 1')
|
|
56
|
+
plt.plot(avg3, label='Off 2')
|
|
57
|
+
plt.xlabel('Pixel')
|
|
58
|
+
plt.ylabel('Intensity')
|
|
59
|
+
plt.title('Average Intensity for each sample type for reset time 0')
|
|
60
|
+
plt.legend()
|
|
61
|
+
plt.grid(True)
|
|
62
|
+
plt.tight_layout()
|
|
63
|
+
plt.show()
|
|
64
|
+
|
|
65
|
+
for i in range(measurement_cnt):
|
|
66
|
+
print("Measurement " + str(i + 1) + " of " + str(measurement_cnt) + ", sensor reset = " + str(stresing.settings.camera_settings[drvno].sensor_reset_or_hsir_ec) + " (" + str(stresing.settings.camera_settings[drvno].sensor_reset_or_hsir_ec * 4) +" ns)")
|
|
67
|
+
# Initialize the measurement.
|
|
68
|
+
stresing.init_measurement()
|
|
69
|
+
# Start the measurement. This is the blocking call, which means it will return when the measurement is finished. This is done to ensure that no data access happens before all data is collected.
|
|
70
|
+
stresing.start_measurement_blocking()
|
|
71
|
+
list_x.append(stresing.settings.camera_settings[drvno].sensor_reset_or_hsir_ec * 4)
|
|
72
|
+
# Get all the data in a 2D list
|
|
73
|
+
frame_buffer_2d = stresing.copy_all_data_2d(drvno)
|
|
74
|
+
# Drop the first 200 samples
|
|
75
|
+
frame_buffer_2d = frame_buffer_2d[200:]
|
|
76
|
+
# Calculate the 4 averages of every 4th row of frame_buffer_2d
|
|
77
|
+
import numpy as np
|
|
78
|
+
avg0 = np.mean([row for i, row in enumerate(frame_buffer_2d) if i % 4 == 0], axis=0)
|
|
79
|
+
avg1 = np.mean([row for i, row in enumerate(frame_buffer_2d) if i % 4 == 1], axis=0)
|
|
80
|
+
avg2 = np.mean([row for i, row in enumerate(frame_buffer_2d) if i % 4 == 2], axis=0)
|
|
81
|
+
avg3 = np.mean([row for i, row in enumerate(frame_buffer_2d) if i % 4 == 3], axis=0)
|
|
82
|
+
list_y1.append(avg0[pixel_plot])
|
|
83
|
+
list_y2.append(avg1[pixel_plot])
|
|
84
|
+
list_y3.append(avg2[pixel_plot])
|
|
85
|
+
list_y4.append(avg3[pixel_plot])
|
|
86
|
+
stresing.settings.camera_settings[drvno].sensor_reset_or_hsir_ec += step_size
|
|
87
|
+
|
|
88
|
+
# Plot all four lists as separate graphs in one figure
|
|
89
|
+
plt.figure(figsize=(10, 8))
|
|
90
|
+
plt.plot(list_x, list_y1, label='On 1')
|
|
91
|
+
plt.plot(list_x, list_y2, label='On 2')
|
|
92
|
+
plt.plot(list_x, list_y3, label='Off 1')
|
|
93
|
+
plt.plot(list_x, list_y4, label='Off 2')
|
|
94
|
+
plt.xlabel('sensor reset in ns')
|
|
95
|
+
plt.ylabel('Pixel Value')
|
|
96
|
+
plt.title('Sensor Reset Sweep - Pixel ' + str(pixel_plot))
|
|
97
|
+
plt.grid(True)
|
|
98
|
+
plt.legend()
|
|
99
|
+
plt.tight_layout()
|
|
100
|
+
plt.show()
|
|
101
|
+
|
|
102
|
+
print("Create a measurement with reset time " + str(stresing.settings.camera_settings[drvno].sensor_reset_or_hsir_ec * 4) + " ns")
|
|
103
|
+
# Initialize the measurement.
|
|
104
|
+
stresing.init_measurement()
|
|
105
|
+
# Start the measurement. This is the blocking call, which means it will return when the measurement is finished. This is done to ensure that no data access happens before all data is collected.
|
|
106
|
+
stresing.start_measurement_blocking()
|
|
107
|
+
# Get all the data in a 2D list
|
|
108
|
+
frame_buffer_2d = stresing.copy_all_data_2d(drvno)
|
|
109
|
+
# Drop the first 200 samples
|
|
110
|
+
frame_buffer_2d = frame_buffer_2d[200:]
|
|
111
|
+
# Calculate the 4 averages of every 4th row of frame_buffer_2d
|
|
112
|
+
import numpy as np
|
|
113
|
+
avg0 = np.mean([row for i, row in enumerate(frame_buffer_2d) if i % 4 == 0], axis=0)
|
|
114
|
+
avg1 = np.mean([row for i, row in enumerate(frame_buffer_2d) if i % 4 == 1], axis=0)
|
|
115
|
+
avg2 = np.mean([row for i, row in enumerate(frame_buffer_2d) if i % 4 == 2], axis=0)
|
|
116
|
+
avg3 = np.mean([row for i, row in enumerate(frame_buffer_2d) if i % 4 == 3], axis=0)
|
|
117
|
+
# plot the 4 averages
|
|
118
|
+
plt.figure(figsize=(10, 8))
|
|
119
|
+
plt.plot(avg0, label='On 1')
|
|
120
|
+
plt.plot(avg1, label='On 2')
|
|
121
|
+
plt.plot(avg2, label='Off 1')
|
|
122
|
+
plt.plot(avg3, label='Off 2')
|
|
123
|
+
plt.xlabel('Pixel')
|
|
124
|
+
plt.ylabel('Intensity')
|
|
125
|
+
plt.title('Average Intensity for each sample type for reset time ' + str(stresing.settings.camera_settings[drvno].sensor_reset_or_hsir_ec * 4) + ' ns')
|
|
126
|
+
plt.legend()
|
|
127
|
+
plt.grid(True)
|
|
128
|
+
plt.tight_layout()
|
|
129
|
+
plt.show()
|
|
130
|
+
|
|
131
|
+
# Exit the driver
|
|
132
|
+
stresing.exit_driver()
|
examples/shutter.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
## @file: shutter.py
|
|
2
|
+
# @brief: This script is closing and opening all shutters 10 times once per second.
|
|
3
|
+
# @details:
|
|
4
|
+
# @author: Florian Hahn
|
|
5
|
+
# @date: 19.06.2025
|
|
6
|
+
# @copyright: Copyright (c) 202, Entwicklungsbüro Stresing. Released as public domain under the Unlicense.
|
|
7
|
+
|
|
8
|
+
import time
|
|
9
|
+
import stresing
|
|
10
|
+
|
|
11
|
+
# Always use board 0. There is only one PCIe board in this example script.
|
|
12
|
+
drvno = 0
|
|
13
|
+
|
|
14
|
+
stresing.init_driver()
|
|
15
|
+
|
|
16
|
+
# Loop for closing and opening all shutters 10 times once per second
|
|
17
|
+
for i in range(10):
|
|
18
|
+
print("Open")
|
|
19
|
+
# Set all shutters to open
|
|
20
|
+
stresing.set_shutter_states(drvno, 0)
|
|
21
|
+
|
|
22
|
+
# Wait for 1 second
|
|
23
|
+
time.sleep(1)
|
|
24
|
+
|
|
25
|
+
print("Close")
|
|
26
|
+
# Set all shutters to closed
|
|
27
|
+
# 15 = 0b00001111, which means all shutters are set to open
|
|
28
|
+
stresing.set_shutter_states(drvno, 15)
|
|
29
|
+
|
|
30
|
+
# Wait for 1 second
|
|
31
|
+
time.sleep(1)
|
|
32
|
+
|
|
33
|
+
# Exit the driver
|
|
34
|
+
stresing.exit_driver()
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
## @file: simple_blocking_measurement.py
|
|
2
|
+
# @brief: This script shows how to operate the Stresing camera using the python module stresing.
|
|
3
|
+
# @details: This script initializes the camera, does one measurement, reads the data and plots the data. The data access happens after the complete measurement is done. This example is written for 1 camera on 1 PCIe board.
|
|
4
|
+
# @author: Florian Hahn
|
|
5
|
+
# @date: 13.10.2022
|
|
6
|
+
# @copyright: Copyright (c) 2025, Entwicklungsbüro Stresing. Released as public domain under the Unlicense.
|
|
7
|
+
|
|
8
|
+
import stresing
|
|
9
|
+
# matplotlib is used for the data plot
|
|
10
|
+
import matplotlib.pyplot as plt
|
|
11
|
+
|
|
12
|
+
# Initialize the driver.
|
|
13
|
+
number_of_boards = stresing.init_driver()
|
|
14
|
+
# Set all settings that are needed for the measurement in config.ini. The file config.ini is also compatible with the exported settings of Escam. Settings that are not found in the file, will be left as default. You can find a description of all settings here: https://entwicklungsburo-stresing.github.io/structmeasurement__settings.html
|
|
15
|
+
stresing.load_config_file("config.ini")
|
|
16
|
+
# Initialize the measurement.
|
|
17
|
+
stresing.init_measurement()
|
|
18
|
+
# Start the measurement. This is the blocking call, which means it will return when the measurement is finished. This is done to ensure that no data access happens before all data is collected.
|
|
19
|
+
stresing.start_measurement_blocking()
|
|
20
|
+
frame_buffer = stresing.copy_one_sample(0, 5, 0 ,0)
|
|
21
|
+
# Plot the frame
|
|
22
|
+
plt.plot(frame_buffer)
|
|
23
|
+
plt.show()
|
|
24
|
+
# Exit the driver
|
|
25
|
+
stresing.exit_driver()
|
examples/stime_sweep.py
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
## @file: stime_sweep.py
|
|
2
|
+
# @brief: This script does a sweep of the stime parameter.
|
|
3
|
+
# @details:
|
|
4
|
+
# @author: Florian Hahn
|
|
5
|
+
# @date: 07.01.2025
|
|
6
|
+
# @copyright: Copyright (c) 2025, Entwicklungsbüro Stresing. Released as public domain under the Unlicense.
|
|
7
|
+
|
|
8
|
+
# matplotlib is used for the data plot
|
|
9
|
+
import matplotlib.pyplot as plt
|
|
10
|
+
import stresing
|
|
11
|
+
|
|
12
|
+
# Always use board 0. There is only one PCIe board in this example script.
|
|
13
|
+
drvno = 0
|
|
14
|
+
# Initialize the driver and pass the created pointer to it. number_of_boards should show the number of detected PCIe boards after the next call.
|
|
15
|
+
stresing.init_driver()
|
|
16
|
+
# Set all settings that are needed for the measurement in config.ini. The file config.ini is also compatible with the exported settings of Escam. Settings that are not found in the file, will be left as default. You can find a description of all settings here: https://entwicklungsburo-stresing.github.io/structmeasurement__settings.html
|
|
17
|
+
stresing.load_config_file("config.ini")
|
|
18
|
+
# create an empty list to store the data
|
|
19
|
+
list_x = []
|
|
20
|
+
list_y = []
|
|
21
|
+
# plot this pixel
|
|
22
|
+
pixel_plot = 363
|
|
23
|
+
# this is the exposure time at which the sweep starts
|
|
24
|
+
start_value = stresing.settings.camera_settings[drvno].stime
|
|
25
|
+
# do the first measurements with step_size
|
|
26
|
+
step_size1_measurement_cnt = 200
|
|
27
|
+
# this is the exposure time at which the step size changes
|
|
28
|
+
value_step2 = start_value + step_size1_measurement_cnt
|
|
29
|
+
# this is the exposure time at which the sweep stops
|
|
30
|
+
stop_value = 21000
|
|
31
|
+
# this is the step size for the first measurements
|
|
32
|
+
step_size = 1
|
|
33
|
+
# after the count of measurements of step_size1_measurement_cnt are done change the step size to step_size2
|
|
34
|
+
step_size2 = 10
|
|
35
|
+
measurement_cnt = int((value_step2 - start_value) / step_size) + int((stop_value - value_step2) / step_size2)
|
|
36
|
+
|
|
37
|
+
for i in range(measurement_cnt):
|
|
38
|
+
print("Measurement " + str(i + 1) + " of " + str(measurement_cnt) + ", stime = " + str(stresing.settings.camera_settings[drvno].stime) + " µs")
|
|
39
|
+
# Initialize the measurement.
|
|
40
|
+
stresing.init_measurement()
|
|
41
|
+
# Start the measurement. This is the blocking call, which means it will return when the measurement is finished. This is done to ensure that no data access happens before all data is collected.
|
|
42
|
+
stresing.start_measurement_blocking()
|
|
43
|
+
# Get the data of one frame. Sample settings.nos-1, block 0, camera 0
|
|
44
|
+
frame_buffer = stresing.copy_one_sample(drvno, stresing.settings.nos-1, 0, 0)
|
|
45
|
+
list_x.append(stresing.settings.camera_settings[drvno].stime)
|
|
46
|
+
list_y.append(frame_buffer[pixel_plot])
|
|
47
|
+
if i < step_size1_measurement_cnt:
|
|
48
|
+
stresing.settings.camera_settings[drvno].stime += step_size
|
|
49
|
+
else:
|
|
50
|
+
stresing.settings.camera_settings[drvno].stime += step_size2
|
|
51
|
+
|
|
52
|
+
# Plot
|
|
53
|
+
plt.figure(layout="constrained")
|
|
54
|
+
plt.subplot(211)
|
|
55
|
+
plt.plot(list_x, list_y)
|
|
56
|
+
plt.yscale('linear')
|
|
57
|
+
plt.xscale('linear')
|
|
58
|
+
plt.xlabel('stime in µs')
|
|
59
|
+
plt.title('linear')
|
|
60
|
+
plt.grid(True)
|
|
61
|
+
|
|
62
|
+
plt.subplot(212)
|
|
63
|
+
plt.plot(list_x, list_y)
|
|
64
|
+
plt.yscale('log')
|
|
65
|
+
plt.xscale('log')
|
|
66
|
+
plt.xlabel('stime in µs')
|
|
67
|
+
plt.title('log')
|
|
68
|
+
plt.grid(True)
|
|
69
|
+
plt.show()
|
|
70
|
+
|
|
71
|
+
# Exit the driver
|
|
72
|
+
stresing.exit_driver()
|