Update IO
This commit is contained in:
@@ -15,6 +15,9 @@ def generate_sample(input_tuple):
|
||||
assemble them into multi-photon pile-up clusters (e.g. 6x6 for 2 photons, 9x9 for 3 photons)
|
||||
'''
|
||||
output_path = conf.output_folder
|
||||
import os
|
||||
if not os.path.exists(output_path):
|
||||
os.makedirs(output_path)
|
||||
all_samples, all_labels = None, None
|
||||
for file in file_list:
|
||||
data = np.load(file)
|
||||
@@ -88,9 +91,10 @@ def generate_sample(input_tuple):
|
||||
pileup_samples = np.array(pileup_samples)
|
||||
pileup_labels = np.array(pileup_labels)
|
||||
|
||||
np.savez(f'{output_path}/pileupOf{conf.num_of_photons}phs_sample_{worker_idx}.npz', samples=pileup_samples, labels=pileup_labels)
|
||||
print(f"Worker {worker_idx}: finished generating {count_of_event} events, saved to {output_path}/pileupOf{conf.num_of_photons}phs_sample_{worker_idx}.npz")
|
||||
output_file_name = f'{output_path}/{conf.energy}keV_Noise{conf.noise_keV}keV_pileupOf{conf.num_of_photons}phs_sample_{worker_idx}.npz'
|
||||
np.savez(output_file_name, samples=pileup_samples, labels=pileup_labels)
|
||||
print(f"Worker {worker_idx}: finished generating {count_of_event} events, saved to {output_file_name}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
with Pool(processes=16) as pool:
|
||||
pool.map(generate_sample, [(i, [f'{conf.sample_folder}/12keV_Moench040_150V_{i}.npz']) for i in range(16)])
|
||||
pool.map(generate_sample, [(i, [f'{conf.sample_folder}/{conf.energy}keV_Moench040_150V_{i}.npz']) for i in range(16)])
|
||||
Reference in New Issue
Block a user