@@ -42,20 +42,12 @@ def getKineticsDepository(family, depositoryLabel, missingGroups):
4242 approxKinetics = {}
4343
4444 for key , entry in depository .entries .iteritems ():
45- try :
46- reaction = entry .item
47- template = family .getReactionTemplate (reaction )
48- exactKinetics [key ]= entry .data
49- approxKinetics [key ]= family .rules .estimateKinetics (template )[0 ]
50-
51-
52- except UndeterminableKineticsError :
53- missingGroups .append ([family .label , key , 'No Template found' ])
54-
55- except Exception as inst :
56- missingGroups .append ([family .label , key , 'Other error, needs further investigation' ])
45+ reaction = entry .item
46+ template = family .getReactionTemplate (reaction )
47+ exactKinetics [key ]= entry .data
48+ approxKinetics [key ]= family .rules .estimateKinetics (template )[0 ]
5749
58- return exactKinetics , approxKinetics , missingGroups
50+ return exactKinetics , approxKinetics
5951
6052def getKineticsLeaveOneOut (family , missingGroups ):
6153 """
@@ -71,42 +63,19 @@ def getKineticsLeaveOneOut(family, missingGroups):
7163 index = 0
7264 for entryKey in entryKeys :
7365 index += 1
74- # templateKeys=re.split(';', entryKey)
75- # print entryKey, templateKeys, index
76- try :
77- # print entryKey
78- template = family .getReactionTemplate (family .rules .entries [entryKey ][0 ].item )
79-
80- print entryKey , [templateEntry .label for templateEntry in template ], index
81- exactKinetics [entryKey ], exactKineticsEntry = family .rules .estimateKinetics (template )
82-
83- familyCopy = copy .deepcopy (family )
84- familyCopy .rules .entries .pop (entryKey )
85- familyCopy .fillKineticsRulesByAveragingUp ()
86-
87- approxKinetics [entryKey ], approxKineticsEntry = familyCopy .rules .estimateKinetics (template )
88-
89- except UndeterminableKineticsError :
90- missingGroups .append ([family .label , re .split (';' , entryKey ), 'No Template found' ])
66+ template = family .getReactionTemplate (family .rules .entries [entryKey ][0 ].item )
67+
68+ print entryKey , [templateEntry .label for templateEntry in template ], index
69+ exactKinetics [entryKey ], exactKineticsEntry = family .rules .estimateKinetics (template )
9170
92- except Exception as inst :
93- missingGroups .append ([family .label , re .split (';' , entryKey ), 'Other error, needs further investigation' ])
71+ familyCopy = copy .deepcopy (family )
72+ familyCopy .rules .entries .pop (entryKey )
73+ familyCopy .fillKineticsRulesByAveragingUp ()
9474
95- except AttributeError :
96- # if family.label in logicErrorNodes.keys():
97- # logicErrorNodes[family.label].append(entryKey)
98- # else:
99- # logicErrorNodes[family.label]=[entryKey]
100- pass #maybe add more later
101-
102- return exactKinetics , approxKinetics , missingGroups
103-
104- #returns the average temperature for the range given by the kinetic model
105- def getAverageTemp (kineticModel ):
106- # try:
107- # return (kineticModel.Tmin.value + kineticModel.Tmax.value)/2
108- # except AttributeError:
109- return 1000
75+ approxKinetics [entryKey ], approxKineticsEntry = familyCopy .rules .estimateKinetics (template )
76+
77+ return exactKinetics , approxKinetics
78+
11079
11180#calculates the parity values for each
11281def calculateParity (exactKineticModel , approxKineticModel , T ):
@@ -116,7 +85,7 @@ def calculateParity(exactKineticModel, approxKineticModel, T):
11685 return float (approx )/ float (exact )
11786
11887
119- def analyzeForParity (exactKinetics , approxKinetics , T = None , cutoff = 0 ):
88+ def analyzeForParity (exactKinetics , approxKinetics , T = 1000 , cutoff = 0 ):
12089 """
12190 Creates a parity plot from the exactKinetics and approxKinetics (dictionarys with
12291 kineticModels are entries). Uses the median temperature of the exactKinetics to
@@ -125,9 +94,7 @@ def analyzeForParity(exactKinetics, approxKinetics, T=None, cutoff=0):
12594 """
12695 parityData = {}
12796 for key in approxKinetics :
128- if T is None :
129- T = getAverageTemp (exactKinetics [key ])
130- print exactKinetics [key ]
97+
13198 exact = exactKinetics [key ].getRateCoefficient (T )
13299 approx = approxKinetics [key ].getRateCoefficient (T )
133100 dataPoint = [exact , approx ]
@@ -198,21 +165,6 @@ def countNodes(family):
198165 return countList
199166
200167
201- def getKineticsFromRules (family , entryKey ):
202-
203-
204- family .addKineticsRulesFromTrainingSet (thermoDatabase = FullDatabase .thermo )
205- family .fillKineticsRulesByAveragingUp ()
206-
207- entryKeys = re .split (';' , entryKey )
208-
209- template = []
210- for key in entryKeys :
211- template .append (family .groups .entries [key ])
212-
213- return family .rules .estimateKinetics (template )
214-
215-
216168###########################################################################################################
217169# Functions for the full Database
218170
@@ -270,11 +222,8 @@ def NISTExact(FullDatabase, trialDir):
270222 for key in keysToRemove :
271223 del approxKinetics [key ]
272224
273- try :
274- parityData = analyzeForParity (exactKinetics , approxKinetics , None , 8 )
275- except KeyError :
276- familiesWithErrors .append (family .label )
277- continue
225+ parityData = analyzeForParity (exactKinetics , approxKinetics , None , 8 )
226+
278227 if len (parityData )< 2 :
279228 print ' Skipping' , familyName , ': only one node was calculated...'
280229 continue
@@ -331,13 +280,9 @@ def leaveOneOut(FullDatabase, trialDir):
331280 if len (family .rules .entries ) < 2 :
332281 print ' Skipping' , familyName , ': only has one node...'
333282 else :
334- ##getKineticsLeaveOneOut
335283 exactKinetics , approxKinetics , missingGroups = getKineticsLeaveOneOut (family , missingGroups )
336- try :
337- parityData = analyzeForParity (exactKinetics , approxKinetics , None , 8 )
338- except KeyError :
339- familiesWithErrors .append (family .label )
340- continue
284+ parityData = analyzeForParity (exactKinetics , approxKinetics , None , 8 )
285+
341286 if len (parityData )< 2 :
342287 print ' Skipping' , familyName , ': only one node was calculated...'
343288 continue
@@ -383,15 +328,6 @@ def leaveOneOut(FullDatabase, trialDir):
383328 trialDir = os .path .join (settings ['database.directory' ],'..' ,'testing' ,'eval' )
384329 if not os .path .exists (trialDir ):
385330 os .makedirs (trialDir )
386-
387- family = FullDatabase .kinetics .families ['Disproportionation' ]
388- print family .depositories
389- print FullDatabase .thermo .libraries
390- entryKey = 'Y_1centerbirad;O_Cdrad'
391-
392- retrievedKinetics , retrievedEntry = getKineticsFromRules (family , entryKey )
393-
394- print retrievedKinetics
395331
396332 NISTExact (FullDatabase , trialDir )
397333 countNodesAll (FullDatabase , trialDir )
0 commit comments