-
Notifications
You must be signed in to change notification settings - Fork 166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix smoothing bug when signal is shorter than a window #590
Conversation
Interesting, I think I meant for Would you like to attempt merging |
This PR should also fix a tinu bug I got from running Full traceback here: traceback.txt Here is a minimal".cnr" that reproduce the bug: sample.cnr.txt Hope this helps. |
In Savitzky-Golay smoothing, for certain combinations of parameters, a (wing-padded) signal length can turn out to be shorter than the smoothing window requested, which is mathematically impossible to compute and causes an index mismatch exception downstream. This change avoids this by checking for this condition and reducing the smoothing window length and, if necessary, also the polynomial order. This ensures (compared to e.g. returning the original signal) that at least some sensible smoothing is still being performed.
81ca551
to
6f15e0f
Compare
@etal Thank you for your comments! I've now investigated this further and here's what I found. You are right: Lines 41 to 44 in 9dd1e7c
The problem is how these results are then used. After calling Because
I have now rewritten this PR to properly address both of them. An additional function is no longer required, as well as any modifications to |
@tetedange13 Thank you for the additional test file! I've verified that the latest version of this PR should indeed fix the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is good. Thanks!
Closes #587. Thank you @tetedange13 for an amazingly detailed investigation which helped a lot!
In Savitzky-Golay smoothing, for certain combinations of parameters, a (wing-padded) signal length can turn out to be shorter than the smoothing window requested, which is mathematically impossible to compute and causes an index mismatch exception downstream.
This change avoids this by checking for this condition and reducing the smoothing window length and, if necessary, also the polynomial order. This ensures (compared to e.g. returning the original signal) that at least some sensible smoothing is still being performed.