Skip to content

Optimize radar and lidar forward operators - #163

Merged
isilber merged 4 commits into
ARM-DOE:masterfrom
isilber:optimize_lidar_radar
Aug 31, 2026
Merged

Optimize radar and lidar forward operators#163
isilber merged 4 commits into
ARM-DOE:masterfrom
isilber:optimize_lidar_radar

Conversation

@isilber

@isilber isilber commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

This pull request introduces significant improvements to the parallelism options and radar spectral width calculation in the lidar and radar simulators. This is primarily the result of a more efficient single-pass computation for radar spectral width, and several code cleanups and refactorings.

These changes make the simulator more flexible, efficient, and user-friendly for both small and large-scale simulations. From preliminary tests, these changes cut sigma_D calcuation by an order of magnitude, with an estimated total speedup by a factor of 4.

…idar_micro

Introduces ProcessPoolExecutor as a third parallelism mode alongside the existing Dask (parallel=True) and serial (parallel=False) paths.

Primary Changes:
- Added ProcessPoolExecutor + os + tqdm imports to radar_moments.py and lidar_moments.py
- Updated parallel parameter to accept bool | str; 'processes' routes to
  ProcessPoolExecutor, True/'dask' retains existing Dask bag logic
- Applied to all 4 parallel blocks in calc_radar_micro (Ze/Vd pass + spectral width pass) and the single parallel block in calc_lidar_micro
- Replaced all 5 local lambdas with module-level _PoolWorker callable class:
  standard pickle cannot serialize closures, which caused AttributeError when
  parallel='processes'; _PoolWorker also eliminates implicit capture of model/
  instrument objects in cloudpickle, yielding significant speedup under parallel=True (Dask)
No algorithm changes; backward compatible (True still uses Dask, False still serial).
… computation

Cache N_0, lambdas, mu parameters from the main reflectivity/
velocity pass (pass 1) and reuse them in the spectral width pass (pass 2),
eliminating the second call to calc_and_set_psd_params per hydrometeor class.
Add single-pass spectral width computation using variance decomposition formula,
eliminating the expensive second parallel pass when calc_spectral_width=True.

Primary changes:
- Modify worker functions (_calculate_observables_liquid, _calculate_other_observables)
  to compute v2_numer (velocity-squared integrals) during pass 1
- Accumulate v2_numer across hydrometeor types in calc_radar_micro
- Compute total spectral width from variance formula: σ_d² = E[v²] - (E[v])²
  after Vd_tot is finalized.
- Expose parameter in make_simulated_data (main.py) with default=True
- Backward compatible: disable with single_pass_spectral_width=False
@isilber
isilber merged commit 6ee9b19 into ARM-DOE:master Aug 31, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant