-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpeakplotter.py
50 lines (38 loc) · 1.16 KB
/
peakplotter.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import matplotlib.pyplot as plt
import sys, numpy, scipy.signal
from scipy.signal import find_peaks, medfilt
from scipy.stats import iqr, gaussian_kde
data = numpy.loadtxt(sys.argv[1], skiprows=100)
smooth = scipy.signal.savgol_filter(data, 20, 3)
smooth = data
baseline = numpy.median(smooth[0:int(len(smooth)/10)])
# smooth = -(smooth - 15120)
smooth = -(smooth - baseline)
peaks, properties = find_peaks(smooth, prominence=10) # was 50, then 20 for r4, recently 4
print(peaks)
print(len(peaks))
# plt.plot(smooth)
# plt.plot(peaks, smooth[peaks], ".", markersize=5, color="r")
# # plt.plot(peaks, medfilt(smooth[peaks], 101), "b-") # was 1001
# plt.show()
# exit()
# plt.hist(peaks, bins=100)
# # plt.gca().set_xlim(0, 3500000)
# # plt.gca().set_ylim(0, 120)
# plt.gca().set_xlabel("Time [s]")
# plt.gca().set_ylabel("Peak count")
# plt.show()
# exit()
plt.hist(smooth[peaks], bins=188)
# plt.gca().set_xlim(0, 3500000)
# plt.gca().set_ylim(0, 120)
plt.gca().set_yscale("log")
plt.gca().set_xlabel("Peak height")
plt.gca().set_ylabel("Peak count")
plt.show()
exit()
# plt.gca().set_yscale("log")
plt.title(sys.argv[1])
# plt.show()
plt.savefig(sys.argv[1] + "_PEAKS.png")
#