NuRadioReco.modules.io.coreas.coreasInterpolator module

class NuRadioReco.modules.io.coreas.coreasInterpolator.coreasInterpolator(corsika_evt)[source]

Bases: object

Interface to interpolate the electric field traces, as for example provided by CoREAS.

For the best results, ensure that the electric fields are in on-sky coordinates (this is the case when using the NuRadioReco.modules.io.coreas.coreas.read_CORSIKA7 function).

After having created the interpolator, you can either choose to interpolate the electric field traces or either the fluence (or both, but be careful to not mix them up). In order to do this, you first need to initialize the corresponding interpolator with the desired settings. Refer to the documentation of initialize_efield_interpolator and initialize_fluence_interpolator for more information. After initialization, you can call the interpolate_efield and interpolate_fluence functions to get the interpolated values.

Note that when trying to interpolate the electric fields of an air shower with a geomagnetic angle smaller than 15 degrees, the interpolator will fall back to using the closest observer position instead of performing the Fourier interpolation. Also, when attempting to extrapolate (ie get a value for a position that is outside the star shape pattern), the default behaviour is to return zeros when r > r_max and return a constant value when r <= r_min. This behaviour can be changed using the allow_extrapolation keyword argument when initialising the interpolator.

Parameters:
corsika_evtEvent

An Event object containing the CoREAS output, from read_CORSIKA7()

Attributes:
azimuth

The azimuth of the shower axis

efields_rotation_angle

The angle with which the e_theta and e_phi components of the electric field were rotated

magnetic_field_vector

The magnetic field vector stored inside the shower

starshape_radius

returns the maximal radius of the star shape pattern in the shower plane

starshape_radius_ground

returns the maximal radius of the star shape pattern on ground

zenith

The zenith of the shower axis

Methods

get_closest_observer_efield(...)

Returns the electric field of the closest observer position for an antenna position in the shower plane.

get_empty_efield()

Get an array of zeros in the shape of the electric field on the sky

get_interp_efield_value(position_on_ground)

Calculate the interpolated electric field given an antenna position on ground.

get_interp_fluence_value(position_on_ground)

Calculate the interpolated fluence for a given position on the ground.

get_position_showerplane(position_on_ground)

Transform the position of the antenna on ground to the shower plane.

initialize_efield_interpolator(...)

Initialise the efield signal interpolator

initialize_fluence_interpolator([quantity])

Initialise fluence interpolator.

initialize_star_shape()

Initializes the star shape pattern for interpolation, e.g. creates the arrays with the observer positions in the shower plane and the electric field.

plot_fluence_footprint([radius])

plots the interpolated values of the fluence in the shower plane

set_fluence_of_efields(function[, quantity])

Set the fluence quantity of all electric fields in the SimStation of the interpolator.

Notes

The interpolation method is based on the Fourier interpolation method described in Corstanje et al. (2023), JINST 18 P09005. The implementation lives in a separate package called cr-pulse-interpolator (this package is a optional dependency of NuRadioReco).

In short, the interpolation method works as follows: everything is done in the showerplane, where we expect circular symmetries due to the emission mechanisms. In case of fluence interpolation, we are working with a single value per observer position. The positions are expected to be in a starshape pattern, such that for each ring a Fourier series can be constructed for the fluence values. The components of the Fourier series are then radially interpolated using a cubic spline.

When interpolating electric fields, the traces are first transformed to frequency spectra. The amplitude in each frequency bin is then interpolated as a single value, as described above. The phases are also interpolated, making the relative timings consistent. To also get an absolute timing, one can provide the trace start times to also be interpolated (this is done in this implementation).

initialize_star_shape()[source]

Initializes the star shape pattern for interpolation, e.g. creates the arrays with the observer positions in the shower plane and the electric field.

property zenith

The zenith of the shower axis

property azimuth

The azimuth of the shower axis

property magnetic_field_vector

The magnetic field vector stored inside the shower

property starshape_radius

returns the maximal radius of the star shape pattern in the shower plane

property starshape_radius_ground

returns the maximal radius of the star shape pattern on ground

property efields_rotation_angle

The angle with which the e_theta and e_phi components of the electric field were rotated

get_empty_efield()[source]

Get an array of zeros in the shape of the electric field on the sky

set_fluence_of_efields(function, quantity=<electricFieldParameters.signal_energy_fluence: 4>)[source]

Set the fluence quantity of all electric fields in the SimStation of the interpolator.

Helper function to set the fluence of electric fields. These values can then be used for fluence interpolation.

One option to use as function is NuRadioReco.utilities.trace_utilities.get_electric_field_energy_fluence.

Parameters:
function: callable

The function to apply to the traces in order to calculate the fluence. Should take in a (3, n_samples) shaped array and return a float (or an array with 3 elements if you want the fluence per polarisation).

quantity: electric field parameter, default=efp.signal_energy_fluence

The parameter where to store the result of the fluence calculation

See also

NuRadioReco.utilities.trace_utilities.get_electric_field_energy_fluence

Function that can be passed as function to obtain the energy fluence of the electric fields in the SimStation.

initialize_efield_interpolator(interp_lowfreq, interp_highfreq, **kwargs)[source]

Initialise the efield signal interpolator

If initialised correctly, this method returns the resulting efield interpolator (it is also stored as the efield_interpolator attribute of the class). If the latter, the efield_interpolator_initialized is also set to True.

If the geomagnetic angle is smaller than 15deg, the interpolator switches to using the closest observer position instead. In this case, no interpolator object is returned and the efield_interpolator attribute is set to a Fourier interpolator which interpolates the arrival times. To distinguish between the two cases, you can check the efield_interpolator_initialized attribute, which is True when the signal interpolator is initialised and False when the closest observer is used.

To adjust the parameters of the signal interpolation, the options for the interp2d_signal class can be passed as keyword arguments. Please refer to the cr-pulse-interpolator documentation for all available options.

Parameters:
interp_lowfreqfloat

Lower frequency for the bandpass filter in interpolation (in internal units)

interp_highfreqfloat

Upper frequency for the bandpass filter in interpolation (in internal units)

**kwargsoptions to pass on to the interp2d_signal class

Default values are:

  • phase_method : ‘phasor’

  • radial_method : ‘cubic’

  • upsample_factor : 5

  • coherency_cutoff_threshold : 0.9

  • allow_extrapolation : False

  • ignore_cutoff_freq_in_timing : False

  • verbose : False

Returns:
efield_interpolatorinterpolator object
initialize_fluence_interpolator(quantity=<electricFieldParameters.signal_energy_fluence: 4>, **kwargs)[source]

Initialise fluence interpolator.

Initialize the fluence interpolator using the values stored in the quantity parameter of the electric fields.

Parameters:
quantityelectric field parameter, default=efp.signal_energy_fluence

The quantity to get the values from which are fed to the interpolator. It needs to be available as parameter in the electric field object! You can use the set_fluence_of_efields() function to set this value for all electric fields.

**kwargs: options to pass on to the `interp2d_fourier` class

Default values are:

  • radial_method : ‘cubic’

  • fill_value : None

  • recover_concentric_rings : False

Returns:
fluence_interpolatorinterpolator object
get_position_showerplane(position_on_ground)[source]

Transform the position of the antenna on ground to the shower plane.

Parameters:
position_on_groundnp.ndarray

Position of the antenna on ground This value can either be a 2D array (x, y) or a 3D array (x, y, z). If the z-coordinate is missing, the z-coordinate is automatically set to the observation level of the simulation.

get_interp_efield_value(position_on_ground, cs_transform='no_transform')[source]

Calculate the interpolated electric field given an antenna position on ground.

If the geomagnetic angle is smaller than 15deg, the electric field of the closest observer position is returned instead.

Note that position_on_ground is in absolute coordinates, not relative to the core position. Extrapolation outside of the starshape is handled by the cr-pulse-interpolator package (see also the description of kwargs in initialize_efield_interpolator).

Parameters:
position_on_groundnp.ndarray

Position of the antenna on ground This value can either be a 2D array (x, y) or a 3D array (x, y, z). If the z-coordinate is missing, the z-coordinate is automatically set to the observation level of the simulation.

cs_transform: {‘no_transform’, ‘sky_to_ground’}, default=’no_transform’

Optional coordinate system transformation to apply to the interpolated electric field. If ‘no_transform’, the default, the electric field is returned in the same coordinate system as it was stored in the Event used for initialisation (usually on-sky). If ‘sky_to_ground’, the electric field is transformed to the ground coordinate system using the cstrafo.transform_from_onsky_to_ground() function.

Returns:
efield_interpfloat

Interpolated efield value

trace_start_timefloat

Start time of the trace

get_interp_fluence_value(position_on_ground)[source]

Calculate the interpolated fluence for a given position on the ground.

Note that position_on_ground is in absolute coordinates, not relative to the core position. Extrapolation outside of the starshape is handled by the cr-pulse-interpolator package (see also the description of kwargs in initialize_fluence_interpolator).

Parameters:
position_on_groundnp.ndarray

Position of the antenna on ground This value can either be a 2D array (x, y) or a 3D array (x, y, z). If the z-coordinate is missing, the z-coordinate is automatically set to the observation level of the simulation.

Returns:
fluence_interpfloat

interpolated fluence value

get_closest_observer_efield(antenna_pos_showerplane)[source]

Returns the electric field of the closest observer position for an antenna position in the shower plane.

The start time of the trace is also returned, by interpolating the start times of the electric field traces.

This function is not meant to be called directly, but only from get_interp_efield_value as it assumes the efield_interpolator attribute is set to the start time interpolator, which is done in initialize_efield_interpolator.

Parameters:
antenna_pos_showerplanenp.ndarray

antenna position in the shower plane

Returns:
efield: np.ndarray

electric field, as an array shaped

efield_start_time: float

The start time of the selected electric field trace (in internal units)

plot_fluence_footprint(radius=300)[source]

plots the interpolated values of the fluence in the shower plane

Parameters:
radiusfloat

radius around shower core which should be plotted

Returns:
figfigure object
axaxis object