Skip to content
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

hampel_filter filtsize doesn't work as expected/intended. #111

Open
multigummie opened this issue Jan 20, 2024 · 0 comments
Open

hampel_filter filtsize doesn't work as expected/intended. #111

multigummie opened this issue Jan 20, 2024 · 0 comments

Comments

@multigummie
Copy link

Two issues:

  1. The documentation for the hampel_filter function states:
    filtsize : int
        the filter size expressed the number of datapoints
        taken surrounding the analysed datapoint. a filtsize
        of 6 means three datapoints on each side are taken.
        total filtersize is thus filtsize + 1 (datapoint evaluated)

however, as currently implemented the slices will not be filtesize + 1, it will be exactly filtsize. e.g. for filtsize = 6, the following line:

dataslice = output[i - onesided_filt : i + onesided_filt]

on the first iteration of the loop (i = onesided_filt -> i = 3) will evaluate to dataslice = output[0:6]. Python is exclusive on the end of the slice, so you will only get 6 data points in the slice. I believe the code should read:

dataslice = output[i - onesided_filt:i + onesided_filt + 1]
  1. behavior for odd numbered filtsize is not well defined. Python's // operator will round down for odd numbers (e.g. 7//2 will result in 3). This means a filtsize = 7 is actually functionally the same as filtsize = 6. If I understand correctly an odd-numbered filtsize isn't really intended to be possible, so I'd suggest adding a guard clause at the top of the function to prevent this, as well as updating the docs.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant