Don't die when flat-filtering curves shorter than blind window.
authorW. Trevor King <wking@drexel.edu>
Tue, 1 Jun 2010 16:50:16 +0000 (12:50 -0400)
committerW. Trevor King <wking@drexel.edu>
Tue, 1 Jun 2010 16:50:16 +0000 (12:50 -0400)
This will probably only happen if the user uses an absurdly large
blind window by mistake, but that shouldn't crash Hooke.

hooke/plugin/flatfilt.py

index 6637eb81f7ec37d8e3a81cf0b0e8786d97d6fc40..1a4997218771a3ea47c40003f76243c0370c04bb 100644 (file)
@@ -123,7 +123,8 @@ class FlatPeaksCommand (Command):
     def _run(self, hooke, inqueue, outqueue, params):
         z_data,d_data,params = self._setup(params)
         start_index = 0
-        while z_data[start_index] < params['blind window']:
+        while (start_index < len(z_data)
+               and z_data[start_index] < params['blind window']):
             start_index += 1
         median = medfilt(d_data[start_index:], params['median window'])
         deriv = diff(median)