3 """@namespace IMP.isd.History
4 Classes to store output from replicas.
11 """Class that contains the output of one replica, used by the
14 def __init__(self, filename):
15 self.filename = filename
18 def create_category(self, name):
21 def create_entry(self, cat, name):
22 if not cat
in self.data:
23 self.create_category(cat)
24 self.data[cat][name]=[]
26 def add_data(self, cat, name, data):
27 self.data[cat][name].append(data)
30 """checks if all entries have same length and are of constant type"""
34 for name
in self.data[cat]:
36 goodlen = len(self.data[cat][name])
37 if len(self.data[cat][name]) != goodlen:
38 print "category %s entry %s : length %s expected, got %s"\
39 % (cat, name, goodlen, len(self.data[cat][name]))
41 goodtype = type(self.data[cat][name][0])
42 for ent
in self.data[cat][name]:
43 if type(ent) != goodtype:
44 print "category %s entry %s : %s expected, got %s"\
45 % (cat, name, goodtype, type(ent))
48 def get_data(self, cat, name):
49 return self.data[cat][name]
51 def get_categories(self):
52 i=sorted(self.data.keys())
58 def get_entries(self,cat):
59 i=sorted(self.data[cat].keys())
67 for name
in self.data[cat]:
68 self.data[cat][name] = [i
for i
in self.data[cat][name] \
71 def toc(self, out=sys.stdout):
72 """print the "table of contents" of this History
73 tendency is a comparison of the last 200 frames, and whether it goes up
75 mean100 is the average over the last 100 frames
77 if not type(out) == file:
79 out.write(
"category\tkey_name\tn_frames\ttype\taverage\tstd\tmean100\ttendency\n")
82 for name
in self.data[cat]:
83 ent=self.data[cat][name]
93 avg100=numpy.mean(ent[-100:])
94 avg200=numpy.mean(ent[-200:-100])
96 st200=numpy.std(ent[-200])
97 if st200 ==0
or abs(avg200 - avg100)/st200 > 3:
104 out.write(
"\t%20s\t%12d\t%20s\t%10f\t%10f\t%10f\t%5s\n" % \
105 (name, len(ent),tp,avg,st,avg100,tend))
109 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.