-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathutils.py
33 lines (28 loc) · 859 Bytes
/
utils.py
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
# 1. Successfully import matplotlib
import matplotlib
gui_env = ['TKAgg','GTKAgg','Qt4Agg','WXAgg']
for gui in gui_env:
try:
print("Testing backend: ", gui)
matplotlib.use(gui,warn=False, force=True)
from matplotlib import pyplot as plt
break
except:
continue
print("Using:", matplotlib.get_backend())
# 2. FDLS example
import data
(b, a) = fdls.fdls(data.frequency, data.amplitude, data.phase, fs=khz)
# 3. Clear all local variables
import sys
sys.modules[__name__].__dict__.clear()
# 4. Handle SIGINT ^+C signals, remember to register singal handler
# before showing the plot, otherwise enters TKAgg event loop and is hard to interupt
import signal, sys
def handler(signum, frame):
print('Quitting')
try:
plt.close()
finally:
sys.exit(0)
signal.signal(signal.SIGINT, handler)