Run update-copyright.py.
[hooke.git] / hooke / plugin / tccd.py
1 # Copyright (C) 2009-2012 Massimo Sandal <devicerandom@gmail.com>
2 #                         W. Trevor King <wking@drexel.edu>
3 #
4 # This file is part of Hooke.
5 #
6 # Hooke is free software: you can redistribute it and/or modify it under the
7 # terms of the GNU Lesser General Public License as published by the Free
8 # Software Foundation, either version 3 of the License, or (at your option) any
9 # later version.
10 #
11 # Hooke is distributed in the hope that it will be useful, but WITHOUT ANY
12 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13 # A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
14 # details.
15 #
16 # You should have received a copy of the GNU Lesser General Public License
17 # along with Hooke.  If not, see <http://www.gnu.org/licenses/>.
18
19 """General utilities for TCCD stuff
20 """
21
22 class generaltccdCommands(object):
23
24     def plotmanip_threshold(self, plot, current, customvalue=False):
25         '''
26         Cuts from the plot everything below the threshold.
27         Set the threshold with "set tccd_threshold"
28         '''
29
30         if current.curve.experiment != 'smfluo':
31             return plot
32
33         if not self.config['tccd_threshold'] and (not customvalue):
34             return plot
35
36         if customvalue:
37             thresh=customvalue
38         else:
39             thresh=self.config['tccd_threshold']
40
41         for set in plot.vectors:
42             newy=[]
43             for value in set[1]:
44                 if abs(value) < thresh:
45                     newy.append(0)
46                 else:
47                     newy.append(value)
48
49             set[1]=newy
50
51         return plot
52
53
54     def plotmanip_coincident(self,plot,current, customvalue=False):
55         '''
56         Shows only coincident events
57         '''
58         if current.curve.experiment != 'smfluo':
59             return plot
60
61         if not self.config['tccd_coincident'] and (not customvalue):
62             return plot
63
64         newred=[]
65         newblue=[]
66         for index in range(len(plot.vectors[0][1])):
67             if abs(plot.vectors[0][1][index])>self.config['tccd_threshold'] and abs(plot.vectors[1][1][index])>self.config['tccd_threshold']:
68                 newred.append(plot.vectors[0][1][index])
69                 newblue.append(plot.vectors[1][1][index])
70             else:
71                 newred.append(0)
72                 newblue.append(0)
73
74         plot.vectors[0][1]=newred
75         plot.vectors[1][1]=newblue
76
77         return plot