katsdpsigproc.rfi package

Submodules

katsdpsigproc.rfi.device module

RFI flagging algorithms that run on an accelerator, using OpenCL or CUDA.

The noise estimation and thresholding functions may take data in either channel-major or baseline-major order (the flags are emitted in the same order). In the former case, the transposed member is False, otherwise it is True. The flagger classes automatically detect this and apply a transposition kernel at the appropriate point.

class katsdpsigproc.rfi.device.AbstractBackgroundDevice(command_queue: AbstractCommandQueue, allocator: AbstractAllocator | None = None)[source]

Bases: Operation

class katsdpsigproc.rfi.device.AbstractBackgroundDeviceTemplate[source]

Bases: ABC

context: AbstractContext
host_class: Type[AbstractBackgroundHost]
abstract instantiate(command_queue: AbstractCommandQueue, channels: int, baselines: int, allocator: AbstractAllocator | None = None) AbstractBackgroundDevice[source]

Create an instance.

use_flags: BackgroundFlags
class katsdpsigproc.rfi.device.AbstractNoiseEstDevice(command_queue: AbstractCommandQueue, allocator: AbstractAllocator | None = None)[source]

Bases: Operation

transposed: bool
class katsdpsigproc.rfi.device.AbstractNoiseEstDeviceTemplate[source]

Bases: ABC

context: AbstractContext
host_class: Type[AbstractNoiseEstHost]
abstract instantiate(command_queue: AbstractCommandQueue, channels: int, baselines: int, allocator: AbstractAllocator | None = None) AbstractNoiseEstDevice[source]

Create an instance.

transposed: bool
class katsdpsigproc.rfi.device.AbstractThresholdDevice(command_queue: AbstractCommandQueue, allocator: AbstractAllocator | None = None)[source]

Bases: Operation

transposed: bool
class katsdpsigproc.rfi.device.AbstractThresholdDeviceTemplate[source]

Bases: ABC

context: AbstractContext
host_class: Type[AbstractThresholdHost]
abstract instantiate(command_queue: AbstractCommandQueue, channels: int, baselines: int, n_sigma: float, *, allocator: AbstractAllocator | None = None) AbstractThresholdDevice[source]

Create an instance.

transposed: bool
class katsdpsigproc.rfi.device.BackgroundFlags(value)[source]

Bases: Enum

An enumeration.

CHANNEL = 1
FULL = 2
NONE = 0
class katsdpsigproc.rfi.device.BackgroundHostFromDevice(template: AbstractBackgroundDeviceTemplate, command_queue: AbstractCommandQueue)[source]

Bases: AbstractBackgroundHost

Wrap a device-side background template to present the host interface.

class katsdpsigproc.rfi.device.BackgroundMedianFilterDevice(template: BackgroundMedianFilterDeviceTemplate, command_queue: AbstractCommandQueue, channels: int, baselines: int, allocator: AbstractAllocator | None = None)[source]

Bases: AbstractBackgroundDevice

Concrete instance of BackgroundMedianFilterDeviceTemplate.

Slots

vischannels × baselines, float32 or complex64

Input visibilities, or their amplitudes if template.is_amplitude is true

flagschannels × baselines or channels, float32

Input flags (only present if template.use_flags is used)

deviationschannels × baselines, float32

Output deviations from the background

Parameters:
  • template – Operation template

  • command_queue – Command queue for the operation

  • channels – Shape of the visibilities array

  • baselines – Shape of the visibilities array

  • allocator – Allocator used to allocate unbound slots

parameters() Mapping[str, Any][source]

Return dictionary of configuration options for this operation.

class katsdpsigproc.rfi.device.BackgroundMedianFilterDeviceTemplate(context: AbstractContext, width: int, is_amplitude: bool = False, use_flags: BackgroundFlags | bool = BackgroundFlags.NONE, tuning: Mapping[str, Any] | None = None)[source]

