-
Notifications
You must be signed in to change notification settings - Fork 73
NWaves for MATLAB and sciPy users
Tim Sharii edited this page Sep 12, 2021
·
11 revisions
scipy.signal | NWaves |
z, p, k = tf2zpk(num, den) |
var tf = new TransferFunction(num, den);
var z = tf.Zeros;
var p = tf.Poles;
var k = tf.Gain; |
num, den = zpk2tf(z, p, k) |
Complex[] z = new [] { ... }; // zeros
Complex[] p = new [] { ... }; // poles
var tf = new TransferFunction(z, p, k);
var num = tf.Numerator;
var den = tf.Denominator; |
sos = tf2sos(num, den) |
var tf = new TransferFunction(num, den);
var sos = DesignFilter.TfToSos(tf); |
A, B, C, D = tf2ss(num, den) |
var tf = new TransferFunction(num, den);
var ss = tf.StateSpace;
// then get ss.A, ss.B, ss.C, ss.D |
sos = zpk2sos(z, p, k) |
var tf = new TransferFunction(z, p, k);
var sos = DesignFilter.TfToSos(tf); |
num, den = ss2tf(A, B, C, D) |
var ss = new StateSpace { A=a, B=b, C=c, D=d };
var tf = new TransferFunction(ss);
var num = tf.Numerator;
var den = tf.Denominator; |
num, den = sos2tf(sos) |
TransferFunction[] sos; // fill array
var tf = DesignFilter.SosToTf(sos);
var num = tf.Numerator;
var den = tf.Denominator; |
y = lfilter(num, den, x) |
var filter = new IirFilter(num, den);
// or if den == [1]:
// var filter = new FirFilter(num);
var y = filter.ApplyTo(x); |
y = lfilter(num, den, x, zi=zi) |
var filter = new ZiFilter(num, den);
filter.Init(zi);
var y = filter.ApplyTo(x); |
zi = lfilter_zi(num, den) |
var tf = new TransferFunction(num, den);
var zi = tf.Zi; |
p = 3*(max(len(num), len(den))-1)
y = filtfilt(num, den, x, padlen=p) |
var filter = new ZiFilter(num, den);
var y = filter.ZeroPhase(x); |
y = sosfilt(sos, x) |
var tf = new TransferFunction(num, den);
var sos = DesignFilter.TfToSos(tf);
var filter = new FilterChain(sos);
var y = filter.ApplyTo(x); |
# cutoff freqs are in range [0..1]:
# fc = 2*f / fs
h1 = firwin(order, 0.2,
window='blackman')
h2 = firwin(order, 0.2,
pass_zero=False)
h3 = firwin(order, [0.2, 0.6])
h4 = firwin(order, [0.2, 0.6],
pass_zero=False) |
// cutoff freqs are in range [0, 0.5]:
// fc = f / fs
var h1 = DesignFilter.FirWinLp(order, 0.1);
var h2 = DesignFilter.FirWinHp(order, 0.1,
WindowType.Hamming);
var h3 = DesignFilter.FirWinBs(order, 0.1, 0.3,
WindowType.Hamming);
var h4 = DesignFilter.FirWinBp(order, 0.1, 0.3,
WindowType.Hamming); |
order = 19
freqs = [0, 0.25, 0.5, 0.54, 0.75, 1.0]
gain = [1, 1, 1, 0.9, 0, 0]
kernel = firwin2(order, freqs, gain) |
var order = 19;
double[] freqs = { 0, 0.125, 0.25, 0.27, 0.375, 0.5 };
double[] gains = { 1, 1, 1, 0.9, 0, 0 };
var kernel = DesignFilter.Fir(order, freqs, gains,
WindowType.Hamming); |
order = 57
freqs = [ 0, 0.3, 0.34, 1 ]
gain = [ 1, 0 ]
weights = [ 0.01, 0.1 ]
kernel = remez(order, freqs, response, weights) |
var order = 57;
double[] freqs = { 0, 0.15, 0.17, 0.5 };
double[] response = { 1, 0 };
double[] weights = { 0.01, 0.1 };
var remez = new Remez(order, freqs, response, weights);
var kernel = remez.Design();
// or in this particular case, also:
kernel = DesignFilter.FirEquirippleLp(57, 0.15, 0.17,
0.01, 0.1); |
w, h = freqz(num, den, 1024) |
var tf = new TransferFunction(num, den);
var h = tf.FrequencyResponse(1024).Magnitude; |