casys.editing.filter
OCTANT-NG filter classes.
Classes
|
Apply several individual filters one after the other. |
|
Median filter. |
|
|
|
|
|
Gaussian filter. |
|
Kernel = alpha + beta * cos(x). |
|
Lanczos filter. |
|
Apply a filter several times, output also contains a selection indicator. |
|
Apply a filter on data with evenly spaced abscissa (data is resampled before and after filtering if needed) |
- class casys.editing.filter.Bartlett(half_window_size, rejection_threshold=0)
Bases:
ConvolutionFilter
- apply(x_in, y_in, **kwargs)
- Parameters:
x_in (
ndarray
) – Input abscissay_in (
ndarray
) – Input ordinateskwargs –
- check_param
check x_in/y_in parameters
- evenly_spaced_absc
Are abscissa evenly spaced ? (default=False) If so, a special scipy processing - possibly faster - is applied WARNING : if true, NaN values in y_in are forbidden (use ResampleFilter)
- plot
plot input and output signals
- preserve_dim
Preserve dimension after filtering (default=True)
- Returns:
Output (filtered) ordinates
- class casys.editing.filter.CompositeFilter(filters)
Bases:
Filter
Apply several individual filters one after the other.
- apply(x_in, y_in, **kwargs)
- Parameters:
- Returns:
Output (filtered) ordinates
- class casys.editing.filter.Gaussian(half_window_size, rejection_threshold=0, sigma=0.5)
Bases:
ConvolutionFilter
Gaussian filter.
- half_window_size
The window size in one direction, the real size is 2*half_window_size. This value is related to the abscissa step of the x apply(x,y) parameter, its unit is the same as abscissa (seconds for timedelta).
- rejection_threshold
Number of minimum valid points in a window below which the output is invalidated.
- sigma
Standard deviation coefficient
- apply(x_in, y_in, **kwargs)
- Parameters:
x_in (
ndarray
) – Input abscissay_in (
ndarray
) – Input ordinateskwargs –
- check_param
check x_in/y_in parameters
- evenly_spaced_absc
Are abscissa evenly spaced ? (default=False) If so, a special scipy processing - possibly faster - is applied WARNING : if true, NaN values in y_in are forbidden (use ResampleFilter)
- plot
plot input and output signals
- preserve_dim
Preserve dimension after filtering (default=True)
- Returns:
Output (filtered) ordinates
- class casys.editing.filter.Hamming(half_window_size, rejection_threshold=0, alpha=0.54, beta=0.46)
Bases:
ConvolutionFilter
Kernel = alpha + beta * cos(x).
Hamming : alpha=0.54, beta=0.46 Hanning : alpha=beta=0.5 https://en.wikipedia.org/wiki/Window_function
- apply(x_in, y_in, **kwargs)
- Parameters:
x_in (
ndarray
) – Input abscissay_in (
ndarray
) – Input ordinateskwargs –
- check_param
check x_in/y_in parameters
- evenly_spaced_absc
Are abscissa evenly spaced ? (default=False) If so, a special scipy processing - possibly faster - is applied WARNING : if true, NaN values in y_in are forbidden (use ResampleFilter)
- plot
plot input and output signals
- preserve_dim
Preserve dimension after filtering (default=True)
- Returns:
Output (filtered) ordinates
- class casys.editing.filter.IterativeFilter(filter, nb_iter, std_coeff=1.0, const_coeff=0.0)
Bases:
Filter
Apply a filter several times, output also contains a selection indicator.
- Parameters:
- apply(x_in, y_in, **kwargs)
Apply filter to ordinates.
- Parameters:
x_in (
ndarray
) – Input abscissa.y_in (
ndarray
) – Input ordinates (NaN values allowed).kwargs –
- check_param
check x_in/y_in parameters.
- evenly_spaced_absc
Are abscissa evenly spaced ? (default=False) If so, a special scipy processing - possibly faster - is applied for median and convolution filters.
- plot
plot input and output signals.
- threshold
threshold (default=3.0).
- Return type:
- Returns:
Output (filtered) ordinates.
- apply_filter(x_in, y_in, **kwargs)
Apply filter to ordinates and compute the validity mask. (this function was created to be used for IterativeFilter of algo/editing)
- class casys.editing.filter.Lanczos(half_window_size=None, rejection_threshold=0, nb_lobes=1, cutoff=None)
Bases:
ConvolutionFilter
Lanczos filter.
https://en.wikipedia.org/wiki/Lanczos_resampling
- Parameters:
half_window_size (
float
|None
) – The window size in one direction, the real size is 2*half_window_size. This value is related to the abscissa step of the x apply(x,y) parameter, its unit is the same as abscissa (seconds for timedelta).rejection_threshold (
int
) – Number of minimum valid points in a window below which the output is invalidated.nb_lobes (
int
) – Number of lobes.
- apply(x_in, y_in, **kwargs)
- Parameters:
x_in (
ndarray
) – Input abscissay_in (
ndarray
) – Input ordinateskwargs –
- check_param
check x_in/y_in parameters
- evenly_spaced_absc
Are abscissa evenly spaced ? (default=False) If so, a special scipy processing - possibly faster - is applied WARNING : if true, NaN values in y_in are forbidden (use ResampleFilter)
- plot
plot input and output signals
- preserve_dim
Preserve dimension after filtering (default=True)
- Returns:
Output (filtered) ordinates
- property cutoff
- property nb_lobes
- class casys.editing.filter.Mean(half_window_size, rejection_threshold=0)
Bases:
ConvolutionFilter
- apply(x_in, y_in, **kwargs)
- Parameters:
x_in (
ndarray
) – Input abscissay_in (
ndarray
) – Input ordinateskwargs –
- check_param
check x_in/y_in parameters
- evenly_spaced_absc
Are abscissa evenly spaced ? (default=False) If so, a special scipy processing - possibly faster - is applied WARNING : if true, NaN values in y_in are forbidden (use ResampleFilter)
- plot
plot input and output signals
- preserve_dim
Preserve dimension after filtering (default=True)
- Returns:
Output (filtered) ordinates
- class casys.editing.filter.Median(half_window_size, rejection_threshold=0, mean_value=0)
Bases:
WindowFilter
Median filter.
- Parameters:
half_window_size (
float
) – The window size in one direction, the real size is 2*half_window_size. This value is related to the abscissa step of the x apply(x,y) parameter, its unit is the same as abscissa (seconds for timedelta).rejection_threshold (
int
) – Number of minimum valid points in a window below which the output is invalidated.mean_value (
int
) – Half window size of mean sorted values window filter This window is applied on the rolling window defined by half_window_size attributes.
- apply(x_in, y_in, check_param=False, evenly_spaced_absc=False, plot=False, preserve_dim=True, same_mask=True, **kwargs)
Apply median filter.
- Parameters:
x_in (
ndarray
) – Input abscissay_in (
ndarray
) – Input ordinatescheck_param (
bool
) – check x_in/y_in parametersevenly_spaced_absc (
bool
) – Are abscissa evenly spaced ? (default=False) If so, a special scipy processing - possibly faster - is applied WARNING : if true, NaN values in y_in are forbidden (use ResampleFilter)plot (
bool
) – plot input and output signalspreserve_dim (
bool
) – Preserve dimension in the result (default=True)same_mask (
bool
) – If True (default), the filtered signal will have invalids where the input is invalid.**kwargs – Arbitrary keyword arguments. Ignored by this filter
- Return type:
- Returns:
Output (filtered) ordinates
- class casys.editing.filter.ResampleFilter(filter)
Bases:
Filter
Apply a filter on data with evenly spaced abscissa (data is resampled before and after filtering if needed)
- Parameters:
filter (
Filter
)
- apply(x_in, y_in, **kwargs)
- Parameters:
x_in (
ndarray
) – Input abscissay_in (
ndarray
) – Input ordinates (NaN values allowed)kwargs –
- max_step
Add a constraint to the creation of the evenly spaced abscissa (x_reg) : The effective step if then the highest value < max_step keeping the same bounds (i.e. x_reg[0] = x_in[0] and x_reg[-1] = x_in[-1]). Default value : the median step of x_in
- Return type:
- Returns:
Output (filtered) ordinates
- property filter