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 True by 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:

ndarray[tuple[Any, ...], dtype[bool]]

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.

Return type:

ndarray[tuple[Any, ...], dtype[double]]

Returns:

+1 where it increases, -1 where it decreases, 0 where it remains the same.

Parameters:
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 array is locally increasing at index.

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 between array[idx-width/2] and array[idx+width/2] is lower than tol, we return no_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_value if 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:

ndarray[tuple[Any, ...], dtype[bool]]

Returns:

A copy of mask without the isolated True/False points.