-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpole.py
More file actions
52 lines (41 loc) · 1.88 KB
/
pole.py
File metadata and controls
52 lines (41 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import mpmath as mp
def butterworth(n):
'''Returns a list of Q,f multiplier values for a cascade of length N.'''
n = int(n)
step = mp.pi/(2.0*n)
start = step/2.0
q = []
value = start
while value < mp.pi/2:
q.append(1./(2.0*mp.cos(value)))
value += step
return q, [1.0] * int(n)
# Presolved bessel Q,f (a,b) polynomials
BESSEL_Q = [
[0.57735026919],
[0.805538281842, 0.521934581669],
[1.02331395383, 0.611194546878, 0.510317824749],
[1.22566942541, 0.710852074442, 0.559609164796, 0.505991069397],
[1.41530886916, 0.809790964842, 0.620470155556, 0.537552151325, 0.503912727276],
[1.59465693507, 0.905947107025, 0.684008068137, 0.579367238641, 0.525936202016, 0.502755558204],
[1.76552743493, 0.998998442993, 0.747625068271, 0.624777082395, 0.556680772868, 0.519027293158, 0.502045428643],
[1.9292718407, 1.08906376917, 0.810410302962, 0.671382379377, 0.591144659703, 0.542678365981, 0.514570953471, 0.501578400482]
]
BESSEL_F = [
[1.0],
[1.05881751607, 0.944449808226],
[1.10221694805, 0.977488555538, 0.928156550439],
[1.13294518316, 1.01102810214, 0.948341760923, 0.920583104484],
[1.1558037036, 1.03936894925, 0.972611094341, 0.934100034374, 0.916249124617],
[1.17355271619, 1.06292406317, 0.99546178686, 0.952166527388, 0.92591429605, 0.913454385093],
[1.18780032771, 1.08266791426, 1.0159112847, 0.970477661528, 0.939810654318, 0.920703208467, 0.911506866227],
[1.19953740587, 1.09943305993, 1.03400291299, 0.987760087301, 0.954673832805, 0.93169889496, 0.917142770586, 0.910073839264]
]
def bessel(n):
'''Returns a list of Q,f multiplier values for a cascade of length N.'''
n = int(n)
if n > 8:
print("Max cascade length for Bessel filters is 8")
exit(1)
# Return with smallest Q in the first stage
return BESSEL_Q[n-1][::-1], BESSEL_F[n-1][::-1]