Ran update_copyright.py
[hooke.git] / hooke / util / peak.py
index f980267390d1d5211d5f63b4f69188bd368a6fb1..ef168910c6c3eb4ce542e0c7262cb9bd13aebdb0 100644 (file)
@@ -4,15 +4,15 @@
 #
 # This file is part of Hooke.
 #
-# Hooke is free software: you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation, either
-# version 3 of the License, or (at your option) any later version.
+# Hooke is free software: you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
 #
-# Hooke is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU Lesser General Public License for more details.
+# Hooke is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General
+# Public License for more details.
 #
 # You should have received a copy of the GNU Lesser General Public
 # License along with Hooke.  If not, see
@@ -71,7 +71,7 @@ class Peak (object):
         """
         return self.index + len(self.values)
 
-def mask_to_peaks(data, mask, name):
+def mask_to_peaks(data, mask, name='peak'):
     """Convert a mask array to a list of :class:`Peak`\s.
 
     Parameters
@@ -246,7 +246,7 @@ def noise(data, cut_side='both', stable=0.005, max_cut=0.2):
 
     if cut_side == 'both':
         def new_mask(data, mask, masked_mean):
-            mask[((data-masked_mean).abs()*mask).argmax()] = 0
+            mask[(numpy.absolute(data-masked_mean)*mask).argmax()] = 0
             return mask
     elif cut_side == 'positive':
         def new_mask(data, mask, masked_mean):
@@ -323,12 +323,12 @@ def above_noise(data, side='both', min_deviations=5.0, mean=None, std=None):
     --------
 
     >>> data = numpy.arange(-3, 4)
-    >>> above_noise(data, side='both', min_deviations=1.0, mean=0, std=1.0)
-    array([ True, False, False, False, False, False,  True], dtype=bool)
-    >>> above_noise(data, side='positive', min_deviations=1.0, mean=0, std=1.0)
-    array([False, False, False, False, False, False,  True], dtype=bool)
-    >>> above_noise(data, side='negative', min_deviations=1.0, mean=0, std=1.0)
-    array([ True, False, False, False, False, False, False], dtype=bool)
+    >>> above_noise(data, side='both', min_deviations=1.1, mean=0, std=1.0)
+    array([ True,  True, False, False, False,  True,  True], dtype=bool)
+    >>> above_noise(data, side='positive', min_deviations=1.1, mean=0, std=1.0)
+    array([False, False, False, False, False,  True,  True], dtype=bool)
+    >>> above_noise(data, side='negative', min_deviations=1.1, mean=0, std=1.0)
+    array([ True,  True, False, False, False, False, False], dtype=bool)
     """
     if mean == None:
         mean = data.mean()
@@ -340,7 +340,7 @@ def above_noise(data, side='both', min_deviations=5.0, mean=None, std=None):
     elif side == 'both':
         data = numpy.absolute(data-mean)
         mean = 0
-    return data > (min_deviations + std)
+    return data > (min_deviations * std)
 
 above_noise_arguments = [
     Argument('side', type='string', default='both',