Commit 10ec6b76 authored by bliss administrator's avatar bliss administrator
Browse files

Correction of bugs

parent 2cac7b2b
......@@ -312,8 +312,8 @@ class Tomo(TomoParameters):
self.sequence = "tomo:basic"
self.field_of_view = "Full"
self.active_tomo = self.fasttomo
self.tomo_scan.acc_margin = config["rotation"].get("acc_margin", 0.0)
self.tomo_scan.use_step_size = config["rotation"].get("use_step_size", False)
self.active_tomo.tomo_scan.acc_margin = config["rotation"].get("acc_margin", 0.0)
self.active_tomo.tomo_scan.use_step_size = config["rotation"].get("use_step_size", False)
self.scan_motors = [self.rotation_axis]
self.in_pars = {}
......@@ -707,117 +707,134 @@ class Tomo(TomoParameters):
label="Number of Consecutive Tomo?", defval=self.pcotomo.parameters.ntomo
)
dlg_nwait = UserIntInput(
label="Number of Waiting Turns between Tomo?",
defval=self.pcotomo.parameters.nwait,
label="Number of Waiting Turns between Tomo?", defval=self.pcotomo.parameters.nwait
)
dlg_nloop = UserIntInput(
label="Number of Repetitions (Consecutive Tomo + Waiting Turns)?",
defval=self.pcotomo.parameters.nloop,
label="Number of Repetitions (tomo + waiting turns)?", defval=self.pcotomo.parameters.nloop
)
dlg_useroutput = UserIntInput(
label="User Output after Repetition Number?",
defval=self.pcotomo.parameters.user_output,
dlg_user_output = UserIntInput(
label="User Output after Repetition Number?", defval=self.pcotomo.parameters.user_output
)
dlg_startturn = UserIntInput(
label="Number of Turns before Starting?",
defval=self.pcotomo.parameters.start_turn,
dlg_start_turn = UserIntInput(
label="Number of Turns before starting?", defval=self.pcotomo.parameters.start_turn
)
ret = BlissDialog(
[[dlg_trange], [dlg_ntomo], [dlg_nwait], [dlg_nloop], [dlg_useroutput], [dlg_startturn]],
title="PcoTomo Setup",
).show()
[[dlg_trange], [dlg_ntomo], [dlg_nwait], [dlg_nloop], [dlg_user_output], [dlg_start_turn]],
title="PcoTomo Acquisition Setup (1/2)",
).show()
# returns False on cancel
if ret != False:
self.parameters.end_pos = self.parameters.start_pos + ret[dlg_trange]
self.pcotomo.parameters.ntomo = ret[dlg_ntomo]
self.pcotomo.parameters.nwait = ret[dlg_nwait]
self.pcotomo.parameters.nloop = ret[dlg_nloop]
self.pcotomo.parameters.user_output = ret[dlg_useroutput]
self.pcotomo.parameters.start_turn = ret[dlg_startturn]
self.pcotomo.parameters.user_output = ret[dlg_user_output]
self.pcotomo.parameters.start_turn = ret[dlg_start_turn]
self.pcotomo_mode_setup()
def pcotomo_mode_setup(self):
self.pcotomo.calculate_parameters()
dlg_trans_rate = UserMsg(
label=f"Transfer Rate: {self.pcotomo.in_pars['transferrate']} MB/s"
)
dlg_roi = UserMsg(
label=f"ROI: {self.tomo_ccd.detector.image.width} x {self.tomo_ccd.detector.image.height}\n"
)
pcotomo_in_pars = self.pcotomo.in_pars
dlg_trans_rate = UserMsg(label=f"Transfer Rate: {pcotomo_in_pars['transferrate']} MB/s")
dlg_roi = UserMsg(label=f"ROI: {self.tomo_ccd.detector.image.width} x {self.tomo_ccd.detector.image.height}\n")
dlg_continuous_mode = UserCheckBox(
label="Consecutive Scans Without Waiting Turns"
)
dlg_max_nb_scans = UserMsg(
label=f"You can collect a maximum of {self.pcotomo.in_pars['numberofscans']} scans in the memory"
label=f"You can collect a maximum of {pcotomo_in_pars['maxnumberofscans']} scans in the memory"
)
dlg_one_scan_size = UserMsg(
label=f"One scan is {round(self.pcotomo.in_pars['sizeofonescan'] * 1024 * 1024 * 1024, 2)} B or {round(self.pcotomo.in_pars['sizeofonescan'], 2)} GB"
label=f"One scan is {round(pcotomo_in_pars['sizeofonescan']*1024*1024*1024,2)} B or {round(pcotomo_in_pars['sizeofonescan'],2)} GB"
)
dlg_max_acq_time = UserMsg(
label=f"It means a film of {round(pcotomo_in_pars['maxtotalcontinuoustime'],2)} s ({round(pcotomo_in_pars['maxtotalcontinuoustime']/60,2)} min)\n"
)
dlg_max_saving_time = UserMsg(
label=f"Time to download film: {round((pcotomo_in_pars['sizeofonescan']*pcotomo_in_pars['maxnumberofscans'])/(pcotomo_in_pars['transferrate']/1024),2)} s ({round((pcotomo_in_pars['sizeofonescan']*pcotomo_in_pars['maxnumberofscans'])/(pcotomo_in_pars['transferrate']/1024)/60,2)} min)\n"
)
dlg_scans = UserMsg(
label=f"Currently, you will collect {self.pcotomo.parameters.ntomo} scans in the memory"
)
dlg_acq_time = UserMsg(
label=f"It means a film of {self.pcotomo.in_pars['totalcontinuoustime']} s ({round(self.pcotomo.in_pars['totalcontinuoustime'] / 60, 2)} min)\n"
label=f"It means a film of {round(pcotomo_in_pars['totalcontinuoustime'],2)} s ({round(pcotomo_in_pars['totalcontinuoustime']/60,2)} min)\n"
)
dlg_saving_time = UserMsg(
label=f"Time to download film: "
f"{round((self.pcotomo.in_pars['sizeofonescan'] * self.pcotomo.in_pars['numberofscans']) / (self.pcotomo.in_pars['transferrate'] / 1024), 2)} s ("
f"{round((self.pcotomo.in_pars['sizeofonescan'] * self.pcotomo.in_pars['numberofscans']) / (self.pcotomo.in_pars['transferrate'] / 1024) / 60, 2)} min)\n"
label=f"Time to download film: {round((pcotomo_in_pars['sizeofonescan']*self.pcotomo.parameters.ntomo)/(pcotomo_in_pars['transferrate']/1024),2)} s ({round((pcotomo_in_pars['sizeofonescan']*self.pcotomo.parameters.ntomo)/(pcotomo_in_pars['transferrate']/1024)/60,2)} min)\n"
)
dlg_cont_nb_scans = UserIntInput(label="Number of scans?", defval=self.pcotomo.parameters.ntomo)
ct1 = Container(
[
dlg_continuous_mode,
dlg_max_nb_scans,
dlg_one_scan_size,
dlg_max_acq_time,
dlg_max_saving_time,
dlg_scans,
dlg_acq_time,
dlg_saving_time,
dlg_cont_nb_scans,
],
title="Continuous Mode",
title="Consecutive Mode",
)
dlg_multiple_mode = UserCheckBox(label="Waiting Turns Between Each Scan")
dlg_nb_scans = UserMsg(
label=f"You will collect a total of {self.pcotomo.in_pars['numberofscans']} scans\n"
dlg_max_nb_scans = UserMsg(
label=f"You can collect a total of {pcotomo_in_pars['maxnumberofscans']} scans\n"
)
dlg_scans = UserMsg(
label=f"Currently, you will collect {self.pcotomo.parameters.nloop} scans in the memory"
)
dlg_waiting_turns = UserMsg(
label=f"You will wait {self.pcotomo.parameters.nwait} turns between each scan"
)
dlg_acq_time = UserMsg(
label=f"One scan of {self.pcotomo.in_pars['time']} s every {self.pcotomo.in_pars['frequency']} s during {self.pcotomo.in_pars['totaltime']} s ({round(self.pcotomo.in_pars['totaltime'] / 60, 2)} min) \n"
label=f"One scan of {round(pcotomo_in_pars['time'],2)} s every {round(pcotomo_in_pars['frequency'],2)} s during {round(pcotomo_in_pars['totaltime'],2)} s ({round(pcotomo_in_pars['totaltime']/60,2)} min) \n"
)
dlg_saving_time = UserMsg(
label=f"Time to download film: {round((self.pcotomo.in_pars['sizeofonescan'] * self.pcotomo.in_pars['numberofscans']) / (self.pcotomo.in_pars['transferrate'] / 1024), 2)} s ("
f"{round((self.pcotomo.in_pars['sizeofonescan'] * self.pcotomo.in_pars['numberofscans']) / (self.pcotomo.in_pars['transferrate'] / 1024) / 60, 2)} min)\n"
label=f"Time to download film: {round((pcotomo_in_pars['sizeofonescan']*self.pcotomo.parameters.nloop)/(pcotomo_in_pars['transferrate']/1024),2)} s ({round((pcotomo_in_pars['sizeofonescan']*self.pcotomo.parameters.nloop)/(pcotomo_in_pars['transferrate']/1024)/60,2)} min)\n"
)
dlg_mult_nb_scans = UserIntInput(label="Number of scans?", defval=self.pcotomo.parameters.nloop)
ct2 = Container(
[
dlg_multiple_mode,
dlg_nb_scans,
dlg_max_nb_scans,
dlg_scans,
dlg_waiting_turns,
dlg_acq_time,
dlg_saving_time,
dlg_mult_nb_scans,
],
title="Multiple Mode",
)
dlg_endless_mode = UserCheckBox(label="Downloading Between Each Scan")
dlg_waiting_turns = UserMsg(
label=f"You will wait around {self.pcotomo.in_pars['unlimitwaitingturns']} turns between each scan, during this time, scan is downloaded"
label=f"You will wait around {pcotomo_in_pars['unlimitwaitingturns']} turns between each scan, during this time, scan is downloaded"
)
dlg_acq_time = UserMsg(
label=f"One scan of {self.pcotomo.in_pars['time']} s every {self.pcotomo.in_pars['unlimitfrequency']} s FOREVER \n"
label=f"One scan of {round(pcotomo_in_pars['time'],2)} s every {round(pcotomo_in_pars['unlimitfrequency'],2)} s FOREVER \n"
)
dlg_saving_time = UserMsg(
label=f"Time to download one scan: {round(self.pcotomo.in_pars['sizeofonescan'] / (self.pcotomo.in_pars['transferrate'] / 1024), 2)} s "
f"({round(self.pcotomo.in_pars['sizeofonescan'] / (self.pcotomo.in_pars['transferrate'] / 1024) / 60, 2)} min) \n"
label=f"Time to download one scan: {round(pcotomo_in_pars['sizeofonescan']/(pcotomo_in_pars['transferrate']/1024),2)} s ({round(pcotomo_in_pars['sizeofonescan']/(pcotomo_in_pars['transferrate']/1024)/60,2)} min) \n"
)
dlg_endl_nb_scans = UserIntInput(label="Number of scans?", defval=self.pcotomo.parameters.nloop)
ct3 = Container(
[dlg_endless_mode, dlg_waiting_turns, dlg_acq_time, dlg_saving_time],
[
dlg_endless_mode,
dlg_waiting_turns,
dlg_acq_time,
dlg_saving_time,
dlg_endl_nb_scans,
],
title="Endless Mode",
)
......@@ -830,14 +847,21 @@ class Tomo(TomoParameters):
if ret[dlg_continuous_mode]:
self.pcotomo.parameters.mode = "consecutive"
self.pcotomo.parameters.nloop = 1
self.pcotomo.parameters.ntomo = ret[dlg_cont_nb_scans]
self.pcotomo.parameters.nwait = 0
self.pcotomo.parameters.noread = 1
elif ret[dlg_multiple_mode]:
self.pcotomo.parameters.mode = "multiple"
self.pcotomo.parameters.ntomo = 1
self.pcotomo.parameters.nloop = ret[dlg_mult_nb_scans]
self.pcotomo.parameters.noread = 1
elif ret[dlg_endless_mode]:
self.pcotomo.parameters = "endless"
self.pcotomo.parameters.mode = "endless"
self.pcotomo.parameters.ntomo = 1
self.pcotomo.parameters.noread = 0
self.ppcotomo.arameters.nwait = -1
self.pcotomo.parameters.nloop = ret[dlg_endl_nb_scans]
self.pcotomo.parameters.nwait = -1
def return_scan(self, scan_sequence=None, header={}, save=True, run=True):
"""
......@@ -867,7 +891,7 @@ class Tomo(TomoParameters):
if self.parameters.return_images_aligned_to_refs:
shift_angle = (
self.tomo_scan.in_pars["scan_step_size"]
self.active_tomo.tomo_scan.in_pars["scan_step_size"]
* self.in_pars["nb_group_points"][i]
)
rot_position = rot_position - (shift_angle * rot_direction)
......@@ -1418,17 +1442,17 @@ class Tomo(TomoParameters):
print(f"Scan start position: {self.parameters.start_pos}")
print(f"Scan end position: {self.parameters.end_pos}")
print(f"Scan number of images: {self.parameters.tomo_n}")
print(f"Scan step size: {self.tomo_scan.in_pars['scan_step_size']:.3f} degrees")
print(f"Scan step size: {self.active_tomo.tomo_scan.in_pars['scan_step_size']:.3f} degrees")
print(
f"Scan point time: {self.tomo_scan.in_pars['scan_point_time']:.4f} sec (Exposure time: {self.tomo_scan.in_pars['scan_point_time'] * self.tomo_scan.in_pars['integration_ratio']} sec)"
f"Scan point time: {self.active_tomo.tomo_scan.in_pars['scan_point_time']:.4f} sec (Exposure time: {self.active_tomo.tomo_scan.in_pars['scan_point_time'] * self.active_tomo.tomo_scan.in_pars['integration_ratio']} sec)"
)
print(f"Scan speed: {self.tomo_scan.in_pars['scan_speed']:.2f} degrees / sec")
print(f"Integration ratio ==> {self.tomo_scan.in_pars['integration_ratio']*100:.2f} %")
print(f"Scan speed: {self.active_tomo.tomo_scan.in_pars['scan_speed']:.2f} degrees / sec")
print(f"Integration ratio ==> {self.active_tomo.tomo_scan.in_pars['integration_ratio']*100:.2f} %")
print(f"Saving path: {current_session.scan_saving.get_path()}")
print(f"Image file format: {self.tomo_ccd.detector.saving.file_format}")
print(f"Frames per file: {self.tomo_ccd.detector.saving.frames_per_file}")
print(
f"Estimated data rate ==> {round(self.tomo_ccd.in_pars['image_mbsize'] / self.tomo_scan.in_pars['scan_point_time'], 1)} MB/s"
f"Estimated data rate ==> {round(self.tomo_ccd.in_pars['image_mbsize'] / self.active_tomo.tomo_scan.in_pars['scan_point_time'], 1)} MB/s"
)
print(
f"Approximative Estimated Scan Time: {self.in_pars['estimated_time_scan']}"
......@@ -1440,16 +1464,16 @@ class Tomo(TomoParameters):
def pco_tomo(
self,
start_pos,
end_pos,
tomo_n,
expo_time,
mode,
ntomo=1,
nloop=1,
nwait=0,
start_turn=0,
user_output=0,
start_pos=None,
end_pos=None,
tomo_n=None,
expo_time=None,
mode=None,
ntomo=None,
nloop=None,
nwait=None,
start_turn=None,
user_output=None,
dataset_name=None,
run=True,
):
......@@ -1459,32 +1483,36 @@ class Tomo(TomoParameters):
If a dataset name is specified, it will update tomo scan dataset.
"""
self.sequence = "tomo:pcotomo"
self.parameters.start_pos = start_pos
self.parameters.end_pos = end_pos
self.parameters.tomo_n = tomo_n
self.parameters.exposure_time = expo_time
self.active_tomo = self.pcotomo
self.pcotomo.parameters.mode = mode
self.pcotomo.parameters.user_output = user_output
self.pcotomo.parameters.start_turn = start_turn
if mode == "consecutive":
self.pcotomo.parameters.ntomo = ntomo
self.pcotomo.parameters.nloop = 1
self.pcotomo.parameters.noread = 1
self.pcotomo.parameters.nwait = 0
elif mode == "multiple":
if start_pos is not None:
self.parameters.start_pos = start_pos
if end_pos is not None:
self.parameters.end_pos = end_pos
if tomo_n is not None:
self.parameters.tomo_n = tomo_n
if expo_time is not None:
self.parameters.exposure_time = expo_time
if ntomo is not None:
self.pcotomo.parameters.ntomo = ntomo
if nloop is not None:
self.pcotomo.parameters.nloop = nloop
if nwait is not None:
self.pcotomo.parameters.nwait = nwait
if user_output is not None:
self.pcotomo.parameters.user_output = user_output
if start_turn is not None:
self.pcotomo.parameters.start_turn = start_turn
if mode is not None:
self.pcotomo.parameters.mode = mode
if self.pcotomo.parameters.mode == "consecutive":
self.pcotomo.parameters.noread = 1
elif self.pcotomo.parameters.mode == "multiple":
self.pcotomo.parameters.noread = 0
elif mode == "endless":
self.pcotomo.parameters.ntomo = ntomo
self.pcotomo.parameters.nloop = nloop
self.pcotomo.parameters.nwait = nwait
elif self.pcotomo.parameters.mode == "endless":
self.pcotomo.parameters.noread = 0
else:
raise AttributeError(
......
......@@ -227,10 +227,6 @@ class TomoScan:
if self.tomo.tomo_ccd.detector.acquisition.mode == 'ACCUMULATION':
acq_params.update({'acq_mode' : 'ACCUMULATION'})
else:
if self.tomo.tomo_ccd.detector.camera_type.lower() == 'pco' and 'dimax' in self.tomo.tomo_ccd.detector.camera.cam_name.lower():
acq_params.update({'acq_mode' : 'ACCUMULATION',
'acc_max_expo_time' : 0.04})
# prepare LIMA
lima_acq = LimaAcquisitionMaster(self.tomo.tomo_ccd.detector,
......
......@@ -146,7 +146,7 @@ class TomoTools():
"""
if self.tomo_ccd.detector.camera_type.lower() == 'pco' and 'dimax' in self.tomo_ccd.detector.camera.cam_name.lower():
self.tomo_ccd.detector.proxy.image_roi = [self.tomo_ccd.detector.image.roi.x,self.tomo_ccd.detector.image.roi.y,self.tomo_ccd.detector.image.roi.width,self.tomo_ccd.detector.image.roi.height]
self.tomo_ccd.detector.proxy.image_roi = self.tomo_ccd.detector.image.roi
self.tomo_ccd.detector.prepareAcq()
self.tomo_ccd.detector.startAcq()
self.tomo_ccd.detector.stopAcq()
......@@ -221,7 +221,7 @@ class TomoTools():
ref_img += self.parameters.ref_n
motor_time += unit_time
image_time = ref_img * self.tomo.tomo_scan.in_pars['scan_point_time']
image_time = ref_img * self.tomo.active_tomo.tomo_scan.in_pars['scan_point_time']
return motor_time + image_time
......@@ -238,7 +238,7 @@ class TomoTools():
if self.parameters.dark_images_at_end:
dark_img += self.parameters.dark_n
image_time = dark_img * self.tomo.tomo_scan.in_pars['scan_point_time']
image_time = dark_img * self.tomo.active_tomo.tomo_scan.in_pars['scan_point_time']
return image_time
......@@ -260,10 +260,10 @@ class TomoTools():
step_size = scan_range/self.parameters.tomo_n
one_move_disp = step_size*self.parameters.ref_on
else:
acc_margin = self.tomo.tomo_scan.acc_margin
if self.tomo.tomo_scan.use_step_size:
acc_margin = abs(self.tomo.tomo_scan.in_pars['scan_step_size'])
undershoot = self.tomo.tomo_scan.in_pars['scan_speed']**2 / (2*motor.acceleration)
acc_margin = self.tomo.active_tomo.tomo_scan.acc_margin
if self.tomo.active_tomo.tomo_scan.use_step_size:
acc_margin = abs(self.tomo.active_tomo.tomo_scan.in_pars['scan_step_size'])
undershoot = self.tomo.active_tomo.tomo_scan.in_pars['scan_speed']**2 / (2*motor.acceleration)
return_img = 0
nr_moves = 1
one_move_disp = scan_range + undershoot + acc_margin
......@@ -280,7 +280,7 @@ class TomoTools():
motor_time += one_move_time
image_time = return_img * self.tomo.tomo_scan.in_pars['scan_point_time']
image_time = return_img * self.tomo.active_tomo.tomo_scan.in_pars['scan_point_time']
return motor_time + image_time
......@@ -289,11 +289,11 @@ class TomoTools():
Estimates step scan duration.
"""
# one_move_time represents one step
one_move_disp = self.tomo.tomo_scan.in_pars['scan_step_size']
one_move_disp = self.tomo.active_tomo.tomo_scan.in_pars['scan_step_size']
one_move_time = self.mot_disp_time(motor,one_move_disp,motor.velocity)
scan_time = one_move_time*nb_points
image_time = (nb_points+1) * self.tomo.tomo_scan.in_pars['scan_point_time']
image_time = (nb_points+1) * self.tomo.active_tomo.tomo_scan.in_pars['scan_point_time']
return scan_time + image_time
......@@ -308,23 +308,23 @@ class TomoTools():
end_pos = self.tomo.in_pars['start_group_pos'][1]
nb_points = nb_points / self.tomo.in_pars['nb_groups']
acc_margin = self.tomo.tomo_scan.acc_margin
if self.tomo.tomo_scan.use_step_size:
acc_margin = abs(self.tomo.tomo_scan.in_pars['scan_step_size']) / abs(self.tomo.tomo_ccd.detector.accumulation.nb_frames)
acc_margin = self.tomo.active_tomo.tomo_scan.acc_margin
if self.tomo.active_tomo.tomo_scan.use_step_size:
acc_margin = abs(self.tomo.active_tomo.tomo_scan.in_pars['scan_step_size']) / abs(self.tomo.tomo_ccd.detector.accumulation.nb_frames)
undershoot = self.tomo.tomo_scan.in_pars['scan_speed']**2 / (2*motor.acceleration)
undershoot = self.tomo.active_tomo.tomo_scan.in_pars['scan_speed']**2 / (2*motor.acceleration)
acc_disp = 2 * (undershoot + acc_margin)
cst_disp = (end_pos - start_pos) / nb_points
start_disp = cst_disp + acc_disp
start_time = self.mot_disp_time(motor,start_disp,self.tomo.tomo_scan.in_pars['scan_speed']) * tomo_n
start_time = self.mot_disp_time(motor,start_disp,self.tomo.active_tomo.tomo_scan.in_pars['scan_speed']) * tomo_n
first_prepare_disp = undershoot + acc_margin
if self.tomo.tomo_scan.in_pars['scan_speed'] > motor.velocity:
prepare_time = self.mot_disp_time(motor,first_prepare_disp,self.tomo.tomo_scan.in_pars['scan_speed'])
if self.tomo.active_tomo.tomo_scan.in_pars['scan_speed'] > motor.velocity:
prepare_time = self.mot_disp_time(motor,first_prepare_disp,self.tomo.active_tomo.tomo_scan.in_pars['scan_speed'])
else:
prepare_time = self.mot_disp_time(motor,first_prepare_disp,motor.velocity)
prepare_disp = acc_disp
if self.tomo.tomo_scan.in_pars['scan_speed'] > motor.velocity:
prepare_time += self.mot_disp_time(motor,prepare_disp,self.tomo.tomo_scan.in_pars['scan_speed']) * (tomo_n-1)
if self.tomo.active_tomo.tomo_scan.in_pars['scan_speed'] > motor.velocity:
prepare_time += self.mot_disp_time(motor,prepare_disp,self.tomo.active_tomo.tomo_scan.in_pars['scan_speed']) * (tomo_n-1)
else:
prepare_time += self.mot_disp_time(motor,prepare_disp,motor.velocity) * (tomo_n-1)
scan_time = start_time + prepare_time
......@@ -343,15 +343,15 @@ class TomoTools():
if self.tomo.in_pars['nb_groups'] > 1:
end_pos = self.tomo.in_pars['start_group_pos'][1]
acc_margin = self.tomo.tomo_scan.acc_margin
if self.tomo.tomo_scan.use_step_size:
acc_margin = abs(self.tomo.tomo_scan.in_pars['scan_step_size'])
acc_margin = self.tomo.active_tomo.tomo_scan.acc_margin
if self.tomo.active_tomo.tomo_scan.use_step_size:
acc_margin = abs(self.tomo.active_tomo.tomo_scan.in_pars['scan_step_size'])
undershoot = self.tomo.tomo_scan.in_pars['scan_speed']**2 / (2*motor.acceleration)
undershoot = self.tomo.active_tomo.tomo_scan.in_pars['scan_speed']**2 / (2*motor.acceleration)
acc_disp = 2 * (undershoot + acc_margin)
cst_disp = end_pos - start_pos
start_disp = acc_disp + cst_disp
start_time = self.mot_disp_time(motor,start_disp,self.tomo.tomo_scan.in_pars['scan_speed'])
start_time = self.mot_disp_time(motor,start_disp,self.tomo.active_tomo.tomo_scan.in_pars['scan_speed'])
prepare_time = self.mot_disp_time(motor,acc_disp/2,motor.velocity)
# one_move_time represents one group
......@@ -370,7 +370,7 @@ class TomoTools():
end_pos = end_tomo
cst_disp = end_pos - start_pos
start_disp = acc_disp + cst_disp
start_time = self.mot_disp_time(motor,start_disp,self.tomo.tomo_scan.in_pars['scan_speed'])
start_time = self.mot_disp_time(motor,start_disp,self.tomo.active_tomo.tomo_scan.in_pars['scan_speed'])
prepare_time = self.mot_disp_time(motor,prepare_disp,motor.velocity)
move_time = start_time + prepare_time
......@@ -415,24 +415,24 @@ class TopoTools(TomoTools):
"""
Estimates sweep scan duration.
"""
acc_margin = self.tomo.tomo_scan.acc_margin
if self.tomo.tomo_scan.use_step_size:
acc_margin = abs(self.tomo.tomo_scan.in_pars['scan_step_size'])
acc_margin = self.tomo.active_tomo.tomo_scan.acc_margin
if self.tomo.active_tomo.tomo_scan.use_step_size:
acc_margin = abs(self.tomo.active_tomo.tomo_scan.in_pars['scan_step_size'])
undershoot = self.tomo.tomo_scan.in_pars['scan_speed']**2 / (2*motor.acceleration)
undershoot = self.tomo.active_tomo.tomo_scan.in_pars['scan_speed']**2 / (2*motor.acceleration)
acc_disp = 2 * (undershoot + acc_margin)
cst_disp = (end_pos - start_pos) / nb_points
start_disp = acc_disp + cst_disp
start_time = self.mot_disp_time(motor,start_disp,self.tomo.tomo_scan.in_pars['scan_speed']) * nb_points
start_time = self.mot_disp_time(motor,start_disp,self.tomo.active_tomo.tomo_scan.in_pars['scan_speed']) * nb_points
first_prepare_disp = undershoot + acc_margin
if self.tomo.tomo_scan.in_pars['scan_speed'] > motor.velocity:
prepare_time = self.mot_disp_time(motor,first_prepare_disp,self.tomo.tomo_scan.in_pars['scan_speed'])
if self.tomo.active_tomo.tomo_scan.in_pars['scan_speed'] > motor.velocity:
prepare_time = self.mot_disp_time(motor,first_prepare_disp,self.tomo.active_tomo.tomo_scan.in_pars['scan_speed'])
else:
prepare_time = self.mot_disp_time(motor,first_prepare_disp,motor.velocity)
prepare_disp = acc_disp
if self.tomo.tomo_scan.in_pars['scan_speed'] > motor.velocity:
prepare_time += self.mot_disp_time(motor,prepare_disp,self.tomo.tomo_scan.in_pars['scan_speed']) * (nb_points-1)
if self.tomo.active_tomo.tomo_scan.in_pars['scan_speed'] > motor.velocity:
prepare_time += self.mot_disp_time(motor,prepare_disp,self.tomo.active_tomo.tomo_scan.in_pars['scan_speed']) * (nb_points-1)
else:
prepare_time += self.mot_disp_time(motor,prepare_disp,motor.velocity) * (nb_points-1)
......@@ -444,15 +444,15 @@ class TopoTools(TomoTools):
"""
Estimates continuous scan duration.
"""
acc_margin = self.tomo.tomo_scan.acc_margin
if self.tomo.tomo_scan.use_step_size:
acc_margin = abs(self.tomo.tomo_scan.in_pars['scan_step_size'])
acc_margin = self.tomo.active_tomo.tomo_scan.acc_margin
if self.tomo.active_tomo.tomo_scan.use_step_size:
acc_margin = abs(self.tomo.active_tomo.tomo_scan.in_pars['scan_step_size'])
undershoot = self.tomo.tomo_scan.in_pars['scan_speed']**2 / (2*motor.acceleration)
undershoot = self.tomo.active_tomo.tomo_scan.in_pars['scan_speed']**2 / (2*motor.acceleration)
acc_disp = 2 * (undershoot + acc_margin)
cst_disp = end_pos - start_pos
start_disp = acc_disp + cst_disp
start_time = self.mot_disp_time(motor,start_disp,self.tomo.tomo_scan.in_pars['scan_speed'])
start_time = self.mot_disp_time(motor,start_disp,self.tomo.active_tomo.tomo_scan.in_pars['scan_speed'])
prepare_time = self.mot_disp_time(motor,acc_disp,motor.velocity)
one_move_time = start_time + prepare_time
......
......@@ -269,9 +269,9 @@ class PcoTomoScan:
motors=self.tomo.scan_motors,
limas=(self.tomo.tomo_ccd.detector,),
),
# watchdog_callback=pcotomo.PcoTomoScanWatchdog(trigger_name=musst_slave.channels[0].name,
# limas= (self.tomo.tomo_ccd.detector,),
# trig_difference= self.watchdog_trig_difference),
watchdog_callback=pcotomo.PcoTomoScanWatchdog(trigger_name=musst_slave.channels[0].name,
limas= (self.tomo.tomo_ccd.detector,),
trig_difference= self.watchdog_trig_difference),
)
print(scan.acq_chain._tree)
......
......@@ -173,7 +173,7 @@ class PcoTomoTools(TomoTools):
Checks if scan parameters are consistant
"""
if self.tomo.rotation_axis.name == 'hrsrot' and self.tomo.tomo_scan.in_pars['scan_speed'] >= 1810:
if self.tomo.rotation_axis.name == 'hrsrot' and self.tomo.pcotomo.tomo_scan.in_pars['scan_speed'] >= 1810:
raise Exception(f"Error, scan speed is too high for this motor (should be <= 1200 °/s)")
# must be checked, new controller for rotation on mr
#elif self.tomo.rotation_axis.name == 'mrsrot' and self.tomo.tomo_scan.in_pars['speed'] > 600:
......@@ -197,27 +197,29 @@ class PcoTomoTools(TomoTools):
"""
Estimates continuous motor scan time
"""
speed = self.tomo.tomo_scan.in_pars['trange'] / self.tomo.tomo_scan.in_pars['time']
speed = self.tomo.pcotomo.tomo_scan.in_pars['trange'] / self.tomo.pcotomo.tomo_scan.in_pars['time']
acctime = speed / motor.acceleration
accdisp = speed * acctime / 2
undershoot,undershoot_start_margin = self.tomo.tomo_scan.calculate_undershoot(motor,start_pos,self.tomo.tomo_scan.in_pars['time'],
undershoot,undershoot_start_margin = self.tomo.pcotomo.tomo_scan.calculate_undershoot(motor,start_pos,self.tomo.pcotomo.tomo_scan.in_pars['time'],
self.tomo.pcotomo.parameters.start_turn)
disp = undershoot + undershoot_start_margin
scan_time = 0
disp += self.tomo.pcotomo.parameters.nloop*self.tomo.tomo_scan.in_pars['trange']
disp += self.tomo.pcotomo.parameters.nloop*self.tomo.pcotomo.tomo_scan.in_pars['trange']
if self.tomo.pcotomo.parameters.nloop > 1:
delta = (start_pos + self.tomo.tomo_scan.in_pars['trange'])%360
delta = (start_pos + self.tomo.pcotomo.tomo_scan.in_pars['trange'])%360
if delta > 0:
delta = 360 - delta
if self.tomo.parameters.trigger_type == TriggerType.TIME: