From 97e55cd383af34b81ab013c7a0887161ec1224f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20Schl=C3=BCter?= Date: Wed, 20 Dec 2023 13:25:07 +0100 Subject: [PATCH] Only remove whitespace. Often from my code. --- NuRadioReco/detector/detector_base.py | 36 ++--- NuRadioReco/framework/base_shower.py | 16 +-- NuRadioReco/framework/base_station.py | 36 ++--- NuRadioReco/framework/electric_field.py | 2 +- NuRadioReco/framework/event.py | 28 ++-- NuRadioReco/framework/parameters.py | 4 +- NuRadioReco/framework/particle.py | 10 +- ...fieldRadioInterferometricReconstruction.py | 130 +++++++++--------- NuRadioReco/utilities/interferometry.py | 30 ++-- 9 files changed, 148 insertions(+), 144 deletions(-) diff --git a/NuRadioReco/detector/detector_base.py b/NuRadioReco/detector/detector_base.py index 8d28b0f8d..fd4e2ffd4 100644 --- a/NuRadioReco/detector/detector_base.py +++ b/NuRadioReco/detector/detector_base.py @@ -140,7 +140,7 @@ def __init__(self, source='json', json_filename='ARIANNA/arianna_detector_db.jso is returned. To force the creation of a new detector instance, pass the additional keyword parameter `create_new=True` to this function. For more details, check the documentation for the `Singleton metaclass `_. - + Parameters ---------- source : str @@ -231,7 +231,7 @@ def _query_channels(self, station_id): return self._channels.search((Channel.station_id == station_id) & (Channel.commission_time <= self.__current_time.datetime) & (Channel.decommission_time > self.__current_time.datetime)) - + def _query_devices(self, station_id): Device = Query() if self.__current_time is None: @@ -305,13 +305,13 @@ def __get_channel(self, station_id, channel_id): if station_id not in self._buffered_stations.keys(): self._buffer(station_id) return self._buffered_channels[station_id][channel_id] - - + + def __get_devices(self, station_id): if station_id not in self._buffered_stations.keys(): self._buffer(station_id) return self._buffered_devices[station_id] - + def __get_device(self, station_id, device_id): if station_id not in self._buffered_stations.keys(): self._buffer(station_id) @@ -333,7 +333,7 @@ def _buffer(self, station_id): self._buffered_devices[station_id][device['device_id']] = device self.__valid_t0 = max(self.__valid_t0, astropy.time.Time(channel['commission_time'])) self.__valid_t1 = min(self.__valid_t1, astropy.time.Time(channel['decommission_time'])) - + def __buffer_position(self, position_id): self.__buffered_positions[position_id] = self.__query_position(position_id) @@ -411,6 +411,7 @@ def update(self, time): self.__current_time = astropy.time.Time(time) else: self.__current_time = time + logger.info("updating detector time to {}".format(self.__current_time)) if not ((self.__current_time > self.__valid_t0) and (self.__current_time < self.__valid_t1)): self._buffered_stations = {} @@ -440,8 +441,8 @@ def get_channel(self, station_id, channel_id): dict of channel parameters """ return self.__get_channel(station_id, channel_id) - - + + def get_device(self, station_id, device_id): """ returns a dictionary of all device parameters @@ -530,11 +531,14 @@ def get_relative_position(self, station_id, channel_id, mode = 'channel'): ------- 3-dim array of relative station position """ - if mode == 'channel': res = self.__get_channel(station_id, channel_id) - elif mode == 'device': res = self.__get_device(station_id, channel_id) - else: + if mode == 'channel': + res = self.__get_channel(station_id, channel_id) + elif mode == 'device': + res = self.__get_device(station_id, channel_id) + else: logger.error("Mode {} does not exist. Use 'channel' or 'device'".format(mode)) raise NameError + return np.array([res['ant_position_x'], res['ant_position_y'], res['ant_position_z']]) def get_site(self, station_id): @@ -639,10 +643,10 @@ def get_parallel_channels(self, station_id): if np.sum(mask): parallel_antennas.append(channel_ids[mask]) return np.array(parallel_antennas) - - - - + + + + def get_number_of_devices(self, station_id): """ Get the number of devices per station @@ -921,7 +925,7 @@ def get_noise_RMS(self, station_id, channel_id, stage='amp'): stage: string (default 'amp') specifies the stage of reconstruction you want the noise RMS for, `stage` can be one of - + * 'raw' (raw measured trace) * 'amp' (after the amp was deconvolved) * 'filt' (after the trace was highpass with 100MHz diff --git a/NuRadioReco/framework/base_shower.py b/NuRadioReco/framework/base_shower.py index 754930f4b..9d6af2cad 100644 --- a/NuRadioReco/framework/base_shower.py +++ b/NuRadioReco/framework/base_shower.py @@ -43,17 +43,17 @@ def has_parameter(self, key): def get_axis(self): """ - Returns the (shower) axis. - + Returns the (shower) axis. + The axis is antiparallel to the movement of the shower particla and point towards the origin of the shower. Returns ------- - np.array(3,) + np.array(3,) Shower axis - + """ if not self.has_parameter(parameters.showerParameters.azimuth) or \ not self.has_parameter(parameters.showerParameters.zenith): @@ -66,18 +66,18 @@ def get_axis(self): self.get_parameter(parameters.showerParameters.azimuth)) def get_coordinatesystem(self): - """ + """ Returns radiotools.coordinatesystem.cstrafo for shower geometry. - + Can be used to transform the radio pulses or the observer coordiates - in the shower frame. Requieres the shower arrival direction + in the shower frame. Requieres the shower arrival direction (azimuth and zenith angle) and magnetic field vector (parameters.showerParameters). Returns ------- radiotools.coordinatesystem.cstrafo - + """ if not self.has_parameter(parameters.showerParameters.azimuth) or \ not self.has_parameter(parameters.showerParameters.zenith) or \ diff --git a/NuRadioReco/framework/base_station.py b/NuRadioReco/framework/base_station.py index d1d671e9b..18730600c 100644 --- a/NuRadioReco/framework/base_station.py +++ b/NuRadioReco/framework/base_station.py @@ -76,18 +76,18 @@ def remove_parameter(self, key): self._parameters.pop(key, None) def set_station_time(self, time, format=None): - """ + """ Set the (absolute) time for the station (stored as astropy.time.Time). Not related to the event._event_time. - + Parameters ---------- - + time: astropy.time.Time or datetime.datetime or float - If "time" is a float, you have to specify its format. - + If "time" is a float, you have to specify its format. + format: str - Only used when "time" is a float. Format to interpret "time". (Default: None) + Only used when "time" is a float. Format to interpret "time". (Default: None) """ if isinstance(time, datetime.datetime): @@ -100,26 +100,26 @@ def set_station_time(self, time, format=None): self._station_time = astropy.time.Time(time, format=format) def get_station_time(self, format='isot'): - """ - Returns a astropy.time.Time object - + """ + Returns a astropy.time.Time object + Parameters ---------- - + format: str Format in which the time object is displayed. (Default: isot) - + Returns ------- - + _station_time: astropy.time.Time """ if self._station_time is None: return None - + self._station_time.format = format return self._station_time - + def get_station_time_dict(self): """ Return the station time as dict {value, format}. Used for reading and writing """ if self._station_time is None: @@ -270,13 +270,13 @@ def serialize(self, save_efield_traces): trigger_pkls = [] for trigger in self._triggers.values(): trigger_pkls.append(trigger.serialize()) - + efield_pkls = [] for efield in self.get_electric_fields(): efield_pkls.append(efield.serialize(save_trace=save_efield_traces)) station_time_dict = self.get_station_time_dict() - + data = {'_parameters': NuRadioReco.framework.parameter_serialization.serialize(self._parameters), '_parameter_covariances': NuRadioReco.framework.parameter_serialization.serialize_covariances(self._parameter_covariances), '_ARIANNA_parameters': self._ARIANNA_parameters, @@ -286,7 +286,7 @@ def serialize(self, save_efield_traces): 'triggers': trigger_pkls, '_triggered': self._triggered, 'electric_fields': efield_pkls} - + return pickle.dumps(data, protocol=4) def deserialize(self, data_pkl): @@ -308,7 +308,7 @@ def deserialize(self, data_pkl): self._parameter_covariances = NuRadioReco.framework.parameter_serialization.deserialize_covariances( data['_parameter_covariances'], parameters.stationParameters) - + if '_ARIANNA_parameters' in data: self._ARIANNA_parameters = data['_ARIANNA_parameters'] diff --git a/NuRadioReco/framework/electric_field.py b/NuRadioReco/framework/electric_field.py index 3f1b60fe4..a207245ee 100644 --- a/NuRadioReco/framework/electric_field.py +++ b/NuRadioReco/framework/electric_field.py @@ -22,7 +22,7 @@ def __init__(self, channel_ids, position=None, Parameters ---------- channel_ids: array of ints - the channels ids this electric field is valid for. + the channels ids this electric field is valid for. (For cosmic rays one electric field is typically valid for several channels. For neutrino simulations, we typically simulate the electric field for each diff --git a/NuRadioReco/framework/event.py b/NuRadioReco/framework/event.py index 1d4c06128..49df21a37 100644 --- a/NuRadioReco/framework/event.py +++ b/NuRadioReco/framework/event.py @@ -41,7 +41,7 @@ def register_module_event(self, instance, name, kwargs): kwargs: the key word arguments of the run method """ - + self.__modules_event.append([name, instance, kwargs]) def register_module_station(self, station_id, instance, name, kwargs): @@ -61,7 +61,7 @@ def register_module_station(self, station_id, instance, name, kwargs): """ if station_id not in self.__modules_station: self.__modules_station[station_id] = [] - + iE = len(self.__modules_event) self.__modules_station[station_id].append([iE, name, instance, kwargs]) @@ -164,7 +164,7 @@ def get_station_ids(self): def set_station(self, station): self.__stations[station.get_id()] = station - + def has_triggered(self, trigger_name=None): """ Returns true if any station has been triggered. @@ -175,16 +175,16 @@ def has_triggered(self, trigger_name=None): * if None: The function returns False if not trigger was set. If one or multiple triggers were set, it returns True if any of those triggers triggered * if trigger name is set: return if the trigger with name 'trigger_name' has a trigger - + Returns ------- - + has_triggered : bool """ for station in self.get_stations(): if station.has_triggered(trigger_name): return True - + # if it reaches this point, no station has a trigger return False @@ -200,11 +200,11 @@ def add_particle(self, particle): if not isinstance(particle, NuRadioReco.framework.particle.Particle): logger.error("Requested to add non-Particle item to the list of particles. {particle} needs to be an instance of Particle.") raise TypeError("Requested to add non-Particle item to the list of particles. {particle} needs to be an instance of Particle.") - + if particle.get_id() in self.__particles: logger.error("MC particle with id {particle.get_id()} already exists. Simulated particle id needs to be unique per event") raise AttributeError("MC particle with id {particle.get_id()} already exists. Simulated particle id needs to be unique per event") - + self.__particles[particle.get_id()] = particle def get_particles(self): @@ -254,13 +254,13 @@ def has_particle(self, particle_id=None): """ if particle_id is None: return len(self.__particles) > 0 - + return particle_id in self.__particles.keys() def get_interaction_products(self, parent_particle, showers=True, particles=True): """ Return all the daughter particles and showers generated in the interaction of the - + Parameters ---------- showers: bool @@ -437,9 +437,9 @@ def serialize(self, mode): showers_pkl = [shower.serialize() for shower in self.get_showers()] sim_showers_pkl = [shower.serialize() for shower in self.get_sim_showers()] particles_pkl = [particle.serialize() for particle in self.get_particles()] - + hybrid_info = self.__hybrid_information.serialize() - + modules_out_event = [] for value in self.__modules_event: # remove module instances (this will just blow up the file size) modules_out_event.append([value[0], None, value[2]]) @@ -493,11 +493,11 @@ def deserialize(self, data_pkl): particle = NuRadioReco.framework.particle.Particle(None) particle.deserialize(particle_pkl) self.add_particle(particle) - + self.__hybrid_information = NuRadioReco.framework.hybrid_information.HybridInformation() if 'hybrid_info' in data.keys(): self.__hybrid_information.deserialize(data['hybrid_info']) - + self._parameters = data['_parameters'] self.__run_number = data['__run_number'] self._id = data['_id'] diff --git a/NuRadioReco/framework/parameters.py b/NuRadioReco/framework/parameters.py index b234ec112..eca29dd4b 100644 --- a/NuRadioReco/framework/parameters.py +++ b/NuRadioReco/framework/parameters.py @@ -1,7 +1,7 @@ """ Provides an interface to store simulated and reconstructed quantities -The parameters module provides access to store and read simulated or +The parameters module provides access to store and read simulated or reconstructed quantities in the different custom classes used in NuRadioMC. """ @@ -36,7 +36,7 @@ class stationParameters(Enum): cr_xmax = 28 #: Depth of shower maximum of the air shower vertex_2D_fit = 29 #: horizontal distance and z coordinate of the reconstructed vertex of the neutrino distance_correlations = 30 - shower_energy = 31 #: the energy of the shower + shower_energy = 31 #: the energy of the shower viewing_angles = 32 #: reconstructed viewing angles. A nested map structure. First key is channel id, second key is ray tracing solution id. Value is a float diff --git a/NuRadioReco/framework/particle.py b/NuRadioReco/framework/particle.py index da365b96b..6a55b9425 100644 --- a/NuRadioReco/framework/particle.py +++ b/NuRadioReco/framework/particle.py @@ -11,11 +11,11 @@ class Particle: def __init__(self, particle_index): - # "_id" is not the PDG code but a hierarchical index + # "_id" is not the PDG code but a hierarchical index # (PDG code is stored in _parameters["flavor"]) self._id = particle_index self._parameters = {} - + def __setitem__(self, key, value): self.set_parameter(key, value) @@ -25,7 +25,7 @@ def __getitem__(self, key): def get_id(self): """ Returns hierarchical index """ return self._id - + def __str__(self): msg = ( "Particle ({}): " @@ -35,7 +35,7 @@ def __str__(self): math.log10(self.get_parameter(parameters.particleParameters.energy)), math.cos(self.get_parameter(parameters.particleParameters.zenith))) ) - + return msg def get_parameter(self, key): @@ -55,7 +55,7 @@ def has_parameter(self, key): logger.error("parameter key needs to be of type NuRadioReco.framework.parameters.particleParameters") raise ValueError("parameter key needs to be of type NuRadioReco.framework.parameters.particleParameters") return key in self._parameters - + def as_hdf5_dict(self): hdf5_dict = collections.OrderedDict() hdf5_dict['azimuths'] = self.get_parameter(parameters.particleParameters.azimuth) diff --git a/NuRadioReco/modules/efieldRadioInterferometricReconstruction.py b/NuRadioReco/modules/efieldRadioInterferometricReconstruction.py index 99bf53517..f9b0f86cc 100644 --- a/NuRadioReco/modules/efieldRadioInterferometricReconstruction.py +++ b/NuRadioReco/modules/efieldRadioInterferometricReconstruction.py @@ -1,6 +1,6 @@ from NuRadioReco.modules.base.module import register_run from NuRadioReco.utilities import units, interferometry -from NuRadioReco.framework.parameters import stationParameters as stnp + from NuRadioReco.framework.parameters import showerParameters as shp from radiotools import helper as hp, coordinatesystems @@ -16,12 +16,12 @@ import logging logger = logging.getLogger('efieldRadioInterferometricReconstruction') -""" +""" This module hosts to classes - efieldInterferometricDepthReco - efieldInterferometricAxisReco (TODO: Not yet implemented) -The radio-interferometric reconstruction (RIT) was proposed in [1]. +The radio-interferometric reconstruction (RIT) was proposed in [1]. The implementation here is based on work published in [2]. [1]: H. Schoorlemmer, W. R. Carvalho Jr., arXiv:2006.10348 @@ -31,12 +31,12 @@ class efieldInterferometricDepthReco: """ - This class reconstructs the depth of the maximum of the longitudinal profile of the - beam-formed radio emission: X_RIT along a given axis. X_RIT is found to correlate with X_max. + This class reconstructs the depth of the maximum of the longitudinal profile of the + beam-formed radio emission: X_RIT along a given axis. X_RIT is found to correlate with X_max. This correlation may depend on the zenith angle, the frequency band, and detector layout (if the detector is very irregular). - For the reconstruction, a shower axis is needed. The radio emission in the vxB polarisation is used + For the reconstruction, a shower axis is needed. The radio emission in the vxB polarisation is used (and thus the arrival direction is needed). """ @@ -62,7 +62,7 @@ def begin(self, interpolation=True, signal_kind="power", debug=False): signal_kind : str Define which signal "metric" is used on the beamformed traces. Default "power" : sum over the squared amplitudes in a 100 ns window around the peak. - Other options are "amplitude" or "hilbert_sum" + Other options are "amplitude" or "hilbert_sum" debug : bool If true, show some debug plots (Default: False). @@ -79,7 +79,7 @@ def sample_longitudinal_profile( self, traces, times, station_positions, shower_axis, core, depths=None, distances=None): """ - Returns the longitudinal profile of the interferometic signal sampled along the shower axis. + Returns the longitudinal profile of the interferometic signal sampled along the shower axis. Parameters ---------- @@ -100,7 +100,7 @@ def sample_longitudinal_profile( Shower core. Keep in mind that the altitudes (z-coordinate) matters. depths : array (optinal) - Define the positions (slant depth along the axis) at which the interferometric signal is sampled. + Define the positions (slant depth along the axis) at which the interferometric signal is sampled. Instead of "depths" you can provide "distances". distances : array (optinal) @@ -109,7 +109,7 @@ def sample_longitudinal_profile( Returns ------- - + signals : array Interferometric singals sampled along the given axis """ @@ -165,9 +165,9 @@ def reconstruct_interferometric_depth( self, traces, times, station_positions, shower_axis, core, lower_depth=400, upper_depth=800, bin_size=100, return_profile=False): """ - Returns Gauss-parameters fitted to the "peak" of the interferometic + Returns Gauss-parameters fitted to the "peak" of the interferometic longitudinal profile along the shower axis. - + A initial samping range and size in defined by "lower_depth", "upper_depth", "bin_size". However if the "peak", i.e., maximum signal is found at an edge the sampling range in continually increased (with a min/max depth of 0/2000 g/cm^2). The Gauss is fitted around the @@ -201,26 +201,26 @@ def reconstruct_interferometric_depth( Define the step size pf the inital sampling (default: 100 g/cm2). The refined sampling around the peak region is / 10 this value. - return_profile : bool + return_profile : bool If true return the sampled profile in addition to the Gauss parameter (default: False). Returns ------- - + If return_profile is True - + depths_corse : np.array Depths along shower axis coarsely sampled - + depths_fine : np.array Depths along shower axis finely sampled (used in fitting) - + signals_corese : np.array Beamformed signals along shower axis coarsely sampled - + signals_fine : np.array Beamformed signals along shower axis finely sampled (used in fitting) - + popt : list List of fitted Gauss parameters (amplitude, position, width) @@ -228,7 +228,7 @@ def reconstruct_interferometric_depth( popt : list List of fitted Gauss parameters (amplitude, position, width) - + """ depths = np.arange(lower_depth, upper_depth, bin_size) @@ -280,7 +280,7 @@ def normal(x, A, x0, sigma): def update_atmospheric_model_and_refractivity_table(self, shower): - """ + """ Updates model of the atmosphere and tabulated, integrated refractive index according to shower properties. Parameters @@ -298,18 +298,18 @@ def update_atmospheric_model_and_refractivity_table(self, shower): self._at = models.Atmosphere(shower[shp.atmospheric_model]) self._tab = refractivity.RefractivityTable( self._at.model, refractivity_at_sea_level=shower[shp.refractive_index_at_ground] - 1, curved=True) - + elif self._tab._refractivity_at_sea_level != shower[shp.refractive_index_at_ground] - 1: self._tab = refractivity.RefractivityTable( self._at.model, refractivity_at_sea_level=shower[shp.refractive_index_at_ground] - 1, curved=True) - + else: pass @register_run() def run(self, evt, det, use_MC_geometry=True, use_MC_pulses=True): - """ + """ Run interferometric reconstruction of depth of coherent signal. Parameters @@ -317,7 +317,7 @@ def run(self, evt, det, use_MC_geometry=True, use_MC_pulses=True): evt : Event Event to run the module on. - + det : Detector Detector description @@ -328,7 +328,7 @@ def run(self, evt, det, use_MC_geometry=True, use_MC_pulses=True): if true, take electric field trace from sim_station """ - # TODO: Mimic imperfect time syncronasation by adding a time jitter here? + # TODO: Mimic imperfect time syncronasation by adding a time jitter here? # TODO: Make it more flexible. Choose shower from which the geometry and atmospheric properties are taken. # Also store xrit in this shower. @@ -336,7 +336,7 @@ def run(self, evt, det, use_MC_geometry=True, use_MC_pulses=True): shower = evt.get_first_sim_shower() else: shower = evt.get_first_shower() - + self.update_atmospheric_model_and_refractivity_table(shower) core, shower_axis, cs = get_geometry_and_transformation(shower) @@ -363,7 +363,7 @@ def run(self, evt, det, use_MC_geometry=True, use_MC_pulses=True): shower.set_parameter(shp.interferometric_shower_maximum, xrit * units.g / units.cm2) #TODO: Add calibration Xmax(Xrit, theta, ...)? - + # for plotting self._data["xrit"].append(xrit) self._data["xmax"].append(shower[shp.shower_maximum] / (units.g / units.cm2)) @@ -388,7 +388,7 @@ def end(self): class efieldInterferometricAxisReco(efieldInterferometricDepthReco): """ - Class to reconstruct the shower axis with beamforming. + Class to reconstruct the shower axis with beamforming. """ def __init__(self): super().__init__() @@ -397,7 +397,7 @@ def __init__(self): def find_maximum_in_plane(self, xs, ys, p_axis, station_positions, traces, times, cs): """ Sample interferometric signals in 2-d plane (vxB-vxvxB) perpendicular to a given axis on a rectangular/quadratic grid. - The orientation of the plane is defined by the radiotools.coordinatesytem.cstrafo argument. + The orientation of the plane is defined by the radiotools.coordinatesytem.cstrafo argument. Parameters ---------- @@ -457,9 +457,9 @@ def sample_lateral_cross_section( relative=False, initial_grid_spacing=100, centered_around_truth=True, cross_section_size=1000, deg_resolution=np.deg2rad(0.005)): """ - Sampling the "cross section", i.e., 2d-lateral distribution of the beam formed signal for a slice in the atmosphere. - It is looking for the maximum in the lateral distribution with an (stupid) iterative grid search. - + Sampling the "cross section", i.e., 2d-lateral distribution of the beam formed signal for a slice in the atmosphere. + It is looking for the maximum in the lateral distribution with an (stupid) iterative grid search. + Returns the position and the strenght of the maximum signal. Parameters @@ -486,33 +486,33 @@ def sample_lateral_cross_section( cs : radiotools.coordinatesytem.cstrafo shower_axis_mc : np.array(3,) - + core_mc : np.array(3,) relative : bool False - + initial_grid_spacing : int 100 - + centered_around_truth : bool True cross_section_size : int 1000 - + deg_resolution : float np.deg2rad(0.005)) - + Returns ------- - + point_found : np.array(3,) Position of the found maximum weight : float Amplitude/Strengt of the maximum - + """ zenith_inital, _ = hp.cartesian_to_spherical( @@ -601,7 +601,7 @@ def sample_lateral_cross_section( def reconstruct_shower_axis( - self, + self, traces, times, station_positions, shower_axis, core, magnetic_field_vector, @@ -609,7 +609,7 @@ def reconstruct_shower_axis( initial_grid_spacing=60, cross_section_size=1000): """ - Run interferometric reconstruction of the shower axis. Find the maxima of the interferometric signals + Run interferometric reconstruction of the shower axis. Find the maxima of the interferometric signals within 2-d plane (slices) along a given axis (initial guess). Through those maxima (their position in the atmosphere) a straight line is fitted to reconstruct the shower axis. @@ -634,8 +634,8 @@ def reconstruct_shower_axis( is_mc : bool If true, interprete the provided shower axis as truth and add some gaussian smearing to optain an - inperfect initial guess for the shower axis (Default: True). - + inperfect initial guess for the shower axis (Default: True). + initial_grid_spacing : double Spacing of your grid points in meters (Default: 60m) @@ -644,7 +644,7 @@ def reconstruct_shower_axis( (Default: 1000m). """ - + if is_mc: zenith_mc, azimuth_mc = hp.cartesian_to_spherical(*shower_axis) @@ -656,8 +656,8 @@ def reconstruct_shower_axis( zenith=zenith_inital, azimuth=azimuth_inital) else: - shower_axis_inital = shower_axis - core_inital = core + shower_axis_inital = shower_axis + core_inital = core zenith_inital, azimuth_inital = hp.cartesian_to_spherical( *shower_axis) @@ -667,7 +667,7 @@ def reconstruct_shower_axis( cs = coordinatesystems.cstrafo( zenith_inital, azimuth_inital, magnetic_field_vector=magnetic_field_vector) - + if is_mc: core_inital = cs.transform_from_vxB_vxvxB_2D( np.array([np.random.normal(0, 100), np.random.normal(0, 100), 0]), core) @@ -682,15 +682,15 @@ def reconstruct_shower_axis( centered_around_truth = True def sample_lateral_cross_section_placeholder(dep): - """ + """ Run sample_lateral_cross_section for a particular depth. - + Parameters ---------- dep : double Depth along the axis at which the cross section is sampled in g/cm2. - + """ return self.sample_lateral_cross_section( traces, times, station_positions, @@ -745,7 +745,7 @@ def sample_lateral_cross_section_placeholder(dep): @register_run() def run(self, evt, det, use_MC_geometry=True, use_MC_pulses=True): - """ + """ Run interferometric reconstruction of depth of coherent signal. Parameters @@ -753,7 +753,7 @@ def run(self, evt, det, use_MC_geometry=True, use_MC_pulses=True): evt : Event Event to run the module on. - + det : Detector Detector description @@ -790,7 +790,7 @@ def end(self): def get_geometry_and_transformation(shower): - """ + """ Returns core (def. as intersection between shower axis and observation plane, shower axis, and radiotools.coordinatesytem for given shower. @@ -819,9 +819,9 @@ def get_geometry_and_transformation(shower): def get_station_data(evt, det, cs, use_MC_pulses, n_sampling=None): - """ + """ Returns station data in a proper format - + Parameters ---------- @@ -839,15 +839,15 @@ def get_station_data(evt, det, cs, use_MC_pulses, n_sampling=None): Returns ------- - + traces_vxB : np.array The electric field traces in the vxB polarisation (takes first electric field stored in a station) for all stations/observers. - times : mp.array + times : mp.array The electric field traces time series for all stations/observers. - + pos : np.array - Positions for all stations/observers. + Positions for all stations/observers. """ traces_vxB = [] @@ -869,11 +869,11 @@ def get_station_data(evt, det, cs, use_MC_pulses, n_sampling=None): hw = n_sampling // 2 m = np.argmax(np.abs(trace_vxB)) - if m < hw: + if m < hw: m = hw if m > len(trace_vxB) - hw: m = len(trace_vxB) - hw - + trace_vxB = trace_vxB[m-hw:m+hw] time = time[m-hw:m+hw] @@ -882,7 +882,7 @@ def get_station_data(evt, det, cs, use_MC_pulses, n_sampling=None): break # just take the first efield. TODO: Improve this pos.append(det.get_absolute_position(station.get_id())) - + traces_vxB = np.array(traces_vxB) times = np.array(times) pos = np.array(pos) @@ -891,7 +891,7 @@ def get_station_data(evt, det, cs, use_MC_pulses, n_sampling=None): def plot_lateral_cross_section(xs, ys, signals, mc_pos=None, fname=None, title=None): - """ + """ Plot the lateral distribution of the beamformed singal (in the vxB, vxvxB directions). Parameters @@ -901,7 +901,7 @@ def plot_lateral_cross_section(xs, ys, signals, mc_pos=None, fname=None, title=N Positions on x-axis (vxB) at which the signal is sampled (on a 2d grid) ys : np.array - Positions on y-axis (vxvxB) at which the signal is sampled (on a 2d grid) + Positions on y-axis (vxvxB) at which the signal is sampled (on a 2d grid) signals : np.array Signals sampled on the 2d grid defined by xs and ys. diff --git a/NuRadioReco/utilities/interferometry.py b/NuRadioReco/utilities/interferometry.py index 2d7505d15..a29b0a54f 100644 --- a/NuRadioReco/utilities/interferometry.py +++ b/NuRadioReco/utilities/interferometry.py @@ -10,9 +10,9 @@ def get_signal(sum_trace, tstep, window_width=100 * units.ns, kind="power"): - """ - Calculates signal quantity from beam-formed waveform - + """ + Calculates signal quantity from beam-formed waveform + Parameters ---------- @@ -21,13 +21,13 @@ def get_signal(sum_trace, tstep, window_width=100 * units.ns, kind="power"): tstep : double Sampling bin size - + window_width : double - Time window size to calculate power + Time window size to calculate power kind : str Key-word what to do: "amplitude", "power", or "hilbert_sum" - + Returns ------- @@ -70,11 +70,11 @@ def get_signal(sum_trace, tstep, window_width=100 * units.ns, kind="power"): def interfere_traces_interpolation(target_pos, positions, traces, times, tab): - """ + """ Calculate sum of time shifted waveforms. Performs a linear interpolation between samples. - + Parameters ---------- @@ -92,7 +92,7 @@ def interfere_traces_interpolation(target_pos, positions, traces, times, tab): tab : radiotools.atmosphere.refractivity.RefractivityTable Tabulated table of the avg. refractive index between two points - + Returns ------- @@ -133,9 +133,9 @@ def interfere_traces_interpolation(target_pos, positions, traces, times, tab): def get_time_shifts(target_pos, positions, tab): """ - Calculates the time delay of an electromagnetic wave along a straight trajectories between + Calculates the time delay of an electromagnetic wave along a straight trajectories between a source/traget location and several observers. - + Parameters ---------- @@ -153,7 +153,7 @@ def get_time_shifts(target_pos, positions, tab): tshifts : np.array(n,) Time delay in sec - + """ tshifts = np.zeros(len(positions)) @@ -169,13 +169,13 @@ def get_time_shifts(target_pos, positions, tab): def fit_axis(z, theta, phi, coreX, coreY): - """ + """ Predicts the intersetction of an axis/line with horizontal layers at different heights. Line is described by an anchor on a horizontal plane (coreX, coreY) and a direction in spherical coordinates (theta, phi). - Returns the position/intersection of the line with flat horizontal layers at + Returns the position/intersection of the line with flat horizontal layers at given height(s) z. Resulting array (positions) is flatten. Parameters @@ -231,7 +231,7 @@ def get_intersection_between_line_and_plane(plane_normal, plane_anchor, line_dir Anchor of this line epsilon : double - Numerical precision + Numerical precision Returns -------