smiet.numpy.io.base_shower module

class smiet.numpy.io.base_shower.CoreasHDF5(file_path)

Bases: object

The CoreasHDF5 class is a base class for reading in HDF5 files produced by CoREAS.

It extracts the settings used in the CoREAS simulation, like the time resolution and the core position. It also reads in settings from the CORSIKA part, such as the geometry and the magnetic field. These two are available as dictionaries in the coreas_settings and corsika_settings properties. Next to the settings, it is also possible to get in the longitudinal profile of the shower. Furthermore, the class offers a method to read in the time traces of an observer in the HDF5 file.

Note that it returns all quantities in the NRR coordinate system, which is different from the CORSIKA coordinate system.

Parameters:
file_path : str

The path to the CoREAS HDF5 file

property coreas_settings

Get the CoREAS configuration of this simulation. This is contained in a dictionary, with the following keys:

  • core_coordinate: The core position in the NRR coordinate system

  • time_resolution: The time resolution of the simulation

  • automatic_time_boundaries: The automatic time boundaries of the simulation

  • manual_time_boundaries: The manual time boundaries of the simulation

  • n0: The refractive index at sea level

property corsika_settings

Get the CORSIKA configuration of this simulation. This is contained in a dictionary, with the following keys:

  • zenith: The zenith angle of the shower

  • azimuth: The azimuth angle of the shower

  • magnetic_field: The magnetic field vector in the NRR coordinate system

  • observation_level: The observation level of the shower

  • atmosphere_model: The atmosphere model used in the simulation

  • primary_particle: The primary particle used in the simulation

  • primary_energy: The energy of the primary particle

  • thinning_level: The thinning level used in the simulation

filter_trace(trace, f_min, f_max)

Filter a trace between f_min and f_max using the internal time resolution of the simulation.

The function assumes the time samples are on the last axis, but if this dimension does not match the trace length it will check the other axes to see if any other dimension matches the trace length. The filter used is a straightforward bandpass filter, using the bandpass_filter_trace() function.

Parameters:
trace : np.ndarray

The trace to filter. Can be multidimensional.

f_min : float

The lower frequency (in internal units)

f_max : float

The upper frequency (in internal units)

Returns:

filtered_trace – The bandpass filtered trace

Return type:

np.ndarray

get_gaisser_hillas_parameters()

Get the Gaisser-Hillas parameters of the shower from the HDF5 file stored in the self._file attribute.

The parameters are read from the “GaisserHillasParameters” dataset, which sits in the “atmosphere” group.

Returns:

gh_parameters – A dictionary containing the Gaisser-Hillas parameters of the shower. The keys are: ‘nmax’, ‘x0’, ‘xmax’, ‘lambda’, ‘L’, ‘R’

Return type:

dict

get_long_profile()

Get the longitudinal profile of the shower from the HDF5 file stored in the self._file attribute.

The profile is read from the “NumberOfParticles” dataset, which sits in the “atmosphere” group.

Returns:

  • grammages (np.ndarray) – The grammages at which the longitudinal profile is defined

  • long_profile (np.ndarray) – The longitudinal profile of the shower

get_trace_raw(observer_name)

Get the raw trace (as produced by CoREAS) from an observer in the HDF5.

The trace is converted to the internal coordinate system before being returned.

Parameters:
observer_name : str

The name of the observer as defined in the HDF5 file

Returns:

  • trace_slice_ground (np.ndarray) – The raw trace (on the ground), shaped as (trace_length, 3).

  • trace_time_array (np.ndarray) – The array containing the timings of the samples, shaped as (trace_length,). This is just the first column of the CoREAS output, converted to internal units.

property name

Get the name of the simulation, which is the filename without the extension.

property trace_length

The number of samples in each time trace. This is calculated from the time boundaries (automatic or manual) and the time resolution of the simulation.

class smiet.numpy.io.base_shower.Shower(atm_model=17)

Bases: object

