Ran update_copyright.py.
[hooke.git] / hooke / plugin / showconvoluted.py
1 # Copyright (C) 2009-2012 Rolf Schmidt <rschmidt@alcor.concordia.ca>
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
7 # under the terms of the GNU Lesser General Public License as
8 # published by the Free Software Foundation, either version 3 of the
9 # License, or (at your option) any later version.
10 #
11 # Hooke is distributed in the hope that it will be useful, but WITHOUT
12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 # or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General
14 # Public License for more details.
15 #
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with Hooke.  If not, see
18 # <http://www.gnu.org/licenses/>.
19
20 """This plugin contains a plotmanipulator to show the convoluted curve.
21 """
22
23 import libpeakspot
24
25 class showconvolutedCommands:
26
27     #def _plug_init(self):
28         #pass
29
30     def plotmanip_showconvoluted(self, plot, curve):
31         '''
32         BEGIN: taken from procplots.py
33         might need some tweaking
34         '''
35         #use only for force spectroscopy experiments!
36         if curve.driver.experiment != 'smfs':
37             return plot
38
39         '''
40         END: taken from procplots.py
41         '''
42
43         #need to convert the string that contains the list into a list
44         #convolution = eval(self.config['convfilt']['convolution']['value'])
45         convolution = eval(self.GetStringFromConfig('flatfilts', 'convfilt', 'convolution'))
46
47         xRet = plot.vectors[1][0]
48         yRet = plot.vectors[1][1]
49         convoluted = libpeakspot.conv_dx(yRet, convolution)
50         #convoluted=libpeakspot.conv_dx(yRet, [-20, -10, -6, 0, 12, 12, 12])
51         plot.add_set(xRet, convoluted)
52         #plot.vectors[1][1]=[i for i in convoluted]
53         #set contact point plot style to 'plot'
54         #and the color to red
55         plot.styles.append('plot')
56         plot.colors.append('black')
57         #peak_location, peak_size = self.has_peaks(plot, blindwindow, convolution, minpeaks)
58         peak_locations, peak_sizes = self.has_peaks(plot, curve)
59
60         if peak_locations:
61             peak_locations_x = []
62             peak_locations_y = []
63             for location in peak_locations:
64                 peak_locations_x.append(xRet[location])
65                 peak_locations_y.append(yRet[location])
66             plot.add_set(peak_locations_x, peak_locations_y)
67             plot.styles.append('scatter')
68             plot.colors.append('green')
69             plot.add_set(peak_locations_x, peak_sizes)
70             plot.styles.append('scatter')
71             plot.colors.append('magenta')
72
73         #Return the plot object.
74         return plot