Correct number of digits of many output, improvement in the utility 'cut' and 'txt'.
authorfabrizio.benedetti.82 <devnull@localhost>
Fri, 7 May 2010 09:07:54 +0000 (09:07 +0000)
committerfabrizio.benedetti.82 <devnull@localhost>
Fri, 7 May 2010 09:07:54 +0000 (09:07 +0000)
autopeak.py
curvetools.py
cut.py
generalvclamp.py
hooke.conf
hooke_cli.py

index ed4cea8df4fa7b1000d51f7b2e85226904a41d92..41766985b2df43f38db41ec8f22219316e661279 100644 (file)
@@ -256,12 +256,12 @@ class autopeakCommands:
         
         print 'Using fit function: ',self.config['fit_function']
         print 'Measurements for all peaks detected:'
-        print 'contour (nm)', c_lengths
-        print 'sigma contour (nm)',sigma_c_lengths
-        print 'p (nm)',p_lengths
-        print 'sigma p (nm)',sigma_p_lengths
-        print 'forces (pN)',forces
-        print 'slopes (N/m)',slopes
+        print 'contour (nm)', self.print_prec(c_lengths,1)
+        print 'sigma contour (nm)',self.print_prec(sigma_c_lengths,2)
+        print 'p (nm)',self.print_prec(p_lengths,3)
+        print 'sigma p (nm)',self.print_prec(sigma_p_lengths,3)
+        print 'forces (pN)',self.print_prec(forces,1)
+        print 'slopes (N/m)',self.print_prec(slopes,3)
         
         controller=False
         while controller==False:
@@ -300,12 +300,12 @@ class autopeakCommands:
         sigma_p_lengths=[item for item in sigma_p_lengths if item != None]    
         
         print 'Measurements for chosen peaks:'
-        print 'contour (nm)',c_lengths
-        print 'sigma contour (nm)',sigma_c_lengths
-        print 'p (nm)',p_lengths
-        print 'sigma p (nm)',sigma_p_lengths
-        print 'forces (pN)',forces
-        print 'slopes (N/m)',slopes
+        print 'contour (nm)', self.print_prec(c_lengths,1)
+        print 'sigma contour (nm)',self.print_prec(sigma_c_lengths,2)
+        print 'p (nm)',self.print_prec(p_lengths,3)
+        print 'sigma p (nm)',self.print_prec(sigma_p_lengths,3)
+        print 'forces (pN)',self.print_prec(forces,1)
+        print 'slopes (N/m)',self.print_prec(slopes,3)
         
         #Save file info
         if self.autofile=='':
index 51a8fd4868a73a0f9716889386fe92d1a6a2a407..7c16be9c023e6aeb50b85a7fe95bb4b288ac10ea 100755 (executable)
@@ -12,6 +12,17 @@ import time
 
 class curvetoolsCommands:
 
+      def print_prec(self, arr, prec):
+         try:
+           nparr=np.array(arr)
+           np.set_printoptions(precision=prec)
+          #we remove the parentesis if the array is longer that 1
+          if len(nparr)>1:
+            strvals=str(nparr)[1:-1]
+           return strvals
+         except:
+           return "Error in the array."
+
       def fit_interval_nm(self,start_index,plot,nm,backwards):
          '''
          Calculates the number of points to fit, given a fit interval in nm
diff --git a/cut.py b/cut.py
index 975c2d3266e364140593b8760c17ba271bc24bdf..03d1eb483f763af1c7f93bebf2617177755d395e 100644 (file)
--- a/cut.py
+++ b/cut.py
@@ -13,14 +13,15 @@ class cutCommands:
 CUT
         (cut.py)
         Cut the selected signal between two points.
-        With the first parameter you have to select the signal (for FS for example
+       The first parameters is useful to select the window, with a single window wichplot is "0"  (zero).
+        With the second parameter you have to select the signal (for FS for example
         you can select with "0" the approacing curve and 1 for the retracting
        curve. This depend also on how many set of data you have on the graph).
         With the second parameter you select the output name file for the selection.
        The data is arranged in two simple column without a header, the first column
        is the "x" data and the second the "y".
         -----------------
-        Syntax: distance "whatset" "namefile"
+        Syntax: cut "whichplot" "whatset" "namefile"
         '''
         if len(args)==0:
                print "This command need the number of the graph that you want save and a name for the output file."
