Conversation
|
With the changes so far in this PR it overall isn't that much slower using this kind of test |
Co-authored-by: Tom Aldcroft <taldcroft@gmail.com>
Co-authored-by: Tom Aldcroft <taldcroft@gmail.com>
Co-authored-by: Tom Aldcroft <taldcroft@gmail.com>
|
You do have me thinking @taldcroft that I might be able to simplify this further if I call get_monitor_catalog earlier in get_aca_catalog() and then figure out a way to deal with the possible monitor include_ids and changes to n_guide better. I'll ponder it. |
|
@jeanconn - the only thing I'm really waiting for at this point is the comparison of P2 and guide_count for the 10% of catalogs that changed. |
|
The pr410 notebook now has some plots for that - they seem reasonable to me. Should I also just put the plots in the PR description on github? |
taldcroft
left a comment
There was a problem hiding this comment.
Looks good enough! You can always come back and fine tune the code if needed.
Joint Optimization of Guide Stars and Fid Lights
This PR implements joint optimization of guide star and fid light selection to find the best compromise when fids and guides conflict. Previously, guide star selection always avoided selected fid lights, but fid selection was unaware of its impact on guide candidates. This could lead to suboptimal catalogs where fid lights spoiled potential guide stars, reducing guide count below acceptable levels. The new optimization evaluates multiple fid configurations and selects the one that best balances acquisition probability with guide star availability.
In most observations, the initial fid selection (via the first call to get_fid_catalog in _get_aca_catalog) trivially selects a fid set that is non-impacting to guide candidates and acquisition stars and in which the fid lights themselves are "unspoiled" by field stars. If so, no further optimization is needed.
Fixes #300
Reviewed and approved by SSAWG 14-Jan-2026
Architecture Changes
Candidate Reuse Pattern: The optimization now generates initial guide candidates once via the new
get_guide_candidates()function and reuses them across multiple iterations when evaluating different fid configurations. This avoids redundant candidate filtering and improves performance during optimization loops that typically run 3-10 iterations.Guide Count Metric: In addition to acquisition probability (P2), optimization now tracks
guide_count. The optimization prefers fid sets meeting minimum thresholds (P2 ≥ 2.0 AND guide_count ≥ 4.0) over sets that only maximize P2. When no "passable" sets exist, it falls back to maximizing P2.Monitor Window Handling: Monitor keep-out zones are now enforced via direct candidate filtering (
filter_candidates_for_monitors()). This is more straightforward than the previous handling via modifying the dark map.Dynamic Background Function: The
get_t_ccds_bonus()function has been relocated from the sparkles package into proseco to support guide count calculations during optimization. This avoids requiring sparkles as a dependency to run proseco.Interface Changes
New public API:
get_guide_candidates(**kwargs): Returns initial guide candidate table without fid filtering or final selectionget_t_ccds_bonus(mags, t_ccd, dyn_bgd_n_faint, dyn_bgd_dt_ccd): Relocated from sparkles for computing dynamic background temperature bonusesModified signatures:
get_guide_catalog(..., initial_guide_cands=None, ...): Accepts pre-computed candidates for reuseget_fid_catalog(..., guide_cands=None, ...): Accepts guide candidates to evaluate spoiling scenariosoptimize_acqs_fids(initial_guide_cands=None, **kwargs): Passes candidates through optimization loopAll changes maintain backward compatibility - new parameters are optional and default to original behavior, so these are not interface impacts.
Test Coverage
New test file test_guide_fid_optimization.py provides comprehensive coverage:
Extended tests in test_guide.py:
test_get_t_ccds_bonus_*- 4 tests)test_filter_candidates_for_monitors)Tests verify that optimization runs when fid spoiling occurs and selects appropriate fid sets. The tests confirm that guide stars avoid selected fids and that fid trap spoilers are correctly excluded.
Implementation Notes
The optimization logic (lines 582-640 in
catalog.py) explicitly checks for "passable" sets before selecting the best configuration. This operational knowledge was previously implicit in downstream sparkles review but is now codified for better catalog quality during optimization.Column initialization for candidates happens after filtering operations to avoid unnecessary table copies and prevent in-place modifications of shared data structures.
Interface impacts
Testing
Unit tests
Independent check of unit tests by [REVIEWER NAME]
Functional tests
No functional testing.