From 281beba65a56d001cf256c9a989bad95d1265bad Mon Sep 17 00:00:00 2001 From: "Timur A. Fatkhullin" Date: Fri, 11 Oct 2024 15:01:20 +0300 Subject: [PATCH] ... --- focus_utils.py | 48 +++++++++++++++++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/focus_utils.py b/focus_utils.py index 5b21478..a0957d8 100644 --- a/focus_utils.py +++ b/focus_utils.py @@ -251,7 +251,12 @@ def computeFocus( if len(futures): print("", file=log_output) print(log_ident, file=log_output, end="") - print("waiting for the end of calculations ...\t", file=log_output, end="", flush=True) + print( + "waiting for the end of calculations ...\t", + file=log_output, + end="", + flush=True, + ) for i in range(len(futures)): flux_rad.append(futures[i].result()) @@ -390,41 +395,55 @@ def focussingSequence( ret_code = 0 for foc_val in focus_value: print(log_ident, file=log_output, end="") - print("set focus value to {:g} ...\t".format(foc_val), file=log_output, end="", flush=True) + print( + "set focus value to {:g} ...\t".format(foc_val), + file=log_output, + end="", + flush=True, + ) ret_code = set_focus_func(foc_val) if ret_code: ret_val["ret_code"] = ret_code - print("FAIL!", file=log_output) + print("FAIL!", file=log_output, flush=True) break else: - print("OK", file=log_output) + print("OK", file=log_output, flush=True) filename = "{}_{:04d}{}".format(fname, i_foc, file_ext) full_filename = str(pt.Path.joinpath(dir, pt.Path(filename))) print(log_ident, file=log_output, end="") - print("get image '{}' ...\t".format(full_filename), file=log_output, end="", flush=True) + print( + "get image '{}' ...\t".format(full_filename), + file=log_output, + end="", + flush=True, + ) ret_code = get_image_func(full_filename, seq_kwds["exp_time"]) if ret_code: ret_val["ret_code"] = ret_code - print("FAIL!", file=log_output) + print("FAIL!", file=log_output, flush=True) break else: - print("OK", file=log_output) + print("OK", file=log_output, flush=True) - futures.append(executor.submit(amt.compute_mean_flux_radius, full_filename, **seq_kwds)) + futures.append( + executor.submit(amt.compute_mean_flux_radius, full_filename, **seq_kwds) + ) i_foc += 1 - print("", file=log_output) - print(log_ident, file=log_output, end="") - print("waiting for the end of calculations ...\t", file=log_output, end="") + print("", file=log_output, flush=True) + print(log_ident, file=log_output, end="", flush=True) + print( + "waiting for the end of calculations ...\t", file=log_output, end="", flush=True + ) for i in range(len(futures)): flux_rad.append(futures[i].result()) - print("OK", file=log_output) + print("OK", file=log_output, flush=True) if ret_code == 0: fit_res = fitFocusCurve(focus_value, flux_rad, **seq_kwds) @@ -434,7 +453,10 @@ def focussingSequence( ret_val["is_robust"] = fit_res[2] else: print( - "THERE WERE ERRORS DURING FOCUSSING SEQUENCE SO NO BEST FOCUS IS AVAILABLE!!!" + "THERE WERE ERRORS DURING FOCUSSING SEQUENCE SO NO BEST FOCUS IS AVAILABLE!!!", + file=log_output, + end="", + flush=True, ) return ret_val