ad76521f7a5fc7061a390784f037496a21af1e5f
[hooke.git] / hooke / plugin / showconvoluted.py
1 # Copyright
2
3 """This plugin contains a plotmanipulator to show the convoluted curve.
4 """
5
6 import libpeakspot
7
8 class showconvolutedCommands:
9
10     #def _plug_init(self):
11         #pass
12
13     def plotmanip_showconvoluted(self, plot, curve):
14         '''
15         BEGIN: taken from procplots.py
16         might need some tweaking
17         '''
18         #use only for force spectroscopy experiments!
19         if curve.driver.experiment != 'smfs':
20             return plot
21
22         '''
23         END: taken from procplots.py
24         '''
25
26         #need to convert the string that contains the list into a list
27         #convolution = eval(self.config['convfilt']['convolution']['value'])
28         convolution = eval(self.GetStringFromConfig('flatfilts', 'convfilt', 'convolution'))
29
30         xRet = plot.vectors[1][0]
31         yRet = plot.vectors[1][1]
32         convoluted = libpeakspot.conv_dx(yRet, convolution)
33         #convoluted=libpeakspot.conv_dx(yRet, [-20, -10, -6, 0, 12, 12, 12])
34         plot.add_set(xRet, convoluted)
35         #plot.vectors[1][1]=[i for i in convoluted]
36         #set contact point plot style to 'plot'
37         #and the color to red
38         plot.styles.append('plot')
39         plot.colors.append('black')
40         #peak_location, peak_size = self.has_peaks(plot, blindwindow, convolution, minpeaks)
41         peak_locations, peak_sizes = self.has_peaks(plot, curve)
42
43         if peak_locations:
44             peak_locations_x = []
45             peak_locations_y = []
46             for location in peak_locations:
47                 peak_locations_x.append(xRet[location])
48                 peak_locations_y.append(yRet[location])
49             plot.add_set(peak_locations_x, peak_locations_y)
50             plot.styles.append('scatter')
51             plot.colors.append('green')
52             plot.add_set(peak_locations_x, peak_sizes)
53             plot.styles.append('scatter')
54             plot.colors.append('magenta')
55
56         #Return the plot object.
57         return plot