Enhance memory handling (and performance to a lesser extent) in simulator modules - #164
Merged
Merged
Conversation
Replace 9× np.tile(..., (n, m, k)) patterns with [None, :, :] broadcasting Remove dead parameters from _allocate_strat_sub_col to reduce per-task Dask serialization: cld_2_assigns, I_min, I_max were computed in caller but immediately shadowed locally on each loop iteration.
Replace np.tile(..., (n_subcolumns, 1, 1)) with [None, :, :] broadcasting in radar_moments.py and lidar_moments.py:
Replace redundant per-level np.all()==0 checks with single precomputed active_k index array per time step. Applied to 5 worker functions (_calculate_observables_liquid, _calculate_other_observables, _calc_sigma_d_tot_cl, _calc_sigma_d_tot, _calc_strat_lidar_properties). Benefits proportional to cloud sparsity.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request refactors array broadcasting and tiling logic in both the lidar and radar moment simulation code. The main focus is to replace repeated use of
np.tilewith more explicit broadcasting viaNoneindexing andnp.broadcast_to, which improves efficiency and clarity. Additionally, there are minor optimizations and cleanups, such as deleting temporary lists and improving conditional logic.