@@ -22,63 +22,63 @@ class PeakFinderDerivation(object):
2222 peak_max_final_value = - 1
2323 peak_min_final_value = - 1
2424
25- def __init__ (cls , xdata , ydata , edata = [], back_offset = 3 ):
26- cls .initArrays ()
27-
28- cls .xdata = np .array (xdata )
29- cls .ydata = np .array (ydata )
30- cls .edata = np .array (edata )
31-
32- cls .calculate5HighestPoints () # step2
33- cls .calculatePeakPixel () # step3
34-
35- cls .calculateFirstDerivative () # step4
36- cls .calculateMinMaxDerivativePixels () # step5
37- cls .calculateAvgAndStdDerivative () # step6
38- cls .calculateMinMaxSignalPixel () # step7
39-
40- def initArrays (cls ):
41- cls .xdata_firstderi = []
42- cls .ydata_firstderi = []
43- cls .edata_firstderi = []
44- cls .peaks = [- 1 , - 1 ]
45- cls .five_highest_ydata = []
46- cls .five_highest_xdata = []
47- cls .sum_five_highest_ydata = - 1
48- cls .peak_pixel = - 1
49- cls .deri_min = 1
50- cls .deri_max = - 1
51- cls .deri_min_pixel_value = - 1
52- cls .deri_max_pixel_value = - 1
53- cls .mean_counts_firstderi = - 1
54- cls .std_deviation_counts_firstderi = - 1
55- cls .peak_max_final_value = - 1
56- cls .peak_min_final_value = - 1
57-
58- def calculate5HighestPoints (cls ):
59- _xdata = cls .xdata
60- _ydata = cls .ydata
25+ def __init__ (self , xdata , ydata , edata = [], back_offset = 3 ):
26+ self .initArrays ()
27+
28+ self .xdata = np .array (xdata )
29+ self .ydata = np .array (ydata )
30+ self .edata = np .array (edata )
31+
32+ self .calculate5HighestPoints () # step2
33+ self .calculatePeakPixel () # step3
34+
35+ self .calculateFirstDerivative () # step4
36+ self .calculateMinMaxDerivativePixels () # step5
37+ self .calculateAvgAndStdDerivative () # step6
38+ self .calculateMinMaxSignalPixel () # step7
39+
40+ def initArrays (self ):
41+ self .xdata_firstderi = []
42+ self .ydata_firstderi = []
43+ self .edata_firstderi = []
44+ self .peaks = [- 1 , - 1 ]
45+ self .five_highest_ydata = []
46+ self .five_highest_xdata = []
47+ self .sum_five_highest_ydata = - 1
48+ self .peak_pixel = - 1
49+ self .deri_min = 1
50+ self .deri_max = - 1
51+ self .deri_min_pixel_value = - 1
52+ self .deri_max_pixel_value = - 1
53+ self .mean_counts_firstderi = - 1
54+ self .std_deviation_counts_firstderi = - 1
55+ self .peak_max_final_value = - 1
56+ self .peak_min_final_value = - 1
57+
58+ def calculate5HighestPoints (self ):
59+ _xdata = self .xdata
60+ _ydata = self .ydata
6161
6262 _sort_ydata = np .sort (_ydata )
6363 _decreasing_sort_ydata = _sort_ydata [::- 1 ]
64- cls .five_highest_ydata = _decreasing_sort_ydata [0 :5 ]
64+ self .five_highest_ydata = _decreasing_sort_ydata [0 :5 ]
6565
6666 _sort_index = np .argsort (_ydata )
6767 _decreasing_sort_index = _sort_index [::- 1 ]
6868 _5decreasing_sort_index = _decreasing_sort_index [0 :5 ]
69- cls .five_highest_xdata = _xdata [_5decreasing_sort_index ]
69+ self .five_highest_xdata = _xdata [_5decreasing_sort_index ]
7070
71- def calculatePeakPixel (cls ):
72- cls .sum_peak_counts = sum (cls .five_highest_ydata )
71+ def calculatePeakPixel (self ):
72+ self .sum_peak_counts = sum (self .five_highest_ydata )
7373 _sum_peak_counts_time_pixel = - 1
74- for index , yvalue in enumerate (cls .five_highest_ydata ):
75- _sum_peak_counts_time_pixel += yvalue * cls .five_highest_xdata [index ]
76- cls .sum_peak_counts_time_pixel = _sum_peak_counts_time_pixel
77- cls .peak_pixel = round (cls .sum_peak_counts_time_pixel / cls .sum_peak_counts )
74+ for index , yvalue in enumerate (self .five_highest_ydata ):
75+ _sum_peak_counts_time_pixel += yvalue * self .five_highest_xdata [index ]
76+ self .sum_peak_counts_time_pixel = _sum_peak_counts_time_pixel
77+ self .peak_pixel = round (self .sum_peak_counts_time_pixel / self .sum_peak_counts )
7878
79- def calculateFirstDerivative (cls ):
80- xdata = cls .xdata
81- ydata = cls .ydata
79+ def calculateFirstDerivative (self ):
80+ xdata = self .xdata
81+ ydata = self .ydata
8282
8383 _xdata_firstderi = []
8484 _ydata_firstderi = []
@@ -91,35 +91,35 @@ def calculateFirstDerivative(cls):
9191 _right_y = ydata [i + 1 ]
9292 _ydata_firstderi .append ((_right_y - _left_y ) / (_right_x - _left_x ))
9393
94- cls .xdata_firstderi = _xdata_firstderi
95- cls .ydata_firstderi = _ydata_firstderi
94+ self .xdata_firstderi = _xdata_firstderi
95+ self .ydata_firstderi = _ydata_firstderi
9696
97- def calculateMinMaxDerivativePixels (cls ):
98- _pixel = cls .xdata_firstderi
99- _counts_firstderi = cls .ydata_firstderi
97+ def calculateMinMaxDerivativePixels (self ):
98+ _pixel = self .xdata_firstderi
99+ _counts_firstderi = self .ydata_firstderi
100100
101101 _sort_counts_firstderi = np .sort (_counts_firstderi )
102- cls .deri_min = _sort_counts_firstderi [0 ]
103- cls .deri_max = _sort_counts_firstderi [- 1 ]
102+ self .deri_min = _sort_counts_firstderi [0 ]
103+ self .deri_max = _sort_counts_firstderi [- 1 ]
104104
105105 _sort_index = np .argsort (_counts_firstderi )
106- cls .deri_min_pixel_value = min ([_pixel [_sort_index [0 ]], _pixel [_sort_index [- 1 ]]])
107- cls .deri_max_pixel_value = max ([_pixel [_sort_index [0 ]], _pixel [_sort_index [- 1 ]]])
106+ self .deri_min_pixel_value = min ([_pixel [_sort_index [0 ]], _pixel [_sort_index [- 1 ]]])
107+ self .deri_max_pixel_value = max ([_pixel [_sort_index [0 ]], _pixel [_sort_index [- 1 ]]])
108108
109- def calculateAvgAndStdDerivative (cls ):
110- _counts_firstderi = np .array (cls .ydata_firstderi )
111- cls .mean_counts_firstderi = np .mean (_counts_firstderi )
109+ def calculateAvgAndStdDerivative (self ):
110+ _counts_firstderi = np .array (self .ydata_firstderi )
111+ self .mean_counts_firstderi = np .mean (_counts_firstderi )
112112 _mean_counts_firstderi = np .mean (_counts_firstderi * _counts_firstderi )
113- cls .std_deviation_counts_firstderi = math .sqrt (_mean_counts_firstderi )
113+ self .std_deviation_counts_firstderi = math .sqrt (_mean_counts_firstderi )
114114
115- def calculateMinMaxSignalPixel (cls ):
116- _counts = cls .ydata_firstderi
117- _pixel = cls .xdata_firstderi
115+ def calculateMinMaxSignalPixel (self ):
116+ _counts = self .ydata_firstderi
117+ _pixel = self .xdata_firstderi
118118
119- _deri_min_pixel_value = cls .deri_min_pixel_value
120- _deri_max_pixel_value = cls .deri_max_pixel_value
119+ _deri_min_pixel_value = self .deri_min_pixel_value
120+ _deri_max_pixel_value = self .deri_max_pixel_value
121121
122- _std_deviation_counts_firstderi = cls .std_deviation_counts_firstderi
122+ _std_deviation_counts_firstderi = self .std_deviation_counts_firstderi
123123
124124 px_offset = 0
125125 while abs (_counts [int (_deri_min_pixel_value - px_offset )]) > _std_deviation_counts_firstderi :
@@ -131,45 +131,45 @@ def calculateMinMaxSignalPixel(cls):
131131 px_offset += 1
132132 _peak_max_final_value = _pixel [int (round (_deri_max_pixel_value + px_offset ))]
133133
134- cls .peaks = [int (_peak_min_final_value ), int (np .ceil (_peak_max_final_value ))]
134+ self .peaks = [int (_peak_min_final_value ), int (np .ceil (_peak_max_final_value ))]
135135
136136 # getters
137137
138- def getAverageOfFirstDerivationCounts (cls ):
139- return cls .mean_counts_firstderi
138+ def getAverageOfFirstDerivationCounts (self ):
139+ return self .mean_counts_firstderi
140140
141- def getStdDeviationOfFirstDerivationCounts (cls ):
142- return cls .std_deviation_counts_firstderi
141+ def getStdDeviationOfFirstDerivationCounts (self ):
142+ return self .std_deviation_counts_firstderi
143143
144- def getMinDerivativeValue (cls ):
145- return cls .deri_min
144+ def getMinDerivativeValue (self ):
145+ return self .deri_min
146146
147- def getMaxDerivativeValue (cls ):
148- return cls .deri_max
147+ def getMaxDerivativeValue (self ):
148+ return self .deri_max
149149
150- def getMinDerivationPixelValue (cls ):
151- return cls .deri_min_pixel_value
150+ def getMinDerivationPixelValue (self ):
151+ return self .deri_min_pixel_value
152152
153- def getMaxDerivationPixelValue (cls ):
154- return cls .deri_max_pixel_value
153+ def getMaxDerivationPixelValue (self ):
154+ return self .deri_max_pixel_value
155155
156- def getPeakPixel (cls ):
157- return cls .peak_pixel
156+ def getPeakPixel (self ):
157+ return self .peak_pixel
158158
159- def getSumPeakCounts (cls ):
160- return cls .sum_peak_counts
159+ def getSumPeakCounts (self ):
160+ return self .sum_peak_counts
161161
162- def getSumPeakCountsTimePixel (cls ):
163- return cls .sum_peak_counts_time_pixel
162+ def getSumPeakCountsTimePixel (self ):
163+ return self .sum_peak_counts_time_pixel
164164
165- def get5HighestPoints (cls ):
166- return [cls .five_highest_xdata , cls .five_highest_ydata ]
165+ def get5HighestPoints (self ):
166+ return [self .five_highest_xdata , self .five_highest_ydata ]
167167
168- def getFirstDerivative (cls ):
169- return [cls .xdata_firstderi , cls .ydata_firstderi ]
168+ def getFirstDerivative (self ):
169+ return [self .xdata_firstderi , self .ydata_firstderi ]
170170
171- def getPeaks (cls ):
172- return cls .peaks
171+ def getPeaks (self ):
172+ return self .peaks
173173
174174
175175if __name__ == "__main__" :
0 commit comments