def _detector_simulation(self): calculateAmplitudePerRaySolution.run(self._evt, self._station, self._det) # save the amplitudes to output hdf5 file # save amplitudes per ray tracing solution to hdf5 data output if('max_amp_ray_solution' not in self._mout): self._mout['max_amp_ray_solution'] = np.zeros((self._n_events, self._n_antennas, 2)) * np.nan # for sim_channel in self._station.get_sim_station().iter_channels(): for sim_channel in self._station.iter_channels(): for iCh2, sim_channel2 in enumerate(sim_channel): channel_id = sim_channel2.get_id() self._mout['max_amp_ray_solution'][self._iE, channel_id, iCh2] = sim_channel2.get_parameter( chp.maximum_amplitude_envelope) self._increase_signal(0, 8**0.5) self._increase_signal(1, 8**0.5) self._increase_signal(2, 8**0.5) # start detector simulation # efieldToVoltageConverterPerChannel.run(self._evt, self._station, self._det) # convolve efield with antenna pattern efieldToVoltageConverter.run(self._evt, self._station, self._det) # convolve efield with antenna pattern if(bool(self._cfg['signal']['zerosignal'])): self._increase_signal(None, 0) if bool(self._cfg['noise']): Vrms = self._Vrms / self._bandwidth * 2 * units.GHz # normalize noise level to the bandwidth its generated for channelGenericNoiseAdder.run(self._evt, self._station, self._det, amplitude=Vrms, min_freq=0 * units.MHz, max_freq=2 * units.GHz, type='rayleigh') channelBandPassFilter.run(self._evt, self._station, self._det, filter_type='NTU+cheb') triggerSimulator.run(self._evt, self._station, self._det, threshold=4.24 * self._Vrms, triggered_channels=[0, 1, 2, 3, 4, 5], # run trigger on all channels number_concidences=3, trigger_name='simple_threshold') # the name of the trigger
def _detector_simulation(self): # start detector simulation efieldToVoltageConverter.run(self._evt, self._station, self._det) # convolve efield with antenna pattern # downsample trace to internal simulation sampling rate (the efieldToVoltageConverter upsamples the trace to # 20 GHz by default to achive a good time resolution when the two signals from the two signal paths are added) channelResampler.run(self._evt, self._station, self._det, sampling_rate=1. / self._dt) if self._is_simulate_noise(): max_freq = 0.5 / self._dt norm = self._get_noise_normalization(self._station.get_id()) # assuming the same noise level for all stations Vrms = self._Vrms / (norm / (max_freq)) ** 0.5 # normalize noise level to the bandwidth its generated for channelGenericNoiseAdder.run(self._evt, self._station, self._det, amplitude=Vrms, min_freq=0 * units.MHz, max_freq=max_freq, type='rayleigh') # bandpass filter trace, the upper bound is higher then the sampling rate which makes it just a highpass filter channelBandPassFilter.run(self._evt, self._station, self._det, passband=[80 * units.MHz, 500 * units.MHz], filter_type='butter', order=10) triggerSimulator.run(self._evt, self._station, self._det, threshold=1 * self._Vrms, triggered_channels=[0, 1, 2, 3], number_concidences=1, trigger_name='pre_trigger_1sigma') # downsample trace back to detector sampling rate channelResampler.run(self._evt, self._station, self._det, sampling_rate=self._sampling_rate_detector)
def _detector_simulation_filter_amp(self, evt, station, det): """ This function defines the signal chain, i.e., typically the filters and amplifiers. (The antenna response will be applied automatically using the antenna model defined in the detector description.) In our case, we will only implement a couple of filters, one that acts as a low-pass and another one that acts as a high-pass. """ channelBandPassFilter.run(evt, station, det, passband=[1 * units.MHz, 700 * units.MHz], filter_type="butter", order=10) channelBandPassFilter.run(evt, station, det, passband=[150 * units.MHz, 800 * units.GHz], filter_type="butter", order=8)
def _detector_simulation_filter_amp(self, evt, station, det): channelBandPassFilter.run(evt, station, det, passband=[130 * units.MHz, 1000 * units.GHz], filter_type='butter', order=6) channelBandPassFilter.run(evt, station, det, passband=[0, 750 * units.MHz], filter_type='butter', order=10)
def _detector_simulation(self): # start detector simulation if (bool(self._cfg['signal']['zerosignal'])): self._increase_signal(None, 0) efieldToVoltageConverter.run( self._evt, self._station, self._det) # convolve efield with antenna pattern # downsample trace to internal simulation sampling rate (the efieldToVoltageConverter upsamples the trace to # 20 GHz by default to achive a good time resolution when the two signals from the two signal paths are added) channelResampler.run(self._evt, self._station, self._det, sampling_rate=1. / self._dt) if bool(self._cfg['noise']): Vrms = self._Vrms / ( self._bandwidth / (2.5 * units.GHz) )**0.5 # normalize noise level to the bandwidth its generated for channelGenericNoiseAdder.run(self._evt, self._station, self._det, amplitude=Vrms, min_freq=0 * units.MHz, max_freq=2.5 * units.GHz, type='rayleigh') # bandpass filter trace, the upper bound is higher then the sampling rate which makes it just a highpass filter channelBandPassFilter.run(self._evt, self._station, self._det, passband=[80 * units.MHz, 1000 * units.GHz], filter_type='butter', order=2) channelBandPassFilter.run(self._evt, self._station, self._det, passband=[0, 500 * units.MHz], filter_type='butter', order=10) # first run a simple threshold trigger simpleThreshold.run( self._evt, self._station, self._det, threshold=3 * self._Vrms, triggered_channels=None, # run trigger on all channels number_concidences=1, trigger_name='simple_threshold') # the name of the trigger """
def _detector_simulation_filter_amp(self, evt, station, det): # bandpass filter trace, the upper bound is higher then the sampling rate which makes it just a highpass filter channelBandPassFilter.run(evt, station, det, passband=[80 * units.MHz, 1000 * units.GHz], filter_type='butter', order=2) channelBandPassFilter.run(evt, station, det, passband=[0, 500 * units.MHz], filter_type='butter', order=10)
def _detector_simulation_filter_amp(self, evt, station, det): channelBandPassFilter.run(evt, station, det, passband=passband_low, filter_type=filter_type, order=order_low, rp=0.1) channelBandPassFilter.run(evt, station, det, passband=passband_high, filter_type=filter_type, order=order_high, rp=0.1)
def _detector_simulation_filter_amp(self, evt, station, det): channelBandPassFilter.run(evt, station, det, passband=[87 * units.MHz, 225 * units.MHz], filter_type='cheby1', order=4, rp=.1) channelBandPassFilter.run(evt, station, det, passband=[0 * units.MHz, 235 * units.MHz], filter_type='cheby1', order=9, rp=.1)
def _detector_simulation_filter_amp(self, evt, station, det): channelBandPassFilter.run(evt, station, det, passband=[1 * units.MHz, 230 * units.MHz], filter_type="cheby1", order=9, rp=0.1) channelBandPassFilter.run(evt, station, det, passband=[80 * units.MHz, 800 * units.GHz], filter_type="cheby1", order=4, rp=0.1)
def _detector_simulation(self): # start detector simulation efieldToVoltageConverterPerChannel.run( self._evt, self._station, self._det) # convolve efield with antenna pattern # downsample trace back to detector sampling rate channelResampler.run(self._evt, self._station, self._det, sampling_rate=1. / self._dt) # bandpass filter trace, the upper bound is higher then the sampling rate which makes it just a highpass filter channelBandPassFilter.run(self._evt, self._station, self._det, passband=[80 * units.MHz, 1000 * units.MHz], filter_type='butter10') triggerSimulator.run( self._evt, self._station, self._det, threshold=3 * self._Vrms, # triggered_channels=None, triggered_channels=[0, 1, 2, 3, 4, 5, 6, 7], # triggered_channels=[0, 1, 2, 3], number_concidences=1, trigger_name='simple_threshold') triggerSimulatorARIANNA.run( self._evt, self._station, self._det, threshold_high=3 * self._Vrms, threshold_low=-3 * self._Vrms, triggered_channels=[0, 1, 2, 3, 4, 5, 6, 7], number_concidences=3, cut_trace=False, trigger_name='high_low_3of8', set_not_triggered=( not self._station.has_triggered("simple_threshold")) ) # calculate more time consuming ARIANNA trigger only if station passes simple trigger triggerSimulatorARIANNA.run( self._evt, self._station, self._det, threshold_high=3 * self._Vrms, threshold_low=-3 * self._Vrms, triggered_channels=[0, 1, 2, 3, 4, 5, 6, 7], number_concidences=2, cut_trace=False, trigger_name='high_low_2of8', set_not_triggered=( not self._station.has_triggered("simple_threshold")) ) # calculate more time consuming ARIANNA trigger only if station passes simple trigger triggerSimulatorARIANNA.run( self._evt, self._station, self._det, threshold_high=3 * self._Vrms, threshold_low=-3 * self._Vrms, triggered_channels=[0, 1, 2, 3, 12, 13, 14, 15], number_concidences=3, cut_trace=False, trigger_name='high_low_2of8_LPDAs', set_not_triggered=( not self._station.has_triggered("simple_threshold")) ) # calculate more time consuming ARIANNA trigger only if station passes simple trigger triggerSimulatorARIANNA.run( self._evt, self._station, self._det, threshold_high=3 * self._Vrms, threshold_low=-3 * self._Vrms, triggered_channels=[0, 1, 2, 3], number_concidences=2, cut_trace=False, trigger_name='high_low_2of4_LPDA', set_not_triggered=( not self._station.has_triggered("simple_threshold")) ) # calculate more time consuming ARIANNA trigger only if station passes simple trigger triggerSimulatorARIANNA.run( self._evt, self._station, self._det, threshold_high=3 * self._Vrms, threshold_low=-3 * self._Vrms, triggered_channels=[4, 5, 6, 7], number_concidences=4, cut_trace=False, trigger_name='high_low_4of4_dipoles', set_not_triggered=( not self._station.has_triggered("simple_threshold")) ) # calculate more time consuming ARIANNA trigger only if station passes simple trigger triggerSimulatorARIANNA.run(self._evt, self._station, self._det, threshold_high=3 * self._Vrms, threshold_low=-3 * self._Vrms, triggered_channels=[8, 9, 10, 11], number_concidences=2, cut_trace=False, trigger_name='high_low_2of4_deep_dipoles') triggerSimulatorARIANNA.run( self._evt, self._station, self._det, threshold_high=3 * self._Vrms, threshold_low=-3 * self._Vrms, triggered_channels=[0, 1, 2, 3, 4, 5, 6, 7], number_concidences=6, cut_trace=False, trigger_name='high_low_6of8_3sigma', set_not_triggered=( not self._station.has_triggered("simple_threshold")) ) # calculate more time consuming ARIANNA trigger only if station passes simple trigger triggerSimulatorARIANNA.run( self._evt, self._station, self._det, threshold_high=4 * self._Vrms, threshold_low=-4 * self._Vrms, triggered_channels=[0, 1, 2, 3], number_concidences=2, cut_trace=False, trigger_name='high_low_2of4_LPDA_4sigma', set_not_triggered=( not self._station.has_triggered("simple_threshold")) ) # calculate more time consuming ARIANNA trigger only if station passes simple trigger triggerSimulatorARIANNA.run( self._evt, self._station, self._det, threshold_high=3.3 * self._Vrms, threshold_low=-3.3 * self._Vrms, triggered_channels=[0, 1, 2, 3], number_concidences=4, cut_trace=False, trigger_name='high_low_4of4_LPDA_3.3sigma', set_not_triggered=( not self._station.has_triggered("simple_threshold")) ) # calculate more time consuming ARIANNA trigger only if station passes simple trigger triggerSimulatorARIANNA.run( self._evt, self._station, self._det, threshold_high=3.3 * self._Vrms, threshold_low=-3.3 * self._Vrms, triggered_channels=[4, 5, 6, 7], number_concidences=4, cut_trace=False, trigger_name='high_low_4of4_3.3sigma', set_not_triggered=( not self._station.has_triggered("simple_threshold")) ) # calculate more time consuming ARIANNA trigger only if station passes simple trigger
def _detector_simulation_trigger(self, evt, station, det): # Start detector simulation orig_traces = {} for channel in station.iter_channels(): orig_traces[channel.get_id()] = channel.get_trace() # If there is an empty trace, leave if (np.sum(channel.get_trace()) == 0): return filtered_signal_traces = {} for channel in station.iter_channels(use_channels=channels): trace = np.array(channel.get_trace()) channel.set_trace(trace, new_sampling_rate) filtered_signal_traces[channel.get_id()] = trace # Since there are often two traces within the same thing, gotta be careful Vpps = [] for channel in station.iter_channels(use_channels=channels): trace = np.array(channel.get_trace()) Vpps += [np.max(trace) - np.min(trace)] Vpps = np.array(Vpps) # loop over all channels (i.e. antennas) of the station for channel in station.iter_channels(use_channels=channels): trace = np.zeros(len(filtered_signal_traces[channel.get_id()][:])) channel.set_trace(trace, sampling_rate=new_sampling_rate) # Adding noise AFTER the SNR calculation channelGenericNoiseAdder.run(evt, station, det, amplitude=Vrms / Vrms_ratio, min_freq=min_freq, max_freq=max_freq, type='rayleigh') # bandpass filter trace, the upper bound is higher then the sampling rate which makes it just a highpass filter channelBandPassFilter.run(evt, station, det, passband=[0 * units.MHz, 220.0 * units.MHz], filter_type='cheby1', order=7, rp=.1) channelBandPassFilter.run( evt, station, det, passband=[96.0 * units.MHz, 100.0 * units.GHz], filter_type='cheby1', order=4, rp=.1) filtered_noise_traces = {} for channel in station.iter_channels(use_channels=channels): filtered_noise_traces[channel.get_id()] = channel.get_trace() factor = 1.0 / (np.mean(Vpps) / (2.0 * Vrms)) mult_factors = factor * SNRs if (np.mean(Vpps) == 0.0): return for factor, iSNR in zip(mult_factors, range(len(mult_factors))): for channel in station.iter_channels(use_channels=channels): trace = copy.deepcopy( filtered_signal_traces[channel.get_id()][:]) * factor noise = copy.deepcopy(filtered_noise_traces[channel.get_id()]) channel.set_trace(trace + noise, sampling_rate=new_sampling_rate) has_triggered = triggerSimulator.run( evt, station, det, Vrms=Vrms, threshold=threshold, triggered_channels=channels, phasing_angles=phasing_angles, ref_index=1.75, trigger_name='primary_phasing', trigger_adc=False, adc_output='voltage', trigger_filter=None, upsampling_factor=upsampling_factor, window=window, step=step) if (has_triggered): print('Trigger for SNR', SNRs[iSNR]) SNRtriggered[iSNR] += 1 count_events() print(count_events.events) print(SNRtriggered) if (count_events.events % 10 == 0): output = { 'total_events': count_events.events, 'SNRs': list(SNRs), 'triggered': list(SNRtriggered) } outputfile = args.outputSNR with open(outputfile, 'w+') as fout: json.dump(output, fout, sort_keys=True, indent=4)
efieldToVoltageConverter.run(evt, station, det) hardwareResponseIncorporator.run(evt, station, det, sim_to_data=True) channelGenericNoiseAdder.run(evt, station, det, type="rayleigh", amplitude=args.noise_level) triggerSimulator.run(evt, station, det, number_concidences=2, threshold=100 * units.mV) if station.get_trigger('default_simple_threshold').has_triggered(): channelBandPassFilter.run(evt, station, det, passband=passband, filter_type='butter', order=10) efieldBandPassFilter.run(evt, sim_station, det, passband, filter_type='butter', order=10) eventTypeIdentifier.run(evt, station, "forced", 'cosmic_ray') # The time differences between channels have to be stored in the channels # We can just calculate it from the CR direction. for channel in station.iter_channels(): channel.set_parameter(chp.signal_receiving_zenith, sim_station.get_parameter(stnp.zenith)) channel.set_parameter(chp.signal_receiving_azimuth,
electric_field = NuRadioReco.framework.electric_field.ElectricField( [2]) electric_field.set_trace(sampling_rate=1. / dt, trace=trace) electric_field[efp.azimuth] = 0 electric_field[efp.zenith] = (90 + 45) * units.deg electric_field[efp.ray_path_type] = 'direct' sim_station.add_electric_field(electric_field) sim_station[stnp.zenith] = (90 + 45) * units.deg sim_station.set_is_neutrino() sim_station[stnp.zenith] = 0 station.set_sim_station(sim_station) event.set_station(station) efieldToVoltageConverter.run(event, station, det) channelBandPassFilter.run(event, station, det, passband=[min_freq, max_freq]) trace_bicone = station.get_channel(2).get_trace() SNRp2p_bicone[counter] = (trace_bicone.max() - trace_bicone.min()) / 2. / Vrms after_tunnel_diode = np.abs( triggerSimulator.tunnel_diode(station.get_channel(2))) power_mean = 0 SNRara_bicone[counter] = np.max( (after_tunnel_diode - power_mean) / power_rms) fig, ax = plt.subplots(1, 1) ax.scatter(SNRp2p_bicone, SNRara_bicone, s=20, alpha=0.5)
def _detector_simulation_part2(self): # Start detector simulation # Convolve efield with antenna pattern efieldToVoltageConverter.run(self._evt, self._station, self._det) # Downsample trace back to detector sampling rate channelResampler.run(self._evt, self._station, self._det, sampling_rate=new_sampling_rate) # Filter signals channelBandPassFilter.run( self._evt, self._station, self._det, passband=[0.0 * units.MHz, 240.0 * units.MHz], filter_type='cheby1', order=9, rp=.1) channelBandPassFilter.run( self._evt, self._station, self._det, passband=[80.0 * units.MHz, 230.0 * units.MHz], filter_type='cheby1', order=4, rp=.1) filtered_signal_traces = {} for channel in self._station.iter_channels(): trace = np.array(channel.get_trace()) filtered_signal_traces[channel.get_id()] = trace # Since there are often two traces within the same thing, gotta be careful Vpps = np.zeros(self._station.get_number_of_channels()) for iChan, channel in enumerate(self._station.iter_channels()): trace = np.array(channel.get_trace()) Vpps[iChan] = np.max(trace) - np.min(trace) factor = 1.0 / (np.mean(Vpps) / 2.0) mult_factors = factor * SNRs has_triggered = True while (has_triggered ): # search for noise traces that don't set off a trigger # loop over all channels (i.e. antennas) of the station for channel in self._station.iter_channels(): trace = np.zeros( len(filtered_signal_traces[channel.get_id()][:])) channel.set_trace(trace, sampling_rate=new_sampling_rate) # Adding noise AFTER the SNR calculation channelGenericNoiseAdder.run(self._evt, self._station, self._det, amplitude=1.0 / Vrms_ratio, min_freq=min_freq, max_freq=max_freq, type='rayleigh') # bandpass filter trace, the upper bound is higher then the sampling rate which makes it just a highpass filter channelBandPassFilter.run( self._evt, self._station, self._det, passband=[0 * units.MHz, 240.0 * units.MHz], filter_type='cheby1', order=9, rp=.1) channelBandPassFilter.run( self._evt, self._station, self._det, passband=[80.0 * units.MHz, 230.0 * units.MHz], filter_type='cheby1', order=4, rp=.1) if (phase): has_triggered = triggerSimulator.run( self._evt, self._station, self._det, Vrms=1.0, threshold=threshold, triggered_channels=channels, phasing_angles=phasing_angles, ref_index=1.75, trigger_name='primary_phasing', trigger_adc= False, # Don't have a seperate ADC for the trigger clock_offset=np.random.uniform(0.0, 2.0), adc_output='voltage', # output in volts trigger_filter=None, upsampling_factor=upsampling_factor, window=window, step=step) else: original_traces_ = self._station.get_channel(4).get_trace() squared_mean, num_frames = triggerSimulator.power_sum( coh_sum=original_traces_, window=window, step=step, adc_output='voltage') squared_mean_threshold = np.power(threshold, 2.0) has_triggered = (True in (squared_mean > squared_mean_threshold)) if (has_triggered): print('Trigger on noise... ') filtered_noise_traces = {} for channel in self._station.iter_channels(): filtered_noise_traces[channel.get_id()] = channel.get_trace() for factor, iSNR in zip(mult_factors, range(len(mult_factors))): for channel in self._station.iter_channels(): trace = copy.deepcopy( filtered_signal_traces[channel.get_id()][:]) * factor noise = filtered_noise_traces[channel.get_id()] channel.set_trace(trace + noise, sampling_rate=new_sampling_rate) if (phase): has_triggered = triggerSimulator.run( self._evt, self._station, self._det, Vrms=1.0, threshold=threshold, triggered_channels=channels, phasing_angles=phasing_angles, ref_index=1.75, trigger_name='primary_phasing', trigger_adc=False, clock_offset=np.random.uniform(0.0, 2.0), adc_output='voltage', trigger_filter=None, upsampling_factor=upsampling_factor, window=window, step=step) else: original_traces_ = self._station.get_channel(4).get_trace() squared_mean, num_frames = triggerSimulator.power_sum( coh_sum=original_traces_, window=window, step=step, adc_output='voltage') squared_mean_threshold = np.power(threshold, 2.0) has_triggered = (True in (squared_mean > squared_mean_threshold)) if (has_triggered): print('Trigger for SNR', SNRs[iSNR]) SNRtriggered[iSNR] += 1 count_events() print(count_events.events) print(SNRtriggered) if (count_events.events % 10 == 0): # plt.show() # Save every ten triggers output = { 'total_events': count_events.events, 'SNRs': list(SNRs), 'triggered': list(SNRtriggered) } outputfile = args.outputSNR with open(outputfile, 'w+') as fout: json.dump(output, fout, sort_keys=True, indent=4)
def _detector_simulation(self): # start detector simulation if (bool(self._cfg['signal']['zerosignal'])): self._increase_signal(None, 0) efieldToVoltageConverter.run( self._evt, self._station, self._det) # convolve efield with antenna pattern # downsample trace to internal simulation sampling rate (the efieldToVoltageConverter upsamples the trace to # 20 GHz by default to achive a good time resolution when the two signals from the two signal paths are added) channelResampler.run(self._evt, self._station, self._det, sampling_rate=1. / self._dt) if bool(self._cfg['noise']): Vrms = self._Vrms / ( self._bandwidth / (2.5 * units.GHz) )**0.5 # normalize noise level to the bandwidth its generated for channelGenericNoiseAdder.run(self._evt, self._station, self._det, amplitude=Vrms, min_freq=0 * units.MHz, max_freq=2.5 * units.GHz, type='rayleigh') # bandpass filter trace, the upper bound is higher then the sampling rate which makes it just a highpass filter channelBandPassFilter.run(self._evt, self._station, self._det, passband=[80 * units.MHz, 1000 * units.GHz], filter_type='butter', order=2) channelBandPassFilter.run(self._evt, self._station, self._det, passband=[0, 500 * units.MHz], filter_type='butter', order=10) # first run a simple threshold trigger simpleThreshold.run( self._evt, self._station, self._det, threshold=3 * self._Vrms, triggered_channels=None, # run trigger on all channels number_concidences=1, trigger_name='simple_threshold') # the name of the trigger # run a high/low trigger on the 4 downward pointing LPDAs highLowThreshold.run( self._evt, self._station, self._det, threshold_high=4 * self._Vrms, threshold_low=-4 * self._Vrms, triggered_channels=[0, 1, 2, 3], # select the LPDA channels number_concidences=2, # 2/4 majority logic trigger_name='LPDA_2of4_4.1sigma', set_not_triggered=( not self._station.has_triggered("simple_threshold")) ) # calculate more time consuming ARIANNA trigger only if station passes simple trigger # run a high/low trigger on the 4 surface dipoles highLowThreshold.run( self._evt, self._station, self._det, threshold_high=3 * self._Vrms, threshold_low=-3 * self._Vrms, triggered_channels=[4, 5, 6, 7], # select the bicone channels number_concidences=4, # 4/4 majority logic trigger_name='surface_dipoles_4of4_3sigma', set_not_triggered=( not self._station.has_triggered("simple_threshold")) ) # calculate more time consuming ARIANNA trigger only if station passes simple trigger # downsample trace back to detector sampling rate channelResampler.run(self._evt, self._station, self._det, sampling_rate=self._sampling_rate_detector)
det, type="rayleigh", amplitude=20 * units.mV) triggerSimulator.run(evt, station, det, number_concidences=2, threshold=100 * units.mV) if station.get_trigger('default_simple_threshold').has_triggered(): channelBandPassFilter.run( evt, station, det, passband=[80 * units.MHz, 500 * units.MHz], filter_type='butter', order=10) eventTypeIdentifier.run(evt, station, "forced", 'cosmic_ray') channelStopFilter.run(evt, station, det) channelBandPassFilter.run( evt, station, det, passband=[60 * units.MHz, 600 * units.MHz], filter_type='rectangular')
SNR_ARIANNA = 0 max = [] for n in range(n_iter): channel_ARA.set_trace(test_pulse_sc, 10 * units.GHz) station_ARA.add_channel(channel_ARA) station_ARA.remove_triggers() channel_ARIANNA.set_trace(test_pulse_sc, 10 * units.GHz) station_ARIANNA.add_channel(channel_ARIANNA) station_ARIANNA.remove_triggers() channelBandPassFilter.run(event_ARIANNA, station_ARIANNA, det, passband=[50 * units.MHz, 1000 * units.MHz], filter_type='rectangular') channelBandPassFilter.run(event_ARA, station_ARA, det, passband=[50 * units.MHz, 1000 * units.MHz], filter_type='rectangular') channelGenericNoiseAdder.run(event_ARA, station_ARA, det, amplitude=20 * units.mV, min_freq=50 * units.MHz, max_freq=1000 * units.MHz, type='perfect_white')
def _detector_simulation_filter_amp(self, evt, station, det): channelBandPassFilter.run(evt, station, det, passband=[80 * units.MHz, 1000 * units.GHz], filter_type="butter", order=2) channelBandPassFilter.run(evt, station, det, passband=[0 * units.MHz, 500 * units.MHz], filter_type="butter", order=10)
def _detector_simulation_part2(self): # start detector simulation efieldToVoltageConverter.run( self._evt, self._station, self._det) # convolve efield with antenna pattern # downsample trace to 1.5 Gs/s new_sampling_rate = 1.5 * units.GHz channelResampler.run(self._evt, self._station, self._det, sampling_rate=new_sampling_rate) cut_times = get_window_around_maximum(self._station) # Bool for checking the noise triggering rate check_only_noise = False if check_only_noise: for channel in self._station.iter_channels(): trace = channel.get_trace() * 0 channel.set_trace(trace, sampling_rate=new_sampling_rate) if self._is_simulate_noise(): max_freq = 0.5 / self._dt norm = self._get_noise_normalization(self._station.get_id( )) # assuming the same noise level for all stations channelGenericNoiseAdder.run(self._evt, self._station, self._det, amplitude=self._Vrms, min_freq=0 * units.MHz, max_freq=max_freq, type='rayleigh', bandwidth=norm) # bandpass filter trace, the upper bound is higher then the sampling rate which makes it just a highpass filter channelBandPassFilter.run(self._evt, self._station, self._det, passband=[130 * units.MHz, 1000 * units.GHz], filter_type='butter', order=6) channelBandPassFilter.run(self._evt, self._station, self._det, passband=[0, 750 * units.MHz], filter_type='butter', order=10) # run the phased trigger triggerSimulator.run( self._evt, self._station, self._det, threshold=2.5 * self._Vrms, # see phased trigger module for explanation triggered_channels=None, # run trigger on all channels secondary_channels=[0, 1, 3, 4, 6, 7], # secondary channels trigger_name= 'primary_and_secondary_phasing', # the name of the trigger coupled=True, cut_times=cut_times)
def _detector_simulation_trigger(self, evt, station, det): original_traces = {} for channel in station.iter_channels(): trace = np.array(channel.get_trace()) original_traces[channel.get_id()] = trace # channel 8 is a noiseless channel at 100m depth simpleThreshold.run( evt, station, det, threshold=3 * self._Vrms_per_channel[station.get_id()][8], triggered_channels=[8], # run trigger on all channels number_concidences=1, trigger_name=f'dipole_3.0sigma') simpleThreshold.run( evt, station, det, threshold=2.5 * self._Vrms_per_channel[station.get_id()][8], triggered_channels=[8], # run trigger on all channels number_concidences=1, trigger_name=f'dipole_2.5sigma') simpleThreshold.run( evt, station, det, threshold=2.0 * self._Vrms_per_channel[station.get_id()][8], triggered_channels=[8], # run trigger on all channels number_concidences=1, trigger_name=f'dipole_2.0sigma') simpleThreshold.run( evt, station, det, threshold=1.5 * self._Vrms_per_channel[station.get_id()][8], triggered_channels=[8], # run trigger on all channels number_concidences=1, trigger_name=f'dipole_1.5sigma') simpleThreshold.run( evt, station, det, threshold=1.0 * self._Vrms_per_channel[station.get_id()][8], triggered_channels=[8], # run trigger on all channels number_concidences=1, trigger_name=f'dipole_1.0sigma') # Trigger windows Vrms = self._Vrms_per_channel[station.get_id()][4] resample = self._cfg[ 'sampling_rate'] * units.GHz # Old name, just the MC clock frequency # x2 for upsampling window_4ant = int(16 * units.ns * self._sampling_rate_detector * 2.0) step_4ant = int(8 * units.ns * self._sampling_rate_detector * 2.0) # x4 for upsampling window_8ant = int(16 * units.ns * self._sampling_rate_detector * 4.0) step_8ant = int(8 * units.ns * self._sampling_rate_detector * 4.0) # Seperately add noise, filter it, then add filtered signal back in filtered_signal_traces = {} for channel in station.iter_channels(): trace = np.array(channel.get_trace()) filtered_signal_traces[channel.get_id()] = trace channel.set_trace(np.zeros(len(trace)), sampling_rate=resample) channelGenericNoiseAdder.run(evt, station, det, amplitude=Vrms / Vrms_ratio, min_freq=min_freq, max_freq=max_freq, type='rayleigh') # bandpass filter trace, the upper bound is higher then the sampling rate which makes it just a highpass filter channelBandPassFilter.run(evt, station, det, passband=[0 * units.MHz, 235.0 * units.MHz], filter_type='cheby1', order=9, rp=.1) channelBandPassFilter.run( evt, station, det, passband=[87.0 * units.MHz, 225.0 * units.MHz], filter_type='cheby1', order=4, rp=.1) for channel in station.iter_channels(): trace = copy.deepcopy(filtered_signal_traces[channel.get_id()][:]) noise = channel.get_trace() channel.set_trace(trace + noise, sampling_rate=resample) # run the 4 phased trigger phasedArrayTrigger.run( evt, station, det, Vrms=Vrms, threshold=1.95 * np.power(Vrms, 2.0) * window_8ant, # see phased trigger module for explanation triggered_channels=range(0, 8), phasing_angles=phasing_angles_8ant, ref_index=1.75, trigger_name=f'PA_8channel_100Hz', # the name of the trigger trigger_adc=False, # Don't have a seperate ADC for the trigger adc_output=f'voltage', # output in volts trigger_filter=None, upsampling_factor=4, window=window_8ant, step=step_8ant) # run the 4 phased trigger phasedArrayTrigger.run( evt, station, det, Vrms=Vrms, threshold=1.89 * np.power(Vrms, 2.0) * window_4ant, triggered_channels=range(2, 6), phasing_angles=phasing_angles_4ant, ref_index=1.75, trigger_name=f'PA_4channel_100Hz', # the name of the trigger trigger_adc=False, # Don't have a seperate ADC for the trigger adc_output=f'voltage', # output in volts trigger_filter=None, upsampling_factor=2, window=window_4ant, step=step_4ant) for channel in station.iter_channels(): channel.set_trace(original_traces[channel.get_id()], resample) # downsample trace back to detector sampling rate resample = self._sampling_rate_detector channelResampler.run(evt, station, det, sampling_rate=resample) # channel 8 is a noiseless channel at 100m depth simpleThreshold.run( evt, station, det, threshold=3 * self._Vrms_per_channel[station.get_id()][8], triggered_channels=[8], # run trigger on all channels number_concidences=1, trigger_name=f'dipole_3.0sigma_500MHz') simpleThreshold.run( evt, station, det, threshold=2.5 * self._Vrms_per_channel[station.get_id()][8], triggered_channels=[8], # run trigger on all channels number_concidences=1, trigger_name=f'dipole_2.5sigma_500Mhz') simpleThreshold.run( evt, station, det, threshold=2.0 * self._Vrms_per_channel[station.get_id()][8], triggered_channels=[8], # run trigger on all channels number_concidences=1, trigger_name=f'dipole_2.0sigma_500Mhz') simpleThreshold.run( evt, station, det, threshold=1.5 * self._Vrms_per_channel[station.get_id()][8], triggered_channels=[8], # run trigger on all channels number_concidences=1, trigger_name=f'dipole_1.5sigma_500Mhz') simpleThreshold.run( evt, station, det, threshold=1.0 * self._Vrms_per_channel[station.get_id()][8], triggered_channels=[8], # run trigger on all channels number_concidences=1, trigger_name=f'dipole_1.0sigma_500Mhz') filtered_signal_traces = {} for channel in station.iter_channels(): trace = np.array(channel.get_trace()) filtered_signal_traces[channel.get_id()] = trace channel.set_trace(np.zeros(len(trace)), sampling_rate=resample) channelGenericNoiseAdder.run(evt, station, det, amplitude=Vrms / Vrms_ratio, min_freq=min_freq, max_freq=max_freq, type='rayleigh') channelBandPassFilter.run(evt, station, det, passband=[0 * units.MHz, 235.0 * units.MHz], filter_type='cheby1', order=9, rp=.1) channelBandPassFilter.run( evt, station, det, passband=[87.0 * units.MHz, 225.0 * units.MHz], filter_type='cheby1', order=4, rp=.1) for channel in station.iter_channels(): trace = copy.deepcopy(filtered_signal_traces[channel.get_id()][:]) noise = channel.get_trace() channel.set_trace(trace + noise, sampling_rate=resample) phasedArrayTrigger.run( evt, station, det, Vrms=Vrms, threshold=1.95 * np.power(Vrms, 2.0) * window_8ant, # see phased trigger module for explanation triggered_channels=range(0, 8), phasing_angles=phasing_angles_8ant, ref_index=1.75, trigger_name=f'PA_8channel_100Hz_500MHz', # the name of the trigger trigger_adc=False, # Don't have a seperate ADC for the trigger adc_output=f'voltage', # output in volts trigger_filter=None, upsampling_factor=4, window=window_8ant, step=step_8ant) # run the 4 phased trigger phasedArrayTrigger.run( evt, station, det, Vrms=Vrms, threshold=1.89 * np.power(Vrms, 2.0) * window_4ant, triggered_channels=range(2, 6), phasing_angles=phasing_angles_4ant, ref_index=1.75, trigger_name=f'PA_4channel_100Hz_500MHz', # the name of the trigger trigger_adc=False, # Don't have a seperate ADC for the trigger adc_output=f'voltage', # output in volts trigger_filter=None, upsampling_factor=2, window=window_4ant, step=step_4ant)
r.find_solutions() if (not r.has_solution()): continue results['depth'].append(d) rvec = r.get_receive_vector(0) zen, az = hp.cartesian_to_spherical(*rvec) az = hp.get_normalized_angle(az) results['exp'].append((zen, az)) print("{} depth = {:.1f}m -> {:.2f} {:.2f} (solution type {})".format( t, d, zen / units.deg, az / units.deg, r.get_solution_type(0))) channelResampler.run(evt, station, det, 50 * units.GHz) channelBandPassFilter.run(evt, station, det, passband=[120 * units.MHz, 300 * units.MHz], filter_type='butterabs', order=10) channelBandPassFilter.run(evt, station, det, passband=[10 * units.MHz, 1000 * units.MHz], filter_type='rectangular') hardwareResponseIncorporator.run(evt, station, det) channelSignalReconstructor.run(evt, station, det) # channelTimeWindow.run(evt, station, det, window_function='hanning', around_pulse=True, window_width=20*units.ns, # window_rise_time=20*units.ns) correlationDirectionFitter.run( evt, station,