Repository navigation
Conversation
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds to
pytta.functionsthe conversion between the power series of a memoryless nonlinearity and the harmonics it produces, asita_nonlinear_power_to_harmonic_seriesandita_nonlinear_harmonic_to_power_seriesof the ITA-Toolbox, following Dietrich, Uncertainties in acoustical transfer functions (2013), sec. 3.3:power_to_harmonic_series(coefficients, gain=1, phase=0): the amplitudes of the harmonics 1 to N that y = Σ a_k x^k gives for a cosine of amplitudegain, divided bygainas the sweep deconvolution does, with harmonic m turned by (m - 1)phase. The coefficients go along the first axis and may be arrays, converted entry by entry.harmonic_to_power_series(harmonics, gain=1, phase=0): the inverse.The amplitudes come from the Chebyshev expansion of cos^k (
numpy.polynomial.chebyshev.poly2cheb). Two points differ from the ITA-Toolbox:gain=1, the default, both agree.ita_nonlinear_shift_frequency_vector) when it converts spectra of anitaAudio; here the arrays are converted entry by entry and no axis is shifted.The ITA code was read for its semantics only and nothing was copied.
The tests in
tests/test_nonlinear_series.pyprint the measured differences:phase, as the ITA-Toolbox gives, and the inverse returns complex coefficients given per frequency (9.0e-16).Checked with Python 3.12, numpy 1.26 and scipy 1.17, and against the ITA-Toolbox in MATLAB R2026b for the gain and phase conventions. The 7 failures of
development(3 intest_h5io.py, 4 intest_pyttasave.py) are the same with and without this change.Co-Authored-By: Claude Fable 5.1 noreply@anthropic.com