-
Notifications
You must be signed in to change notification settings - Fork 22
multidimensional kerneldiff and butterdiff #181
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
Conversation
…xis parameter and support multidimensional data
| [(1, 0), (2, 2), (1, 0), (2, 2)], | ||
| [(1, 0), (3, 3), (1, 0), (3, 3)]], | ||
| spectraldiff: [[(-15, -15), (-14, -15), (0, -1), (0, 0)], | ||
| spectraldiff: [[(-15, -15), (-14, -14), (0, -1), (0, 0)], |
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.
spectraldiff uses convolution, which is now based on scipy's convolve1d rather than numpy's convolve, which changes its answers ever so slightly.
| for i in range(num_iterations): | ||
| x_padded = np.pad(x_hat, pad_width, mode='symmetric') # pad with repetition of the edges | ||
| x_hat = np.convolve(x_padded, kernel, 'valid')[:len(x)] # 'valid' slices out only full-overlap spots | ||
| x_hat = convolve1d(x_hat, kernel, axis=axis, mode='reflect') # 'reflect' pads the signal with repeats |
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 function is great. No more need to pad things ourselves nor carefully slice out the answer to ensure same-length.
|
|
||
| # included code | ||
| from pynumdiff.finite_difference import second_order as finite_difference | ||
| from pynumdiff.finite_difference import finitediff |
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.
Why I wasn't doing this before I'm not sure.
| x_hat = x | ||
| for _ in range(num_iterations): | ||
| x_hat = scipy.signal.medfilt(x_hat, window_size) | ||
| x_hat = scipy.signal.medfilt(x_hat, s) |
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.
medfilt has a slightly different mechanism for working with multidimensional data; you have to give a multidimensional kernel. Where that kernel has dimensional length 1, no filtering occurs.
| ``` | ||
|
|
||
| where `x` is data, `dt` is a step size, and various keyword arguments control the behavior. Some methods support variable step size, in which case the second parameter is renamed `dt_or_t` and can receive either a constant step size or an array of values to denote sample locations. | ||
| where `x` is data, `dt` is a step size, and various keyword arguments control the behavior. Some methods support variable step size, in which case the second parameter is renamed `dt_or_t` and can receive either a constant step size or an array of values to denote sample locations. Some methods support multidimensional data, in which case there is an `axis` argument to control the dimension differentiated along. |
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.
Calling attention to the fact we support multidimensional data.
extended the non-legacy smooth_finite_difference methods to have an axis parameter and support multidimensional data