def createMultiMers(self): d = self.multiMers[0] dNeu = d for j in range(2,self.elements[-1]+1): #print(j) dNeu = ITFClusterLib.convolute(dNeu,d) dNeu = ITFClusterLib.combineMasses(dNeu, self.mindist) dNeu = ITFClusterLib.applyThresh(dNeu, self.thresh) #print(dNeu) self.multiMers.append(dNeu)
def createClusters(self,elements): # create Cluster from elements dictionary distributions = [] for key in elements.keys(): d = ITFClusterLib.loadAtomicDist(key) n = elements[key] temp = ITFClusterLib.selfConvolute(d,n,self.mmd,self.th) distributions.append(temp) # combine distributions dFinal = distributions[0] for mols in range(len(distributions)-1): dFinal = ITFClusterLib.convolute(dFinal,distributions[mols+1]) dFinal = ITFClusterLib.combineMasses(dFinal, self.mmd) dFinal = ITFClusterLib.applyThresh(dFinal, self.th) return dFinal
def combineClusters(self,startwert='',node='Cluster'): #combine clusters #create lists for cartesian product if self.clusterTree.baum.get_children(node) == (): #am Ende eines Astes #print(startwert) elements, charge = ITFClusterLib.parseFormula(startwert) #print(elements) oneString = ITFClusterLib.oneString(elements, charge) #print(oneString) if oneString in self.combinedClusters.keys(): print('Cluster already in list') else: #create cluster knoten = self.nodes[node] temp = knoten.createClusters(elements) #multiply charged ions: divide masses by charge temp[:,0] = temp[:,0]/float(charge) self.combinedClusters[oneString] = temp # speichern in IFC self.dataIFC.addDist(temp,oneString) return for child in self.clusterTree.baum.get_children(node): knoten = self.nodes[child] if node == 'Cluster': #äusserster Knoten temp = self.clusterTree.baum.item(child,'text') temp = temp.split('{') startwert = temp[3].strip('}') for j in knoten.elements: #print(j) if j > 1: self.combineClusters(startwert+'['+ knoten.sumFormula+']'+str(j),child) elif j == 1: self.combineClusters(startwert+'['+knoten.sumFormula+']',child) else: self.combineClusters(startwert,child)
def genIFCInput(self): # define options for selecting IFC-File # initial directory is folder displayed on screen selectFileOptions = dict(initialdir=self.ordner.wert.get(), defaultextension='.ifc',title='Save cluster data', filetypes=[('IsotopeFit cluster data','*.ifc')], initialfile='cluster.ifc') ifcFilename = filedialog.asksaveasfilename(**selectFileOptions) if ifcFilename == '': # Cancel is clicked return # Loading of existing IFC-file omitted as file was deleted Clusters, numClusters = self.genInputCommon() dataIFC = IFC() for combi in numClusters: dCombi = np.zeros((1,2)) dCombi[0,1] = 1 molname = '' for j in range(len(combi)): mmn = Clusters[j].elements[combi[j]] if mmn > 0: molname = molname+'['+Clusters[j].sumformula+']' if mmn > 1: molname = molname+str(mmn) for j in range(len(combi)): mmn = Clusters[j].elements[combi[j]] if mmn > 0: dCombi = ITFClusterLib.convolute(dCombi,Clusters[j].multiMers[mmn-1]) dCombi = ITFClusterLib.combineMasses(dCombi, Clusters[j].mindist) dCombi = ITFClusterLib.applyThresh(dCombi, Clusters[j].thresh) #multiply charged ions: divide masses by charge dCombi[:,0] = dCombi[:,0]/float(self.charge.wert.get()) # speichern in IFC dataIFC.addDist(dCombi,molname) # speichern der IFC Datei dataIFC.save(ifcFilename) print('Done')
def __init__(self,nlist,name,clist,mmd,th,folder): if '[' in nlist: self.elements = list(map(int,nlist.strip('[]').split(','))) else: temp = list(map(int,nlist.split(':'))) if len(temp) > 2: #step is given self.elements = range(temp.pop(0),temp.pop()+1,temp.pop(0)) else: self.elements = range(temp.pop(0),temp.pop()+1) #print(self.elements) self.name = name self.sumformula = clist self.mindist = mmd self.thresh = th self.multiMers = [] distribution, elements = ITFClusterLib.parseMolecule(clist,mmd,th) self.multiMers.append(distribution) self.createMultiMers()