3 """@namespace IMP.isd.History
4 Classes to store output from replicas.
13 """Class that contains the output of one replica, used by the
17 def __init__(self, filename):
18 self.filename = filename
21 def create_category(self, name):
24 def create_entry(self, cat, name):
25 if not cat
in self.data:
26 self.create_category(cat)
27 self.data[cat][name] = []
29 def add_data(self, cat, name, data):
30 self.data[cat][name].append(data)
33 """checks if all entries have same length and are of constant type"""
37 for name
in self.data[cat]:
39 goodlen = len(self.data[cat][name])
40 if len(self.data[cat][name]) != goodlen:
41 print "category %s entry %s : length %s expected, got %s"\
42 % (cat, name, goodlen, len(self.data[cat][name]))
44 goodtype = type(self.data[cat][name][0])
45 for ent
in self.data[cat][name]:
46 if not isinstance(ent, goodtype):
47 print "category %s entry %s : %s expected, got %s"\
48 % (cat, name, goodtype, type(ent))
51 def get_data(self, cat, name):
52 return self.data[cat][name]
54 def get_categories(self):
55 i = sorted(self.data.keys())
61 def get_entries(self, cat):
62 i = sorted(self.data[cat].keys())
70 for name
in self.data[cat]:
71 self.data[cat][name] = [i
for i
in self.data[cat][name]
74 def toc(self, out=sys.stdout):
75 """print the "table of contents" of this History
76 tendency is a comparison of the last 200 frames, and whether it goes up
78 mean100 is the average over the last 100 frames
80 if not isinstance(out, file):
83 "category\tkey_name\tn_frames\ttype\taverage\tstd\tmean100\ttendency\n")
86 for name
in self.data[cat]:
87 ent = self.data[cat][name]
95 ent = numpy.array(ent)
97 avg100 = numpy.mean(ent[-100:])
98 avg200 = numpy.mean(ent[-200:-100])
100 st200 = numpy.std(ent[-200])
101 if st200 == 0
or abs(avg200 - avg100) / st200 > 3:
109 "\t%20s\t%12d\t%20s\t%10f\t%10f\t%10f\t%5s\n" %
110 (name, len(ent), tp, avg, st, avg100, tend))
114 out.write(
"\t%20s\t%12d\t%20s\n" % (name, len(ent), tp))
def sanity_check
checks if all entries have same length and are of constant type
def toc
print the "table of contents" of this History tendency is a comparison of the last 200 frames...
Class that contains the output of one replica, used by the Analysis class.