From f907102660254652e3f59722ce801d24e5e68c0c Mon Sep 17 00:00:00 2001 From: Shiny Horo Date: Thu, 22 Jan 2026 07:33:26 +0530 Subject: [PATCH] Update sim_axion.py Portable saving of simulation images with np.savez --- Model_I/sim_axion.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Model_I/sim_axion.py b/Model_I/sim_axion.py index e778412..aff18e2 100644 --- a/Model_I/sim_axion.py +++ b/Model_I/sim_axion.py @@ -1,15 +1,14 @@ import matplotlib.pyplot as plt import numpy as np import random - +import os from deeplense.lens import DeepLens - # Number of sims num_sim = int(5e3) - - axion_masses = 10**np.random.uniform(-24,-22,num_sim) +base_path = os.path.join(os.getcwd(), 'data', 'Model_I_test', 'axion') +os.makedirs(base_path, exist_ok=True) for i in range(num_sim): lens = DeepLens(axion_mass=axion_masses[i]) @@ -17,10 +16,13 @@ lens.make_vortex(3e10) lens.make_source_light() lens.simple_sim() - File = np.array([lens.image_real,axion_masses[i]]) - np.save('/users/mtoomey/scratch/deeplense/Model_I_test/axion/axion_sim_' + str(random.getrandbits(128)),File) + filename = f"axion_sim_{random.getrandbits(128)}.npz" + path = os.path.join(base_path, filename) + np.savez(path, + image=lens.image_real, + axion_mass=axion_masses[i]) if False: plt.figure(figsize=(10,5))