#--------------------------------------------------------------------- i_file = list_of_file_ids_test[0] print("Done!\n Loading labels...") datapath = "/mnt/ssd2/data/SouthPole/single_surface_4LPDA_PA_15m_RNOG_fullsim.json/ARZ2020_emhad_noise.yaml/G03generate_events_full_surface_sim/LPDA_2of4_100Hz/4LPDA_1dipole_fullband/em_had_separately" labels_em = np.load(os.path.join(datapath, f"labels_emhad_emhad_1-3_had_1_LPDA_2of4_100Hz_4LPDA_1dipole_fullband_{i_file:04d}.npy"), allow_pickle=True) labels_had = np.load(os.path.join(datapath, f"labels_had_emhad_1-3_had_1_LPDA_2of4_100Hz_4LPDA_1dipole_fullband_{i_file:04d}.npy"), allow_pickle=True) print("Done!\n Loading data files...") #TRY NOISELESS DATA AND SEE IF HIGH AND LOW EM SHOWER ENERGY EVENTS DIFFER. #MAYBE LOW EM SHOWER ENERGY EVENTS LOOK MORE LIKE HADRONIC SHOWERS. data, category = load_file(i_file, noise=False, em=True) #Plot singlas: High vs low EM shower energy, high vs low total shower energy. #EM component energies for the e CC events em_shower_energy = np.array(labels_em.item()["shower_energy_em"]) low_energy_indeces = np.where(em_shower_energy < 1e16) low_energy_plot_indeces = low_energy_indeces[0][0] #250 12 high_energy_indeces = np.where(em_shower_energy > 10**18.5) high_energy_plot_indeces = high_energy_indeces[0][0] xaxis = np.linspace(0, 256, 512) fig, ax = plt.subplots(5, 2, sharex=True)
import tensorflow as tf physical_devices = tf.config.list_physical_devices('GPU') for device in physical_devices: tf.config.experimental.set_memory_growth(device, True) from tensorflow import keras from generator import load_file, list_of_file_ids_test, TestDataset model = keras.models.load_model( '/mnt/md0/oericsson/NuRadio/saved_models/FINN04/model_best.h5') i_file = list_of_file_ids_test[0] data, labels = load_file(i_file, noise=True, em=True) max_LPDA = np.max(np.max(np.abs(data[:, :, 0:4]), axis=1), axis=1) SNR = max_LPDA[:, 0] / 10 predictions = model.predict(data, batch_size=64) #----SNR Bins---- #4 events with SNR<1. min(SNR) = 0.9250, max(SNR)=271.1495. 98841 events in interval 1<SNR<5. SNR_bins = np.append( np.linspace(1, 5, num=17), 10 ) #np.array([min(SNR), 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, max(SNR)]) #ind = np.where((SNR>=min(SNR)) & (SNR<1.5)) accuracy = []
i_file= list_of_file_ids_test[0] # print("Done!\n Loading labels...") # datapath = "/mnt/ssd2/data/SouthPole/single_surface_4LPDA_PA_15m_RNOG_fullsim.json/ARZ2020_emhad_noise.yaml/G03generate_events_full_surface_sim/LPDA_2of4_100Hz/4LPDA_1dipole_fullband/em_had_separately" # labels = np.load(os.path.join(datapath, f"labels_emhad_emhad_1-3_had_1_LPDA_2of4_100Hz_4LPDA_1dipole_fullband_{i_file:04d}.npy"), allow_pickle=True) #print("Done!") print(f'Loading file {i_file}...') test_data, test_labels = load_file(i_file, noise=True, em=True) #shower_energy_em = test_labels[1] nu_energy = test_labels[2] #print(f'shower energy em shape: {shower_energy_em.shape}') print("Done!") print("Making predictons...") predictions = model.predict(test_data) print(f'predicitons shape: {predictions.shape}') print("Done!") #for-loop iterating over energy intervals and saving the accuracies to a list: accuracy = [] energies = np.logspace(17, 19, 17) #For file 19: Only 41 events with shower_energy_em < 1e15, 432 events < 1e16.
import numpy as np import matplotlib.pyplot as plt import itertools from generator import load_file import os from gpuutils import GpuUtils GpuUtils.allocate(gpu_count=1, framework='keras') import tensorflow as tf physical_devices = tf.config.list_physical_devices('GPU') for device in physical_devices: tf.config.experimental.set_memory_growth(device, True) datapath = "/mnt/md0/data/SouthPole/single_surface_4LPDA_PA_15m_RNOG_fullsim.json/ARZ2020_emhad_noise.yaml/G03generate_events_full_surface_sim/LPDA_2of4_100Hz/4LPDA_1dipole_fullband" data, labels = load_file(10) One, TheOther = np.bincount(labels) total = Hadr + EMplusHadr print('Examples:\n Total: {}\n One: {} ({:.2f}% of total)\n'.format( total, Hadr, 100 * pos / total))