Bases: AbstractBackgroundDeviceTemplate

Device algorithm that applies a median filter to each baseline (in amplitude).

It is the same algorithm as host.BackgroundMedianFilterHost, but may give slightly different results due to rounding errors when computing complex magnitude.

Parameters:
  • context (katsdpsigproc.abc.AbstractContext) – Context for which kernels will be compiled

  • width – The kernel width (must be odd)

  • is_amplitude – If True, the inputs are amplitudes rather than complex visibilities

  • use_flags (katsdpsigproc.rfi.device.BackgroundFlags) –

    Specify that flags are taken as input to indicate bad data that should not contribute to the backgrounding. The legal values are

    • FULL: takes flags with same shape as visibilities

    • CHANNEL: takes a single flag per channel

    • NONE: do not take flags as input

    For backwards compatibility, True is an alias for CHANNEL and False is an alias for NONE.

  • tuning (mapping, optional) –

    Kernel tuning parameters; if omitted, will autotune. The possible parameters are

    • wgs: number of work-items per baseline

    • csplit: approximate number of workitems for each channel

classmethod autotune(context: AbstractContext, width: int, is_amplitude: bool, use_flags: BackgroundFlags) Mapping[str, Any][source]
autotune_version = 4
context: AbstractContext
host_class

alias of BackgroundMedianFilterHost

instantiate(command_queue: AbstractCommandQueue, channels: int, baselines: int, allocator: AbstractAllocator | None = None) BackgroundMedianFilterDevice[source]

Create an instance. See BackgroundMedianFilterDevice.

use_flags: BackgroundFlags
class katsdpsigproc.rfi.device.FlaggerDevice(template: FlaggerDeviceTemplate, command_queue: AbstractCommandQueue, channels: int, baselines: int, background_args: Mapping[str, Any] = {}, noise_est_args: Mapping[str, Any] = {}, threshold_args: Mapping[str, Any] = {}, allocator: AbstractAllocator | None = None)[source]

Bases: OperationSequence

Concrete instance of FlaggerDeviceTemplate.

Slots

vischannels × baselines, float32 or complex64

Input visibilities (or amplitudes, if the backgrounder takes amplitudes)

noisebaselines, float32

Estimate of per-baseline noise

flagschannels × baselines, uint8

Output flags

input_flagschannels × baseline or channels, uint8

Input flags. These are only used for estimating the background, and are not automatically copied into the output. Any visibilities marked as flagged here will not be flagged as RFI.

This slot is only present if the backgrounder template has use_flags set, and the value determines the shape.

Temporary slots

Temporary buffers are presented as slots, which allows them to either be set by the user or allocated automatically on first use.

deviationschannels × baselines, float32

Deviations from the background

deviations_tbaselines × channels, float32, optional

Transpose of deviations

flags_tbaselines × channels, uint8, optional

Transpose of flags

Parameters:
  • template – Operation template

  • command_queue – Command queue for the operation

  • channels – Shape of the visibilities array

  • baselines – Shape of the visibilities array

  • background_args – Extra keyword arguments to pass to the background instantiation

  • noise_est_args – Extra keyword arguments to pass to the noise estimation instantiation

  • threshold_args – Extra keyword arguments to pass to the threshold instantiation

  • allocator – Allocator used to allocate unbound slots

class katsdpsigproc.rfi.device.FlaggerDeviceTemplate(background: AbstractBackgroundDeviceTemplate, noise_est: AbstractNoiseEstDeviceTemplate, threshold: AbstractThresholdDeviceTemplate)[source]

Bases: object

Combine device backgrounder, noise estimation and thresholder to create a flagger.

The thresholder and/or noise estimation may take transposed input, in which case this object will manage temporary buffers and the transposition automatically.

Parameters:
  • background – The templates for the individual steps

  • noise_est – The templates for the individual steps

  • threshold – The templates for the individual steps

