c9ab2cc4e871a24d344b5440933b98c71cb91433
[hooke.git] / hooke / plugin / showconvoluted.py
1 # Copyright (C) 2009-2012 Rolf Schmidt <rschmidt@alcor.concordia.ca>
2 #                         W. Trevor King <wking@tremily.us>
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 """This plugin contains a plotmanipulator to show the convoluted curve.
20 """
21
22 import libpeakspot
23
24 class showconvolutedCommands:
25
26     #def _plug_init(self):
27         #pass
28
29     def plotmanip_showconvoluted(self, plot, curve):
30         '''
31         BEGIN: taken from procplots.py
32         might need some tweaking
33         '''
34         #use only for force spectroscopy experiments!
35         if curve.driver.experiment != 'smfs':
36             return plot
37
38         '''
39         END: taken from procplots.py
40         '''
41
42         #need to convert the string that contains the list into a list
43         #convolution = eval(self.config['convfilt']['convolution']['value'])
44         convolution = eval(self.GetStringFromConfig('flatfilts', 'convfilt', 'convolution'))
45
46         xRet = plot.vectors[1][0]
47         yRet = plot.vectors[1][1]
48         convoluted = libpeakspot.conv_dx(yRet, convolution)
49         #convoluted=libpeakspot.conv_dx(yRet, [-20, -10, -6, 0, 12, 12, 12])
50         plot.add_set(xRet, convoluted)
51         #plot.vectors[1][1]=[i for i in convoluted]
52         #set contact point plot style to 'plot'
53         #and the color to red
54         plot.styles.append('plot')
55         plot.colors.append('black')
56         #peak_location, peak_size = self.has_peaks(plot, blindwindow, convolution, minpeaks)
57         peak_locations, peak_sizes = self.has_peaks(plot, curve)
58
59         if peak_locations:
60             peak_locations_x = []
61             peak_locations_y = []
62             for location in peak_locations:
63                 peak_locations_x.append(xRet[location])
64                 peak_locations_y.append(yRet[location])
65             plot.add_set(peak_locations_x, peak_locations_y)
66             plot.styles.append('scatter')
67             plot.colors.append('green')
68             plot.add_set(peak_locations_x, peak_sizes)
69             plot.styles.append('scatter')
70             plot.colors.append('magenta')
71
72         #Return the plot object.
73         return plot