Commit 18c734df authored by bliss administrator's avatar bliss administrator
Browse files

Correction of last static image position

+ addition of image saving suffix for zseries scans
+ correction of opiom shutter state
parent 2bfdbcf1
......@@ -388,7 +388,6 @@ class PcoTomoMotorMaster(JogMotorMaster):
def prepare(self):
if self._iter_index == 0:
JogMotorMaster.prepare(self)
#breakpoint()
else:
return
......
......@@ -19,9 +19,9 @@ class ScanDisplay(object):
"""
Class to display data during a tomo scan
"""
HEADER = (
"Scan {scan_nb} {start_time_str} {filename} "
"Scan {} {start_time_str} {filename} "
+ "{session_name} user = {user_name}\n"
+ "{title}"
)
......@@ -56,8 +56,14 @@ class ScanDisplay(object):
scan -- is the scan object
info -- is the dict of information about this scan
"""
print(self.HEADER.format(**info))
# displays scan number / total number of scans to see the acquisition progression
if info.get('tomo_sequence') not in ['fasttomo','halftomo']:
SCAN_NB = f"{info.get('scan_nb')} / {int(info.get('scan_nb'))+self.NB_SCANS}"
else:
SCAN_NB = '{scan_nb}'
print(self.HEADER.format(SCAN_NB,**info))
self.__state = None
self.__infos = dict()
for name in self.__motor_names:
......@@ -135,7 +141,6 @@ class ScanDisplay(object):
# print last images acquired and saved
for cam in self.__limas:
last_acq = cam._proxy.last_image_ready + 1
#last_rec = cam.camera.last_img_recorded + 1
last_saved = cam._proxy.last_image_saved + 1
diff_trigger = self.__infos["trig"] - last_acq
depth = cam._proxy.image_sizes[1]
......
......@@ -147,6 +147,8 @@ class Tomo(TomoParameters):
self.last_parameters = None
self.last_roi = None
self.scan_par = None
self.scan_motors = [self.rotation_axis]
self.sequence = None
log_info(self,"__init__() leaving")
......@@ -390,7 +392,7 @@ class Tomo(TomoParameters):
i=len(self.scan_par['nb_trig'])-1
while (self.rotation_axis.position - limit_pos) * rot_direction >= 0:
while (self.rotation_axis.position - limit_pos) * rot_direction > 0:
print ("srot = %f\n" % self.rotation_axis.position)
self.tomo_ccd.set_saving_file(self.saving.parameters.scan_name+'_',0,'_%04d'%self.rotation_axis.position)
......@@ -400,8 +402,14 @@ class Tomo(TomoParameters):
shift_angle = self.scan_par['scan_step_size']*self.scan_par['nb_trig'][i]
mvr(self.rotation_axis, (-shift_angle * rot_direction))
i-=1
else:
else:
mvr(self.rotation_axis, (-90.0 * rot_direction))
# take last images (limit position)
print ("srot = %f\n" % self.rotation_axis.position)
self.tomo_ccd.set_saving_file(self.saving.parameters.scan_name+'_',0,'_%04d'%self.rotation_axis.position)
self.tomo_ccd.take_image(self.parameters.exposure_time)
log_info(self,"take_static_images() leaving")
......@@ -442,7 +450,7 @@ class Tomo(TomoParameters):
"""
log_info(self,"take_reference_images() entering")
print ("Take reference images")
print ("\nTake reference images")
#
# Move the sample out of the beam
......@@ -554,7 +562,8 @@ class Tomo(TomoParameters):
self.detector.camera.pixel_rate = self.detector.camera.pixel_rate_valid_values[-1]
if self.parameters.half_acquisition:
self.sequence = 'halftomo'
if self.sequence is None:
self.sequence = 'halftomo'
self.halftomo.prepare()
if self.scan is None:
print('\n')
......@@ -568,7 +577,8 @@ class Tomo(TomoParameters):
else:
print(f'Warning: {self.lateral_align_axis.name} half acquisition pos. is equal to full-frame pos.\n')
else:
self.sequence = 'fasttomo'
if self.sequence is None:
self.sequence = 'fasttomo'
self.fasttomo.prepare()
if self.scan is None:
print('\n')
......@@ -682,6 +692,8 @@ class Tomo(TomoParameters):
print(f'Data file path: {self.saving.get_path()}')
else:
print(f'Saving path: {self.saving.get_path()}')
print(f'Image file format: {self.saving.parameters.image_file_format}')
print(f'Frames per file: {self.saving.parameters.frames_per_file}')
print(f"Estimated data rate ==> {self.scan_par['image_size']/self.scan_par['scan_point_time']:.2f} MB/s")
print(f"Approximative Estimated Scan Time: {self.scan_par['estimated_time_scan']}")
print("=================================================================")
......@@ -696,6 +708,7 @@ class Tomo(TomoParameters):
"""
self.scan = None
self.sequence = None
# to compare with next tomo parameters and detect a parameter change
self.last_parameters = self.parameters.to_dict()
self.last_roi=self.tomo_ccd.get_image_parameters()['roi']
......
......@@ -57,7 +57,17 @@ class TomoSaving(TomoParameters):
"""
Set-up scan saving parameters
"""
dlg_disk = UserChoice(values=[("lbs","lbs"),("visitor","visitor"),("inhouse","inhouse"),("local","local")])
values = [("lbs","lbs"),("visitor","visitor"),("inhouse","inhouse"),("local","local")]
if 'lbs' not in self.parameters.saving_path:
if 'visitor' in self.parameters.saving_path or 'inhouse' in self.parameters.saving_path:
for v in values:
if v[0] in self.parameters.saving_path:
values.remove(v)
values.insert(0,v)
else:
values.remove(("local","local"))
values.insert(0,("local","local"))
dlg_disk = UserChoice(values=values)
ct = Container( [dlg_disk], title="Storage Space")
ret = BlissDialog( [ [ct] ] , title='Saving Setup').show()
......@@ -65,7 +75,7 @@ class TomoSaving(TomoParameters):
# returns False on cancel
if ret != False:
dir_space = ret[dlg_disk]
dlg_path = UserInput(label="Saving Path", defval= self.parameters.last_path[dir_space])
dlg_format = UserInput(label="Image File Format (HDF5 or EDF)", defval=self.parameters.image_file_format)
dlg_frames = UserIntInput(label="Frames per Image File", defval=self.parameters.frames_per_file)
......@@ -82,11 +92,8 @@ class TomoSaving(TomoParameters):
last_path[dir_space] = self.parameters.saving_path
self.parameters.last_path = last_path
if len(setup_globals.config.get(self.tomo_name).detector.directories_mapping) > 0:
for dir_space in setup_globals.config.get(self.tomo_name).detector.directories_mapping_names:
if dir_space in self.parameters.saving_path:
if 'tmp' in dir_space:
dir_space = 'local'
setup_globals.config.get(self.tomo_name).detector.select_directories_mapping(dir_space)
if dir_space in setup_globals.config.get(self.tomo_name).detector.directories_mapping:
setup_globals.config.get(self.tomo_name).detector.select_directories_mapping(dir_space)
self.parameters.image_file_format = ret[dlg_format]
self.parameters.frames_per_file = int(ret[dlg_frames])
self.parameters.sample_name = ret[dlg_sample]
......
......@@ -123,7 +123,7 @@ class TomoScan:
self.tomo.scan = Scan(chain, name=self.tomo.saving.scan_saving.tomo_scan_name,
scan_saving=self.tomo.saving.scan_saving, scan_info=scan_info,
data_watch_callback=tomo.ScanDisplay(trigger_name=f'axis:{self.tomo.rotation_axis.name}',
motors= (self.tomo.rotation_axis,),
motors= self.tomo.scan_motors,
limas= (self.tomo.tomo_ccd.detector,)))
def continuous_scan(self):
......@@ -212,7 +212,7 @@ class TomoScan:
self.tomo.scan = Scan(chain, name=self.tomo.saving.scan_saving.tomo_scan_name,
scan_saving=self.tomo.saving.scan_saving, scan_info=scan_info,
data_watch_callback=tomo.ScanDisplay(trigger_name='musst_master:TIMER',
motors= (self.tomo.rotation_axis,),
motors= self.tomo.scan_motors,
limas= (self.tomo.tomo_ccd.detector,)))
......@@ -291,7 +291,7 @@ class TomoScan:
self.tomo.scan = Scan(chain, name=self.tomo.saving.scan_saving.tomo_scan_name,
scan_saving=self.tomo.saving.scan_saving, scan_info=scan_info,
data_watch_callback=tomo.ScanDisplay(trigger_name=f'axis:{self.tomo.rotation_axis.name}',
motors= (self.tomo.rotation_axis,),
motors= self.tomo.scan_motors,
limas= (self.tomo.tomo_ccd.detector,)))
def sweep_scan(self):
......@@ -386,7 +386,7 @@ class TomoScan:
self.tomo.scan = Scan(chain, name=self.tomo.saving.scan_saving.tomo_scan_name,
scan_saving=self.tomo.saving.scan_saving, scan_info=scan_info,
data_watch_callback=tomo.ScanDisplay(trigger_name='musst:TIMER',
motors= (self.tomo.rotation_axis,),
motors= self.tomo.scan_motors,
limas= (self.tomo.tomo_ccd.detector,)))
......@@ -17,6 +17,7 @@ from tomo.TomoScan import TomoScan
from tomo.TopoScan import TopoScan
from tomo.Tomo import Tomo, ScanType
from tomo.TomoParameters import TomoParameters
from tomo.ScanDisplay import ScanDisplay
......@@ -420,9 +421,12 @@ class ZSeries:
if start_nb > 1:
self.start_pos = self.start_pos + (start_nb -1) * delta_pos
self.nb_scans = self.nb_scans - (start_nb -1)
log_debug(self,'Prepare tomo scan')
self.tomo.prepare()
# add z axis to scan display
self.tomo.scan_motors.append(self.z_axis)
#log_debug(self,'Prepare tomo scan')
#self.tomo.prepare()
log_info(self,"prepare() leaving")
......@@ -433,17 +437,23 @@ class ZSeries:
"""
log_info(self,"run() entering")
with error_cleanup(self.z_axis, restore_list=(cleanup_axis.POS,)):
common_scan_name = self.tomo.saving.parameters.scan_name
with cleanup(self.z_axis,self.scan_cleanup, restore_list=(cleanup_axis.POS,)):
# move Z motor to start position
umv (self.z_axis, self.start_pos)
# sleep when requested
time.sleep(self.sleep)
ScanDisplay.NB_SCANS = self.nb_scans-1
self.tomo.saving.parameters.scan_name = common_scan_name + '_000'
print ("First tomo scan\n")
self.tomo.run()
for i in range(1, self.nb_scans):
ScanDisplay.NB_SCANS -= 1
# move Z motor
print ("%d move Z motor\n" % i)
umvr (self.z_axis, self.delta_pos)
......@@ -451,6 +461,7 @@ class ZSeries:
# sleep when requested
time.sleep(self.sleep)
self.tomo.saving.parameters.scan_name = common_scan_name + '_%03d' %i
print ("%d tomo scan\n" % i)
self.tomo.run()
......@@ -459,7 +470,12 @@ class ZSeries:
log_info(self,"run() leaving")
def scan_cleanup(self):
"""
Restores all parameters that have been modified by the zseries acquisition
"""
self.tomo.scan_motors.remove(self.z_axis)
self.tomo.saving.parameters.scan_name = "_".join(self.tomo.saving.parameters.scan_name.split("_")[:-1])
class TopoTomo:
"""
......@@ -830,8 +846,8 @@ class Progressive:
self.tomo.parameters.end_pos = self.tomo.parameters.start_pos + 360
self.tomo.parameters.tomo_n = tomo_n
skip_end_imgages = (turn_idx < (self.nb_turns - 1))
if skip_end_imgages:
skip_end_images = (turn_idx < (self.nb_turns - 1))
if skip_end_images:
self.tomo.parameters.dark_images_at_end = False
self.tomo.parameters.ref_images_at_end = False
self.tomo.parameters.no_return_images = True
......
......@@ -7,7 +7,7 @@
from gevent import Timeout, sleep
from bliss.common.shutter import BaseShutter
from bliss.common.shutter import BaseShutter, BaseShutterState
"""
Handle the experiment beam shutter via the OPIOM multiplexer
......@@ -57,19 +57,19 @@ class OpiomShutter(BaseShutter):
def state(self):
try:
if self.opiom.getOutputStat('SOFTSHUT') == "OPEN":
return self.OPEN
return BaseShutterState.OPEN
else:
return self.CLOSED
return BaseShutterState.CLOSED
except:
raise RuntimeError("{}: Communication error with {}".format(
self.__name, self.opion.name))
self.__name, self.opiom.name))
@property
def state_string(self):
s = self.state
if s in [self.OPEN, self.CLOSED, self.UNKNOWN]:
return self.STATE2STR.get(s, self.STATE2STR[self.UNKNOWN])
if s in [BaseShutterState.OPEN, BaseShutterState.CLOSED, BaseShutterState.UNKNOWN]:
return s.value
else:
return (self._tango_state, self._tango_status)
......@@ -82,7 +82,7 @@ class OpiomShutter(BaseShutter):
except:
raise RuntimeError("{}: Communication error with {}".format(
self.__name, self.opion.name))
self.__name, self.opiom.name))
def open(self):
try:
......@@ -92,7 +92,7 @@ class OpiomShutter(BaseShutter):
except:
raise RuntimeError("{}: Communication error with {}".format(
self.__name, self.opion.name))
self.__name, self.opiom.name))
@property
def closing_time(self):
......
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