various fixes
This commit is contained in:
82
swissmx.py
82
swissmx.py
@@ -30,6 +30,7 @@ logging.getLogger('matplotlib').setLevel(logging.INFO)
|
||||
logging.getLogger('PIL').setLevel(logging.INFO)
|
||||
logging.getLogger('illumination').setLevel(logging.INFO)
|
||||
logging.getLogger('zoom').setLevel(logging.INFO)
|
||||
logging.getLogger('pbtools.misc.pp_comm').setLevel(logging.INFO)
|
||||
_log = logging.getLogger("swissmx")
|
||||
#_log.setLevel(logging.INFO)
|
||||
|
||||
@@ -47,6 +48,8 @@ import sys, os, time
|
||||
import json, re
|
||||
import random, signal, subprocess
|
||||
import matplotlib as mpl
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
mpl.use('Qt5Agg') # needed to avoid blocking of ui !
|
||||
|
||||
TASK_JUNGFRAU_SETTINGS = "jungfrau_settings"
|
||||
@@ -1595,7 +1598,10 @@ Author Thierry Zamofing (thierry.zamofing@psi.ch)
|
||||
app=QApplication.instance()
|
||||
geo=app._geometry
|
||||
#geo.autofocus(app._camera, self.tweakers['base_z'],rng=(-1, 1), n=30,saveImg=True)
|
||||
geo.autofocus(app._camera, self.tweakers['base_z'],rng=(-1, 1), n=10)
|
||||
n=10
|
||||
rng=(-1, 1)
|
||||
with pg.ProgressDialog('Progress', 0, n) as dlg:
|
||||
geo.autofocus(app._camera, self.tweakers['base_z'],rng, n,dlg)
|
||||
|
||||
def cb_find_fiducial(self):
|
||||
app=QApplication.instance()
|
||||
@@ -2059,33 +2065,53 @@ Author Thierry Zamofing (thierry.zamofing@psi.ch)
|
||||
sp.verbose=dt_misc['verbose']
|
||||
sp.points=kwargs['points']
|
||||
sp.meta['pt2pt_time']=dt_misc['pt2pt_time']
|
||||
sp.setup_gather()
|
||||
sp.setup_sync(verbose=sp.verbose&0x20, timeOfs=0.05)
|
||||
try:
|
||||
p=geo._fitPlane
|
||||
sp.setup_coord_trf(cz=f'{p[0]:+.18g}X{p[1]:+.18g}Y{p[2]:+.18g}') # reset to shape path system
|
||||
except AttributeError:
|
||||
_log.warning('no plane fitting done. z does not move')
|
||||
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) after given time
|
||||
jf.acquire('filename.tmp',sp.points.shape[0])
|
||||
if not dt._comm is None:
|
||||
while True:
|
||||
p=sp.progress()
|
||||
if p<0: break
|
||||
_log.info(f'progress {p}/{sp.points.shape[0]}')
|
||||
time.sleep(.1)
|
||||
sp.gather_upload(fnRec=fn+'.npz')
|
||||
if dt_misc['show_plots']:
|
||||
dp=deltatau.shapepath.DebugPlot(sp)
|
||||
dp.plot_gather(mode=11)
|
||||
plt.show(block=False)
|
||||
#plt.show(block=True)
|
||||
with pg.ProgressDialog('Progress', 0, 100) as dlg:
|
||||
dlg.setWindowModality(Qt.WindowModal)
|
||||
#dlg.setRange(0, 0)
|
||||
#dlg.setCancelButtonText("Abort Acquisition")
|
||||
#dlg.canceled.connect(self.complete_daq)
|
||||
#dlg.setAutoClose(True)
|
||||
#dlg.show()
|
||||
|
||||
dlg.setLabelText("Setup Gather/Sync");dlg+=5
|
||||
sp.setup_gather()
|
||||
sp.setup_sync(verbose=sp.verbose&0x40, timeOfs=0.05)
|
||||
try:
|
||||
p=geo._fitPlane
|
||||
sp.setup_coord_trf(cz=f'{p[0]:+.18g}X{p[1]:+.18g}Y{p[2]:+.18g}') # reset to shape path system
|
||||
except AttributeError:
|
||||
_log.warning('no plane fitting done. z does not move')
|
||||
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
|
||||
dlg.setLabelText("Download motion program");dlg+=5
|
||||
sp.setup_motion(fnPrg=fn+'.prg', mode=3, scale=1., dwell=10)
|
||||
dlg.setLabelText("Homing and get ready");dlg+=35
|
||||
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) after given time
|
||||
#PV with the current pulse
|
||||
# [sf-lc7a ~]$ caget
|
||||
jf.acquire('filename.tmp',sp.points.shape[0])
|
||||
if not dt._comm is None:
|
||||
dlg.setLabelText("run motion/acquisition")
|
||||
dlg.setMaximum(sp.points.shape[0])
|
||||
while True:
|
||||
p=sp.progress()
|
||||
if p<0 or dlg.wasCanceled():
|
||||
break
|
||||
#_log.info(f'progress {p}/{sp.points.shape[0]}')
|
||||
dlg.setValue(p)
|
||||
time.sleep(.1)
|
||||
if not dlg.wasCanceled():
|
||||
jf.gather_upload()
|
||||
dlg.setLabelText("upload gather data")
|
||||
sp.gather_upload(fnRec=fn+'.npz')
|
||||
if dt_misc['show_plots']:
|
||||
dp=psi_device.shapepath.DebugPlot(sp)
|
||||
dp.plot_gather(mode=11)
|
||||
plt.show(block=False)
|
||||
#plt.show(block=True)
|
||||
|
||||
def esc_run_steps(self, steps, title, esc_state):
|
||||
self._esc_state ="busy"
|
||||
|
||||
Reference in New Issue
Block a user