From 0f09dbad148e3a122b15168845268c6ae4db4382 Mon Sep 17 00:00:00 2001 From: "xiangyu.xie" Date: Mon, 6 Jul 2026 10:14:52 +0200 Subject: [PATCH] Update IO --- GeneratePileupSample.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/GeneratePileupSample.py b/GeneratePileupSample.py index 8074968..fff5752 100644 --- a/GeneratePileupSample.py +++ b/GeneratePileupSample.py @@ -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)]) \ No newline at end of file + pool.map(generate_sample, [(i, [f'{conf.sample_folder}/{conf.energy}keV_Moench040_150V_{i}.npz']) for i in range(16)]) \ No newline at end of file