Irregular $\Delta t$ for splinediff#148
Conversation
…o cover this case, and reworked readme to reflect
| <img src="https://joss.theoj.org/papers/102257ee4b0142bf49bc18d7c810e9d5/status.svg"></a> | ||
| </p> | ||
|
|
||
| ## Table of contents |
There was a problem hiding this comment.
This takes up really valuable real estate at the top of the page, and the readme is short enough that the value of a TOC is unclear to me, so I nixed it.
| For more details, refer to [this paper](https://doi.org/10.1109/ACCESS.2020.3034077). | ||
| PyNumDiff is a Python package that implements various methods for computing numerical derivatives of noisy data, which can be a critical step in developing dynamic models or designing control. There are seven different families of methods implemented in this repository: | ||
|
|
||
| 1. convolutional smoothing followed by finite difference calculation |
There was a problem hiding this comment.
You only listed 4 families, which was quite out of date.
|
|
||
| Most of these methods have multiple parameters, so we take a principled approach and propose a multi-objective optimization framework for choosing parameters that minimize a loss function to balance the faithfulness and smoothness of the derivative estimate. For more details, refer to [this paper](https://doi.org/10.1109/ACCESS.2020.3034077). | ||
|
|
||
| ## Installing |
There was a problem hiding this comment.
Installation and usage are now prioritized.
| x_hat, dxdt_hat = method(x, dt, param1=val1, param2=val2, ...) | ||
| ``` | ||
|
|
||
| Or you can find parameter by calling the multi-objective optimization algorithm from the `optimize` module: |
There was a problem hiding this comment.
I simplified this section somewhat. The second two usage examples were slightly repetitive.
| tt = np.linspace(0, 3) # full domain, for visualizing denser plots | ||
| np.random.seed(7) # for repeatability of the test, so we don't get random failures | ||
| noise = 0.05*np.random.randn(*t.shape) | ||
| t_irreg = t + np.random.uniform(-dt/3, dt/3, *t.shape) # add jostle |
There was a problem hiding this comment.
Thinking through how to test the irregular step case took more thought than actually extending splinediff to do it.
| (splinediff, {'degree':5, 's':2}), (splinediff, [5, 2]), | ||
| (spline_irreg_step, {'degree':5, 's':2}), | ||
| (polydiff, {'degree':2, 'window_size':3}), (polydiff, [2, 3]), | ||
| (savgoldiff, {'degree':2, 'window_size':5, 'smoothing_win':5}), (savgoldiff, [2, 5, 5]), |
There was a problem hiding this comment.
I reordered these a bit. They have a canonical ordering in my mind now, and I'm slowly getting all the listings of them to agree.
| (jerk_sliding, {'gamma':1, 'window_size':15}), (jerk_sliding, [1], {'window_size':15}) | ||
| (jerk_sliding, {'gamma':1, 'window_size':15}), (jerk_sliding, [1], {'window_size':15}), | ||
| (spectraldiff, {'high_freq_cutoff':0.2}), (spectraldiff, [0.2]), | ||
| (lineardiff, {'order':3, 'gamma':5, 'window_size':11, 'solver':'CLARABEL'}), (lineardiff, [3, 5, 11], {'solver':'CLARABEL'}) |
There was a problem hiding this comment.
Funny that it works with OSQP locally (Mac) but doesn't in the cloud (Linux). I was having trouble with OSQP on my Linux machine at home too.
| if diff_method in [spline_irreg_step]: # list that can handle variable dt | ||
| x = f(t_irreg) | ||
| dxdt = df(t_irreg) | ||
| _t = t_irreg |
There was a problem hiding this comment.
Somewhat annoyingly, you can't reassign t or dt, or it breaks the binding with the global variable for all tests, so I have to create alternatively-named temp variables.
added support for irregular steps to splinediff, extended test code to cover this case, and reworked readme to reflect