pyValEIA.utils.filters
Functions to filter data.
Functions
|
Roll barrel over data to detrended over large decreases in value. |
|
Calculate the rolling mean or median of an array with or without nans. |
|
Identify continuous ranges of NaN values in an array. |
|
Identify gaps in a list of indices. |
|
Detect outliers in an array. |
Module Contents
- pyValEIA.utils.filters.simple_barrel_roll(xvar, yvar, barrel_radius, envelope=True, envelope_lower=0.6, envelope_upper=0.2)[source]
Roll barrel over data to detrended over large decreases in value.
- Parameters:
- xvar: array-like
Independent data variable along which yvar will be smoothed.
- yvar: array-like
Dependent data variable of the same size as xvar; needs to be scaled such that its magnitude is similar to yvar
- barrel_radiusdouble
Radius of the ‘barrel’ rolling over the data in the same units as xvar
- envelopebool
If True, the barrel roll results will be used as constraints for the original yvar values (default=True)
- envelope_lowerfloat
Fraction starting from zero to multiply the minimum by, used to calculate the lower limit of the barrel roll envelope; a larger value creates a larger lower envelope (default=0.6)
- envelope_upperfloat
Fraction starting from zero to multiply the maximum by, used to calculate the upper limit of the barrel roll envelope; a larger value creates a larger upper envelope (default=0.2)
- Returns:
- yvar_detarray-like
Detrended values for the dependent variable, yvar
- pyValEIA.utils.filters.rolling_nanmeasure(arr, window, measure='mean')[source]
Calculate the rolling mean or median of an array with or without nans.
- Parameters:
- arr: array-like
array of values to roll over
- windowint
window size
- measurestr
Method to apply to data; ‘mean’, ‘median’, ‘average’ (default=’mean’)
- Returns:
- outarray-like
rolling measured array of same length as original
- pyValEIA.utils.filters.find_nan_ranges(arr)[source]
Identify continuous ranges of NaN values in an array.
- Parameters:
- arrarray-like
array with nans
- Returns:
- nan_listlist-like
List of (start_idx, end_idx) for each contiguous NaN section
- pyValEIA.utils.filters.find_all_gaps(inds)[source]
Identify gaps in a list of indices.
- Parameters:
- indslist-like
Array of indices
- Returns:
- gap_indiceslist-like
Indices of gap start and end
Notes
For example, in an array of arr=[2,3,5,6,7,8], this function will return gap_inds=[1] to indicate where the gap starts.