The Shower class represents an air shower setup and evolution.

It holds the geometric information for a shower, like the zenith/azimuth, as well as the longitudinal profile. Next to this, it can also store the magnetic field, the atmosphere in which it was simulated, and the core. These variables are used to calculate the radiotools.coordinatesystems.cstrafo object, which can be used to convert between different coordinate systems. The primary use case is to specify the target parameters for a shower in template synthesis.

atmosphere

The atmosphere in which the shower was simulated

Type:

radiotools.atmosphere.models.Atmosphere

core

The position of the core in the NRR coordinate system

Type:

np.ndarray

property GH_parameters : dict

Get the Gaisser-Hillas parameters as a dictionary.

property azimuth

The azimuth angle of the shower (in internal units).

copy_settings(other)

This convenience method allows to easily copy the settings from another Shower, which is useful when for example creating a target Shower.

Parameters:
other : Shower

The Shower to copy the settings from.

Notes

The settings which are copied from the other shower are:

  • The geometry

  • The magnetic field vector

  • The simulation core

  • The slice grammage

  • The atmosphere

fit_gaisser_hillas()

Fit a Gaisser-Hillas function to the currently loaded longitudinal profile, to determine the parameters like \(X_{max}\) and \(N_{max}\).

Returns:

popt – The parameters of the Gaisser-Hillas function, in the order [N, X0, Xmax, p0, p1, p2] (p0,p1,p2 are the polynomial coefficients in denominator for lambda)

Return type:

np.ndarray

Notes

The Gaisser-Hillas function is defined as:

\[f(X) = N \left( \frac{X - X_0}{X_{max} - X_0} \right)^{\frac{X_{max} - X_0}{\lambda}} \exp\left( \frac{X_{max} - X}{\lambda} \right)\]
property geomagnetic_angle

Calculate the angle between the magnetic field vector and the shower axis

get_transformer()

Get the transformer object from radiotools which can be used to convert between different coordinate systems. The transformer is cached, so that it is only calculated once. If the geometry or magnetic field vector gets updated, the transformer is reset.

Returns:

transformer – The cstrafo object with the current geometry and magnetic field vector.

Return type:

radiotools.coordinatesystems.cstrafo

property grammages

The grammages at which the longitudinal profile is defined in.

property long_profile

The longitudinal profile of the shower, containing the sum of positrons and electrons. The profile should have the shape (slices,).

property magnet

Magnetic field vector in the NRR coordinate system

property nmax

The \(N_{max}\) of the shower. This results from fitting a GH to the longitudinal profile (ie not set manually).

set_parameters(grammages, long_profile, xmax, nmax, zenith, azimuth, magnetic_field, core) None

Set the parameters of the shower model from a dictionary of parameters.

This is a convenience function to set all parameters at once.

Parameters:
grammages : np.ndarray

an array of atmospheric depth in g/cm^2

long_profile : np.ndarray

an array of the longitudinal profile of the shower

xmax : float

depth of shower maximum in g/cm^2. Not used for now as the values are directly fitted from the profile.

nmax : float

number of particles at shower maximum. Not used for now as the values are directly fitted from the profile.

zenith : float

zenith angle in radians

azimuth : float

azimuthal angle in radians

magnetic_field : np.ndarray

magnetic field vector in Gauss. Must be a 3-vector

core : np.ndarray

core position in meters. Must be a 3-vector

property slice_grammage

The (slant depth) step width with which the longitudinal profile is sampled. This is inferred from the longitudinal profile when that one is set.

transform_profile_to_origin(origin_grammages) None

Transform the longitudinal profile to match those of the origin shower.

This is needed such that the grammages of the origin and target match.

Parameters:
origin_grammages : jax.typing.ArrayLike

The grammages of the origin shower.

property xmax

The \(X_{max}\) of the shower. This is the result from fitting a GH to the longitudinal profile (not set manually).

property zenith

The zenith angle of the shower (in internal units).