Compare commits

...

1 Commits

Author SHA1 Message Date
Holler Mirko
d5e01418d1 variables for progress 2024-05-08 11:34:57 +02:00

View File

@@ -525,6 +525,7 @@ class LamNI(LamNIOpticsMixin):
self._beam_is_okay = True self._beam_is_okay = True
self._stop_beam_check_event = None self._stop_beam_check_event = None
self.beam_check_thread = None self.beam_check_thread = None
self.progress = {}
def get_beamline_checks_enabled(self): def get_beamline_checks_enabled(self):
print( print(
@@ -587,6 +588,27 @@ class LamNI(LamNIOpticsMixin):
def tomo_circfov(self, val: float): def tomo_circfov(self, val: float):
self.client.set_global_var("tomo_circfov", val) self.client.set_global_var("tomo_circfov", val)
@property
def tomo_type(self):
val = self.client.get_global_var("tomo_type")
if val is None:
return 1
return val
@tomo_type.setter
def tomo_type(self, val: float):
if val == 1:
# equally spaced tomography with 8 sub tomograms
self.client.set_global_var("tomo_type", val)
#elif val == 2:
# # golden ratio tomography (sorted bunches)
# self.client.set_global_var("tomo_type", val)
#elif val == 3:
# # equally spaced tomography with starting angles shifted by golden ratio
# self.client.set_global_var("tomo_type", val)
else:
raise ValueError("Unknown tomo_type.")
@property @property
def tomo_countingtime(self): def tomo_countingtime(self):
val = self.client.get_global_var("tomo_countingtime") val = self.client.get_global_var("tomo_countingtime")
@@ -949,16 +971,42 @@ class LamNI(LamNIOpticsMixin):
# _tomo_shift_angles (potential global variable) # _tomo_shift_angles (potential global variable)
_tomo_shift_angles = 0 _tomo_shift_angles = 0
angle_end = start_angle + 360 angle_end = start_angle + 360
for angle in np.linspace( angles = np.linspace(
start_angle + _tomo_shift_angles, start_angle + _tomo_shift_angles,
angle_end, angle_end,
num=int(360 / self.tomo_angle_stepsize) + 1, num=int(360 / self.tomo_angle_stepsize) + 1,
endpoint=True, endpoint=True,
): )
# reverse even sub-tomograms
if not (subtomo_number % 2):
angles = np.flip(angles)
for angle in angles:
self.progress["subtomo"] = subtomo_number
self.progress["subtomo_projection"] = angles.index(angle)
self.progress["subtomo_total_projections"] = 180 / self.tomo_angle_stepsize
self.progress["projection"] = (subtomo_number - 1) * self.progress[
"subtomo_total_projections"
] + self.progress["subtomo_projection"]
self.progress["total_projections"] = 180 / self.tomo_angle_stepsize * 8
self.progress["angle"] = angle
self._tomo_scan_at_angle(angle, subtomo_number)
def _print_progress(self):
print("\x1b[95mProgress report:")
print(f"Tomo type: ....................... {self.progress['tomo_type']}")
print(f"Projection: ...................... {self.progress['projection']}")
print(f"Total projections expected ....... {self.progress['total_projections']}")
print(f"Angle: ........................... {self.progress['angle']}")
print(f"Current subtomo: ................. {self.progress['subtomo']}")
print(f"Current projection within subtomo: {self.progress['subtomo_projection']}\x1b[0m")
def _tomo_scan_at_angle(self, angle, subtomo_number):
successful = False successful = False
error_caught = False error_caught = False
if 0 <= angle < 360.05: if 0 <= angle < 360.05:
print(f"Starting LamNI scan for angle {angle}") print(f"Starting LamNI scan for angle {angle} in subtomo {subtomo_number}")
self._print_progress()
while not successful: while not successful:
self._start_beam_check() self._start_beam_check()
if not self.special_angles: if not self.special_angles:
@@ -1007,8 +1055,9 @@ class LamNI(LamNIOpticsMixin):
scans = builtins.__dict__.get("scans") scans = builtins.__dict__.get("scans")
self._current_special_angles = self.special_angles.copy() self._current_special_angles = self.special_angles.copy()
if subtomo_start == 1 and start_angle is None: if (self.tomo_type == 1 and subtomo_start == 1 and start_angle is None):
# pylint: disable=undefined-variable # pylint: disable=undefined-variable
if bec.active_account != "":
self.tomo_id = self.add_sample_database( self.tomo_id = self.add_sample_database(
self.sample_name, self.sample_name,
str(datetime.date.today()), str(datetime.date.today()),
@@ -1019,7 +1068,13 @@ class LamNI(LamNIOpticsMixin):
"BEC", "BEC",
) )
self.write_pdf_report() self.write_pdf_report()
else:
self.tomo_id = 0
with scans.dataset_id_on_hold: with scans.dataset_id_on_hold:
if self.tomo_type == 1:
# 8 equally spaced sub-tomograms
self.progress["tomo_type"] = "Equally spaced sub-tomograms"
for ii in range(subtomo_start, 9): for ii in range(subtomo_start, 9):
self.sub_tomo_scan(ii, start_angle=start_angle) self.sub_tomo_scan(ii, start_angle=start_angle)
start_angle = None start_angle = None
@@ -1045,8 +1100,10 @@ class LamNI(LamNIOpticsMixin):
print(f" _tomo_fovy_offset <mm> = {self.align.tomo_fovy_offset}") print(f" _tomo_fovy_offset <mm> = {self.align.tomo_fovy_offset}")
print(f" _manual_shift_x <mm> = {self.manual_shift_x}") print(f" _manual_shift_x <mm> = {self.manual_shift_x}")
print(f" _manual_shift_y <mm> = {self.manual_shift_y}") print(f" _manual_shift_y <mm> = {self.manual_shift_y}")
if self.tomo_type == 1:
print("\x1b[1mTomo type 1:\x1b[0m 8 equally spaced sub-tomograms")
print(f"Total number of projections: {360/self.tomo_angle_stepsize*8}")
print(f"Angular step within sub-tomogram: {self.tomo_angle_stepsize} degrees") print(f"Angular step within sub-tomogram: {self.tomo_angle_stepsize} degrees")
print(f"Resulting in number of projections: {360/self.tomo_angle_stepsize*8}")
print(f"Sample name: {self.sample_name}\n") print(f"Sample name: {self.sample_name}\n")
user_input = input("Are these parameters correctly set for your scan? ") user_input = input("Are these parameters correctly set for your scan? ")