edges_cal.xrfi.xrfi_model

edges_cal.xrfi.xrfi_model(spectrum: ndarray, *, freq: ndarray, inplace: bool = False, init_flags: ndarray | tuple[float, float] | None = None, flags: ndarray | None = None, **kwargs)[source]

Flag RFI by subtracting a smooth model and iteratively removing outliers.

On each iteration, a model is fit to the unflagged data, and another model is fit to the absolute residuals. Bins with absolute residuals greater than n_abs_resid_threshold are flagged, and the process is repeated until no new flags are found.

Parameters:
  • spectrum (array-like) – A 1D spectrum. Note that instead of a spectrum, model residuals can be passed. The function does not assume the input is positive.

  • freq – The frequencies associated with the spectrum.

  • inplace (bool, optional) – Whether to fill up given flags array with the updated flags.

  • init_flags – Initial flags that are not remembered after the first iteration. These can help with getting the initial model. If a tuple, should be a min and max frequency of a range to flag.

  • **kwargs – All other parameters passed to model_filter()

Returns:

flags (array-like) – Boolean array of the same shape as spectrum indicated which channels/times have flagged RFI.