Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 25 additions & 21 deletions examples/1_basic_tutorial.ipynb

Large diffs are not rendered by default.

42 changes: 24 additions & 18 deletions examples/2a_optimizing_parameters_with_dxdt_known.ipynb

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions examples/2b_optimizing_parameters_with_dxdt_unknown.ipynb

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions pynumdiff/linear_model/_linear_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ def spectraldiff(x, dt, params=None, options=None, high_freq_cutoff=None, even_e
:param dict options: (**deprecated**, prefer :code:`even_extension`
and :code:`pad_to_zero_dxdt`) a dictionary consisting of {'even_extension': (bool), 'pad_to_zero_dxdt': (bool)}
:param float high_freq_cutoff: The high frequency cutoff as a multiple of the Nyquist frequency: Should be between 0
and 0.5. Frequencies below this threshold will be kept, and above will be zeroed.
and 1. Frequencies below this threshold will be kept, and above will be zeroed.
:param bool even_extension: if True, extend the data with an even extension so signal starts and ends at the same value.
:param bool pad_to_zero_dxdt: if True, extend the data with extra regions that smoothly force the derivative to
zero before taking FFT.
Expand Down Expand Up @@ -310,7 +310,7 @@ def spectraldiff(x, dt, params=None, options=None, high_freq_cutoff=None, even_e
omega = k*2*np.pi/(dt*N) # turn wavenumbers into frequencies in radians/s

# Frequency based smoothing: remove signals with a frequency higher than high_freq_cutoff
discrete_cutoff = int(high_freq_cutoff*N)
discrete_cutoff = int(high_freq_cutoff*N/2) # Nyquist is at N/2 location, and we're cutting off as a fraction of that
omega[discrete_cutoff:N-discrete_cutoff] = 0

# Derivative = 90 deg phase shift
Expand Down
2 changes: 1 addition & 1 deletion pynumdiff/tests/test_diff_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def iterated_first_order(*args, **kwargs): return first_order(*args, **kwargs)
(lineardiff, {'order':3, 'gamma':5, 'window_size':11, 'solver':'CLARABEL'}), (lineardiff, [3, 5, 11], {'solver':'CLARABEL'}),
(polydiff, {'poly_order':2, 'window_size':3}), (polydiff, [2, 3]),
(savgoldiff, {'poly_order':2, 'window_size':5, 'smoothing_win':5}), (savgoldiff, [2, 5, 5]),
(spectraldiff, {'high_freq_cutoff':0.1}), (spectraldiff, [0.1]),
(spectraldiff, {'high_freq_cutoff':0.2}), (spectraldiff, [0.2]),
(mediandiff, {'window_size':3, 'num_iterations':2}), (mediandiff, [3, 2], {'iterate':True}),
(meandiff, {'window_size':3, 'num_iterations':2}), (meandiff, [3, 2], {'iterate':True}),
(gaussiandiff, {'window_size':5}), (gaussiandiff, [5]),
Expand Down
4 changes: 2 additions & 2 deletions pynumdiff/tests/test_optimize.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ def test_savgoldiff():
def test_spectraldiff():
params1, val1 = optimize(spectraldiff, x, dt, dxdt_truth=dxdt_truth, padding='auto')
params2, val2 = optimize(spectraldiff, x, dt, tvgamma=tvgamma, padding='auto')
np.testing.assert_almost_equal(params1['high_freq_cutoff'], 0.0975, decimal=3)
np.testing.assert_almost_equal(params2['high_freq_cutoff'], 0.10, decimal=2)
np.testing.assert_almost_equal(params1['high_freq_cutoff'], 0.105, decimal=2)
np.testing.assert_almost_equal(params2['high_freq_cutoff'], 0.105, decimal=2)

def test_polydiff():
params1, val1 = optimize(polydiff, x, dt, search_space={'step_size':1}, dxdt_truth=dxdt_truth, padding='auto')
Expand Down