NuRadioReco.modules.channelBandPassFilter module

class NuRadioReco.modules.channelBandPassFilter.channelBandPassFilter(caching=True)[source]

Bases: object

Band pass filters the channels using different band-pass filters.

Methods

get_filter(frequencies, station_id, ...[, ...])

helper function to return the filter that the module applies.

run(evt, station, det[, passband, ...])

Run the filter

begin

end

get_filter_arguments

Parameters:
caching: bool, default True

If True (default), internally caches the filter. This speeds up the (common) case where the same filter is applied to multiple channels.

Methods

get_filter(frequencies, station_id, ...[, ...])

helper function to return the filter that the module applies.

run(evt, station, det[, passband, ...])

Run the filter

begin

end

get_filter_arguments

begin()[source]
static get_filter_arguments(channel_id, passband, filter_type, order=2, rp=None, roll_width=None, half_hann_percent=None)[source]
run(evt, station, det, passband=None, filter_type='rectangular', order=2, rp=None, roll_width=0.0025, half_hann_percent=0.1)[source]

Run the filter

Parameters:
evt, station, det

Event, Station, Detector

passband: list or dict of lists, (default: [55 * units.MHz, 1000 * units.MHz])

passband[0]: lower boundary of filter, passband[1]: upper boundary of filter

a dict can be used to specify a different bandwidth per channel, the key is the channel_id

filter_type: string or dict
  • ‘rectangular’: perfect straight line filter

  • ‘butter’: butterworth filter from scipy

  • ‘butterabs’: absolute of butterworth filter from scipy

  • ‘gaussian_tapered’ : a rectangular bandpass filter convolved with a Gaussian

  • ‘hann_tapered’ : a rectangular bandpass filter with the ends replaced by a half-Hann window to applied in the time domain. In this case the passband parameter is ignored

  • ‘FIR <type> <parameter>’ - see below for FIR filter options

or any filter that is implemented in NuRadioReco.detector.filterresponse. In this case the passband parameter is ignored

a dict can be used to specify a different bandwidth per channel, the key is the channel_id

order: int (optional, default 2) or dict

for a butterworth filter: specifies the order of the filter

rp: float

The maximum ripple allowed below unity gain in the passband. Specified in decibels, as a positive number. (for chebyshev filter)

a dict can be used to specify a different bandwidth per channel, the key is the channel_id

roll_widthfloat, default=2.5MHz

Determines the sigma of the Gaussian to be used in the convolution of the rectangular filter. (Relevant for the Gaussian tapered filter)

half_hann_percentfloat, default=0.1

The size of the half-Hann window expressed as a percentage of the length of the trace. (Relevant for the Hann tapered filter)

Notes

Added Jan-07-2018 by robert.lahmann@fau.de: FIR filter: see https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.get_window.html for window types; some windows need additional parameters; Default window is hamming (does not need parameters). Examples:

  • filter_type=’FIR’ : use hamming window

  • filter_type=’FIR hamming’: same as above

  • filter_type=’FIR kaiser 10’ : Use Kaiser window with beta parameter 10

  • filter_type=’FIR kaiser’ : Use Kaiser window with default beta parameter 6

In principle, window names are just passed on to signal.firwin(), but if parameters are required, then these cases must be explicitly implemented in the code below.

The four main filter types can be implemented:

  • LP: passband[0]=None, passband[1] = f_cut

  • HP: passband[0]=f_cut, passband[1] = None

  • BP: passband[0]=f_cut_low, passband[1] = f_cut_high

  • BS: passband[0]=f_cut_high, passband[1] = f_cut_low (i.e. passband[0] > passband[1])

get_filter(frequencies, station_id, channel_id, det, passband, filter_type, order=2, rp=None, roll_width=0.0025, half_hann_percent=None)[source]

helper function to return the filter that the module applies.

The unused parameters station_id, channel_id, det are needed to have the same signature as the get_filter functions of other modules, e.g. the hardwareResponseIncorporator.

Note that this function returns the filter response in the frequency domain. Filters which are applied in the time domain (e.g. ‘FIR’, ‘hann_tapered’) will raise a NotImplementedError

Parameters:
frequencies: array of floats

the frequency array for which the filter should be returned

station_id: int

the station id

channel_id: int

the channel id

det: detector instance

the detector

passband: list or dict of lists, (default: [55 * units.MHz, 1000 * units.MHz])

passband[0]: lower boundary of filter, passband[1]: upper boundary of filter a dict can be used to specify a different bandwidth per channel, the key is the channel_id

filter_type: string or dict
  • ‘rectangular’: perfect straight line filter

  • ‘butter’: butterworth filter from scipy

  • ‘butterabs’: absolute of butterworth filter from scipy

  • ‘gaussian_tapered’ : Gaussian tapered version of the rectangular filter

or any filter that is implemented in NuRadioReco.detector.filterresponse. In this case the passband parameter is ignored

a dict can be used to specify a different bandwidth per channel, the key is the channel_id

order: int (optional, default 2) or dict

for a butterworth filter: specifies the order of the filter

rp: float

The maximum ripple allowed below unity gain in the passband. Specified in decibels, as a positive number. (for chebyshev filter)

a dict can be used to specify a different bandwidth per channel, the key is the channel_id

roll_widthfloat, default=2.5MHz

Determines the sigma of the Gaussian to be used in the convolution of the rectangular filter. (Relevant for the Gaussian tapered filter)

Returns:
array of complex floats

the complex filter amplitudes

Other Parameters:
half_hann_percent: None

This parameter is included to have the same signature as the run() method. As it is only relevant for the hann_tapered filter it is not actually used here.

end()[source]
NuRadioReco.modules.channelBandPassFilter.test_equality(a, b)[source]

Test if two things are equal.

Generalizes a==b to support lists, lists of lists and arrays etc. Will return True if and only if a and b are equal.

Parameters:
a: object | list | array
b: object | list | array
Returns:
is_equal: bool

True if and only if a == b