towards jungfrau and shapepath...
This commit is contained in:
129
swissmx.py
129
swissmx.py
@@ -2194,14 +2194,6 @@ class Main(QMainWindow, Ui_MainWindow):
|
||||
params = (xp[:, 0].tolist(), xp[:, 1].tolist())
|
||||
self.daq_collect_points(points, visualizer_method=method, visualizer_params=params)
|
||||
|
||||
def daq_grid_collect_grid(self):
|
||||
grid = self._grids[0] # FIXME one grid at a time only
|
||||
points = np.array(grid.get_grid_targets())
|
||||
method = "grid"
|
||||
params = grid._grid_dimensions
|
||||
# params = ([grid._grid_dimensions[0]], [grid._grid_dimensions[1]]) # FIXME something wrong here<
|
||||
self.daq_collect_points(points, visualizer_method=method, visualizer_params=params)
|
||||
|
||||
def daq_grid_findxtals(self):
|
||||
feature_size = self._sb_findxtals_feature_size.value()
|
||||
image = sample_camera.get_image()
|
||||
@@ -2232,27 +2224,75 @@ class Main(QMainWindow, Ui_MainWindow):
|
||||
return True
|
||||
|
||||
def daq_collect_points(self, points, visualizer_method, visualizer_params):
|
||||
app = QApplication.instance()
|
||||
cfg = app._cfg
|
||||
verbose=0xff
|
||||
fn='/tmp/shapepath'
|
||||
try:
|
||||
dt=app._deltatau
|
||||
except AttributeError:
|
||||
import matplotlib.pyplot as plt
|
||||
import deltatau
|
||||
app._deltatau=dt=deltatau.Deltatau()
|
||||
try:
|
||||
jf=app._jungfrau
|
||||
except AttributeError:
|
||||
import detector
|
||||
app._jungfrau=jf=detector.Jungfrau()
|
||||
|
||||
dt=app._deltatau
|
||||
|
||||
|
||||
sp=dt._shapepath
|
||||
|
||||
sp.gen_grid_points(w=15, h=15, pitch=3, rnd=0, ofs=(0, +2000));
|
||||
sp.sort_points(False, 15);
|
||||
sp.meta['pt2pt_time']=10
|
||||
|
||||
gtMaxLn=116508
|
||||
ovhdTime=100
|
||||
acq_per=int(np.ceil((sp.meta['pt2pt_time']*sp.points.shape[0]+ovhdTime)/(gtMaxLn*sp.meta['srv_per'])))
|
||||
sp.setup_gather(acq_per=acq_per)
|
||||
sp.setup_sync(verbose=verbose&32, timeOfs=0.05)
|
||||
sp.setup_coord_trf() # reset to shape path system
|
||||
# sp.meta['pt2pt_time']=10 #put between setup_sync and setup_motion to have more motion points than FEL syncs
|
||||
sp.setup_motion(fnPrg=fn+'.prg', mode=3, scale=1., dwell=10)
|
||||
sp.homing() # homing if needed
|
||||
sp.run() # start motion program
|
||||
sp.wait_armed() # wait until motors are at first position
|
||||
sp.trigger(0.5) # send a start trigger (if needed) ater given time
|
||||
if not dt._comm is None:
|
||||
while True:
|
||||
p=sp.progress()
|
||||
if p<0: break
|
||||
print('progress %d/%d'%(p, sp.points.shape[0]));
|
||||
time.sleep(.1)
|
||||
sp.gather_upload(fnRec=fn+'.npz')
|
||||
dp=deltatau.shapepath.DebugPlot(sp);
|
||||
dp.plot_gather(mode=11)
|
||||
|
||||
print('done')
|
||||
plt.show(block=False)
|
||||
return
|
||||
|
||||
|
||||
|
||||
task = self.active_task()
|
||||
XDIR = -1
|
||||
|
||||
folders.make_if_needed()
|
||||
#folders.make_if_needed()
|
||||
#if ( cfg.option(AppCfg.ACTIVATE_PULSE_PICKER) and not jungfrau_detector.is_running_detector()):
|
||||
# if QMessageBox.No == QMessageBox.question(self, "X-rays but no Jungfrau",
|
||||
# "X-rays will be used bu the Jungfrau will not run.\n\n\tContinue?",):
|
||||
# _log.warning("user forgot to turn on the jungfrau")
|
||||
# return
|
||||
|
||||
if ( option(ACTIVATE_PULSE_PICKER) and not jungfrau_detector.is_running_detector()):
|
||||
if QMessageBox.No == QMessageBox.question(self, "X-rays but no Jungfrau",
|
||||
"X-rays will be used bu the Jungfrau will not run.\n\n\tContinue?",):
|
||||
_log.warning("user forgot to turn on the jungfrau")
|
||||
return
|
||||
#if option(ACTIVATE_PULSE_PICKER) or not option(SKIP_ESCAPE_TRANSITIONS_IF_SAFE):
|
||||
# self.escape_goToDataCollection()
|
||||
|
||||
if option(ACTIVATE_PULSE_PICKER) or not option(SKIP_ESCAPE_TRANSITIONS_IF_SAFE):
|
||||
self.escape_goToDataCollection()
|
||||
|
||||
ntrigger = len(points)
|
||||
points *= 1000 # delta tau uses micrometers
|
||||
points[:, 0] *= XDIR # fast X axis is reversed
|
||||
|
||||
etime = settings.value("exposureTime", type=float)
|
||||
vscale = settings.value(DELTATAU_VELOCITY_SCALE, 1.0, type=float)
|
||||
sort_points = option(DELTATAU_SORT_POINTS)
|
||||
|
||||
# sync_mode : default=2
|
||||
# 0 : no sync at all
|
||||
@@ -2264,38 +2304,48 @@ class Main(QMainWindow, Ui_MainWindow):
|
||||
# sync_run are the commands to run the whole program
|
||||
# sync_flag if not using jungfrau =1 otherwise =0
|
||||
# D.O. shapepath.meta.update(sync_mode=2, sync_flag=1)
|
||||
shapepath.meta.update(sync_mode=0, sync_flag=0)
|
||||
sp.meta.update(sync_mode=0, sync_flag=0)
|
||||
|
||||
maxacq_points = 116508
|
||||
samp_time = 0.0002 # s
|
||||
overhead_time = 0.1
|
||||
acq_per = int(np.ceil((etime * ntrigger + overhead_time) / (maxacq_points * samp_time)))
|
||||
etime=10
|
||||
vscale=1.0
|
||||
#etime = settings.value("exposureTime", type=float)
|
||||
#vscale = settings.value(DELTATAU_VELOCITY_SCALE, 1.0, type=float)
|
||||
#sort_points = option(DELTATAU_SORT_POINTS)
|
||||
|
||||
acq_per = int(np.ceil((etime * len(points) + overhead_time) / (maxacq_points * samp_time)))
|
||||
_log.info(f"gather acquisotion period = {acq_per}")
|
||||
_log.info(f"velocity scale {vscale}")
|
||||
shapepath.setup_gather(acq_per=acq_per)
|
||||
shapepath.setup_sync(verbose=True)
|
||||
shapepath.setup_coord_trf()
|
||||
shapepath.points = np.copy(points)
|
||||
sp.setup_gather(acq_per=acq_per)
|
||||
sp.setup_sync(verbose=True)
|
||||
sp.setup_coord_trf()
|
||||
|
||||
assert(points.dtcfgype==np.float)
|
||||
sp.points = points
|
||||
|
||||
if TASK_GRID == task:
|
||||
width, height = visualizer_params
|
||||
_log.debug(f"grid: {width} x {height}")
|
||||
details_1 = [width]
|
||||
details_2 = [height]
|
||||
shapepath.sort_points(xy=False, grp_sz=height)
|
||||
# width, height = visualizer_params
|
||||
# _log.debug(f"grid: {width} x {height}")
|
||||
# details_1 = [width]
|
||||
# details_2 = [height]
|
||||
# sp.sort_points(xy=False, grp_sz=height)
|
||||
pass
|
||||
elif task in (TASK_PRELOCATED, TASK_EMBL):
|
||||
if sort_points:
|
||||
shapepath.sort_points()
|
||||
self.daq_method_prelocated_remove_markers()
|
||||
details_1, details_2 = visualizer_params
|
||||
|
||||
shapepath.setup_motion(
|
||||
sp.setup_motion(
|
||||
mode=3, # 1 = bad pvt 3 = pft (pvt via inverse fourier transform)
|
||||
pt2pt_time=etime * 1000.,
|
||||
fnPrg=folders.get_prefixed_file("_program.prg"),
|
||||
#fnPrg=folders.get_prefixed_file("_program.prg"),
|
||||
scale=vscale, # velocity at target position scaling: 1=optimal speed, 0=zero speed
|
||||
dwell=10, # milli-seconds wait
|
||||
)
|
||||
shapepath.run()
|
||||
sp.run()
|
||||
|
||||
self.qprogress = QProgressDialog(self)
|
||||
self.qprogress.setRange(0, 0)
|
||||
@@ -2735,7 +2785,14 @@ class Main(QMainWindow, Ui_MainWindow):
|
||||
)
|
||||
self._inspect = self._grid_inspect_area
|
||||
self._inspect.setPlainText("")
|
||||
self.daq_grid_collect_grid()
|
||||
for fixTrg in self._goTracked['objLst']:
|
||||
points=fixTrg.get_points()
|
||||
method="grid"
|
||||
params=None #grid._grid_dimensions
|
||||
# params = ([grid._grid_dimensions[0]], [grid._grid_dimensions[1]]) # FIXME something wrong here<
|
||||
self.daq_collect_points(points, visualizer_method=method, visualizer_params=params)
|
||||
|
||||
#self.daq_grid_collect_grid()
|
||||
elif task == TASK_PRELOCATED:
|
||||
self._inspect = self._preloc_inspect_area
|
||||
self._inspect.setPlainText("")
|
||||
|
||||
Reference in New Issue
Block a user