From 07fb140401df27a89ec9f9f69cc14a4ecb9c5243 Mon Sep 17 00:00:00 2001 From: "Sergey E. Koposov" Date: Fri, 9 Feb 2024 19:00:02 +0000 Subject: [PATCH] update how i deal with case where the template is crazy --- py/rvspecfit/spec_fit.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/py/rvspecfit/spec_fit.py b/py/rvspecfit/spec_fit.py index 34ea760..9702dfa 100644 --- a/py/rvspecfit/spec_fit.py +++ b/py/rvspecfit/spec_fit.py @@ -286,6 +286,13 @@ def getCurTempl(spec_setup, atm_param, rot_params, config): curInterp = spec_inter.getInterpolator(spec_setup, config) outside = float(curInterp.outsideFlag(atm_param)) spec = curInterp.eval(atm_param) + + MAX_VAL = 1e100 + # DO NOT allow spectra that have values larger than MAX_VAL + if outside > 0: + maxspec = np.abs(spec).max() + if maxspec > MAX_VAL or not np.isfinite(maxspec): + outside = np.nan if not np.isfinite(outside): # The spectrum may be completely crap pass @@ -618,7 +625,7 @@ def get_chisq(specdata, # add bad value and bail out if not np.isfinite(outside): - logl += badchi + logl += 1000 * badchi chisq_array.append(np.nan) red_chisq_array.append(np.nan) models.append(np.zeros(len(curdata.lam)) + np.nan)