Skip to content

Comments

ULTRA l1b add function to flag events that are within the earth keepout angle. #2748

Open
lacoak21 wants to merge 15 commits intoIMAP-Science-Operations-Center:devfrom
lacoak21:ultra_l1b_extended_spin_high_energy_cull
Open

ULTRA l1b add function to flag events that are within the earth keepout angle. #2748
lacoak21 wants to merge 15 commits intoIMAP-Science-Operations-Center:devfrom
lacoak21:ultra_l1b_extended_spin_high_energy_cull

Conversation

@lacoak21
Copy link
Contributor

@lacoak21 lacoak21 commented Feb 20, 2026

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_mask that @laspsandoval wrote and creating a new function compute_unit_target_vectors.

File changes

  • imap_processing/spice/geometry.py
    • pull out code from compute_culling_mask and make a new function that can be used generally for other instruments
  • imap_processing/ultra/l1b/ultra_l1b_culling.py
    • Compute the angle between the earth unit vector and each particle's look direction and flag events where the angle is less than the constant threshold given by the ULTRA IT team.

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

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_vectors function in the SPICE geometry module
  • Added get_valid_earth_angle_events function 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(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

1 participant