Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ID11
id11
Commits
14220d81
Commit
14220d81
authored
Jun 29, 2020
by
Emmanuel Papillon
Browse files
fscans : camera calibration + ftimescan runner
parent
b78d80f3
Changes
1
Hide whitespace changes
Inline
Side-by-side
id11/scans/fscans.py
0 → 100644
View file @
14220d81
import
gevent
import
time
from
fscan.fscanrunner
import
FScanRunner
class
ID11CameraCalib
:
def
__init__
(
self
):
self
.
readout
=
dict
()
def
calibrate
(
self
,
devs
,
acqtime
,
shuttime
=
0.
):
self
.
readout
=
dict
()
for
dev
in
devs
:
camtype
=
dev
.
_proxy
.
lima_type
if
camtype
==
"Andor3"
:
camtime
=
self
.
calibrate_andor
(
dev
,
acqtime
)
elif
camtype
==
"Frelon"
:
camtime
=
self
.
calibrate_frelon
(
dev
,
acqtime
,
shuttime
)
else
:
print
(
"WARNING : software estimation of {dev.name} readout time !!"
)
camtime
=
take_one_image
(
dev
,
acq_time
)
self
.
readout
[
dev
.
name
]
=
camtime
return
max
(
self
.
readout
.
values
())
def
calibrate_andor
(
self
,
dev
,
acqtime
):
self
.
take_image
(
dev
,
acqtime
,
1
)
readout
=
dev
.
camera
.
readout_time
return
readout
def
calibrate_frelon
(
self
,
dev
,
acqtime
,
shuttime
):
dev
.
_proxy
.
saving_mode
=
"MANUAL"
dev
.
_proxy
.
prepareAcq
()
transfer_time
=
dev
.
camera
.
transfer_time
readout_time
=
dev
.
camera
.
readout_time
if
dev
.
camera
.
image_mode
==
"FRAME TRANSFER"
:
readout
=
dev
.
camera
.
transfer_time
minexpo
=
dev
.
camera
.
readout_time
else
:
readout
=
dev
.
camera
.
readout_time
+
shuttime
return
readout
def
take_image
(
self
,
dev
,
acqtime
,
nimg
=
1
):
proxy
=
dev
.
_proxy
# check accumulation
if
proxy
.
acq_mode
==
"ACCUMULATION"
:
if
proxy
.
acc_nb_frames
>
1
:
acqtime
=
proxy
.
acc_expo_time
# prepare
proxy
.
saving_mode
=
"MANUAL"
proxy
.
acq_trigger_mode
=
"INTERNAL_TRIGGER"
proxy
.
acq_expo_time
=
acqtime
proxy
.
acq_nb_frames
=
nimg
proxy
.
prepareAcq
()
# start image acquisition
runtime
=
time
.
time
()
proxy
.
startAcq
()
while
proxy
.
acq_status
==
"Running"
:
gevent
.
sleep
(
0.01
)
runtime
=
time
.
time
()
-
runtime
return
runtime
class
ID11FTimeScan
(
FScanRunner
):
def
__init__
(
self
,
scanname
,
scanmaster
,
fshutter
):
self
.
_fsh
=
fshutter
self
.
_calib
=
ID11CameraCalib
()
super
().
__init__
(
scanname
,
scanmaster
)
def
validate
(
self
):
pars
=
self
.
pars
# --- check minimum period
limadevs
=
self
.
_master
.
get_controllers_found
(
"lima"
)
readout_time
=
self
.
_calib
.
calibrate
(
limadevs
,
pars
.
acq_time
,
self
.
_fsh
.
shutter_time
)
min_period
=
pars
.
acq_time
+
readout_time
+
1e-4
if
pars
.
period
<
min_period
:
pars
.
period
=
min_period
super
().
validate
()
def
__call__
(
self
,
acq_time
,
npoints
,
period
=
0.
,
start_delay
=
0.
):
pars
=
self
.
pars
pars
.
acq_time
=
acq_time
pars
.
npoints
=
npoints
pars
.
period
=
period
self
.
run
()
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment