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
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
""" | |
Thiran allpass interpolator. | |
https://ccrma.stanford.edu/~jos/pasp/Thiran_Allpass_Interpolators.html | |
@author: Arnfinn Eielsen | |
@date: 11.09.2025 | |
@license: BSD 3-Clause |
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
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
"""Balanced realisaton of a stable LTI state-space system. | |
@author: Arnfinn Eielsen | |
@date: 06.03.2024 | |
@license: BSD 3-Clause | |
""" | |
from scipy import linalg |
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
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
""" | |
Created on Fri Feb 16 11:30:34 2024 | |
Power spectral density (PSD) estimation using a simplified version of the | |
Welch method. | |
@author: Arnfinn Eielsen | |
@license: BSD 3-Clause |
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
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
"""Sinusoidal fitting method with inital value guessing | |
Created on Tue Feb 6 10:16:47 2024 | |
Method to that attempts to generate rough esimtates of sinusoidal wave | |
parameters before passing them on to the standard curve fitting method in | |
NumPy. Initial values have to be reasonably accurate to ensure convergence. | |
This implements the sinusoidal fitting described in IEEE Std 1658-2011 |
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
function y = db_to_mag(x,type) | |
% convert from decibels to unscaled real valued magnitude | |
switch type | |
case 'pow' % if the input expresses power | |
y = 10.^(x/10); | |
case 'mag' % if the input expresses magnitude | |
y = 10.^(x/20); | |
otherwise | |
y = x; |
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
function num_str = sig_fig_str(num,d) | |
% Generate string with specified number of significant figures, and | |
% correctly format number string to include trailing zeros. | |
m = mod(round(num,d,'significant'),round(num)); | |
num_str = num2str(num,d); | |
if m == 0 % integer, add dot and trailing zeros | |
if length(num_str) < d | |
num_str = [num_str '.']; |