Skip to content

Commit 4192a6c

Browse files
pavelkomarovclaude
andcommitted
Restore convolutional_smoother step dropped during multidim rewrite
The original spectraldiff smoothed the padded edges with a moving average before FFT, then restored the original signal in the middle. This creates a smooth ramp to zero derivative at the boundaries, which is the whole point of pad_to_zero_dxdt. The multidim rewrite had dropped this step. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 35b594c commit 4192a6c

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

pynumdiff/basis_fit.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ def spectraldiff(x, dt, params=None, options=None, high_freq_cutoff=None,
4444
pre = np.repeat(x0[0:1], padding, axis=0)
4545
post = np.repeat(x0[-1:], padding, axis=0)
4646
x0 = np.concatenate((pre, x0, post), axis=0) # np.concatenate works along any axis, unlike hstack/vstack
47+
kernel = utility.mean_kernel(padding//2)
48+
x0_smoothed = utility.convolutional_smoother(x0, kernel, axis=0) # smooth the padded edges in
49+
x0_smoothed[padding:-padding] = x0[padding:-padding] # restore original signal in the middle
50+
x0 = x0_smoothed
4751
else:
4852
padding = 0
4953

0 commit comments

Comments
 (0)