54 if line[0] ==
'*' or line[0] ==
'!':
59 if fields[0].isalpha():
61 label =
int(fields[0])
62 value = float(fields[1])
63 if label
not in results:
65 results[label].append(value)
69 print(
' comparing MP2 results files')
71 print(
' input file1 ', name1)
74 print(
' input file2 ', name2)
78 sn = sx = sy = sxx = sxy = syy = 0.
79 fout = open(name3,
'w')
80 fout.write(
"label/I:value_1/F:value_2/F\n")
81 for l
in sorted(results.keys()):
85 if r[0] != 0.
or r[1] != 0.:
86 fout.write(
"%10d %12.5g %12.5g \n" % (l, r[0], r[1]))
87 sn += 1.; sx += r[0]; sy += r[1]; sxx += r[0] * r[0]; sxy += r[0] * r[1]; syy += r[1] * r[1]
91 fout.write(
"%10d %12.5g %12.5g \n" % (-l, r[0], r[0]))
92 print(
' unmatched ', l)
95 print(
' output file ', name3)
96 print(
' total parameters ', len(results))
102 print(
' matched parameters ', matched)
104 print(
' mean1, mean2 ', sx, sy)
106 print(
' rms1, rms2 ', math.sqrt(sxx - sx * sx), math.sqrt(syy - sy * sy))
108 print(
' correlation ', (sxy - sx * sy) / (math.sqrt(sxx - sx * sx) * math.sqrt(syy - sy * sy)))
111if __name__ ==
'__main__':
113 fileNameIn1 =
"millepede.res1"
114 fileNameIn2 =
"millepede.res2"
116 fileNameOut =
"mp2compare.txt"
121 print(
" usage: compareResults.py <input file name1> <input file name2> [<output file name>]")
124 fileNameIn1 = sys.argv[1]
125 fileNameIn2 = sys.argv[2]
127 fileNameOut = sys.argv[3]
def combineFiles(name1, name2, name3)
Combine two MP-II result files.