In the fitting function iterfit(), a ValueError is raised if there are no valid data points for the fitting:
|
else: |
|
if not maskwork.any(): |
|
raise ValueError('No valid data points.') |
|
# return (None,None) |
This should be caught by the calling functions and should yield a context-specific error message that will help the user diagnose why there were no valid points in that particular fit. As the code stands, the above lines result in a semi-useless traceback. For consideration, this function also raises a ValueError if various inputs do not match length as they should -- which is a coding error rather than a problem with the input data. I suggest the above lines raise a different type of error that can be caught by the calling functions (perhaps a core-specific custom Exception).
As of the creation of this issue, pypeit.core.fittting.iterfit() is called 5 times from 2 different modules:
|
b_answer, bmask = fitting.iterfit(wave[indsp], flux_sm[indsp], invvar = fluxivar_sm[indsp], |
|
kwargs_bspline={'everyn': 1.5}, kwargs_reject={'groupbadpix':True,'maxrej':1}) |
|
b_answer, bmask2 = fitting.iterfit(wave[indsp], flux_sm[indsp], invvar = fluxivar_sm[indsp]*bmask, |
|
kwargs_bspline={'everyn': 1.5}, kwargs_reject={'groupbadpix':True,'maxrej':1}) |
|
c_answer, cmask = fitting.iterfit(wave[indsp], flux_sm[indsp], invvar = fluxivar_sm[indsp]*bmask2, |
|
kwargs_bspline={'everyn': 30}, kwargs_reject={'groupbadpix':True,'maxrej':1}) |
|
bset, bmask = fitting.iterfit(sigma_x.flat[si],norm_obj.flat[si], invvar = norm_ivar.flat[si], |
|
nord = 4, bkpt = bkpt, maxiter = 15, upper = 1, lower = 1) |
|
# init_breakpoints = fullbkpt |
|
msgs.info("Bspline fit on zeropoint. ") |
|
bset1, bmask = fitting.iterfit(wave, zeropoint_clean, invvar=zeropoint_ivar, inmask=zeropoint_fitmask, upper=upper, lower=lower, |
|
fullbkpt=init_breakpoints, maxiter=maxiter, kwargs_bspline=kwargs_bspline, |
|
kwargs_reject=kwargs_reject) |
|
zeropoint_bspl, zeropoint_fit_gpm = bset1.value(wave) |
|
zeropoint_bspl_bkpt, _ = bset1.value(init_breakpoints) |
In the fitting function
iterfit(), aValueErroris raised if there are no valid data points for the fitting:PypeIt/pypeit/core/fitting.py
Lines 952 to 955 in 81057b0
This should be caught by the calling functions and should yield a context-specific error message that will help the user diagnose why there were no valid points in that particular fit. As the code stands, the above lines result in a semi-useless traceback. For consideration, this function also raises a
ValueErrorif various inputs do not match length as they should -- which is a coding error rather than a problem with the input data. I suggest the above lines raise a different type of error that can be caught by the calling functions (perhaps a core-specific customException).As of the creation of this issue,
pypeit.core.fittting.iterfit()is called 5 times from 2 different modules:PypeIt/pypeit/core/extract.py
Lines 900 to 905 in 81057b0
PypeIt/pypeit/core/extract.py
Lines 1055 to 1056 in 81057b0
PypeIt/pypeit/core/flux_calib.py
Lines 1023 to 1029 in 81057b0