@@ -28,23 +29,32 @@ CUT
        
        a=args.split()
        
-       
-       whatset=int(a[0])
-       outfile=a[1]
+       whichplot=int(a[0])
+       whatset=int(a[1])
+       outfile=a[2]
        plot=self._get_displayed_plot()
-
+       #print plot
+       
         print 'Select two points'
         points=self._measure_N_points(N=2, whatset=whatset)
        minbound=min(points[0].index, points[1].index)
        maxbound=max(points[0].index, points[1].index)
-        boundpoints=[minbound, maxbound]
-       yarr=plot.vectors[whatset][1][boundpoints[0]:boundpoints[1]]
-       xarr=plot.vectors[whatset][0][boundpoints[0]:boundpoints[1]]
+
+       xarr=[]
+       yarr=[]
+       try:
+         dataset=self.plots[whichplot].vectors[whatset]
+       except:
+          print "Invalid whichplot."
+          return
+        
+       xarr=dataset[0][minbound:maxbound]
+       yarr=dataset[1][minbound:maxbound]
+
+
 
        f=open(outfile,'w+')
        for i in range(len(yarr)):
                f.write(str(xarr[i])+";"+str(yarr[i])+"\n")
         f.close()
 
-
-
index 07953128ef62dba29933dc5c264148cab6156d01..2c3f655f62b5e358884a25ec3715874b42154882 100644 (file)
@@ -1,5 +1,5 @@
 #!/usr/bin/env python
-# -*- coding: iso-8859-1 -*-
+# -*- coding: utf-8 -*-
 
 '''
 generalvclamp.py
@@ -44,7 +44,7 @@ class generalvclampCommands:
             return
         else:
             dx,unitx,dy,unity=self._delta(set=1)
-            print str(dx*(10**9))+' nm'
+            print "%.1f nm" %(dx*(10**9))
             to_dump='distance '+self.current.path+' '+str(dx*(10**9))+' nm'
             self.outlet.push(to_dump)
 
@@ -61,7 +61,7 @@ class generalvclampCommands:
             print 'This command makes no sense for a force clamp experiment.'
             return
         dx,unitx,dy,unity=self._delta(set=1)
-        print str(dy*(10**12))+' pN'
+        print " %.1f pN"%(dy*(10**12))
         to_dump='force '+self.current.path+' '+str(dy*(10**12))+' pN'
         self.outlet.push(to_dump)
         
@@ -118,7 +118,7 @@ class generalvclampCommands:
         
         avg=np.mean(to_average)
         forcebase=abs(y-avg)
-        print str(forcebase*(10**12))+' pN'
+        print "%.1f pN"%(forcebase*(10**12))
         to_dump='forcebase '+self.current.path+' '+str(forcebase*(10**12))+' pN'
         self.outlet.push(to_dump)
 
index 3a49693c093fd856dfea14df4638b1e3feb6cf55..48d83daebf4847a392be3689cba0c8f40d85fb04 100755 (executable)
@@ -38,8 +38,9 @@ This section defines which plugins have to be loaded by Hooke.
     <pcluster/>\r
     <generaltccd/>\r
     <multidistance/>\r
-    <jumpstat/>
-    <review/>
+    <jumpstat/>\r
+    <review/>\r
+    <cut/>\r
     <multifit/>                \r
 </plugins>\r
 \r
@@ -54,8 +55,8 @@ This section defines which drivers have to be loaded by Hooke.
     <!-- tutorialdriver/ -->\r
     <jpk/>\r
     <mfp1dexport/>\r
-    <mcs/>
-    <!-- hdf5/ -->
+    <mcs/>\r
+    <!-- hdf5/ -->\r
     <mfp3d/>                   \r
 </drivers>\r
 \r
@@ -71,7 +72,7 @@ and -IMPORTANTLY- their order.
     <multiplier/>\r
     <clamp/>\r
     <threshold/>\r
-    <coincident/>
+    <coincident/>\r
     <centerzero/>\r
 </plotmanips>\r
 \r
index 00699be39156cae0cd4f5061b31b144808fcdc89..4e430cd002933cdd8fa38a803f2c060451f8de0f 100755 (executable)
@@ -658,7 +658,9 @@ Columns are, in order:
 X1 , Y1 , X2 , Y2 , X3 , Y3 ...
 
 -------------
-Syntax: txt [filename] {plot to export}
+Syntax: txt [filename] {plot to export} or
+       txt [filename] all
+       all  : To save all the curves in different windows in a single file.
         '''
     def do_txt(self,args):
         