instantiate(command_queue: AbstractCommandQueue, channels: int, baselines: int, background_args: Mapping[str, Any] = {}, noise_est_args: Mapping[str, Any] = {}, threshold_args: Mapping[str, Any] = {}, allocator: AbstractAllocator | None = None) FlaggerDevice[source]

Create an instance (see FlaggerDevice).

class katsdpsigproc.rfi.device.FlaggerHostFromDevice(template: FlaggerDeviceTemplate, command_queue: AbstractCommandQueue, background_args: Mapping[str, Any] = {}, noise_est_args: Mapping[str, Any] = {}, threshold_args: Mapping[str, Any] = {})[source]

Bases: AbstractFlaggerHost

Wrapper that makes a FlaggerDeviceTemplate look like a FlaggerHost.

This is intended only for ease of use. It is not efficient, because it allocates and frees memory on every call.

Parameters:
  • template – Operation template

  • command_queue – Command queue for the operation

  • background_args – Extra keyword arguments to pass to the background instantiation

  • noise_est_args – Extra keyword arguments to pass to the noise estimation instantiation

  • threshold_args – Extra keyword arguments to pass to the threshold instantiation

class katsdpsigproc.rfi.device.NoiseEstHostFromDevice(template: AbstractNoiseEstDeviceTemplate, command_queue: AbstractCommandQueue)[source]

Bases: AbstractNoiseEstHost

Wrap a device-side noise estimator template to present the host interface.

class katsdpsigproc.rfi.device.NoiseEstMADDevice(template: NoiseEstMADDeviceTemplate, command_queue: AbstractCommandQueue, channels: int, baselines: int, allocator: AbstractAllocator | None = None)[source]

Bases: AbstractNoiseEstDevice

Concrete instantiation of NoiseEstMADDeviceTemplate.

Slots

deviationschannels × baselines, float32

Input deviations from the background, computed by a backgrounder

noisebaselines, float32

Output per-baseline noise estimate

Parameters:
  • template – Operation template

  • command_queue – Command-queue in which work will be enqueued

  • channels – Shape of the visibility array

  • baselines – Shape of the visibility array

  • allocator – Allocator used to allocate unbound slots

hidden_slots: Dict[str, IOSlotBase]
parameters() Mapping[str, Any][source]

Return dictionary of configuration options for this operation.

slots: Dict[str, IOSlotBase]
transposed: bool = False
class katsdpsigproc.rfi.device.NoiseEstMADDeviceTemplate(context: AbstractContext, tuning: Mapping[str, Any] | None = None)[source]

Bases: AbstractNoiseEstDeviceTemplate

Estimate noise using the median of non-zero absolute deviations.

In most cases NoiseEstMADTDeviceTemplate is more efficient.

Parameters:
  • context (katsdpsigproc.abc.AbstractContext) – Context for which kernels will be compiled

  • tuning

    Kernel tuning parameters; if omitted, will autotune. The possible parameters are

    • wgsx: number of baselines per workgroup

    • wgsy: number of channels per workgroup

classmethod autotune(context: AbstractContext) Mapping[str, Any][source]
context: AbstractContext
host_class

alias of NoiseEstMADHost

instantiate(command_queue: AbstractCommandQueue, channels: int, baselines: int, allocator: AbstractAllocator | None = None) NoiseEstMADDevice[source]

Create an instance. See NoiseEstMADDevice.

transposed: bool = False
class katsdpsigproc.rfi.device.NoiseEstMADTDevice(template: NoiseEstMADTDeviceTemplate, command_queue: AbstractCommandQueue, channels: int, baselines: int, allocator: AbstractAllocator | None = None)[source]

Bases: AbstractNoiseEstDevice

Concrete instance of NoiseEstMADTDeviceTemplate.

Slots

deviationsbaselines × channels, float32

Input deviations from the background, computed by a backgrounder

noisebaselines, float32

Output per-baseline noise estimate

