Skip to content

Commit 9c98f19

Browse files
committed
got rid of offset in butterdiff
1 parent 7bc6ca1 commit 9c98f19

3 files changed

Lines changed: 8 additions & 13 deletions

File tree

pynumdiff/optimize/_optimize.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
'proc_huberM': (0, 6),
9898
'meas_huberM': (0, 6)}),
9999
robustdiffclassic: ({'order': {1, 2, 3}, # warning: order 1 hacks the loss function when tvgamma is used, tends to win but is usually suboptimal choice in terms of true RMSE
100-
'log_qr_ratio': [k for k in range(-1, 16, 4)],
100+
'log_qr_ratio': [float(k) for k in range(-1, 16, 4)],
101101
'huberM': [0., 5, 20]}, # 0. so type is float. Good choices here really depend on the data scale
102102
{'log_qr_ratio': (-1, 18),
103103
'huberM': (0, 1e2)}), # really only want to use l2 norm when nearby

pynumdiff/smooth_finite_difference/_smooth_finite_difference.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,7 @@ def butterdiff(x, dt, params=None, options={}, filter_order=2, cutoff_freq=0.5,
170170
for _ in range(num_iterations):
171171
x_hat = scipy.signal.filtfilt(b, a, x_hat, method="pad", padlen=padlen) # applies forward and backward pass so zero phase
172172

173-
x_hat, dxdt_hat = finite_difference(x_hat, dt)
174-
175-
offset = np.mean(x) - np.mean(x_hat)
176-
x_hat = x_hat + offset
177-
178-
return x_hat, dxdt_hat
173+
return finite_difference(x_hat, dt)
179174

180175

181176
def splinediff(*args, **kwargs):

pynumdiff/tests/test_diff_methods.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,12 @@ def spline_irreg_step(*args, **kwargs): return splinediff(*args, **kwargs)
9191
[(0, -1), (1, 1), (0, 0), (1, 1)],
9292
[(1, 1), (2, 2), (1, 1), (2, 2)],
9393
[(1, 1), (3, 3), (1, 1), (3, 3)]],
94-
butterdiff: [[(-13, -14), (-13, -13), (0, -1), (0, 0)],
95-
[(0, -1), (0, 0), (0, -1), (0, 0)],
96-
[(0, 0), (1, 1), (0, 0), (1, 1)],
97-
[(1, 0), (1, 1), (1, 0), (1, 1)],
98-
[(2, 2), (3, 2), (2, 2), (3, 2)],
99-
[(2, 1), (3, 3), (2, 1), (3, 3)]],
94+
butterdiff: [[(-14, -15), (-13, -13), (0, -1), (1, 1)],
95+
[(-3, -3), (-2, -2), (0, -1), (1, 1)],
96+
[(-2, -3), (-1, -1), (0, -1), (1, 1)],
97+
[(-3, -3), (0, -1), (0, -1), (1, 1)],
98+
[(0, -1), (1, 1), (0, 0), (1, 1)],
99+
[(0, 0), (3, 3), (0, 0), (3, 3)]],
100100
first_order: [[(-25, -25), (-25, -25), (0, 0), (1, 1)],
101101
[(-25, -25), (-13, -13), (0, 0), (1, 1)],
102102
[(-25, -25), (0, 0), (0, 0), (1, 1)],

0 commit comments

Comments
 (0)