def process_peaks(self, mph=0.0, mpd=0, startx=0.0, endx=0.0): if mph > 0: self.mph = mph if mpd > 0: self.mpd = mpd x = self.mass y = self.spectrum p = Peaks() ref = startx + (abs(endx - startx) / 2) delta = 1.0 mph, mpd, mask = p.prepare_detect(ref, delta, x, y, startx, endx) # Detect peak on rising edge edge = 'rising' # Detect peak greater than threshold threshold = 0.0 # Don't use default plot ind = p.detect_peaks(y[mask], self.mph, self.mpd, threshold, edge) # print("mass =", x[mask][ind]) # print("inten=", y[mask][ind]) self.mph = mph self.mpd = mpd self.mask = mask self.ind = ind
def automatic_fill(self): log.debug("event from %s", self.sender()) if len(self.mass_list) == 0: return # if self.ana.pip.signal is None: # return x = self.ana.pip.mass y = self.ana.pip.spectrum self.acc_event() p = Peaks() dict_peak = p.masstab_peaks(x, y, self.mass_list, self.acc) text = str(self.short_name).ljust(21) for mass in self.mass_list: text = text + "{:.3f}".format(float(dict_peak[mass])).ljust(8) self.ui.plainTextEdit_Viewer.appendPlainText(text)
def automatic_fill(self): log.debug("event from %s", self.sender()) if len(self.mass_list) == 0: return # if self.ana.pip.signal is None: # return x = self.ana.pip.mass y = self.ana.pip.spectrum self.acc_event() p = Peaks() dict_m, dict_i = p.masstab_peaks(x, y, self.mass_list, self.acc) text = str(self.short_name).ljust(24) for mass in self.mass_list: text = text + \ "{:.4f}".format(float(dict_m[mass])).ljust(9) + \ "{:.3f}".format(float(dict_i[mass])).ljust(9) self.ui.plainTextEdit_Viewer.appendPlainText(text)
def process_peaks(self, xin, yin, mph=0.0, mpd=0, x1=0.0, x2=0.0): """ Within a range of mass [x1, x2], get indices of maximum intensity (ind) with a peak height and a peak distance provided as input params (mph, mpd) suggested values are returned into mph_o, mpd_o, if needed ==> caution ! indices are from x[mask], not full x array """ x = np.asarray(xin) y = np.asarray(yin) p = Peaks() mph_o, mpd_o, mask, ind = p.get_peaks(x, y, x1, x2, mph, mpd) xx = x[mask] yy = y[mask] return mph_o, mpd_o, xx, yy, xx[ind], yy[ind]
pip = Pipeline(filename) # Put your own settings here: start signal, end signal and Hanning start = pip.start start = 10000 end = pip.end end = 1010000 hann = False pip.process_signal(start, end, hann, False, False, False) pip.process_spectrum(factor=1000.0, ref_mass=300.0939, cyclo_freq=255.692e3, mag_freq=0.001e3) x = np.asarray(pip.mass) y = np.asarray(pip.spectrum) # Peak search p = Peaks() dict_m, dict_i = p.masstab_peaks(x, y, mass_list, acc) short_name = os.path.basename(filename) text = text + "\n" + str(short_name).ljust(24) for mass in mass_list: text = text + \ "{:.4f}".format(float(dict_m[mass])).ljust(9) + \ "{:.3f}".format(float(dict_i[mass])).ljust(9) # Write result into file: this is the same masstab.txt file as within sofa with open(out_filename, mode='w', encoding='utf_8') as file: file.write(text) # debug print(text)