support for installing liba.pyi during pip install
[liba.git] / python / test / 3rd / lpf.py
blob2c31dc8e3d82608a2d79c85dd56b6ca95f7e3fb6
1 #!/usr/bin/env python
2 import os, sys
4 base = os.path.dirname(__file__)
5 path = os.path.dirname(base)
6 path = os.path.dirname(path)
7 sys.path.insert(0, path)
8 try:
9 import numpy as np
10 import matplotlib.pyplot as plt
11 except Exception as e:
12 print(e)
13 exit()
15 import liba # type: ignore
17 x = np.arange(0, np.pi * 10, np.pi * 0.1)
18 x1 = np.sin(x) + 0.2 * (np.random.random(len(x)) - 0.5)
19 x2 = x1.copy()
20 lpf = liba.lpf(10, 0.01)
21 for i in range(len(x2)):
22 x2[i] = lpf(x2[i])
23 plt.figure("Low Pass Filter")
24 plt.plot(x, x1, "b-", x, x2, "g-")
25 plt.savefig(os.path.join(base, "lpf.png"))
26 plt.show()