diff --git a/focus_utils.py b/focus_utils.py index 5cc51ad..e8ffeb5 100644 --- a/focus_utils.py +++ b/focus_utils.py @@ -388,13 +388,17 @@ def focussingSequence( executor = ProcessPoolExecutor(max_workers=max_wks) i_foc = 0 + 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="") - set_focus_func(foc_val) - - print("OK", file=log_output) + ret_code = set_focus_func(foc_val) + if ret_code: + print("FAIL!", file=log_output) + break + else: + print("OK", file=log_output) filename = "{}_{:04d}{}".format(fname, i_foc, file_ext) full_filename = pt.Path.joinpath(dir, pt.Path(filename)) @@ -417,11 +421,16 @@ def focussingSequence( print("OK", file=log_output) - fit_res = fitFocusCurve(focus_value, flux_rad, **seq_kwds) + if ret_code == 0: + fit_res = fitFocusCurve(focus_value, flux_rad, **seq_kwds) - ret_val["focus_value"] = fit_res[0] - ret_val["coeffs"] = fit_res[1] - ret_val["is_robust"] = fit_res[2] + ret_val["focus_value"] = fit_res[0] + ret_val["coeffs"] = fit_res[1] + ret_val["is_robust"] = fit_res[2] + else: + print( + "THERE WERE ERRORS DURING FOCUSSING SEQUENCE SO NO BEST FOCUS IS AVAILABLE!!!" + ) return ret_val