spiketools.utils.extract.get_range

spiketools.utils.extract.get_range(data, min_value=None, max_value=None, reset=None)[source]

Get a specified range from a vector of data.

Parameters:
data1d array

Array of data.

min_value, max_valuefloat, optional

Minimum and/or maximum value to extract from the input array.

resetfloat, optional

If provided, resets the values in the data array by the given reset value.

Returns:
data1d array

Data array, restricted to desired range.

Examples

Get all values greater than a specific value:

>>> data = np.array([5, 10, 15, 20, 25, 30])
>>> get_range(data, min_value=10, max_value=None)
array([10, 15, 20, 25, 30])

Get all values less than a specific value:

>>> data = np.array([5, 10, 15, 20, 25, 30])
>>> get_range(data, min_value=None, max_value=22.5)
array([ 5, 10, 15, 20])

Get a specified range from a data array:

>>> data = np.array([5, 10, 15, 20, 25, 30])
>>> get_range(data, min_value=10, max_value=22.5)
array([10, 15, 20])