def test_simulation_time(num_simulations=100): start_time = time() for i in trange(num_simulations): event = SimulatedFRB() event.simulateFRB() end_time = time() print( f"{num_simulations} sims completed in {end_time - start_time} seconds")
def real_RFI_plot(RFI_array_file, seed=24, figsize=(12, 8), SNRmin=5, SNRmax=15): np.random.seed(seed) npz_file = np.load(RFI_array_file) real_RFI = npz_file['rfi_data'] frequencies = npz_file['freq'] weights = npz_file['weights'] print(f"Frequencies: {frequencies}") random_indexes = np.random.randint(low=0, high=len(real_RFI), size=8) sample_RFI, sample_weights = real_RFI[random_indexes], weights[ random_indexes] fig_RFI, ax_RFI = plt.subplots(nrows=4, ncols=2, figsize=figsize) for RFI_image, w, ax in zip(sample_RFI, sample_weights, ax_RFI.flatten()): event = SimulatedFRB(f_low=1850, f_high=2700, f_ref=np.median(frequencies), bandwidth=np.ptp(frequencies)) event.simulateFRB(background=RFI_image, weights=w, SNRmin=SNRmin, SNRmax=SNRmax) ax.imshow(event.simulatedFRB, aspect='auto', extent=[0, 256, np.min(frequencies), np.max(frequencies)]) ax.set_title(f'SNR: {np.round(event.SNR, 1)}') fig_RFI.tight_layout() return fig_RFI
def noise_and_FRB(nrows=4, ncols=2): fig, ax = plt.subplots(nrows=nrows, ncols=ncols) example_number = 1 flat_axes = ax.flatten() while example_number < len(flat_axes): event = SimulatedFRB() event.simulateFRB() frb = event.simulatedFRB # collapse all frequencies by taking mean for each column profile_1D = np.mean(frb, axis=0) # plot results for every 3 axes flat_axes[example_number - 1].imshow(frb) flat_axes[example_number - 1].set_title( f"Noise and FRB (SNR: {np.round(event.SNR, 2)})") flat_axes[example_number].plot(profile_1D) flat_axes[example_number].set_title(f"Profile") example_number += 2 fig.tight_layout() return fig