GitLab will be upgraded on June 23rd evening. During the upgrade the service will be unavailable, sorry for the inconvenience.

Commit 0fbfc595 authored by Emmanuel Papillon's avatar Emmanuel Papillon

fscans : remove lima calibration now managed inside fscan

parent 751b2663
......@@ -5,103 +5,31 @@ from fscan.fscanrunner import FScanRunner, FScanDiagRunner
from fscan.finterlaced import FInterlacedMode
class ID11CameraCalib:
def __init__(self):
self.readout = dict()
def calibrate(self, devs, acqtime, shuttime=0.):
readout_time = 0.0
latency_time = 1e-6
self.readout = dict()
for dev in devs:
camtype = dev._proxy.lima_type
if camtype == "Andor3":
cam_time = dev.camera.readout_time
lat_time = 1e-4
elif camtype == "Frelon":
cam_time = self.calibrate_frelon(dev, acqtime, shuttime)
lat_time = 1e-4
elif camtype == "Eiger":
cam_time = 1e-7 * (acqtime // (1./300.) + 1)
lat_time = 1e-6
def check_frelon_shutter_time(devs, shuttime):
for dev in devs:
camtype = dev._proxy.lima_type
if camtype == "Frelon":
if dev.camera.image_mode == "FULL FRAME":
dev.shutter.close_time = self.fsh.shutter_time
else:
print("WARNING : software estimation of {dev.name} readout time !!")
cam_time = take_one_image(dev, acq_time)
lat_time = 1e-4
self.readout[dev.name] = (cam_time, lat_time)
if len(self.readout):
max_rd = 0.0
max_name = None
for name, (rd, lat) in self.readout.items():
if rd >= max_rd:
max_rd = rd
max_name = name
(readout_time, latency_time) = self.readout[max_name]
return (readout_time, latency_time)
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
dev.shutter.close_time = 0.0
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
if pars.scan_mode != "CAMERA":
limadevs = self._master.get_controllers_found("lima")
(readout_time, min_lat_time) = self._calib.calibrate(limadevs, pars.acq_time, self._fsh.shutter_time)
min_period = pars.acq_time + readout_time + min_lat_time
if pars.period < min_period:
pars.period = min_period
limadevs = self._master.get_controllers_found("lima")
check_frelon_shutter_time(limadevs, self._fsh.shutter_time)
super().validate()
def __call__(self, acq_time, npoints, period=0., scan_mode="TIME", **kwargs):
pars = dict(acq_time=acq_time,
npoints=npoints,
period=period,
scan_mode=scan_mode,
def __call__(self, acq_time, npoints, period=0, **kwargs):
pars = dict(acq_time = acq_time,
npoints = npoints,
period = period,
)
pars.update(kwargs)
self.pars.set(**pars)
......@@ -110,34 +38,19 @@ class ID11FTimeScan(FScanRunner):
class ID11FScan(FScanDiagRunner):
def __init__(self, scanname, scanmaster, fshutter):
self._fsh = fshutter
self._calib = ID11CameraCalib()
super().__init__(scanname, scanmaster)
def validate(self):
pars = self.pars
# --- check minimum step_size
limadevs = self._master.get_controllers_found("lima")
(readout_time, min_lat_time) = self._calib.calibrate(limadevs, pars.acq_time, self._fsh.shutter_time)
if pars.scan_mode != "CAMERA":
if pars.latency_time > min_lat_time:
min_step_time = pars.acq_time + readout_time + pars.latency_time
else:
min_step_time = pars.acq_time + readout_time + min_lat_time
else: # --- camera mode
min_step_time = pars.acq_time + readout_time
check_frelon_shutter_time(limadevs, self._fsh.shutter_time)
if pars.scan_mode == "CAMERA":
if limadevs[0].name == "marana":
limadevs[0].camera.output_signal = "FIREROW1"
if limadevs[0].camera.overlap == "ON":
if pars.acq_time > readout_time:
min_step_time = pars.acq_time
else:
min_step_time = readout_time + readout_time / 2048.
if pars.step_time < min_step_time:
pars.step_time = min_step_time
super().validate()
pars.step_time=0.
def __call__(self, motor, start_pos, step_size, npoints, acq_time, scan_mode="TIME", **kwargs):
pars = dict(motor=motor,
......@@ -155,27 +68,19 @@ class ID11FScan(FScanDiagRunner):
class ID11FScan2D(FScanDiagRunner):
def __init__(self, scanname, scanmaster, fshutter):
self._fsh = fshutter
self._calib = ID11CameraCalib()
super().__init__(scanname, scanmaster)
def validate(self):
pars = self.pars
# --- check minimum step_size
limadevs = self._master.get_controllers_found("lima")
(readout_time, min_lat_time) = self._calib.calibrate(limadevs, pars.acq_time, self._fsh.shutter_time)
if pars.latency_time < min_lat_time:
min_step_time = pars.acq_time + readout_time + min_lat_time
else:
min_step_time = pars.acq_time + readout_time + pars.latency_time
if pars.fast_step_time < min_step_time:
pars.fast_step_time = min_step_time
check_frelon_shutter_time(limadevs, self._fsh.shutter_time)
super().validate()
pars.fast_step_time=0.
def __call__(self, slow_motor, slow_start, slow_step, slow_npoints,
fast_motor, fast_start, fast_step, fast_npoints, acq_time, mode="REWIND", **kwargs):
fast_motor, fast_start, fast_step, fast_npoints, acq_time,
mode="REWIND", **kwargs):
pars = dict(slow_motor=slow_motor,
slow_start_pos=slow_start,
slow_step_size=slow_step,
......@@ -195,21 +100,16 @@ class ID11FScan2D(FScanDiagRunner):
class ID11FInterlaced(FScanDiagRunner):
def __init__(self, scanname, scanmaster, fshutter):
self._fsh = fshutter
self._calib = ID11CameraCalib()
super().__init__(scanname, scanmaster)
def validate(self):
pars = self.pars
# --- frelon readout checks
# --- frelon shutter time checks
limadevs = self._master.get_controllers_found("lima")
check_frelon_shutter_time(limadevs, self._fsh.shutter_time)
frelons = [ dev for dev in limadevs if dev._proxy.lima_type == "Frelon" ]
if len(frelons):
(readout_time, min_lat_time) = self._calib.calibrate(frelons, pars.acq_time, self._fsh.shutter_time)
if pars.acq_time < readout_time:
raise RuntimeError(f"Acquisition time too short for frelon (min={readout_time})")
# --- shift_pos adjusted in zigzag mode with frelon
pars.shift_pos = 0.
if pars.mode == FInterlacedMode.ZIGZAG and len(frelons):
......
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