Commit 14220d81 authored by Emmanuel Papillon's avatar Emmanuel Papillon
Browse files

fscans : camera calibration + ftimescan runner

parent b78d80f3
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()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment