mirror of
https://github.com/ivan-usov-org/bec.git
synced 2025-04-22 02:20:02 +02:00
flomni-improvements
This commit is contained in:
parent
990738431e
commit
cf90614bb2
@ -344,6 +344,9 @@ class FlomniSampleTransferMixin:
|
|||||||
if not curtain_is_triggered:
|
if not curtain_is_triggered:
|
||||||
raise FlomniError("Fosaz did not reach light curtain")
|
raise FlomniError("Fosaz did not reach light curtain")
|
||||||
|
|
||||||
|
def move_fheater_up(self):
|
||||||
|
self.ensure_fheater_up()
|
||||||
|
|
||||||
def ensure_fheater_up(self):
|
def ensure_fheater_up(self):
|
||||||
axis_id = dev.fheater._config["deviceConfig"].get("axis_Id")
|
axis_id = dev.fheater._config["deviceConfig"].get("axis_Id")
|
||||||
axis_id_numeric = self.axis_id_to_numeric(axis_id)
|
axis_id_numeric = self.axis_id_to_numeric(axis_id)
|
||||||
@ -423,17 +426,19 @@ class FlomniSampleTransferMixin:
|
|||||||
|
|
||||||
def rt_feedback_enable_with_reset(self):
|
def rt_feedback_enable_with_reset(self):
|
||||||
self.device_manager.devices.rtx.controller.feedback_enable_with_reset()
|
self.device_manager.devices.rtx.controller.feedback_enable_with_reset()
|
||||||
|
self.rt_feedback_status()
|
||||||
|
|
||||||
def rt_feedback_enable_without_reset(self):
|
def rt_feedback_enable_without_reset(self):
|
||||||
|
self.device_manager.devices.rtx.controller.feedback_enable_without_reset()
|
||||||
|
self.rt_feedback_status()
|
||||||
|
|
||||||
|
def rt_feedback_status(self):
|
||||||
feedback_status = self.device_manager.devices.rtx.controller.feedback_is_running()
|
feedback_status = self.device_manager.devices.rtx.controller.feedback_is_running()
|
||||||
if feedback_status == True:
|
if feedback_status == True:
|
||||||
print("The rt feedback is \x1b[92mrunning\x1b[0m.")
|
print("The rt feedback is \x1b[92mrunning\x1b[0m.")
|
||||||
else:
|
else:
|
||||||
print("The rt feedback is \x1b[91mNOT\x1b[0m running.")
|
print("The rt feedback is \x1b[91mNOT\x1b[0m running.")
|
||||||
|
|
||||||
def rt_feedback_status(self):
|
|
||||||
self
|
|
||||||
|
|
||||||
def lights_off(self):
|
def lights_off(self):
|
||||||
self.device_manager.devices.fsamx.controller.lights_off()
|
self.device_manager.devices.fsamx.controller.lights_off()
|
||||||
|
|
||||||
@ -1002,7 +1007,6 @@ class FlomniAlignmentMixin:
|
|||||||
with open(correction_file, "r") as f:
|
with open(correction_file, "r") as f:
|
||||||
num_elements = f.readline()
|
num_elements = f.readline()
|
||||||
int_num_elements = int(num_elements.split(" ")[2])
|
int_num_elements = int(num_elements.split(" ")[2])
|
||||||
print(int_num_elements)
|
|
||||||
corr_pos = []
|
corr_pos = []
|
||||||
corr_angle = []
|
corr_angle = []
|
||||||
for j in range(int_num_elements * 2):
|
for j in range(int_num_elements * 2):
|
||||||
@ -1013,6 +1017,9 @@ class FlomniAlignmentMixin:
|
|||||||
corr_pos.append(float(value) / 1000)
|
corr_pos.append(float(value) / 1000)
|
||||||
elif name == "corr_angle":
|
elif name == "corr_angle":
|
||||||
corr_angle.append(float(value))
|
corr_angle.append(float(value))
|
||||||
|
print(
|
||||||
|
f"Loading default mirror correction from file {correction_file} containing {int_num_elements} elements."
|
||||||
|
)
|
||||||
return corr_pos, corr_angle
|
return corr_pos, corr_angle
|
||||||
|
|
||||||
def read_additional_correction_y(self, correction_file: str):
|
def read_additional_correction_y(self, correction_file: str):
|
||||||
@ -1067,9 +1074,9 @@ class Flomni(
|
|||||||
super().__init__()
|
super().__init__()
|
||||||
self.client = client
|
self.client = client
|
||||||
self.device_manager = client.device_manager
|
self.device_manager = client.device_manager
|
||||||
self.check_shutter = True
|
self.check_shutter = False
|
||||||
self.check_light_available = True
|
self.check_light_available = False
|
||||||
self.check_fofb = True
|
self.check_fofb = False
|
||||||
self._check_msgs = []
|
self._check_msgs = []
|
||||||
self.tomo_id = -1
|
self.tomo_id = -1
|
||||||
self.special_angles = []
|
self.special_angles = []
|
||||||
@ -1309,6 +1316,56 @@ class Flomni(
|
|||||||
except Exception:
|
except Exception:
|
||||||
logger.warning("Failed to write to scilog.")
|
logger.warning("Failed to write to scilog.")
|
||||||
|
|
||||||
|
def tomo_alignment_scan(self):
|
||||||
|
"""
|
||||||
|
Performs a tomogram alignment scan.
|
||||||
|
"""
|
||||||
|
if self.get_alignment_offset(0) == (0, 0, 0):
|
||||||
|
print("It appears that the xrayeye alignemtn was not performend or loaded. Aborting.")
|
||||||
|
return
|
||||||
|
dev = builtins.__dict__.get("dev")
|
||||||
|
bec = builtins.__dict__.get("bec")
|
||||||
|
tags = ["alignment", self.sample_name]
|
||||||
|
self.write_to_scilog(
|
||||||
|
f"Starting alignment scan. First scan number: {bec.queue.next_scan_number}.", tags
|
||||||
|
)
|
||||||
|
|
||||||
|
start_angle = 0
|
||||||
|
|
||||||
|
angle_end = start_angle + 180
|
||||||
|
for angle in np.linspace(start_angle, angle_end, num=int(180 / 45) + 1, endpoint=True):
|
||||||
|
successful = False
|
||||||
|
error_caught = False
|
||||||
|
if 0 <= angle < 180.05:
|
||||||
|
print(f"Starting flOMNI scan for angle {angle}")
|
||||||
|
while not successful:
|
||||||
|
self._start_beam_check()
|
||||||
|
|
||||||
|
try:
|
||||||
|
start_scan_number = bec.queue.next_scan_number
|
||||||
|
self.tomo_scan_projection(angle)
|
||||||
|
self.tomo_reconstruct()
|
||||||
|
error_caught = False
|
||||||
|
except AlarmBase as exc:
|
||||||
|
if exc.alarm_type == "TimeoutError":
|
||||||
|
bec.queue.request_queue_reset()
|
||||||
|
time.sleep(2)
|
||||||
|
error_caught = True
|
||||||
|
else:
|
||||||
|
raise exc
|
||||||
|
|
||||||
|
if self._was_beam_okay() and not error_caught:
|
||||||
|
successful = True
|
||||||
|
else:
|
||||||
|
self._wait_for_beamline_checks()
|
||||||
|
end_scan_number = bec.queue.next_scan_number
|
||||||
|
for scan_nr in range(start_scan_number, end_scan_number):
|
||||||
|
self._write_tomo_scan_number(scan_nr, angle, 0)
|
||||||
|
|
||||||
|
print("Alignment scan finished. Please run SPEC_ptycho_align and load the new fit.")
|
||||||
|
|
||||||
|
umv(dev.fsamroy, 0)
|
||||||
|
|
||||||
def sub_tomo_scan(self, subtomo_number, start_angle=None):
|
def sub_tomo_scan(self, subtomo_number, start_angle=None):
|
||||||
"""
|
"""
|
||||||
Performs a sub tomogram scan.
|
Performs a sub tomogram scan.
|
||||||
@ -1458,7 +1515,7 @@ class Flomni(
|
|||||||
with open(tomo_scan_numbers_file, "a+") as out_file:
|
with open(tomo_scan_numbers_file, "a+") as out_file:
|
||||||
# pylint: disable=undefined-variable
|
# pylint: disable=undefined-variable
|
||||||
out_file.write(
|
out_file.write(
|
||||||
f"{scan_number} {angle} {dev.lsamrot.read()['lsamrot']['value']:.3f} {self.tomo_id} {subtomo_number} {0} {'lamni'}\n"
|
f"{scan_number} {angle} {dev.fsamroy.read()['fsamroy']['value']:.3f} {self.tomo_id} {subtomo_number} {0} {self.sample_name}\n"
|
||||||
)
|
)
|
||||||
|
|
||||||
def tomo_scan_projection(self, angle: float):
|
def tomo_scan_projection(self, angle: float):
|
||||||
@ -1551,17 +1608,18 @@ class Flomni(
|
|||||||
def write_pdf_report(self):
|
def write_pdf_report(self):
|
||||||
"""create and write the pdf report with the current flomni settings"""
|
"""create and write the pdf report with the current flomni settings"""
|
||||||
dev = builtins.__dict__.get("dev")
|
dev = builtins.__dict__.get("dev")
|
||||||
header = ""
|
# header = ""
|
||||||
# header = (
|
header = (
|
||||||
# " \n" * 3
|
" \n" * 3
|
||||||
# + " ::: ::: ::: ::: :::: ::: ::::::::::: \n"
|
+ " .d888 888 .d88888b. 888b d888 888b 888 8888888 \n"
|
||||||
# + " :+: :+: :+: :+:+: :+:+: :+:+: :+: :+: \n"
|
+ ' d88P" 888 d88P" "Y88b 8888b d8888 8888b 888 888 \n'
|
||||||
# + " +:+ +:+ +:+ +:+ +:+:+ +:+ :+:+:+ +:+ +:+ \n"
|
+ " 888 888 888 888 88888b.d88888 88888b 888 888 \n"
|
||||||
# + " +#+ +#++:++#++: +#+ +:+ +#+ +#+ +:+ +#+ +#+ \n"
|
+ " 888888 888 888 888 888Y88888P888 888Y88b 888 888 \n"
|
||||||
# + " +#+ +#+ +#+ +#+ +#+ +#+ +#+#+# +#+ \n"
|
+ " 888 888 888 888 888 Y888P 888 888 Y88b888 888 \n"
|
||||||
# + " #+# #+# #+# #+# #+# #+# #+#+# #+# \n"
|
+ " 888 888 888 888 888 Y8P 888 888 Y88888 888 \n"
|
||||||
# + " ########## ### ### ### ### ### #### ########### \n"
|
+ ' 888 888 Y88b. .d88P 888 " 888 888 Y8888 888 \n'
|
||||||
# )
|
+ ' 888 888 "Y88888P" 888 888 888 Y888 8888888 \n'
|
||||||
|
)
|
||||||
padding = 20
|
padding = 20
|
||||||
fovxy = f"{self.fovx:.2f}/{self.fovy:.2f}"
|
fovxy = f"{self.fovx:.2f}/{self.fovy:.2f}"
|
||||||
stitching = f"{self.stitch_x:.2f}/{self.stitch_y:.2f}"
|
stitching = f"{self.stitch_x:.2f}/{self.stitch_y:.2f}"
|
||||||
|
@ -33,9 +33,6 @@ class XrayEyeAlign:
|
|||||||
self.flomni.reset_correction()
|
self.flomni.reset_correction()
|
||||||
self.flomni.reset_tomo_alignment_fit()
|
self.flomni.reset_tomo_alignment_fit()
|
||||||
|
|
||||||
def reset_xray_eye_correction(self):
|
|
||||||
self.client.delete_global_var("tomo_fit_xray_eye")
|
|
||||||
|
|
||||||
def _reset_init_values(self):
|
def _reset_init_values(self):
|
||||||
self.shift_xy = [0, 0]
|
self.shift_xy = [0, 0]
|
||||||
self._xray_fov_xy = [0, 0]
|
self._xray_fov_xy = [0, 0]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user