smiet.corsika.write_simulation module¶
-
smiet.corsika.write_simulation.generate_simulation(sim_nr, sim_primary, sim_cores, sim_zenith=
None, sim_azimuth=None, sim_energy=None, sim_xmax=None, slice_gram=5.0, magnetic_field='lofar', thinning=1e-07, atmosphere=17, core=None, radii=None, nr_of_arms=1, cherenkov=False, rotate: bool =False)¶ Prepare the contents for the INP, LIST and REAS files for a sliced MPI simulation, with a star shape pattern for the antenna layout.
One can choose to project the antennas along the shower axis or along the viewing angle by setting the cherenkov option. If this is set to True, the radii parameter will be interpreted as a list of viewing angles expressed as multiples of the slice Cherenkov angle. Otherwise, the radii parameter should be the list of radii to use in the star shape (use this option to generate origin showers).
The magnetic field vector can be taken from the radiotools.helper module, by passing a string as the magnetic_field parameter. This variable is passed on to the radiotools.helper.get_magnetic_field_vector function. But to be consistent with the CORSIKA definition where the magnetic field has no East-West component, the vector x-component is set to zero. This ensures the simulated antennas are indeed on the (vx)vxB axis.
The primary particle can be specified as a string, which will be converted to the corresponding CORSIKA particle code. As of June 2025, only proton, helium, carbon, silicon and iron primaries are supported (this is limited by the CORSIKA_PARTICLE_CODES dictionary).
- Parameters:¶
- sim_nr : int¶
The number of the simulation.
- sim_primary : {'proton', 'helium', 'carbon', 'silicon', 'iron'}¶
The primary particle to inject
- sim_cores : int¶
The number of cores the simulation will be run on
- sim_zenith : float, optional¶
The zenith angle in degrees. If not provided, the angle will be drawn from sample_zenith_angle.
- sim_azimuth : float, optional¶
The azimuth angle in degrees. If not provided, the angle will be drawn from sample_azimuth_angle.
- sim_energy : float, optional¶
The energy of the simulation in GeV. If not provided, the energy will be drawn from sample_primary_energy.
- sim_xmax : float, optional¶
The depth of shower maximum in g/cm^2. If provided, this value (along with sim_energy and sim_zenith) will be used to compute the first interaction height of the shower, using the parameterisation from CONEX. This value will be passed in the FIXHEI parameter in the CORSIKA input file.
- core : list of float, default=[0, 0, 0] * units.m¶
The core to use in the simulation
- slice_gram : float, default=5.0¶
The thickness of the atmospheric slices. NB: DO NOT put in internal units. We default the units to be g/cm^2.
- radii : list of float, default=None¶
The radii of the starshape, passed to smiet.corsika.generate_list_file
- nr_of_arms : int, default=1¶
The number of arms in the star shape pattern. This is passed to smiet.corsika.generate_list_file.
- cherenkov : bool, default=False¶
If True, interpret radii as multiples of slice Cherenkov radius, and calculate antenna radii per slice
- magnetic_field : np.ndarray or str, default='lofar'¶
If a string, the name of the site from which to take the magnetic field vector (using radiotools.helper). Otherwise, this is interpreted as the magnetic field vector (in internal units).
- thinning : float, default=1e-7¶
The thinning level to use
- atmosphere : int or str, default=17¶
The CORSIKA atmosphere identifier. If a string, the path to the GDAS atmosphere file.
- rotate : bool, default=False¶
Whether to rotate the antenna positions in the LIST file by 22.5 degrees so that the do not align with the vxB axis, which we know fails with template synthesis.
-
smiet.corsika.write_simulation.generate_simulation_from_hdf5(base_sim_file: str, sim_nr: int, sim_cores: int, sim_primary: str | int | None =
None, sim_energy: float | None =None, slice_gram: float =5.0, atm_file: str | None =None)¶ Generate simulation files for an origin shower from an existing coreas simulation.
The geometry, primary particle type and energy are taken from the base_sim_file simulation, as well as the observation level, magnetic field and thinning level. If there is no GDAS atmosphere file provided, the atmosphere model number is also taken from the base_sim_file.
- Parameters:¶
- base_sim_file : str¶
Path to the HDF5 simulation file on which we base the new simulation.
- sim_nr : int¶
The number of the new simulation.
- sim_cores : int¶
The number of cores the simulation will be run on
- sim_primary : str or int, default=None¶
If provided, the primary particle type to use in the new simulation. If a string, the type is converted to the CORSIKA identification code using CORSIKA_PARTICLE_CODES dictionary. In this case the particle needs to be supported (see the documentation of
generate_simulation()). Can also be an integer, in which case it is used as the CORSIKA particle code directly. If None, the primary particle type will be taken from the base_sim_file.- sim_energy : float, default=None¶
If provided, the primary energy to use in the new simulation. Otherwise, the energy will be taken from the base_sim_file.
- slice_gram : float, default=5.0¶
The thickness of the atmospheric slices in g/cm^2. NB: DO NOT put in internal units. We default the units to be g/cm^2.
- atm_file : str, default=None¶
The path to the GDAS atmosphere file. If None, the atmosphere model number from the base_sim_file will be used instead, and an atmosphere file will not be used.
-
smiet.corsika.write_simulation.sample_azimuth_angle(range=
(0, 360), size=1)¶ Sample the azimuth angle within the given range, from a uniform distribution.
-
smiet.corsika.write_simulation.sample_primary_energy(exp_range=
(8, 10), size=1)¶ Sample a single primary energy from log-uniform distribution, between the exponents given by exp_range. For example, using the default settings, calling this function will generate a value between \(10^{8}\) and \(10^{10}\) GeV.
-
smiet.corsika.write_simulation.sample_zenith_angle(range=
(0, 90), size=1, uniformity='sin2')¶ Sample the zenith angle from some distribution normalised with the solid angle. The names of the distributions refer to the variable in which they are uniform.
- Parameters:¶
- Returns:¶
zenith_angle – Sampled zenith angles (in internal units), as an array of length size
- Return type:¶
list of float
Notes
The names of the distributions refer to the variable in which they are uniform, in the sense that if you sampled using ‘sin2’ (the default), the zenith angle distribution will look uniform if binned in \(sin^2(\theta)\).
-
smiet.corsika.write_simulation.write_simulation_to_file(inp_file, list_file, reas_file, sim_directory=
'./', reset=False)¶ Write the provided contents of the INP, LIST and REAS files for a single simulation to the files in a directory named after the simulation number.
The directory will be created in the sim_directory path, and will be named SIMXXXXXX, where the last six digits are the simulation number. This is retrieved from the INP file contents, as the first line of the file. The function will fail if the directory already exists, unless reset is set to True, in which case the directory will be removed and re-created.
- Parameters:¶
- inp_file : list¶
The contents of the INP file
- list_file : list¶
The contents of the LIST file
- reas_file : list¶
The contents of the REAS file
- sim_directory : str, default='./'¶
The path to the directory where the simulation directory will be made, in which all files are written
- reset : bool, default=False¶
whether to delete the simulation directory or not