From 3acd57adb977658aec68060646ec674a258eb795 Mon Sep 17 00:00:00 2001 From: Ivan Usov Date: Tue, 5 Oct 2021 14:24:05 +0200 Subject: [PATCH] Abort fit if there is no data in range --- pyzebra/ccl_process.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pyzebra/ccl_process.py b/pyzebra/ccl_process.py index 7a79344..650722e 100644 --- a/pyzebra/ccl_process.py +++ b/pyzebra/ccl_process.py @@ -147,6 +147,10 @@ def fit_scan(scan, model_dict, fit_from=None, fit_to=None): # apply fitting range fit_ind = (fit_from <= x_fit) & (x_fit <= fit_to) + if not np.any(fit_ind): + print(f"No data in fit range for scan {scan['idx']}") + return + y_fit = y_fit[fit_ind] y_err = y_err[fit_ind] x_fit = x_fit[fit_ind] @@ -201,6 +205,9 @@ def fit_scan(scan, model_dict, fit_from=None, fit_to=None): def get_area(scan, area_method, lorentz): + if "fit" not in scan: + return + if area_method not in AREA_METHODS: raise ValueError(f"Unknown area method: {area_method}.")