-
Notifications
You must be signed in to change notification settings - Fork 1
/
unit-test.py
executable file
·249 lines (217 loc) · 8.92 KB
/
unit-test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
#!/usr/bin/python
# -*- coding: utf-8 -*-
### This script should be run after :
### export LD_LIBRARY_PATH="/usr/local/Lima/Lima/lib"
import os,sys,time
from Lima import Core
from Lima import Andor3
print("* The general setup :")
print("\n** The environement of the pocess is now : ")
print(os.environ)
print("\n** Now, importing Lima (Core and Andor3 :")
print("\twith sys.path = " + ":".join(sys.path))
print("\n** Constructing the camera and the other related object :")
cam = Andor3.Camera("/usr/local/bf", 0)
cam_int = Andor3.Interface(cam)
cam_ctr = Core.CtControl(cam_int)
print("\n** Removing all files that could interfer with acquisition :")
os.system("rm -fv /mnt/DataHub3/iGEM/20170903/camera/testing*.tiff")
print("\n** Taking care of the saving format : 1st serie is wihtOUT saving")
cam_sav = cam_ctr.saving()
cam_sav.setDirectory("/mnt/DataHub3/iGEM/20170903/camera")
cam_sav.setPrefix("testing")
cam_sav.setSavingMode(Core.CtSaving.Manual)
# Manual: No automatic saving, you should call CtSaving::writeFrame
print(cam_sav.getParameters())
print("** Testing the ROI : 100, 100, 2360, 1960 (in HardOnly mode)")
cam_ctr.image().setMode(Core.CtImage.HardOnly)
cam_ctr.image().setRoi(Core.Roi(100, 100, 2360, 1960)) ### left, top, width, height
the_roi = cam_ctr.image().getRoi()
print("\tThe retrieved roi is (%d, %d, %d, %d)" % (the_roi.getTopLeft().x, the_roi.getTopLeft().y, the_roi.getSize().getWidth(), the_roi.getSize().getHeight()))
print("\n**Testing the acquisition exposure and latency :")
## ##### Faster frame-rates, lower latency :
## cam.setElectronicShutterMode(Andor3.Camera.Rolling)
## cam.setAdcRate(cam.MHz280)
## cam.getLatTimeRange() ## 0.0103
## ##### Slower frame-rate, higher latency :
## cam.setElectronicShutterMode(Andor3.Camera.Global)
## cam.setAdcRate(cam.MHz100)
## cam.getLatTimeRange() ## 0.0286
cam_acq = cam_ctr.acquisition()
print("Setting the trigger mode to internal :")
cam_acq.setTriggerMode(Core.IntTrig)
print("setting the exposition time to 0.001 ...")
cam_acq.setAcqExpoTime(.01)
print("*** Getting in slow acquisition mode :")
print("setting the true camera speed to Global shutter and 100MHz")
cam.setElectronicShutterMode(Andor3.Camera.Global)
cam.setAdcRate(cam.MHz100)
#print("the range of latency time for the hardware is now %.3f to %.3f s" % cam.getLatTimeRange())
print("setting the latency time to 0.015 (below the limit of the hardware")
cam_acq.setLatencyTime(.015)
print("retrieving the values : ")
print("\texpo time = %f" % cam_acq.getAcqExpoTime())
#print("\tlat time = %f" % cam_acq.getLatencyTime())
#if ( 0.015 != cam_acq.getLatencyTime() ) :
#print("\t The retrieved latency is different from the set one (expected)")
#if ( cam.getLatTimeRange()[0] != cam_acq.getLatencyTime() ) :
# print("\t The retrieved latency time is DIFFERENT from the min latency of the hardware, %.3f vs. %.3f respectively" % (cam_acq.getLatencyTime(), cam.getLatTimeRange()[0]))
print("\nTesting the ROI : 100, 100, 2360, 1960")
cam_ctr.image().setRoi(Core.Roi(100, 100, 2360, 1960)) ### left, top, width, height
the_roi = cam_ctr.image().getRoi()
print("\tThe retrieved roi is (%d, %d, %d, %d)" % (the_roi.getTopLeft().x, the_roi.getTopLeft().y, the_roi.getSize().getWidth(), the_roi.getSize().getHeight()))
print("*** Getting in fast acquisition mode :")
print("setting the true camera speed to Global shutter and 280MHz")
cam.setElectronicShutterMode(Andor3.Camera.Global)
cam.setAdcRate(cam.MHz280)
#print("the range of latency time for the hardware is now %.3f to %.3f s" % cam.getLatTimeRange())
print("setting the latency time to 0.015 (below the limit of the hardware")
cam_acq.setLatencyTime(.015)
print("retrieving the values : ")
print("\texpo time = %f" % cam_acq.getAcqExpoTime())
#print("\tlat time = %f" % cam_acq.getLatencyTime())
#if ( 0.015 != cam_acq.getLatencyTime() ) :
# print("\t The retrieved latency is DIFFERENT from the set one (unexpected in fast mode)")
#if ( cam.getLatTimeRange()[0] != cam_acq.getLatencyTime() ) :
# print("\t The retrieved latency time is DIFFERENT from the min latency of the hardware, %.3f vs. %.3f respectively" % (cam_acq.getLatencyTime(), cam.getLatTimeRange()[0]))
print("* Testing some frame-number based acquisitions")
# print(" Setting the debug to tracing on camera:")
# Core.DebParams.setTypeFlagsNamecam_ctrList(['Fatal', 'Error', 'Warning', 'Trace'])
# Core.DebParams.setModuleFlagsNameList(['Camera'])
print(" Acquiring 3 images, to flush the CtAcquisition and the frame-rate be updated accordingly")
cam_ctr.acquisition().setAcqNbFrames(3)
cam_ctr.prepareAcq()
cam_ctr.startAcq()
time.sleep(5)
print(" Acquiring 50 image using the current settings.")
cam_ctr.acquisition().setAcqNbFrames(50)
print(" Setting the output sink :")
cam_sav = cam_ctr.saving()
cam_sav.setDirectory("/mnt/DataHub3/iGEM/20170903/camera")
cam_sav.setPrefix("testing")
print(" The saving parameters are :")
print(cam_sav.getParameters())
#cam_ctr.video().startLive()
print(" Launching acquisition of %d frames whith exposure time of %.3fs and latency time %.3fs." % (cam_ctr.acquisition().getAcqNbFrames(), cam_acq.getAcqExpoTime(), cam_acq.getLatencyTime()))
print("** Setting the output to none")
cam_sav.setSavingMode(Core.CtSaving.Manual)
print(" The saving parameters are :")
print(cam_sav.getParameters())
cam_ctr.prepareAcq()
cam_ctr.startAcq()
the_wait=0
while ( Core.AcqReady != cam_ctr.getStatus().AcquisitionStatus ) :
time.sleep(1)
the_wait += 1
print("Acquisition done with sleep of %ds" % (the_wait))
time.sleep(1)
print("And again...")
cam_ctr.prepareAcq()
cam_ctr.startAcq()
the_wait=0
while ( Core.AcqReady != cam_ctr.getStatus().AcquisitionStatus ) :
time.sleep(1)
the_wait += 1
print("Acquisition done with sleep of %ds" % (the_wait))
time.sleep(1)
print("** Setting the output to tiff")
cam_sav.setSavingMode(Core.CtSaving.AutoFrame)
cam_sav.setFormat(Core.CtSaving.TIFFFormat)
cam_sav.setSuffix(".tiff")
print(" The saving parameters are :")
print(cam_sav.getParameters())
cam_ctr.prepareAcq()
cam_ctr.startAcq()
the_wait=0
while ( Core.AcqReady != cam_ctr.getStatus().AcquisitionStatus ) :
time.sleep(1)
the_wait += 1
print("Acquisition done with sleep of %ds"% (the_wait))
time.sleep(1)
print("And again...")
cam_ctr.prepareAcq()
cam_ctr.startAcq()
the_wait=0
while ( Core.AcqReady != cam_ctr.getStatus().AcquisitionStatus ) :
time.sleep(1)
the_wait += 1
print("Acquisition done with sleep of %ds"% (the_wait))
time.sleep(1)
# print("** Setting the output to nexus")
# cam_sav.setSavingMode(Core.CtSaving.AutoFrame)
# cam_sav.setFormat(Core.CtSaving.NXS)
# cam_sav.setSuffix(".nxs")
# print(" The saving parameters are :")
# print(cam_sav.getParameters())
# cam_ctr.prepareAcq()
# cam_ctr.startAcq()
# the_wait=0
# while ( Core.AcqReady != cam_ctr.getStatus().AcquisitionStatus ) :
# time.sleep(1)
# the_wait += 1
# print("Acquisition done with sleep of %ds"% (the_wait))
#
# print("And again...")
# cam_ctr.prepareAcq()
# cam_ctr.startAcq()
# the_wait=0
# while ( Core.AcqReady != cam_ctr.getStatus().AcquisitionStatus ) :
# time.sleep(1)
# the_wait += 1
# print("Acquisition done with sleep of %ds"% (the_wait))
#
print("* Testing some free-running acquisitions, during approx 2s each test :")
print(" Setting the output sink :")
cam_sav = cam_ctr.saving()
cam_sav.setDirectory("/mnt/DataHub3/")
cam_sav.setPrefix("testing_A_")
print(" The saving parameters are :")
print(cam_sav.getParameters())
print("** Using the null output sink :")
cam_sav.setSavingMode(Core.CtSaving.Manual)
print(" The saving parameters are :")
print(cam_sav.getParameters())
cam_ctr.video().startLive()
time.sleep(2)
cam_ctr.video().stopLive()
print("Acquisition done in free running while the main thread slept 2s")
time.sleep(1)
print("And again...")
cam_ctr.video().startLive()
time.sleep(2)
cam_ctr.video().stopLive()
print("Acquisition done in free running while the main thread slept 2s")
time.sleep(1)
print("** Setting the output to tiff")
cam_sav.setSavingMode(Core.CtSaving.AutoFrame)
cam_sav.setFormat(Core.CtSaving.TIFFFormat)
cam_sav.setSuffix(".tiff")
print(" The saving parameters are :")
print(cam_sav.getParameters())
cam_ctr.video().startLive()
time.sleep(2)
cam_ctr.video().stopLive()
print("Acquisition done in free running while the main thread slept 2s")
time.sleep(1)
print("And again...")
cam_ctr.video().startLive()
time.sleep(2)
cam_ctr.video().stopLive()
print("Acquisition done in free running while the main thread slept 2s")
time.sleep(1)
## print("** Setting the output to nexus")
## cam_sav.setSavingMode(Core.CtSaving.AutoFrame)
## cam_sav.setFormat(Core.CtSaving.NXS)
## cam_sav.setSuffix(".nxs")
## print(" The saving parameters are :")
## print(cam_sav.getParameters())
## cam_ctr.video().startLive()
## time.sleep(2)
## cam_ctr.video().stopLive()
## print("Acquisition done in free running while the main thread slept 2s")
##
print("And again...")
cam_ctr.video().startLive()
time.sleep(2)
cam_ctr.video().stopLive()
print("Acquisition done in free running while the main thread slept 2s")