rename (t|q)(a|c|d) to (t|q)(1|2|) in traptraj
[liba.git] / python / test / hpf.py
blob3a4d064ef0c90ceb94efecfbeebd3a71be8f50c2
1 #!/usr/bin/env python
2 import os, sys
4 sys.path.insert(0, os.getcwd())
5 prefix = os.path.join(sys.path[0], "build")
6 if not os.path.exists(prefix):
7 os.mkdir(prefix)
8 try:
9 import liba as a
10 import numpy as np
11 import matplotlib.pyplot as plt
12 except Exception as e:
13 print(e)
14 exit()
16 Ts = 1.0
17 f_0 = 1.0
18 f_e = 1000.0
19 c = (f_e - f_0) / Ts
20 T = 1.0 / 10000
21 x = []
22 x1 = 0
23 while x1 < Ts:
24 x.append(x1)
25 x1 += T
26 x1 = np.array(x)
27 x1 = np.cos(2 * np.pi * (f_0 * x1 + 0.5 * c * x1 * x1))
28 x2 = x1.copy()
29 hpf = a.hpf(10, 0.01)
30 for i in range(len(x2)):
31 x2[i] = hpf(x2[i])
32 plt.figure("High Pass Filter")
33 plt.plot(x, x1, "b-", x, x2, "g-")
34 plt.savefig(os.path.join(prefix, "hpf.png"))