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