Parameters:
  • template – Operation template

  • command_queue – Command-queue in which work will be enqueued

  • channels – Shape of the visibility array

  • baselines – Shape of the visibility array

  • allocator – Allocator used to allocate unbound slots

hidden_slots: Dict[str, IOSlotBase]
parameters() Mapping[str, Any][source]

Return dictionary of configuration options for this operation.

slots: Dict[str, IOSlotBase]
transposed: bool = True
class katsdpsigproc.rfi.device.NoiseEstMADTDeviceTemplate(context: AbstractContext, max_channels: int, tuning: Mapping[str, Any] | None = None)[source]

Bases: AbstractNoiseEstDeviceTemplate

Device-side noise estimation by median of absolute deviations.

It should give the same results as NoiseEstMADHost, up to floating-point accuracy. It uses transposed (baseline-major) memory order, which allows an entire baseline to be efficiently loaded into registers.

Note

There is a tradeoff in selecting the workgroup size: a large value gives more parallelism and reduces the register pressure, but increases the overhead of reduction operations.

Note

This class may fail for very large numbers of channels (10k can definitely be supported), in which case NoiseEstMADDevice may be used.

Parameters:
  • context (katsdpsigproc.abc.AbstractContext) – Context for which kernels will be compiled

  • max_channels – Maximum number of channels. Choosing too large a value will reduce performance.

  • tuning

    Kernel tuning parameters; if omitted, will autotune. The possible parameters are

    • wgsx: number of work-items per baseline

classmethod autotune(context: AbstractContext, max_channels: int) Mapping[str, Any][source]
context: AbstractContext
host_class

alias of NoiseEstMADHost

instantiate(command_queue: AbstractCommandQueue, channels: int, baselines: int, allocator: AbstractAllocator | None = None) NoiseEstMADTDevice[source]

Create an instance. See NoiseEstMADTDevice.

transposed: bool = True
class katsdpsigproc.rfi.device.ThresholdHostFromDevice(template: AbstractThresholdDeviceTemplate, command_queue: AbstractCommandQueue, *args, **kwargs)[source]

Bases: AbstractThresholdHost

Wrap a device-side thresholder template to present the host interface.

class katsdpsigproc.rfi.device.ThresholdSimpleDevice(template: ThresholdSimpleDeviceTemplate, command_queue: AbstractCommandQueue, channels: int, baselines: int, n_sigma: float, allocator: AbstractAllocator | None = None)[source]

Bases: AbstractThresholdDevice

Concrete instance of ThresholdSimpleDeviceTemplate.

Slots

deviationschannels × baselines (or transposed), float32

Input deviations from the background

noisebaselines, float32

Noise estimates per baseline

flagschannels × baselines (or transposed), uint8

Output flags

Parameters:
  • template – Operation template

  • command_queue – Command-queue in which work will be enqueued

  • channels – Shape of the visibility array

  • baselines – Shape of the visibility array

  • n_sigma – Number of (estimated) standard deviations for the threshold

  • allocator – Allocator used to allocate unbound slots

hidden_slots: Dict[str, IOSlotBase]
parameters() Mapping[str, Any][source]

Return dictionary of configuration options for this operation.

slots: Dict[str, IOSlotBase]
transposed: bool
class katsdpsigproc.rfi.device.ThresholdSimpleDeviceTemplate(context: AbstractContext, transposed: bool, flag_value: int = 1, tuning: Mapping[str, Any] | None = None)[source]

Bases: AbstractThresholdDeviceTemplate

Device-side thresholding, operating independently on each sample.

It should give the same results as ThresholdSimpleHost, up to floating-point accuracy.

This class can operate on either transposed or non-transposed inputs, depending on a constructor argument.

