Skip to content

Commit

Permalink
Set station time and only read shower energies if simulation is in pa…
Browse files Browse the repository at this point in the history
…rticle mode
  • Loading branch information
christophwelling committed Aug 29, 2023
1 parent 73ec602 commit 681d2b3
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
3 changes: 3 additions & 0 deletions NuRadioMC/simulation/hardware_response_simulator.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import numpy as np
import copy
import astropy.time
import NuRadioReco.framework.station
import NuRadioReco.framework.sim_station
import NuRadioReco.framework.event
Expand Down Expand Up @@ -138,6 +139,8 @@ def simulate_detector_response(
new_station = NuRadioReco.framework.station.Station(station_id)
new_station.set_sim_station(new_sim_station)
new_event = NuRadioReco.framework.event.Event(self.__event_group_id, i_sub_event)
new_station.set_station_time(astropy.time.Time(['2018-01-01T00:00:01.000'], scale='utc', format='isot'))
new_station.get_sim_station().set_station_time(new_station.get_station_time())
new_event.set_station(new_station)
if self.__config['signal']['zerosignal']:
self.__increase_signal(new_station, None, 0)
Expand Down
7 changes: 4 additions & 3 deletions NuRadioMC/simulation/shower_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ def set_event_group(
self,
i_event_group,
event_group_id,
event_indices
event_indices,
particle_mode
):
self.__i_event_group = i_event_group
self.__event_group_id = event_group_id
Expand All @@ -63,7 +64,8 @@ def set_event_group(
self.__event_group_vertex_distances = np.linalg.norm(
self.__event_group_vertices - self.__event_group_vertices[0], axis=1
)
self.__event_group_shower_energies = self.__input_data['energies'][event_indices]
if particle_mode:
self.__event_group_shower_energies = self.__input_data['energies'][event_indices]
self.__channel_efield_simulator.set_event_group(np.sum(self.__event_group_shower_energies))

def simulate_shower(
Expand All @@ -86,7 +88,6 @@ def simulate_shower(
self.__input_data['yy'][shower_index],
self.__input_data['zz'][shower_index]
])
vertex_time = self.__input_data['vertex_times'][shower_index]
if not self.__distance_cut(shower_vertex):
return [], [], [], [], [], [], [], []
if not self.__in_fiducial_volume(shower_vertex):
Expand Down
6 changes: 3 additions & 3 deletions NuRadioMC/simulation/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def run(self):
self._n_showers = len(self._fin['event_group_ids'])
self._shower_ids = np.array(self._fin['shower_ids'])
self._shower_index_array = {} # this array allows to convert the shower id to an index that starts from 0 to be used to access the arrays in the hdf5 file.

self.__particle_mode = "simulation_mode" not in self._fin_attrs or self._fin_attrs['simulation_mode'] != "emitter"
self._raytracer = self._prop(
self._ice, self._cfg['propagation']['attenuation_model'],
log_level=self._log_level_ray_propagation,
Expand Down Expand Up @@ -152,7 +152,6 @@ def run(self):

# Check if vertex_times exists:
self._check_vertex_times()

self._input_time = 0.0
self._askaryan_time = 0.0
self._rayTracingTime = 0.0
Expand Down Expand Up @@ -226,7 +225,8 @@ def run(self):
self.__station_simulator.set_event_group(
i_event_group_id,
event_group_id,
event_indices
event_indices,
self.__particle_mode
)
self.__hardware_response_simulator.set_event_group(
event_group_id
Expand Down
6 changes: 4 additions & 2 deletions NuRadioMC/simulation/station_simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,14 @@ def set_event_group(
self,
i_event_group,
event_group_id,
shower_indices
shower_indices,
particle_mode
):
self.__shower_simulator.set_event_group(
i_event_group,
event_group_id,
shower_indices
shower_indices,
particle_mode
)
self.__i_event_group = i_event_group
self.__event_group_id = event_group_id
Expand Down

0 comments on commit 681d2b3

Please sign in to comment.