NuRadioReco.modules.io.coreas.readCoREASDetector module
- NuRadioReco.modules.io.coreas.readCoREASDetector.get_random_core_positions(xmin, xmax, ymin, ymax, n_cores, seed=None)[source]
Generate random core positions within a rectangle
- Parameters:
- xmin: float
minimum x value
- xmax: float
maximum x value
- ymin: float
minimum y value
- ymax: float
maximum y value
- n_cores: int
number of cores to generate
- seed: int
seed for the random number generator
- Returns:
- cores: np.ndarray
array containing the core positions, shaped as (n_cores, 2)
- NuRadioReco.modules.io.coreas.readCoREASDetector.apply_hanning(efield)[source]
Apply a half-Hann window to the electric field in the time domain. This smoothens the edges to avoid ringing effects.
- Parameters:
- efield: np.ndarray
The electric field in the time domain, shaped as (n_samples, n_polarizations)
- Returns:
- smoothed_efield: np.ndarray
The smoothed trace, shaped as (n_samples, n_polarizations)
- NuRadioReco.modules.io.coreas.readCoREASDetector.select_channels_per_station(det, station_id, requested_channel_ids)[source]
Returns a defaultdict object containing the requested channel ids that are in the given station. This dict contains the channel group ids as keys with lists of channel ids as values.
- Parameters:
- detDetectorBase
The detector object that contains the station
- station_idint
The station id to select channels from
- requested_channel_idslist of int
List of requested channel ids
- Returns:
- channel_idsdefaultdict
Dictionary with channel group ids as keys and lists of channel ids as values
- class NuRadioReco.modules.io.coreas.readCoREASDetector.readCoREASDetector[source]
Bases:
object
Use this as default when reading CoREAS files and combining them with a detector.
This module reads the electric fields of a CoREAS file with a star shaped pattern of observers. The electric field is then interpolated at the positions of the antennas or stations of a detector. If the angle between magnetic field and shower direction are below about 15 deg, the interpolation is no longer reliable and the closest observer is used instead.
Methods
begin
(input_file[, interp_lowfreq, ...])Begin method to initialize readCoREASDetector module.
run
(detector, core_position_list[, ...])run method, get interpolated electric fields for the given detector and core positions and set them in the event.
end
- begin(input_file, interp_lowfreq=0.03, interp_highfreq=1.0, site=None, declination=None, log_level=0)[source]
Begin method to initialize readCoREASDetector module.
This function creates an Event using the provided CoREAS HDF5 file, using the coreas.read_CORSIKA7() function. The latter takes in the declination and
site
parameters in order to specify the declination of the magnetic field. Then, it creates a coreasInterpolator.coreasInterpolator() object with the event and initializes the electric field interpolator.- Parameters:
- input_file: str
coreas hdf5 file
- interp_lowfreq: float, default=30 * units.MHz
lower frequency for the bandpass filter in interpolation, should be broader than the sensitivity band of the detector
- interp_highfreq: float, default=1000 * units.MHz
higher frequency for the bandpass filter in interpolation, should be broader than the sensitivity band of the detector
- declination: float, default=None
The declination to use for the magnetic field, in internal units. Takes precedence over site. This parameter is passed on to the coreas.read_CORSIKA7() function.
- site: str, default=None
Instead of declination, a site name can be given to retrieve the declination. This parameter is passed on to the coreas.read_CORSIKA7() function.
- log_level: default=logging.NOTSET
log level for the logger
- run(detector, core_position_list, selected_station_channel_ids=None)[source]
run method, get interpolated electric fields for the given detector and core positions and set them in the event. The trace is smoothed with a half-Hann window to avoid ringing effects. When using short traces, this might have a significant effect on the result.
- Parameters:
- detector: `NuRadioReco.detector.detector_base.DetectorBase`
Detector description of the detector that shall be simulated
- core_position_list: list of (list of float)
List of 2D or 3D core positions in the format [[x1, y1, (z1)], [x2, y2, (z2)], …] The z coordinate is optional. It is actually encouraged to not use it, as it can mess with the observation level of the event. If not provided, all oberser positions are put at the observation by the interpolator (this is the behaviour of coreasInterpolator.get_interp_efield_value).
- selected_station_channel_ids: dict, default=None
A dictionary containing the list of channels IDs to simulate per station. If None, all channels of all stations in the detector are simulated. To select a station and simulate all its channels, set its value to None.
- Yields:
- evt
NuRadioReco.framework.event.Event
An Event containing a Station object for every selected station, which holds a SimStation containing the interpolated ElectricField traces for the selected channels.
- evt
Examples
When running the module, you will probably want to run it with 2-dimensional core positions. This ensures that the observation level is not altered. It is possible to run with 3-dimensional core positions, but be careful to have the correct altitude, otherwise unexpected results might occur.
>>> reader = readCoREASDetector() >>> reader.begin('coreas.hdf5', interp_lowfreq=30 * units.MHz, interp_highfreq=80 * units.MHz) >>> for evt in reader.run(detector, [[0, 0], [10 * units.m, 10 * units.m]]): >>> print(evt.get_id())
If we only want to simulate a subset of the stations of our detector, we can select them by passing a dictionary for the selected_station_channel_ids parameter. The keys should be the station IDs and the value should be None to indicate we want to simulate all channels. So to simulate all channels of stations 2 and 7, we would do the following.
>>> my_selection = {2: None, 7: None} >>> reader = readCoREASDetector() >>> reader.begin('coreas.hdf5', interp_lowfreq=30 * units.MHz, interp_highfreq=80 * units.MHz) >>> for evt in reader.run(detector, [[0, 0], [10 * units.m, 10 * units.m]], selected_station_channel_ids): >>> print(evt.get_id())
Setting the value to a list of channel IDs will only simulate these selected channels of the station they are associated to. Here we simulate the first 4 channels of station 2 and the first 2 channels of station 7, for the case of the LOFAR detector description.
>>> my_selection = {2: [2000000, 2000001, 2000002, 2000003], 7: [7000000, 7000001]} >>> reader = readCoREASDetector() >>> reader.begin('coreas.hdf5', interp_lowfreq=30 * units.MHz, interp_highfreq=80 * units.MHz) >>> for evt in reader.run(detector, [[0, 0], [10 * units.m, 10 * units.m]], selected_station_channel_ids): >>> print(evt.get_id())