Parameters:
  • context (katsdpsigproc.abc.AbstractContext) – Context for which kernels will be compiled

  • transposed (bool) – Whether inputs and outputs are transposed

  • flag_value – Number stored in returned value to indicate RFI

  • tuning

    Kernel tuning parameters; if omitted, will autotune. The possible parameters are

    • wgsx: number of baselines (channels if transposed) per workgroup

    • wgsy: number of channels (baselines if transposed) per workgroup

classmethod autotune(context: AbstractContext) Mapping[str, Any][source]
context: AbstractContext
host_class

alias of ThresholdSimpleHost

instantiate(command_queue: AbstractCommandQueue, channels: int, baselines: int, n_sigma: float, allocator: AbstractAllocator | None = None) ThresholdSimpleDevice[source]

Create an instance. See ThresholdSimpleDevice.

transposed: bool
class katsdpsigproc.rfi.device.ThresholdSumDevice(template: ThresholdSumDeviceTemplate, command_queue: AbstractCommandQueue, channels: int, baselines: int, n_sigma: float, threshold_falloff: float = 1.2, allocator: AbstractAllocator | None = None)[source]

Bases: AbstractThresholdDevice

Concrete instance of ThresholdSumDeviceTemplate.

Slots

deviationsbaselines × channels, float32

Input deviations from the background

noisebaselines, float32

Noise estimates per baseline

flagsbaselines × channels, uint8

Output flags

Parameters:
  • template – Operation template

  • command_queue – Command-queue in which work will be enqueued

  • channels – Shape of the visibility array

  • baselines – Shape of the visibility array

  • n_sigma – Number of (estimated) standard deviations for the threshold

  • threshold_falloff – Controls rate at which thresholds decrease (ρ in Offringa 2010)

  • allocator – Allocator used to allocate unbound slots

DEFAULT_THRESHOLD_FALLOFF = 1.2
hidden_slots: Dict[str, IOSlotBase]
host_class

alias of ThresholdSumHost

parameters() Mapping[str, Any][source]

Return dictionary of configuration options for this operation.

slots: Dict[str, IOSlotBase]
transposed: bool = True
class katsdpsigproc.rfi.device.ThresholdSumDeviceTemplate(context: AbstractContext, n_windows: int = 4, flag_value: int = 1, tuning: Mapping[str, Any] | None = None)[source]

Bases: AbstractThresholdDeviceTemplate

A device version of katsdpsigproc.rfi.host.ThresholdSumHost.

It uses transposed data. Performance will be best with a large work group size, because of the stencil-like nature of the computation.

Parameters:
  • context (katsdpsigproc.abc.AbstractContext) – Context for which kernels will be compiled

  • n_windows – Number of window sizes to use

  • flag_value – Number stored in returned value to indicate RFI

  • tuning

    Kernel tuning parameters; if omitted, will autotune. The possible parameters are

    • wgs: Number of work items to use per work group

    • vt: Number of elements to process in each work item

classmethod autotune(context: AbstractContext, n_windows: int) Mapping[str, Any][source]
context: AbstractContext
host_class

alias of ThresholdSumHost

instantiate(command_queue: AbstractCommandQueue, channels: int, baselines: int, n_sigma: float, threshold_falloff: float = 1.2, allocator: AbstractAllocator | None = None) ThresholdSumDevice[source]

Create an instance. See ThresholdSumDevice.

transposed: bool = True

katsdpsigproc.rfi.host module

RFI flagging algorithms that run on the CPU.

class katsdpsigproc.rfi.host.AbstractBackgroundHost(width: int, amplitudes: bool = False)[source]

Bases: ABC

class katsdpsigproc.rfi.host.AbstractFlaggerHost[source]

Bases: ABC

class katsdpsigproc.rfi.host.AbstractNoiseEstHost[source]

Bases: ABC

class katsdpsigproc.rfi.host.AbstractThresholdHost(n_sigma: float)[source]

Bases: ABC

class katsdpsigproc.rfi.host.BackgroundMedianFilterHost(width: int, amplitudes: bool = False)[source]

Bases: AbstractBackgroundHost

