def loop(zipped): threshold = float(zipped[0]) seed = int(zipped[1]) station = NuRadioReco.framework.station.Station(station_id) evt = NuRadioReco.framework.event.Event(0, 0) channelGenericNoiseAdder = NuRadioReco.modules.channelGenericNoiseAdder.channelGenericNoiseAdder( ) channelGenericNoiseAdder.begin(seed=seed) for channel_id in channel_ids: # Noise rms is amplified to greater than Vrms so that, after filtering, its the Vrms we expect spectrum = channelGenericNoiseAdder.bandlimited_noise( min_freq, max_freq, n_samples, sampling_rate, amplitude, type="rayleigh", time_domain=False) trace = fft.freq2time(spectrum * filt, sampling_rate) channel = NuRadioReco.framework.channel.Channel(channel_id) channel.set_trace(trace, sampling_rate) station.add_channel(channel) threshold_ = threshold * np.power(Vrms, 2.0) triggered = triggerSimulator.run(evt, station, det, Vrms, threshold_, triggered_channels=channels, phasing_angles=default_angles, ref_index=1.75, trigger_name='primary_phasing', trigger_adc=False, adc_output='voltage', trigger_filter=None, upsampling_factor=upsampling_factor, window=window_length, step=step_length) return triggered
def get_ARA_power_mean_rms(sampling_rate, Vrms, min_freq, max_freq): """ helper function to calculate the mean and rms power of the ARA tunnel diode for a given Vrms, sampling rate and frequency content Parameters ---------- sampling_rate: float the sampling rate e.g. 1GHz Vrms: float the RMS of noise in the time domain min_freq: float the lower bandpass frequency max_freq: float the upper bandpass frequency """ triggerSimulator = NuRadioReco.modules.ARA.triggerSimulator.triggerSimulator( ) channelGenericNoiseAdder = NuRadioReco.modules.channelGenericNoiseAdder.channelGenericNoiseAdder( ) noise = NuRadioReco.framework.channel.Channel(0) long_noise = channelGenericNoiseAdder.bandlimited_noise( min_freq=min_freq, max_freq=max_freq, n_samples=2**20, sampling_rate=sampling_rate, amplitude=Vrms, type='perfect_white') long_noise *= Vrms / long_noise.std() print(long_noise.std()) noise.set_trace(long_noise, sampling_rate) power_noise = triggerSimulator.tunnel_diode(noise) power_mean = np.mean(power_noise) power_rms = np.sqrt(np.mean(power_noise**2)) return power_mean, power_rms
for threshold_factor in threshold_factors: prob_per_window = 0 n_phased = len(primary_channels) low_trigger = power_mean - power_std * np.abs(threshold_factor) low_trigger *= n_phased for Ntry in range(Ntries): noise_array = [] for iant in range(len(primary_channels)): noise_trace = channelGenericNoiseAdder.bandlimited_noise( min_freq, max_freq, n_samples, sampling_rate, amplitude, type='rayleigh' ) channel = NuRadioReco.framework.channel.Channel(0) channel.set_trace(noise_trace, sampling_rate) enveloped_noise = diode.tunnel_diode(channel) noise_array.append(enveloped_noise) for subbeam_rolls in beam_rolls: noise = None for channel_id in range(len(primary_channels)):
primary_angles, input_time_step, upsampling_factor=upsampling_factor) n_samples = 1000000 # number of samples adc_n_samples = int(n_samples * adc_sampling_frequency * upsampling_factor / input_sampling_frequency) bandwidth = max_freq - min_freq amplitude = (300 * 50 * constants.k * bandwidth / units.Hz)**0.5 threshold_factors = [threshold_factor] noise_trace = channelGenericNoiseAdder.bandlimited_noise( min_freq, max_freq, 5 * n_samples, input_sampling_frequency, amplitude, type='rayleigh') noise_rms = get_noise_rms_nyquist_zone(noise_trace, input_sampling_frequency, adc_sampling_frequency, nyquist_zone=nyquist_zone, adc_n_bits=adc_n_bits, noise_rms_bits=noise_rms_bits, bandwidth_edge=20 * units.MHz, min_freq=min_freq) adc_ref_voltage = get_ref_voltage(noise_rms, adc_n_bits=adc_n_bits, noise_rms_bits=noise_rms_bits)
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) ax.set_xlabel("ARIANNA SNR (Vp2p/2/Vrms)") ax.set_ylabel("ARA SNR (tunnel diode output/noise power RMS)") ax.set_title("for ARA bicone response") fig.tight_layout() fig.savefig('plots/SNR_ARA_ARIANNA.png') plt.show() long_noise = channelGenericNoiseAdder.bandlimited_noise(min_freq=min_freq, max_freq=max_freq, n_samples=2**20, sampling_rate=1 / dt, amplitude=Vrms, type='perfect_white') NN = 10000 SS_LPDA = np.zeros(NN) SS_LPDA_amp = np.zeros(NN) Vp2p_LPDA = np.zeros(NN) Vp2p_LPDA_noise_1 = np.zeros(NN) Vp2p_LPDA_noise_2 = np.zeros(NN) Vp2p_LPDA_amp = np.zeros(NN) SS_bicone = np.zeros(NN) Vp2p_bicone = np.zeros(NN) Vp2p_bicone_noise_1 = np.zeros(NN) Vp2p_bicone_noise_2 = np.zeros(NN) counter = -1 if not os.path.isdir('plots'):