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.

begin()

(Unused)

end()

(Unused)

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

Remove block offsets from an event

run(event, station[, det, mode, channel_ids])

Remove the block offsets from all channels of a station.

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:
eventNuRadioReco.framework.event.Event | None
stationNuRadioReco.framework.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='auto', 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:
eventNuRadioReco.framework.event.Event | None
stationNuRadioReco.framework.station.Station

The station to remove the block offsets from

mode: str {‘auto’, ‘fit’, ‘approximate’, ‘stored’}, optional
  • ‘fit’: fit the block offsets with a minimizer

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

  • ‘auto’ (default): decide automatically between ‘approximate’ and ‘fit’ based on the estimated size of the block offsets.

  • ‘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%)

See also

run

alias of this method

begin()[source]

(Unused)

run(event, station, det=None, mode='auto', channel_ids=None, **kwargs)[source]

Remove the block offsets from all channels of a station.

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

This method is an alias of remove_offsets, with the only difference the inclusion of the (unused) det parameter, to be consistent with the run methods of other NuRadio classes.

Parameters:
eventNuRadioReco.framework.event.Event | None
stationNuRadioReco.framework.station.Station

The station to remove the block offsets from

detDetector object, optional

Detector object (not used in this method, included to have the same signature as other NuRadio classes)

modestr {‘auto’, ‘fit’, ‘approximate’, ‘stored’}, optional
  • ‘fit’: fit the block offsets with a minimizer

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

  • ‘auto’ (default): decide automatically between ‘approximate’ and ‘fit’ based on the estimated size of the block offsets.

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

channel_idslist | None

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

**kwargskeyword arguments

Other keyword arguments to be passed to the remove_offsets function.

See also

remove_offsets

alias of this method without the (unused) det parameter

end()[source]

(Unused)

NuRadioReco.modules.RNO_G.channelBlockOffsetFitter.fit_block_offsets(trace, block_size=128, sampling_rate=3.2, max_frequency=0.05, mode='auto', 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

modestr {‘auto’, ‘fit’, ‘approximate’}, optional

Whether to fit the block offsets or just use the first guess from the out-of-band component (faster). By default (‘auto’), decide automatically based on the size of the block offsets (only fit if the largest block offset exceeds 50% of the Vrms).

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

See also

channelBlockOffsets

Class that uses this function to automatically remove the block offsets for all channels in a station.