Host backgrounder that applies a median filter to each baseline (by amplitude).

Parameters:
  • width – The kernel width (must be odd)

  • amplitudes – If True, the inputs are amplitudes rather than complex visibilities

class katsdpsigproc.rfi.host.FlaggerHost(background: AbstractBackgroundHost, noise_est: AbstractNoiseEstHost, threshold: AbstractThresholdHost)[source]

Bases: AbstractFlaggerHost

Combine host background and thresholding implementations to make a flagger.

class katsdpsigproc.rfi.host.NoiseEstMADHost[source]

Bases: AbstractNoiseEstHost

Estimate noise using the median of non-zero absolute deviations.

class katsdpsigproc.rfi.host.ThresholdSimpleHost(n_sigma: float, flag_value: int = 1)[source]

Bases: AbstractThresholdHost

Threshold each element independently.

Parameters:
  • n_sigma – Number of (estimated) standard deviations for the threshold

  • flag_value – Number stored in returned value to indicate RFI

class katsdpsigproc.rfi.host.ThresholdSumHost(n_sigma: float, n_windows: int = 4, threshold_falloff: float = 1.2, flag_value: int = 1)[source]

Bases: AbstractThresholdHost

Thresholding using the Offringa Sum-Threshold algorithm, with power-of-two sized windows.

The initial (single-pixel) threshold is determined by median of absolute deviations.

At present, auto- and cross-correlations are treated the same.

Parameters:
  • n_sigma – Number of (estimated) standard deviations for the threshold

  • n_windows – Number of window sizes to use

  • threshold_falloff – Controls rate at which thresholds decrease (ρ in Offringa 2010)

  • flag_value – Number stored in returned value to indicate RFI

apply_baseline(deviations: ndarray, threshold1: float) ndarray[source]

Apply the thresholding to a single baseline.

The flags are returned as booleans, rather than flag_value.

Parameters:
  • deviations (1D array, float) – Deviations from the background

  • threshold1 – Threshold for RFI on individual samples

katsdpsigproc.rfi.twodflag module

Library to contain 2d RFI flagging routines and other RFI related functions.

class katsdpsigproc.rfi.twodflag.SumThresholdFlagger(outlier_nsigma=4.5, windows_time=[1, 2, 4, 8], windows_freq=[1, 2, 4, 8], background_reject=2.0, background_iterations=1, spike_width_time=12.5, spike_width_freq=10.0, time_extend=3, freq_extend=3, freq_chunks=10, average_freq=1, flag_all_time_frac=0.6, flag_all_freq_frac=0.8, rho=1.3)[source]

Bases: object

Flagger that detects spikes in both frequency and time axes.

It uses the SumThreshold method (Offringa, A., MNRAS, 405, 155-167, 2010). The full algorithm does the following:

  1. Average the data in the frequency dimension (axis 1) into bins of size self.average_freq

  2. Divide the data into overlapping sub-chunks in frequency which are backgrounded and thresholded independently

  3. Flag a 1d spectrum median filtered in time to get fainter contaminated channels.

  4. Derive a smooth 2d background through each chunk

  5. SumThreshold the background subtracted chunks in time and frequency

  6. Extend derived flags in time and frequency, via self.freq_extend and self.time_extend

  7. Extend flags to all times and frequencies in cases when more than a given fraction of samples are flagged (via self.flag_all_time_frac and self.flag_all_freq_frac)

Parameters:
  • outlier_nsigma (float) – Number of sigma to reject outliers when thresholding

  • windows_time (array, int) – Size of averaging windows to use in the SumThreshold method in time

  • windows_freq (array, int) – Size of averaging windows to use in the SumThreshold method in frequency

  • background_reject (float) – Number of sigma to reject outliers when backgrounding

  • background_iterations (int) – Number of iterations to use when determining a smooth background, after each iteration data in excess of background_reject`*`sigma are masked

  • spike_width_time (float) – Characteristic width in dumps to smooth over when backgrounding. This is the one-sigma width of the convolving Gaussian in axis 0.

  • spike_width_freq (float) – Characteristic width in channels to smooth over when backgrounding. This is the one-sigma width of the convolving Gaussian in axis 1.

  • time_extend (int) – Size of kernel in time to convolve with flags after detection

  • freq_extend (int) – Size of kernel in frequency to convolve with flags after detection

  • freq_chunks (int) – Number of equal-sized chunks to independently flag in frequency. Smaller chunks will be less affected by variations in the band in the frequency domain.

  • average_freq (int) – Number of channels to average frequency before flagging. Flags will be extended to the frequency shape of the input data before being returned

  • flag_all_time_frac (float) – Fraction of data flagged above which to extend flags to all data in time axis.

  • flag_all_freq_frac (float) – Fraction of data flagged above which to extend flags to all data in frequency axis.

  • rho (float) – Falloff exponent for SumThreshold

get_flags(data, flags, pool=None, chunk_size=None, is_multiprocess=None)[source]

Compute flags in data array.

It has optional input flags of the same shape that denote samples in data to ignore when backgrounding and deriving thresholds.

This can run in parallel if given a concurrent.futures.Executor. Performance is generally better with a ThreadPoolExecutor. While a ProcessPoolExecutor is supported, it is usually limited by the speed at which the data can be pickled and transferred to the other processes.

Parameters:
  • data (3D array) – The input visibility data, in (time, frequency, baseline) order. It may also contain just the magnitudes.

  • flags (3D array, boolean) – Input flags.

  • pool (concurrent.futures.Executor, optional) – Worker pool for parallel computation. If not specified, computation will be done serially.

  • chunk_size (int, optional) – Number of baselines to process at a time. If not specified, heuristics are used to pick a reasonable value. Values above 16 give diminishing returns and much larger values may actually reduce performance. Power-of-two sizes are likely to perform best.

  • is_multiprocess (bool, optional) – If pool behaves like concurrent.futures.ProcessPoolExecutor (in particular, if it makes copies of its arguments) then this must be set to True to invoke a slower path that ensures that results are returned and reassembled. If unspecified, it defaults to true for concurrent.futures.ProcessPoolExecutor and false for all other types. Thus, it only needs to be specified when using an object that isn’t a concurrent.futures.ProcessPoolExecutor but behaves like one.

Returns:

out_flags – Derived flags (True=flagged)

Return type:

3D array, boolean, same shape as data

katsdpsigproc.rfi.twodflag.masked_gaussian_filter(data, flags, sigma, out, passes=4)[source]

Filter an image using an approximate Gaussian filter.

Some values may be flagged and are ignored. Values outside the grid are also treated as if flagged.

See _box_gaussian_filter() for a number of caveats. The result may contain non-finite values where the finite support of the Gaussian approximation contains no values without flags.

Parameters:
  • data (ndarray, 2D) – Input data to filter

  • flags (ndarray, bool) – True values correspond to elements of data to be ignored

  • sigma (float or sequence of floats) – Standard deviation of the Gaussian filter, per axis

  • out (ndarray, 2D) – Output array, with same shape as data

  • passes (int) – Number of boxcar filters to apply

Module contents

RFI flagging package.

The package consists of a number of algorithms for backgrounding, noise estimation and thresholding. Backgrounding finds a smooth version of the spectrum, with RFI removed. Noise estimation computes statistics on the Thresholding applies to the difference between the original spectrum and the background, and identifies the RFI as deviations that are too large to be noise.

A backgrounding, a noise estimation and a thresholding algorithm are combined in either host.FlaggerHost, device.FlaggerDevice, or device.FlaggerHostFromDevice.

katsdpsigproc.rfi.MAD_NORMAL = 1.4826

Ratio between median absolute deviation and standard deviation of a Gaussian distribution.