NuRadioReco.modules.measured_noise.channelMeasuredNoiseAdder module
- class NuRadioReco.modules.measured_noise.channelMeasuredNoiseAdder.channelMeasuredNoiseAdder[source]
Bases:
object
Module that adds measured noise to channel traces It does so by reading in a set of .nur files, randomly selecting a forced trigger event and adding the noise from it to the channel waveforms. The waveforms from the channels in the noise files need to be at least as long as the waveforms to which the noise is added, so it is recommended to cut them to the right size first, for example using the channelLengthAdjuster.
Methods
begin
([filenames, folder, file_pattern, ...])Set up module parameters
end
()End method.
get_noise_station
(station)Returns a random station from the noise files that can be used as a noise sample.
run
(event, station, det)Add measured noise to station channels
- begin(filenames=None, folder=None, file_pattern='*', random_seed=None, max_iterations=100, debug=False, draw_noise_statistics=False, channel_mapping=None, log_level=0, restrict_station_id=True, station_id=None, allow_noise_resampling=False, baseline_substraction=True, allowed_triggers=['FORCE'])[source]
Set up module parameters
- Parameters:
- filenames: list of strings
List of .nur files containing the measured noise. If None, look for .nur files in “folder”. (Default: None)
- folder: str
Only used when “filenames” is None. Directory to search for .nur files matching the “file_pattern” including subdirectories. (Default: None)
- file_pattern: str
Use
glob.glob(f"{folder}/**/{file_pattern}.nur", recursive=True)
to search for files. (Default: “*”)- random_seed: int, default: None
Seed for the random number generator. By default, no seed is set.
- max_iterations: int, default: 100
The module will pick a random event from the noise files, until a suitable event is found or until the number of iterations exceeds max_iterations. In that case, an error is thrown.
- debug: bool, default: False
Set True to get debug output
- draw_noise_statistics: boolean, default: False
If true, the values of all samples is stored and a histogram with noise statistics is drawn be the end() method
- channel_mapping: dict or None
option relevant for MC studies of new station designs where we do not have forced triggers for. The channel_mapping dictionary maps the channel ids of the MC station to the channel ids of the noise data Default is None which is 1-to-1 mapping
- log_level: logging log level
the log level, default logging.NOTSET (adhere to global logging level)
- baseline_substraction: boolean
Option to subtract mean from trace. Set mean_opt=False to remove mean subtraction from trace.
- restrict_station_id: bool
Require the station in the noise event to be the same as in the simulated event. (Default: True)
- station_id: int
If restrict_station_id is False specify the station id to be used for the noise. If None take first station in the noise event. (Default: None)
- allow_noise_resampling: bool
Allow resampling the noise trace to match the simulated trace. (Default: False)
- allowed_triggers: list(str)
List of trigger names which should be used, events with other triggers are not used. (Default: [“FORCE”])
- run(event, station, det)[source]
Add measured noise to station channels
- Parameters:
- event: event object
- station: station object
- det: detector description
- get_noise_station(station)[source]
Returns a random station from the noise files that can be used as a noise sample. The function selects a random event from the noise files and checks if it is suitable. If it is, the station is returned, otherwise None is returned. The event is suitable if it fulfills these criteria:
It contains a station with the same station ID as the one to which the noise shall be added
The station does not have a trigger that has triggered.
The every channel in the station to which the noise shall be added is also present in the station
- Parameters:
- station: Station class
The station to which the noise shall be added