filtering module
Define useful functions to filter data.
- remove_trailing_true(data, n_trailing_points_to_check=50, array_name_for_warning='')[source]
Replace trailing
Trueby False.- Parameters:
data (
ndarray[tuple[Any,...],dtype[bool]]) – Boolean array to treat.n_trailing_points_to_check (
int, default:50) – The number of points at the end of array that shall be checked. The default is 50, which is a good balance to remove unwanted starts of new power cycle at the end of the array.array_name_for_warning (
str, default:'') – Name of the array, to print a more informative warning message.
- Return type:
- Returns:
Boolean array without trailing True.
- not_noisy_array_is_growing(array, tol=1e-07)[source]
Tell where array is locally growing.
Adapted to not noisy instruments such as
PowerSetpoint.
- noisy_array_is_growing(array, index, width=10, tol=1e-05, no_change_value=None, default_first_value=True)[source]
- Overloads:
array (NDArray[np.float64]), index (int), width (int), tol (float), no_change_value (bool), default_first_value (bool | None) → bool
array (NDArray[np.float64]), index (int), width (int), tol (float), no_change_value (None), default_first_value (bool | None) → bool | None
Tell if
arrayis locally increasing atindex.- Parameters:
array (
ndarray[tuple[Any,...],dtype[double]]) – Array under study.index (
int) – Where you want to know if we increase.width (
int, default:10) – Width of the sample to determine increase.tol (
float, default:1e-05) – If absolute value of variation betweenarray[idx-width/2]andarray[idx+width/2]is lower thantol, we returnno_change_value.default_first_value (
bool|None, default:True) – Default return for the first values. The default is True, which means that we suppose that power increases at the start.no_change_value (
bool|None, default:None) – Default value for when no change in array was detected.
- Returns:
If the array is locally increasing,
no_change_valueif array is locally constant.
- clean_boolean_mask(mask, min_true, max_false_gap)[source]
Remove isolated True and False from
mask.- Parameters:
mask (
ndarray[tuple[Any,...],dtype[TypeVar(_ScalarT, bound=generic)]]) – Boolean mask array. Typically, a multipactor array.min_true (
int) – Minimum size for the multipactor zone. Under this number of samples, we consider that multipactor detection was a false positive.max_false_gap (
int) – Maximum distance between two multipactor zones. Under this number of samples, we consider the multipactor detection was a false negative, and the two neighboring multipactor zones are actually a single zone.
- Return type:
- Returns:
A copy of
maskwithout the isolated True/False points.