def updateTmpSpectrum(self): """Show current profile in the main canvas.""" # check data if self.currentPatternProfile == None: self.parent.updateTmpSpectrum(None) return # apply current shift profile = mspy.offset(self.currentPatternProfile, x=config.massCalculator['patternShift']) # draw tmp spectrum self.parent.updateTmpSpectrum(profile)
def makeProfile(self): """Generate pattern profile.""" self.currentPatternProfile = None self.currentPatternPeaks = None self.currentPatternScan = None # check pattern if self.currentPattern == None: return # get selected charge charge = 0 if self.currentIon != None: charge = self.currentIon[3] # make profile self.currentPatternProfile = mspy.profile( peaklist=self.currentPattern, fwhm=config.massCalculator['patternFwhm'], points=20, model=config.massCalculator['patternPeakShape'], ) # get scale and shift for specified intensity and baseline basepeak = mspy.basepeak(self.currentPatternProfile) scale = (config.massCalculator['patternIntensity'] - config.massCalculator['patternBaseline'] ) / self.currentPatternProfile[basepeak][1] shift = config.massCalculator['patternBaseline'] # rescale profile self.currentPatternProfile = mspy.multiply(self.currentPatternProfile, y=scale) self.currentPatternProfile = mspy.offset(self.currentPatternProfile, y=shift) # make real peaklist from profile peaklist = [] for isotope in mspy.maxima(self.currentPatternProfile): mz = isotope[0] centroid = mspy.centroid(self.currentPatternProfile, isotope[0], isotope[1] * 0.99) if abs(mz - centroid) < config.massCalculator['patternFwhm'] / 20: mz = centroid peak = mspy.peak(mz=mz, ai=isotope[1], base=shift, charge=charge) peaklist.append(peak) peaklist = mspy.peaklist(peaklist) # make individual peak shapes self.currentPatternPeaks = [] if config.massCalculator['patternShowPeaks']: # gaussian shape if config.massCalculator['patternPeakShape'] == 'gaussian': for isotope in self.currentPattern: peak = mspy.gaussian( x=isotope[0], minY=shift, maxY=isotope[1] * scale + shift, fwhm=config.massCalculator['patternFwhm']) self.currentPatternPeaks.append(peak) # lorentzian shape elif config.massCalculator['patternPeakShape'] == 'lorentzian': for isotope in self.currentPattern: peak = mspy.lorentzian( x=isotope[0], minY=shift, maxY=isotope[1] * scale + shift, fwhm=config.massCalculator['patternFwhm']) self.currentPatternPeaks.append(peak) # gauss-lorentzian shape elif config.massCalculator[ 'patternPeakShape'] == 'gausslorentzian': for isotope in self.currentPattern: peak = mspy.gausslorentzian( x=isotope[0], minY=shift, maxY=isotope[1] * scale + shift, fwhm=config.massCalculator['patternFwhm']) self.currentPatternPeaks.append(peak) # make scan object self.currentPatternScan = mspy.scan(profile=self.currentPatternProfile, peaklist=peaklist)
def makeProfile(self): """Generate pattern profile.""" self.currentPatternProfile = None self.currentPatternPeaks = None self.currentPatternScan = None # check pattern if self.currentPattern == None: return # get selected charge charge = 0 if self.currentIon != None: charge = self.currentIon[3] # make profile self.currentPatternProfile = mspy.profile( peaklist = self.currentPattern, fwhm = config.massCalculator['patternFwhm'], points = 20, model = config.massCalculator['patternPeakShape'], ) # get scale and shift for specified intensity and baseline basepeak = mspy.basepeak(self.currentPatternProfile) scale = (config.massCalculator['patternIntensity'] - config.massCalculator['patternBaseline']) / self.currentPatternProfile[basepeak][1] shift = config.massCalculator['patternBaseline'] # rescale profile self.currentPatternProfile = mspy.multiply(self.currentPatternProfile, y=scale) self.currentPatternProfile = mspy.offset(self.currentPatternProfile, y=shift) # make real peaklist from profile peaklist = [] for isotope in mspy.maxima(self.currentPatternProfile): mz = isotope[0] centroid = mspy.centroid(self.currentPatternProfile, isotope[0], isotope[1]*0.99) if abs(mz-centroid) < config.massCalculator['patternFwhm']/20: mz = centroid peak = mspy.peak( mz = mz, ai = isotope[1], base = shift, charge = charge ) peaklist.append(peak) peaklist = mspy.peaklist(peaklist) # make individual peak shapes self.currentPatternPeaks = [] if config.massCalculator['patternShowPeaks']: # gaussian shape if config.massCalculator['patternPeakShape'] == 'gaussian': for isotope in self.currentPattern: peak = mspy.gaussian( x = isotope[0], minY = shift, maxY = isotope[1]*scale+shift, fwhm = config.massCalculator['patternFwhm'] ) self.currentPatternPeaks.append(peak) # lorentzian shape elif config.massCalculator['patternPeakShape'] == 'lorentzian': for isotope in self.currentPattern: peak = mspy.lorentzian( x = isotope[0], minY = shift, maxY = isotope[1]*scale+shift, fwhm = config.massCalculator['patternFwhm'] ) self.currentPatternPeaks.append(peak) # gauss-lorentzian shape elif config.massCalculator['patternPeakShape'] == 'gausslorentzian': for isotope in self.currentPattern: peak = mspy.gausslorentzian( x = isotope[0], minY = shift, maxY = isotope[1]*scale+shift, fwhm = config.massCalculator['patternFwhm'] ) self.currentPatternPeaks.append(peak) # make scan object self.currentPatternScan = mspy.scan(profile=self.currentPatternProfile, peaklist=peaklist)