wotan icon indicating copy to clipboard operation
wotan copied to clipboard

pspline: fix stdev_cut/max iteration bug

Open lgbouma opened this issue 4 years ago • 2 comments

Hi Michael,

Currently line 25 of pspline.py seems to iterate over stdev_cut. This leads to a TypeError when stdev_cut is a float (which generally should be allowed?).

More broadly, I think this might be a bug relative to earlier implementations of this routine, which had this line iterating over constants.SPLINES_MAXITER, which I think might be correct.

Thank you for creating and maintaining this very useful tool! -Luke

lgbouma avatar Nov 07 '21 02:11 lgbouma

Hey Luke, thanks for bringing this up. It was indeed a feature request to change it to stdev_cut to make it user configurable. Would changing the loop to for i in range(int(stdev_cut)) be OK for your use case? Or is there a need to really go float?

hippke avatar Nov 07 '21 09:11 hippke

Hi Michael, thanks for this response. I'm perhaps a bit confused. My understanding of the goal of this loop in pseudo-code is roughly

until we reach convergence:
    find and mask any outlier points outside of +/-*stdev_cut* sigma
    fit the pspline to the remaining points in the light curve
    check if in the residual there are any points outside of +/-*stdev_cut* sigma -- if there are any continue, else exit

If this is correct, why would iterate over range(int(stdev_cut)) instead of over range(constants.SPLINES_MAXITER))? I would think that convergence wouldn't be related to whether one selects 1-sigma, 2-sigma, etc, but would be better achieved by constants.SPLINES_MAXITER. I might be missing something here though!

[edit: fixed typo]

lgbouma avatar Nov 07 '21 19:11 lgbouma