HookeGUI
authorillysam <devnull@localhost>
Mon, 22 Feb 2010 20:29:30 +0000 (20:29 +0000)
committerillysam <devnull@localhost>
Mon, 22 Feb 2010 20:29:30 +0000 (20:29 +0000)
added curvetools.ini
added curvetools.py
added multidistance.ini
added multidistance.py

plugins/curvetools.ini [new file with mode: 0644]
plugins/curvetools.py [new file with mode: 0644]
plugins/multidistance.ini [new file with mode: 0644]
plugins/multidistance.py [new file with mode: 0644]

diff --git a/plugins/curvetools.ini b/plugins/curvetools.ini
new file mode 100644 (file)
index 0000000..d3f5a12
--- /dev/null
@@ -0,0 +1 @@
+\r
diff --git a/plugins/curvetools.py b/plugins/curvetools.py
new file mode 100644 (file)
index 0000000..cd00fc6
--- /dev/null
@@ -0,0 +1,48 @@
+#!/usr/bin/env python\r
+# -*- coding: utf-8 -*-\r
+\r
+'''\r
+curvetools.py\r
+\r
+General library of peak detection related functions.\r
+\r
+Copyright ???? by ?\r
+with modifications by Dr. Rolf Schmidt (Concordia University, Canada)\r
+\r
+This program is released under the GNU General Public License version 2.\r
+'''\r
+\r
+class curvetoolsCommands:\r
+\r
+    def fit_interval_nm(self, start_index, x_vect, nm, backwards):\r
+        '''\r
+        Calculates the number of points to fit, given a fit interval in nm\r
+        start_index: index of point\r
+        plot: plot to use\r
+        backwards: if true, finds a point backwards.\r
+        '''\r
+\r
+        c = 0\r
+        i = start_index\r
+        maxlen=len(x_vect)\r
+        while abs(x_vect[i] - x_vect[start_index]) * (10**9) < nm:\r
+            if i == 0 or i == maxlen-1: #we reached boundaries of vector!\r
+                return c\r
+            if backwards:\r
+                i -= 1\r
+            else:\r
+                i += 1\r
+            c += 1\r
+        return c\r
+\r
+    def pickup_contact_point(self, filename=''):\r
+        '''\r
+        macro to pick up the contact point by clicking\r
+        '''\r
+\r
+        contact_point = self._measure_N_points(N=1, message='Please click on the contact point.')[0]\r
+        contact_point_index = contact_point.index\r
+        self.wlccontact_point = contact_point\r
+        self.wlccontact_index = contact_point.index\r
+        self.wlccurrent = filename\r
+        return contact_point, contact_point_index\r
diff --git a/plugins/multidistance.ini b/plugins/multidistance.ini
new file mode 100644 (file)
index 0000000..778aef4
--- /dev/null
@@ -0,0 +1,83 @@
+[multidistance]\r
+    [[apply_plotmanipulators]]\r
+        default = all\r
+        elements = all, flatten, none\r
+        type = enum\r
+        value = all\r
+    \r
+    [[blindwindow]]\r
+        default = 20\r
+        maximum = 10000\r
+        minimum = 0\r
+        type = float\r
+        value = 20\r
+    \r
+    [[color]]\r
+        default = black\r
+        type = color\r
+        value = "(0,0,0)"\r
+    \r
+    [[convolution]]\r
+        default = "[6.0, -1.0, -1.0, -1.0, -1.0, -1.0, -1.0]"\r
+        type = string\r
+        value = "[6.0,-1.0,-1.0,-1.0,-1.0,-1.0,-1.0]"\r
+    \r
+    [[maxcut]]\r
+        default = 0.2\r
+        maximum = 1\r
+        minimum = 0\r
+        type = float\r
+        value = 0.2\r
+        visible = False\r
+    \r
+    [[medianfilter]]\r
+        default = 7\r
+        maximum = 100\r
+        minimum = 0\r
+        type = integer\r
+        value = 7\r
+    \r
+    [[mindeviation]]\r
+        default = 5\r
+        maximum = 100\r
+        minimum = 0\r
+        type = float\r
+        value = 5\r
+    \r
+    [[minpeaks]]\r
+        default = 5\r
+        maximum = 20\r
+        minimum = 0\r
+        type = integer\r
+        value = 5\r
+    \r
+    [[positive]]\r
+        default = False\r
+        type = boolean\r
+        value = False\r
+    \r
+    [[seedouble]]\r
+        default = 10\r
+        maximum = 1000\r
+        minimum = 0\r
+        type = integer\r
+        value = 10\r
+    \r
+    [[size]]\r
+        default = 20\r
+        maximum = 10000\r
+        minimum = 1\r
+        type = integer\r
+        value = 20\r
+    \r
+    [[stable]]\r
+        default = 0.005\r
+        maximum = 1\r
+        minimum = 0\r
+        type = float\r
+        value = 0.005\r
+    \r
+    [[use_convfilt]]\r
+        default = False\r
+        type = boolean\r
+        value = False\r
diff --git a/plugins/multidistance.py b/plugins/multidistance.py
new file mode 100644 (file)
index 0000000..77b08fa
--- /dev/null
@@ -0,0 +1,85 @@
+#!/usr/bin/env python\r
+# -*- coding: utf-8 -*-\r
+\r
+'''\r
+multidistance.py\r
+\r
+Calculates the distances between peaks.\r
+\r
+Copyright 2010 by Fabrizio Benedetti\r
+with modifications by Dr. Rolf Schmidt (Concordia University, Canada)\r
+\r
+This program is released under the GNU General Public License version 2.\r
+'''\r
+\r
+import lib.libhooke as lh\r
+import wxversion\r
+wxversion.select(lh.WX_GOOD)\r
+\r
+import copy\r
+from numpy import RankWarning\r
+import os.path\r
+import time\r
+\r
+import warnings\r
+warnings.simplefilter('ignore', RankWarning)\r
+\r
+import lib.plugin\r
+import lib.results\r
+\r
+class multidistanceCommands:\r
+\r
+    def do_multidistance(self):\r
+        '''\r
+        MULTIDISTANCE\r
+        multidistance.py\r
+        Based on the convolution recognition automatically gives the distances between the peaks found.\r
+        The command allows also to remove the unwanted peaks that can be due to interference.\r
+        When you first issue the command, it will ask for a filename. If you are giving a filename\r
+        of an existing file, autopeak will resume it and append measurements to it. If you are giving\r
+        a new filename, it will create the file and append to it until you close Hooke.\r
+        You can also define a minimun deviation of the peaks.\r
+\r
+        Syntax:\r
+        multidistance [deviation]\r
+        deviation = number of times the convolution signal is above the noise absolute deviation.\r
+        '''\r
+\r
+        color = self.GetColorFromConfig('multidistance', 'color')\r
+        size = self.GetIntFromConfig('multidistance', 'size')\r
+        use_convfilt = self.GetBoolFromConfig('multidistance', 'use_convfilt')\r
+\r
+        plot = self.GetDisplayedPlotCorrected()\r
+        if use_convfilt:\r
+            peak_location, peak_size = self.has_peaks(plot)\r
+        else:\r
+            plugin = lib.plugin.Plugin()\r
+            plugin.name = 'multidistance'\r
+            plugin.section = 'multidistance'\r
+            peak_location, peak_size = self.has_peaks(plot, plugin)\r
+\r
+        #if no peaks, we have nothing to plot. exit.\r
+        if len(peak_location) == 0:\r
+            self.AppendToOutput('No peaks found.')\r
+            return\r
+\r
+        retraction = plot.curves[lh.RETRACTION]\r
+        results = lib.results.ResultsMultiDistance()\r
+\r
+        for peak in peak_location:\r
+            result = lib.results.Result()\r
+            result.result['Distance'] = retraction.x[peak]\r
+            result.color = color\r
+            result.size = size\r
+            result.x = retraction.x[peak]\r
+            result.y = retraction.y[peak]\r
+            results.results.append(result)\r
+\r
+        results.update()\r
+\r
+        self.results_str = 'multidistance'\r
+\r
+        results.set_multipliers(-1)\r
+        plot = self.GetActivePlot()\r
+        plot.results['multidistance'] = results\r
+        self.UpdatePlot()\r