NuRadioReco.modules.RNO_G.channelBlockOffsetFitter module

Module to remove ‘block offsets’ from RNO-G voltage traces.

The function fit_block_offsets can be used standalone to perform an out-of-band fit to the block offsets. Alternatively, the channelBlockOffsets class contains convenience add_offsets (to add block offsets in simulation) and remove_offsets methods that can be run directly on a NuRadioMC/imported Event. The added/removed block offsets are stored per channel in the NuRadioReco.framework.parameters.channelParameters.block_offsets parameter.

class NuRadioReco.modules.RNO_G.channelBlockOffsetFitter.channelBlockOffsets(block_size=128, max_frequency=0.051000000000000004)[source]

Bases: object

Add or remove block offsets to channel traces

This module adds, fits or removes ‘block offsets’ by fitting them in a specified out-of-band region in frequency space.

Parameters:
block_size: int (default: 128)

The size (in samples) of the blocks

max_frequency: float (default: 51 MHz)

The maximum frequency to include in the out-of-band block offset fit

Methods

add_offsets(event, station[, offsets, ...])

Add (simulated or reconstructed) block offsets to an event.

remove_offsets(event, station[, mode, ...])

Remove block offsets from an event

add_offsets(event, station, offsets=0.001, channel_ids=None)[source]

Add (simulated or reconstructed) block offsets to an event.

Added block offsets for each channel are stored in the channelParameters.block_offsets parameter.

Parameters:
event: Event object | None
station: Station

The station to add block offsets to

offsets: float | array | dict

offsets to add to the event. Default: 1 mV

  • if a float, add gaussian-distributed of amplitude offsets to all channels specified;

  • if an array, the length should be the same as the number of blocks in a single trace, and the entries will be interpreted as the amplitudes of the offsets;

  • if a dict, the keys should be the channel ids, and each value should contain either a float or an array to add to each channel as specified above.

channel_ids: list | None

either a list of channel ids to apply the offsets to, or None to apply the offsets to all channels in the station (default: None).

remove_offsets(event, station, mode='fit', channel_ids=None, maxiter=5)[source]

Remove block offsets from an event

Fits and removes the block offsets from an event. The removed offsets are stored in the channelParameters.block_offsets parameter.

Parameters:
event: NuRadioReco.framework.event.Event | None
station: NuRadioReco.framework.station.Station

The station to remove the block offsets from

mode: ‘fit’ | ‘approximate’ | ‘stored’
  • ‘fit’ (default): fit the block offsets with a minimizer

  • ‘approximate’ : use the first guess from the out-of-band component, without any fitting (slightly faster)

  • ‘stored’: use the block offsets already stored in the channelParameters.block_offsets parameter. Will raise an error if this parameter is not present.

channel_ids: list | None

List of channel ids to remove offsets from. If None (default), remove offsets from all channels in station

maxiter: int, default 5

(Only if mode==’fit’) The maximum number of fit iterations. This can be increased to more accurately remove the block offsets at the cost of performance. (The default value removes ‘most’ offsets to about 1%)

NuRadioReco.modules.RNO_G.channelBlockOffsetFitter.fit_block_offsets(trace, block_size=128, sampling_rate=3.2, max_frequency=0.05, mode='fit', return_trace=False, maxiter=5, tol=1e-06)[source]

Fit ‘block’ offsets for a voltage trace

Fit block offsets (‘rect’-shaped offsets from a baseline) using a fit to the out-of-band spectrum of a voltage trace.

Parameters:
trace: numpy Array

the voltage trace

block_size: int (default: 128)

the number of samples in one block

sampling_rate: float (default: 3.2 GHz)

the sampling rate of the trace

max_frequency: float (default: 50 MHz)

the fit to the block offsets is performed in the frequency domain, in the band up to max_frequency

mode: ‘fit’ | ‘approximate’

Whether to fit the block offsets (default) or just use the first guess from the out-of-band component (faster)

return_trace: bool (default: False)

if True, return the tuple (offsets, output_trace) where the output_trace is the input trace with fitted block offsets removed

maxiter: int (default: 5)

(Only if mode==’fit’) The maximum number of fit iterations. This can be increased to more accurately remove the block offsets at the cost of performance. (The default value removes ‘most’ offsets to about 1%)

Returns:
block_offsets: numpy array

The fitted block offsets.

output_trace: numpy array or None

The input trace with the fitted block offsets removed. Returned only if return_trace=True

Other Parameters:
tol: float (default: 1e-6)

tolerance parameter passed on to scipy.optimize.minimize