ULTRA l1b add function to flag events that are within the earth keepout angle. #2748
Conversation
There was a problem hiding this comment.
Pull request overview
This pull request adds functionality to flag ULTRA L1b events where particle look directions fall within the Earth keepout angle. The changes extract reusable code from compute_culling_mask into a new general-purpose function compute_unit_target_vectors for computing unit vectors from IMAP to target bodies, and implements Earth angle filtering for individual particle events.
Changes:
- Extracted unit vector computation logic into a reusable
compute_unit_target_vectorsfunction in the SPICE geometry module - Added
get_valid_earth_angle_eventsfunction to filter L1b events based on Earth keepout angle - Added Earth angle threshold constant for ULTRA 45 instrument
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| imap_processing/spice/geometry.py | Adds compute_unit_target_vectors function to compute unit vectors from IMAP to target bodies (e.g., Earth) |
| imap_processing/ultra/l1c/ultra_l1c_culling.py | Refactors to use new compute_unit_target_vectors function, removing duplicate code |
| imap_processing/ultra/l1b/ultra_l1b_culling.py | Adds get_valid_earth_angle_events to flag events based on Earth keepout angle |
| imap_processing/ultra/constants.py | Adds EARTH_ANGLE_45_THRESHOLD constant (15 degrees in radians) |
| imap_processing/tests/spice/test_geometry.py | Adds test for compute_unit_target_vectors function |
| imap_processing/tests/ultra/unit/test_ultra_l1b_culling.py | Adds test validating get_valid_earth_angle_events against ULTRA IT team's implementation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| return float(lat_coords) if lat_coords.size == 1 else lat_coords | ||
|
|
||
|
|
||
| def compute_unit_target_vectors( |
There was a problem hiding this comment.
The is the code that was pulled from compute_culling_mask that Laura already tested and validated but I wrote a test for it just to be sure.
Change Summary
Overview
Add a function to flag events where the particle look direction is outside the Earth keepout angle. A lot of this PR is pulling out code from the function
compute_culling_maskthat @laspsandoval wrote and creating a new functioncompute_unit_target_vectors.File changes
Testing
I wrote a test that uses the exact code that Bob uses in order to validate our functions. It can be found here https://github.com/demajistre/imap_processing/blob/dev/ultra_user/planets/ENA_planets.py