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