Skip to content
Snippets Groups Projects
Commit 7a3249ad authored by David Hoese's avatar David Hoese
Browse files

not tested, but should work

parent 55e8b73a
No related branches found
No related tags found
No related merge requests found
"""Array filtering functions
"""
from numpy import ndarray, array, diff
from numpy.ma import MaskedArray, masked_array
from numpy.ma import MaskedArray, masked_array, masked_where
__docformat__ = 'Epytext'
__author__ = 'David Hoese'
......@@ -23,8 +23,12 @@ def filter_arr(arr, threshold, fill_value=None):
if fill_value != None: arr = array(arr)
if fill_value == None: arr = masked_array(arr)
diff_arr = diff(arr, n=1)
diff_arr = zeros(arr.shape[0])
diff_arr[1:] = diff(arr, n=1)
if fill_value == None: arr = masked_where(diff_arr >= threshold, arr)
arr = masked_where(diff_arr >= threshold, arr)
if fill_value != None:
arr.fill_value = fill_value
arr = arr.filled()
return arr
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment