NuRadioReco.modules.channelSinewaveSubtraction module

NuRadioReco.modules.channelSinewaveSubtraction.logger = <NuRadioLogger NuRadioReco.modules.channelSinewaveSubtraction (STATUS)>

This module provides a class for continuous wave (CW) noise filtering using sine subtraction. In contrast to the module channelCWNOtchFilter, which uses a notch filter to remove CW noise.

class NuRadioReco.modules.channelSinewaveSubtraction.channelSinewaveSubtraction[source]

Bases: object

Continuous wave (CW) filter module. Uses sine subtraction based on scipy curve_fit.

Methods

begin([save_filtered_freqs, freq_band])

Initialize the CW filter module.

get_filtered_frequencies()

Get the list of identified noise frequencies for each channel.

run(event, station[, det, peak_prominence])

Run the CW filter module on a given event and station.

begin(save_filtered_freqs: bool = False, freq_band: tuple[float, float] = (0.1, 0.7)) None[source]

Initialize the CW filter module.

Parameters:
save_filtered_freqs: bool (default: False)

Flag to save the identified noise frequencies for each channel.

freq_band: tuple (default: (0.1, 0.7))

Frequency band to calculate baseline RMS of fft spectrum. Used to identify noise peaks. 0.1 to 0.7 GHz is the default for RNO-G, based on bandpass.

run(event: Event, station: Station, det=None, peak_prominence: float = 4.0) None[source]

Run the CW filter module on a given event and station. Removes all the CW peaks > peak_prominence * RMS.

Parameters:
event: `NuRadioReco.framework.event.Event`

Event object to process.

station: `NuRadioReco.framework.station.Station`

Station object to process.

det: `NuRadioReco.detector.detector.Detector` (default: None)

Detector object to process.

peak_prominence: float (default: 4.0)

Threshold for identifying prominent peaks in the FFT spectrum.

get_filtered_frequencies()[source]

Get the list of identified noise frequencies for each channel.

NuRadioReco.modules.channelSinewaveSubtraction.guess_amplitude(wf: ndarray, target_freq: float, sampling_rate: float = 3.2)[source]

Estimate the amplitude of a specific harmonic in the waveform.

Parameters:
wf: np.ndarray

Input waveform (1D array).

target_freq: float

Target frequency (GHz) for which to estimate amplitude.

sampling_rate: float (default: 3.2)

Sampling rate of the waveform (GHz).

Returns:
ampl: float

Estimated amplitude of the target frequency.

NuRadioReco.modules.channelSinewaveSubtraction.guess_amplitude_iir(wf: ndarray, target_freq: float, sampling_rate: float = 3.2)[source]

Estimate the amplitude of a specific frequency using an IIR filter representation of Goertzel.

Parameters:
wf: np.ndarray

Input waveform (1D array).

target_freq: float

Target frequency (GHz) to analyze.

sampling_rate: float (default: 3.2)

Sampling rate of the waveform (GHz).

Returns:
amplitude: float

Estimated amplitude at the target frequency.

NuRadioReco.modules.channelSinewaveSubtraction.guess_phase(fft_spec: ndarray, freqs: ndarray, target_freq: float)[source]

Estimate the phase of a specific frequency in the FFT spectrum.

Parameters:
fft_spec: np.ndarray

FFT spectrum of the waveform.

freq: np.ndarray

Frequency array corresponding to the FFT spectrum.

target_freq: float

Target frequency (GHz) for which to estimate phase.

sampling_rate: float (default: 3.2)

Sampling rate of the waveform (GHz).

Returns:
phase: float

Estimated phase of the target frequency.

NuRadioReco.modules.channelSinewaveSubtraction.sinewave_subtraction(wf: ndarray, peak_prominence: float = 4.0, sampling_rate: float = 3.2, saved_noise_freqs: list | None = None, freq_band: tuple = (0.1, 0.7))[source]

Perform sine subtraction on a waveform to remove CW noise.

Parameters:
wf: np.ndarray

Input waveform (1D array).

sampling_rate: float (default: 3.2)

Sampling rate of the waveform (GHz).

peak_prominance: float (default: 6.0)

Threshold for identifying prominent peaks in the FFT spectrum.

saved_noise_freqs: list (default: None)

A list to store identified noise frequencies for each channel.

freq_band: tuple (default for RNO-g: (0.1, 0.7))

Frequency band to calculate baseline RMS of fft spectrum. Used to identify noise peaks.

Returns:
np.ndarray

Corrected waveform with CW noise removed.

NuRadioReco.modules.channelSinewaveSubtraction.plot_ft(channel, ax, label=None, plot_kwargs={})[source]

Function to plot real frequency spectrum of given channel

Parameters:
channel: `NuRadioReco.framework.channel.Channel`

Channel from which to get trace

ax: matplotlib.axes

ax on which to plot

label: string

plotlabel

plot_kwargs: dict

options for plotting

NuRadioReco.modules.channelSinewaveSubtraction.plot_trace(channel, ax, label=None, plot_kwargs={})[source]

Function to plot trace of given channel.

Parameters:
channel: `NuRadioReco.framework.channel.Channel`

Channel from which to get trace

ax: matplotlib.axes

ax on which to plot

fs: float, default = 3.2 Hz

sampling frequency

label: string

plotlabel

plot_kwargs: dict

options for plotting