Skip PoorFit curves in flatfilt and convfilt.
authorW. Trevor King <wking@drexel.edu>
Mon, 14 Jun 2010 14:25:59 +0000 (10:25 -0400)
committerW. Trevor King <wking@drexel.edu>
Mon, 14 Jun 2010 14:25:59 +0000 (10:25 -0400)
hooke/plugin/convfilt.py
hooke/plugin/flatfilt.py
hooke/plugin/vclamp.py

index 4be6ea86705d4f3f70ee125f3efc9df5dacd2d24..3d1e883365ed3eee8393c83f27580bd78da3756d 100644 (file)
@@ -45,6 +45,7 @@ from ..plugin import Plugin, argument_to_setting
 from ..plugin.curve import CurveArgument
 from ..plugin.playlist import FilterCommand
 from ..plugin.vclamp import scale
+from ..util.fit import PoorFit
 from ..util.peak import find_peaks, find_peaks_arguments, Peak, _kwargs
 
 
@@ -211,6 +212,9 @@ class ConvolutionFilterCommand (FilterCommand):
                         if c.name=='convolution peaks'][0]
         conv_command.run(hooke, inq, outq, **params)
         peaks = outq.get()
+        if isinstance(peaks, UncaughtException) \
+                and isinstance(peaks.exception, PoorFit):
+            return False
         if not (isinstance(peaks, list) and (len(peaks) == 0
                                              or isinstance(peaks[0], Peak))):
             raise Failure('Expected a list of Peaks, not %s' % peaks)
index 1637ce3f6ed12f139e41d2316921f56b05b3dca1..716a4be7f61df45684d554e2915a1519d6664e7f 100644 (file)
@@ -38,13 +38,14 @@ from multiprocessing import Queue
 from numpy import diff
 from scipy.signal.signaltools import medfilt
 
-from ..command import Command, Argument, Success, Failure
+from ..command import Command, Argument, Success, Failure, UncaughtException
 from ..config import Setting
 from ..experiment import VelocityClamp
 from ..plugin import Plugin, argument_to_setting
 from ..plugin.curve import CurveArgument
 from ..plugin.playlist import FilterCommand
 from ..plugin.vclamp import scale
+from ..util.fit import PoorFit
 from ..util.peak import find_peaks, find_peaks_arguments, Peak, _kwargs
 
 
@@ -204,6 +205,9 @@ class FlatFilterCommand (FilterCommand):
                         if c.name=='flat filter peaks'][0]
         filt_command.run(hooke, inq, outq, **params)
         peaks = outq.get()
+        if isinstance(peaks, UncaughtException) \
+                and isinstance(peaks.exception, PoorFit):
+            return False
         if not (isinstance(peaks, list) and (len(peaks) == 0
                                              or isinstance(peaks[0], Peak))):
             raise Failure('Expected a list of Peaks, not %s' % peaks)
index 0dfaeab2bdd08dec77df256666a65a271381dad7..fca2cd3be5352d51cef2c463dc2cc25b390b961d 100644 (file)
@@ -46,8 +46,13 @@ def scale(hooke, curve):
     inqueue = None
     outqueue = NullQueue()
     for i,block in enumerate(curve.data):
+        numpy.savetxt(open('curve.dat', 'w'), block, delimiter='\t')
         params = {'curve':curve, 'block':i}
-        contact._run(hooke, inqueue, outqueue, params)
+        try:
+            contact._run(hooke, inqueue, outqueue, params)
+        except PoorFit, e:
+            raise PoorFit('Could not fit %s %s: %s'
+                          % (curve.path, i, str(e)))
         force._run(hooke, inqueue, outqueue, params)
     return curve
 
@@ -175,7 +180,7 @@ class SurfacePositionModel (ModelFitter):
         if abs(params[3]*10) > abs(params[1]) :
             raise PoorFit('Slope in non-contact region, or no slope in contact')
         if params[2] < self.info['min position']+0.02*self.info['position range']:
-            raise poorFit(
+            raise PoorFit(
                 'No kink (kink %g less than %g, need more space to left)'
                 % (params[2],
                    self.info['min position']+0.02*self.info['position range']))