Commit 16cd9bd9 authored by Emmanuel Papillon's avatar Emmanuel Papillon
Browse files

fit shutter calibration debug

parent 7d55accc
#!/usr/bin/env python
from __future__ import print_function, division
import sys, numpy as np, pylab as pl
......@@ -33,8 +31,6 @@ def fitshutter_all( x, y ):
returns: y_cut, xcuts[N], signs[N], xerrs[N]
"""
print(x)
print(y)
first_cut = 0.5*( y.max() + y.min() ) # mid-height
beam_on = y[ y > first_cut ] # y-vals in beam
beam_off = y[ y < first_cut ] # y-vals in dark
......
from bliss.config.settings import HashObjSetting
from bliss import current_session
from .fshuttercalibration import FastShutterCalibration
from .fshuttercalib import FastShutterCalibration
class FastShutter:
......@@ -104,6 +104,6 @@ class FastShutter:
raise RuntimeError("No shutter calibration available !!")
return self.__calib
def measure(self):
self.calibration.measure()
def measure(self, open_time=1., acq_time=100e-6, delay=200e-3):
self.calibration.measure(open_time, acq_time, delay)
......@@ -61,17 +61,18 @@ class FastShutterCalibration(object):
chain = AcquisitionChain()
musst_time_factor = musst.get_timer_factor()
musst_time_factor = self.__musst.get_timer_factor()
musst_master = MusstAcquisitionMaster(self.__musst, program_data=_MUSST_PRG,
program_start_name="SHUTTER",
vars={'START_DELAY':int(delay*musst_time_factor),
'GATEWIDTH':int(open_time*musst_time_factor)})
npoints = int((delay + open_time + 2*self.__shutter.shutter_time)/acq_time)
npoints = int((open_time + 2*self.__shutter.shutter_time)/acq_time)
dead_time = 1e-6
p201_master = CT2AcquisitionMaster(self.__p201,
npoints=npoints,
acq_mode=AcqMode.ExtTrigSingle,
acq_expo_time=acq_time-1e-6,
acq_expo_time=acq_time-dead_time,
acq_point_period=acq_time)
chain.add(musst_master,p201_master)
......@@ -80,21 +81,22 @@ class FastShutterCalibration(object):
chain.add(p201_master, acq_device)
#calc
class _CumSum(object):
def __init__(self, cnt_name):
class TimeCumSum(object):
def __init__(self, cnt_name, dead_time=0.):
self.previous_time = 0
self.cnt_name = cnt_name
self.dead_time = dead_time
def __call__(self, sender, data_dict):
data = data_dict.get(self.cnt_name)
if data is None:
return {}
data = data + self.dead_time
data = numpy.cumsum(data) + self.previous_time
self.previous_time = data[-1]
return {'time': data}
calc_device = CalcChannelAcquisitionSlave('time_cumsum',(acq_device,),
_CumSum(self.__timer.name),
TimeCumSum(self.__timer.name, dead_time),
(AcquisitionChannel('time',numpy.float,()),))
chain.add(p201_master, calc_device)
......@@ -108,12 +110,16 @@ class FastShutterCalibration(object):
scan.run()
print("Scan finished.")
data= scan.get_data()
self.measurement_fit(data, open_time)
self.__data= scan.get_data()
time_data = self.__data["time"]
sig_data = self.__data[self.__diode.fullname]
print("Running fit procedure ...")
self.measurement_fit(time_data, sig_data, open_time)
def measurement_fit(self, data, exp_time):
data_timer = data[self.__timer.name]
data_diode = data[self.__diode.name]
o, c, oe, ce = fitshutter(data_timer, data_diode, exp_time, plot_title="Fast Shutter Calibration")
print("Shutter Open: %f +/- %f , Close %f +/- %f"%(o, oe, c, ce ))
def measurement_fit(self, timedata, sigdata, exp_time):
o, c, oe, ce = fitshutter(timedata, sigdata, exp_time, plot_title="Fast Shutter Calibration")
print("Fit Results:")
print(f" Open time : {o:f} +/- {oe:f} sec")
print(f" Close time : {c:f} +/- {ce:f} sec")
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