path = "/share/data2/lls/regression/local_inertia/tensor/" ran_5k = np.load("/share/data2/lls/regression/local_inertia/tensor/ran_5k.npy") def pool_local_inertia(particle_id): li, eigi = In.get_local_inertia_single_id(particle_id, snapshot, r_smoothing, rho) np.save( path + "random/inertia_tensor_particle_" + str(particle_id) + ".npy", li) np.save(path + "random/eigenvalues_particle_" + str(particle_id) + ".npy", eigi) # print("Done and saved particle " + str(particle_id)) return li ic = parameters.InitialConditionsParameters(load_final=True) In = inertia.LocalInertia(ran_5k, initial_parameters=ic) snapshot = ic.initial_conditions rho = snapshot["rho"] filtering_scales = In.filt_scales r_smoothing = In.filter_parameters.smoothing_radii.in_units( snapshot["pos"].units)[filtering_scales] pool = Pool(processes=40) li_particles = pool.map(pool_local_inertia, ran_5k) pool.close() pool.join()
def pool_local_inertia(particle_id): li = In.get_local_inertia_single_id(particle_id, snapshot, r_smoothing, rho) np.save(path + "ids/inertia_tensor_particle_" + str(particle_id) + ".npy", li) # print("Done and saved particle " + str(particle_id)) return li path = "/share/data2/lls/regression/local_inertia/tensor/" tr_ids = np.load(path + "subset_ids.npy") ic = parameters.InitialConditionsParameters(load_final=True) In = inertia.LocalInertia(tr_ids, initial_parameters=ic) snapshot = ic.initial_conditions rho = snapshot["rho"] # rho_mean = (np.sum(snapshot["mass"]) / snapshot.properties["boxsize"] ** 3).in_units("Msol kpc**-3") # C = rho - rho_mean filtering_scales = In.filt_scales r_smoothing = In.filter_parameters.smoothing_radii.in_units( snapshot["pos"].units)[filtering_scales] ids_remaining = tr_ids[:] pool = Pool(processes=40) li_particles = pool.map(pool_local_inertia, ids_remaining) pool.close() pool.join()
li, eigi = In.get_local_inertia_single_id(particle_id, snapshot, r_smoothing, rho) np.save( path + "testing/ids/inertia_tensor_particle_" + str(particle_id) + ".npy", li) np.save( path + "testing/ids/eigenvalues_particle_" + str(particle_id) + ".npy", eigi) # print("Done and saved particle " + str(particle_id)) return li testing_ids = training_ind ic = parameters.InitialConditionsParameters(load_final=True) In = inertia.LocalInertia(testing_ids, initial_parameters=ic) snapshot = ic.initial_conditions rho = snapshot["rho"] # rho_mean = (np.sum(snapshot["mass"]) / snapshot.properties["boxsize"] ** 3).in_units("Msol kpc**-3") # C = rho - rho_mean filtering_scales = In.filt_scales r_smoothing = In.filter_parameters.smoothing_radii.in_units( snapshot["pos"].units)[filtering_scales] pool = Pool(processes=40) li_particles = pool.map(pool_local_inertia, testing_ids) pool.close() pool.join()
# training_ids = np.load("/share/data1/lls/regression/in_halos_only/log_m_output/even_radii_and_random/training_ids.npy") # # a = [] # for filename in os.listdir(path + "ids_50scales/"): # a.append(int(get_numbers_from_filename(filename))) # # a = np.array(a) # ids_remaining = training_ids[~np.in1d(training_ids, a)] # del a #ids_remaining = np.load(path + "training_high_mass.npy") ids_remaining = np.load(path + "ran_above_137.npy") ic = parameters.InitialConditionsParameters(load_final=True) #In = inertia.LocalInertia(training_ids, initial_parameters=ic) In = inertia.LocalInertia(ids_remaining, initial_parameters=ic) snapshot = ic.initial_conditions rho = snapshot["rho"] filtering_scales = In.filt_scales r_smoothing = In.filter_parameters.smoothing_radii.in_units(snapshot["pos"].units)[filtering_scales] pool = Pool(processes=40) li_particles = pool.map(pool_local_inertia, ids_remaining) pool.close() pool.join() # n_tot, b_tot, p_tot = plt.hist(np.log10(halo_mass[halo_mass!=0]), bins=50) # n_tr, b_tr, p_tr = plt.hist(np.log10(halo_mass[t_train]), bins=b_tot)