From 5839138aa993bf89d3afe0e4e9427b5e9362890e Mon Sep 17 00:00:00 2001 From: sambit-giri Date: Mon, 30 Dec 2024 10:15:13 +0100 Subject: [PATCH] array to generator to improve memory usage The baseline rotation at every time step is implemented as a generator. This uses same memory only when it is called in a for loop, making it more stable. This change fixes #58 --- setup.py | 2 +- src/tools21cm/telescope_functions.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/setup.py b/setup.py index d6635aa..e711fb2 100644 --- a/setup.py +++ b/setup.py @@ -36,7 +36,7 @@ setup( name='tools21cm', - version='2.2.5', + version='2.2.6', author='Sambit Giri', author_email='sambit.giri@gmail.com', packages=find_packages(where="src"), diff --git a/src/tools21cm/telescope_functions.py b/src/tools21cm/telescope_functions.py index be87df8..dcc1a68 100644 --- a/src/tools21cm/telescope_functions.py +++ b/src/tools21cm/telescope_functions.py @@ -141,11 +141,11 @@ def get_uv_daily_observation(ncells, z, filename=None, total_int_time=4., int_ti total_observations = int((total_int_time * 3600) / int_time) if verbose: - print("Generating uv map from daily observations.") + print("Generating uv map from daily observations...") # Vectorize the observation loop by calculating all rotations at once time_indices = np.arange(total_observations) + 1 - all_rotated_Nbase = np.array([earth_rotation_effect(Nbase, i, int_time, declination) for i in time_indices]) + all_rotated_Nbase = (earth_rotation_effect(Nbase, i, int_time, declination) for i in time_indices) # Grid uv tracks for each observation without individual loops for rotated_Nbase in tqdm(all_rotated_Nbase, disable=not verbose, desc="Gridding uv tracks"): @@ -154,9 +154,9 @@ def get_uv_daily_observation(ncells, z, filename=None, total_int_time=4., int_ti uv_map /= total_observations # Normalize by the total number of observations if verbose: - print("Observation complete.") + print("...done") - return uv_map, N_ant + return uv_map, N_ant def grid_uv_tracks(Nbase, z, ncells, boxsize=None, include_mirror_baselines=False): """