All classes should at least subclass 'object' to avoid being old-style classes.
[hooke.git] / hooke / plugin / generaltccd.py
1 '''
2 generaltccd.py
3
4 General utilities for TCCD stuff
5 '''
6
7 class generaltccdCommands(object):
8
9     def plotmanip_threshold(self, plot, current, customvalue=False):
10         '''
11         Cuts from the plot everything below the threshold.
12         Set the threshold with "set tccd_threshold"
13         '''
14
15         if current.curve.experiment != 'smfluo':
16             return plot
17
18         if not self.config['tccd_threshold'] and (not customvalue):
19             return plot
20
21         if customvalue:
22             thresh=customvalue
23         else:
24             thresh=self.config['tccd_threshold']
25
26         for set in plot.vectors:
27             newy=[]
28             for value in set[1]:
29                 if abs(value) < thresh:
30                     newy.append(0)
31                 else:
32                     newy.append(value)
33
34             set[1]=newy
35
36         return plot
37
38
39     def plotmanip_coincident(self,plot,current, customvalue=False):
40         '''
41         Shows only coincident events
42         '''
43         if current.curve.experiment != 'smfluo':
44             return plot
45
46         if not self.config['tccd_coincident'] and (not customvalue):
47             return plot
48
49         newred=[]
50         newblue=[]
51         for index in range(len(plot.vectors[0][1])):
52             if abs(plot.vectors[0][1][index])>self.config['tccd_threshold'] and abs(plot.vectors[1][1][index])>self.config['tccd_threshold']:
53                 newred.append(plot.vectors[0][1][index])
54                 newblue.append(plot.vectors[1][1][index])
55             else:
56                 newred.append(0)
57                 newblue.append(0)
58
59         plot.vectors[0][1]=newred
60         plot.vectors[1][1]=newblue
61
62         return plot