From 681d2b3de6270201a06f98e473bb2e2170df1998 Mon Sep 17 00:00:00 2001 From: Christoph Date: Tue, 29 Aug 2023 11:39:00 -0500 Subject: [PATCH] Set station time and only read shower energies if simulation is in particle mode --- NuRadioMC/simulation/hardware_response_simulator.py | 3 +++ NuRadioMC/simulation/shower_simulator.py | 7 ++++--- NuRadioMC/simulation/simulation.py | 6 +++--- NuRadioMC/simulation/station_simulator.py | 6 ++++-- 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/NuRadioMC/simulation/hardware_response_simulator.py b/NuRadioMC/simulation/hardware_response_simulator.py index 8181691f8..4f0e856c0 100644 --- a/NuRadioMC/simulation/hardware_response_simulator.py +++ b/NuRadioMC/simulation/hardware_response_simulator.py @@ -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 @@ -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) diff --git a/NuRadioMC/simulation/shower_simulator.py b/NuRadioMC/simulation/shower_simulator.py index 9e076ddde..db9efce17 100644 --- a/NuRadioMC/simulation/shower_simulator.py +++ b/NuRadioMC/simulation/shower_simulator.py @@ -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 @@ -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( @@ -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): diff --git a/NuRadioMC/simulation/simulation.py b/NuRadioMC/simulation/simulation.py index 545a51fc8..34cbb9794 100644 --- a/NuRadioMC/simulation/simulation.py +++ b/NuRadioMC/simulation/simulation.py @@ -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, @@ -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 @@ -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 diff --git a/NuRadioMC/simulation/station_simulator.py b/NuRadioMC/simulation/station_simulator.py index 379e9f487..9f98d6059 100644 --- a/NuRadioMC/simulation/station_simulator.py +++ b/NuRadioMC/simulation/station_simulator.py @@ -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