@@ -678,33 +680,57 @@ Syntax: txt [filename] {plot to export}
         else:
             filename=linp.checkalphainput(args[0],self.current.path+'.txt',[])
             try:
-                whichplot=int(args[1])
+               if args[1]=="all":
+                 whichplot="all"
+                else:
+                  whichplot=int(args[1])
             except:
                 pass
+        
+       if whichplot!="all":
+           try:
+               outofplot=self.plots[whichplot].vectors
+           except:
+               print "Plot index out of range."
+               return 0
+           columns=[]     
+           for dataset in self.plots[whichplot].vectors:
+               for i in range(0,len(dataset)): 
+                   columns.append([])
+                   for value in dataset[i]:
+                       #columns[-1].append(str(value*(10**9)))                   
+                       columns[-1].append(str(value))
+           rows=transposed2(columns, 'nan')
+           rows=[' , '.join(item) for item in rows]
+           text='\n'.join(rows)
+           
+           txtfile=open(filename,'w+')
+           #Save units of measure in header
+           txtfile.write('X:'+self.plots[whichplot].units[0]+'\n')
+           txtfile.write('Y:'+self.plots[whichplot].units[1]+'\n')
+           txtfile.write(text)
+           txtfile.close()
 
-       try:
-            outofplot=self.plots[whichplot].vectors
-        except:
-            print "Plot index out of range."
-           return 0
-
-        columns=[]     
-        for dataset in self.plots[whichplot].vectors:
-            for i in range(0,len(dataset)): 
-                columns.append([])
-                for value in dataset[i]:
-                    columns[-1].append(str(value))                   
-        
-        rows=transposed2(columns, 'nan')
-        rows=[' , '.join(item) for item in rows]
-        text='\n'.join(rows)
-        
-        txtfile=open(filename,'w+')
-        #Save units of measure in header
-        txtfile.write('X:'+self.plots[whichplot].units[0]+'\n')
-        txtfile.write('Y:'+self.plots[whichplot].units[1]+'\n')
-        txtfile.write(text)
-        txtfile.close()
+        else:
+         columns=[]
+          for wp in range(len(self.plots)):     
+           for dataset in self.plots[wp].vectors:
+               for i in range(0,len(dataset)): 
+                   columns.append([])
+                   for value in dataset[i]:
+                       #columns[-1].append(str(value*(10**9)))                   
+                       columns[-1].append(str(value))
+           rows=transposed2(columns, 'nan')
+           rows=[' , '.join(item) for item in rows]
+           text='\n'.join(rows)
+
+           txtfile=open(filename,'w+')
+           #Save units of measure in header
+            for i in range(len(self.plots)):
+             txtfile.write('X:'+self.plots[i].units[0]+'\n')
+             txtfile.write('Y:'+self.plots[i].units[1]+'\n')
+           txtfile.write(text)
+           txtfile.close()
         
     
     #LOGGING, REPORTING, NOTETAKING