def find_peaks(self): print '# Finding peaks.' for i in self.data: for e in self.data[i]: hist = Data(list(self.data[i][e].index), list(self.data[i][e]['hits']), smoothness=1, default_smooth=False) hist.normalize() try: hist.get_peaks(method="slope", peak_amp_thresh=0.00005, valley_thresh=0.00003, intervals=None, lookahead=self.lookahead, avg_interval=100) self.data[i][e]['peaks'] = sorted(np.array(hist.peaks['peaks'][0]).tolist()) self.data[i][e]['valleys'] = sorted(np.array(hist.peaks['valleys'][0]).tolist()) except ValueError: self.data[i][e]['peaks'] = [] self.data[i][e]['valleys'] = [] return True
def find_peaks(func,interpolation_points=1000,peak_finding_smoothness=30, plot=False, plot_new_fig=True): x = np.arange(0,len(func)) y = func f = interp1d(x,y,kind='linear') x_2 = np.linspace(0,len(func)-1,interpolation_points) y_2 = f(x_2) data_obj = Data(x_2,y_2,smoothness=peak_finding_smoothness) data_obj.normalize() try: data_obj.get_peaks(method='slope') if plot==True: data_obj.plot(new_fig=plot_new_fig) return data_obj except ValueError: return 0
def find_peaks(func, interpolation_points=1000, peak_finding_smoothness=30, plot=False, plot_new_fig=True): x = np.arange(0, len(func)) y = func f = interp1d(x, y, kind='linear') x_2 = np.linspace(0, len(func) - 1, interpolation_points) y_2 = f(x_2) data_obj = Data(x_2, y_2, smoothness=peak_finding_smoothness) data_obj.normalize() try: data_obj.get_peaks(method='slope') if plot == True: data_obj.plot(new_fig=plot_new_fig) return data_obj except ValueError: return 0