Merged force clamp patches by Marco Brucale
authordevicerandom <devnull@localhost>
Tue, 27 May 2008 09:35:36 +0000 (09:35 +0000)
committerdevicerandom <devnull@localhost>
Tue, 27 May 2008 09:35:36 +0000 (09:35 +0000)
generalclamp.py
hemingclamp.py
hooke.conf

index 9390146b01b628d51ac0452f5505dca9e9d94a6b..477454e0536e51b9d7b52623a6c0f1a01656b830 100644 (file)
@@ -6,28 +6,68 @@ GENERALCLAMP.py
 Plugin regarding general force clamp measurements
 '''
 from libhooke import WX_GOOD, ClickedPoint
-import wxversion
+import wxversion\r
+import libhookecurve as lhc
 wxversion.select(WX_GOOD)
-from wx import PostEvent
+from wx import PostEvent\r
 
-class generalclampCommands:
-    
-        
-    def do_showdefl(self,args):
+class generalclampCommands:\r
+\r
+    def plotmanip_clamp(self, plot, current, customvalue=False):
         '''
-        SHOWDEFL
-        Shows the deflection plot for a force clamp curve.
-        Use 'close' to close the plot.
-        ---
-        Syntax: showdefl
+        Handles some viewing options for the "force clamp" data format, depending on the state of these configuration variables:\r
+        (1) If self.config['fc_showphase'] != 0, the 'phase' data column (i.e. the 2nd) is shown in the 0th graph (else it isn't)\r
+        (2) If self.config['fc_showimposed'] != 0, the 'imposed deflection' data column (i.e. the 5th) is shown in the 1st graph (else it isn't)\r
+        (3) If self.config['fc_interesting'] == 0, the entire curve is shown in the graphs; if it has a non-zero value N, only phase N is shown.
+\r
+        NOTE - my implementation of point(3) feels quite awkward - someone smarter than me plz polish that!\r
+\r
         '''
-        if self.current.curve.experiment != 'clamp':
-            print 'This command makes no sense for a non-force clamp experiment!'
-        else:
-            self.current.vectors_to_plot(self.config['correct'],self.config['medfilt'],yclamp='defl')
-            plot_graph=self.list_of_events['plot_graph']       
-            wx.PostEvent(self.frame,plot_graph(current=self.current,xaxes=self.config['xaxes'],yaxes=self.config['yaxes'], destination=1))
-    
+        
+        #not a fclamp curve...
+        if current.curve.experiment != 'clamp':
+            return plot\r
+\r
+        if self.config['fc_interesting'] != 0 and plot.destination==0:\r
+            lower = int((self.config['fc_interesting'])-1)\r
+            upper = int((self.config['fc_interesting'])+1)\r
+            trim = current.curve.trimindexes()[lower:upper]\r
+            newtime = []\r
+            newzpiezo = []\r
+            newphase = []\r
+            for x in range(trim[0],trim[1]):\r
+                newtime.append(self.plots[0].vectors[0][0][x])\r
+                newzpiezo.append(self.plots[0].vectors[0][1][x])\r
+                newphase.append(self.plots[0].vectors[1][1][x])\r
+            self.plots[0].vectors[0][0] = newtime\r
+            self.plots[0].vectors[0][1] = newzpiezo\r
+            self.plots[0].vectors[1][0] = newtime\r
+            self.plots[0].vectors[1][1] = newphase\r
+\r
+        if self.config['fc_interesting'] != 0 and plot.destination==1:\r
+            lower = int((self.config['fc_interesting'])-1)\r
+            upper = int((self.config['fc_interesting'])+1)\r
+            trim = current.curve.trimindexes()[lower:upper]\r
+            newtime = []\r
+            newdefl = []\r
+            newimposed = []\r
+            for x in range(trim[0],trim[1]):\r
+                newtime.append(self.plots[1].vectors[0][0][x])\r
+                newdefl.append(self.plots[1].vectors[0][1][x])\r
+                newimposed.append(self.plots[1].vectors[1][1][x])\r
+            self.plots[1].vectors[0][0] = newtime\r
+            self.plots[1].vectors[0][1] = newdefl\r
+            self.plots[1].vectors[1][0] = newtime\r
+            self.plots[1].vectors[1][1] = newimposed            \r
+                        \r
+        if self.config['fc_showphase'] == 0 and plot.destination==0:\r
+            self.plots[0].remove_set(1)\r
+            \r
+        if self.config['fc_showimposed'] == 0 and plot.destination==1:\r
+            self.plots[1].remove_set(1)\r
+                         \r
+        return plot
+      
     def do_time(self,args):
         '''
         TIME
@@ -36,11 +76,10 @@ class generalclampCommands:
         ----
         Syntax: time
         '''
-        if self.current.curve.experiment == 'clamp':
+        if self.current.curve.experiment == 'clamp':\r
             print 'Click two points.'
-            points=self._measure_N_points(N=2)
-            time=abs(points[0].graph_coords[0]-points[1].graph_coords[0])
-            print str(time)+' s'
+            time=self._delta(set=0)[0]\r
+            print str(time*1000)+' ms'
         else:
             print 'This command makes no sense for a non-force clamp experiment.'
             
index bc2bc1dcbb1a498f8cd9d1047d1559b3c6b2fd48..780c5cb9b6e40850def787137bbc92341982ad95 100755 (executable)
@@ -69,32 +69,52 @@ class hemingclampDriver(lhc.Driver):
             return False
         
     def _getdata_all(self):
-        time = []
+        time = []\r
+        phase = []
         zpiezo = []
-        defl = []
-                
+        defl = []\r
+        imposed = []\r
+        trim_indexes = []\r
+        trim_counter = 0.0\r
+                        
         for i in self.data:
             temp = string.split(i)
-            #time.append(float(temp[0])*(1.0e-3))
+            #time.append(float(temp[0])*(1.0e-3)) # This is managed differently now, since each data point = 1ms: see below
+            phase.append(float(temp[1])*(1.0e-7)) # The nonsensical (e-7) multiplier is just there to make phase data nicely plottable along other data\r
             zpiezo.append(float(temp[2])*(1.0e-9))
-            defl.append(float(temp[3])*(1.0e-9))
-        
+            defl.append(float(temp[3])*(1.0e-9))\r
+            imposed.append(float(temp[4])*(1.0e-9))\r
+\r
+        for x in range (0,len(phase)):
+            if phase[x] != trim_counter:
+                trim_indexes.append(x)
+                trim_counter = phase[x]\r
+       
         #we rebuild the time counter assuming 1 point = 1 millisecond
         c=0.0
         for z in zpiezo:
             time.append(c)
-            c+=(1.0e-3)
+            c+=(1.0e-3)            
             
-        return time,zpiezo,defl
+        return time,phase,zpiezo,defl,imposed,trim_indexes
         
     def time(self):
         return DataChunk(self._getdata_all()[0])
-     
+\r
+    def phase(self):
+        return DataChunk(self._getdata_all()[1])\r
+    
     def zpiezo(self):
-        return DataChunk(self._getdata_all()[1])
+        return DataChunk(self._getdata_all()[2])
      
     def deflection(self):
-        return DataChunk(self._getdata_all()[2])
+        return DataChunk(self._getdata_all()[3])
+\r
+    def imposed(self):
+        return DataChunk(self._getdata_all()[4])\r
+\r
+    def trimindexes(self):\r
+        return DataChunk(self._getdata_all()[5])\r
     
     def close_all(self):
         '''
@@ -106,18 +126,20 @@ class hemingclampDriver(lhc.Driver):
         main_plot=lhc.PlotObject()
         defl_plot=lhc.PlotObject()
         
-        time=self.time()
+        time=self.time()\r
+        phase=self.phase()
         zpiezo=self.zpiezo()
-        deflection=self.deflection()
-        
-        main_plot.vectors=[[time,zpiezo]]
+        deflection=self.deflection()\r
+        imposed=self.imposed()\r
+                
+        main_plot.vectors=[[time,zpiezo],[time,phase]]
         main_plot.units=['seconds','meters']
         main_plot.destination=0
         main_plot.title=self.filename
         
-        defl_plot.vectors=[[time,deflection]]
+        defl_plot.vectors=[[time,deflection],[time,imposed]]
         defl_plot.units=['seconds','Newtons']
-        defl_plot.destination=1
-        
+        defl_plot.destination=1\r
         return [main_plot, defl_plot]
     
\ No newline at end of file
index 2fc002d9bc1768ee0be3a07b21b5c8f9da3d6a6a..b6756469b33787a2a3209d1b51d2deb4eeec18b9 100755 (executable)
@@ -2,13 +2,13 @@
 <!-- To comment something, put dashes and ! like here -->
 <config>
 <!-- Internal variabls. -->
-    <display ext="1" colour_ext="None" ret="1" colour_ret="None" correct="1" colour_correct="None" contact_point="0" medfilt="0" xaxes="0" yaxes="0" flatten="1" temperature="293" auto_fit_points="50" auto_slope_span="20" auto_delta_force="10"/>
+    <display ext="1" colour_ext="None" ret="1" colour_ret="None" correct="1" colour_correct="None" contact_point="0" medfilt="0" xaxes="0" yaxes="0" flatten="1" temperature="293" auto_fit_points="50" auto_slope_span="20" auto_delta_force="10" fc_showphase="0" fc_showimposed="0" fc_interesting="0"/>
 
 <!-- 
-This section defines the work directory. Change to your favourite work directory.
+The following section defines your own work directory. Substitute your work directory.
      -->
 <workdir>
-    your_own_directory
+    insert directory
 </workdir>
 
 <!--
@@ -46,6 +46,8 @@ and (importantly) their order.
     <median/>
     <!-- absvalue/ -->
     <flatten/>
+    <clamp/>
 </plotmanips>
 
 </config>
+