Skip to content

ULTRA l1c theta limit check#2941

Merged
lacoak21 merged 5 commits intoIMAP-Science-Operations-Center:devfrom
lacoak21:ultra_l1c_theta_limit_check
Apr 9, 2026
Merged

ULTRA l1c theta limit check#2941
lacoak21 merged 5 commits intoIMAP-Science-Operations-Center:devfrom
lacoak21:ultra_l1c_theta_limit_check

Conversation

@lacoak21
Copy link
Copy Markdown
Contributor

@lacoak21 lacoak21 commented Apr 8, 2026

Change Summary

closes #2856

Overview

The ultra team wants to limit the FOV, This pr calculates pixels that are not in the limited FOV and those pixels are excluded from counts, exposure factor, and sensitivity (eff, gf).

I sent maps to the ULTRA team and they are looking good. I think they still may need to check some things.

File changes

imap_processing/ultra/l1c/helio_pset.py

  • Add boolean flag for restricting the FOV
  • Make sure to filter counts that are not in the restricted fov

imap_processing/ultra/l1c/l1c_lookup_utils.py

  • Create function to check if theta/phi pairs are in the restricted fov
  • When creating the valid pixel map, skip pixels not in restricted fov - downstream this is used by exposure factor, efficiencies and geometric function calculations.

imap_processing/ultra/l1c/ultra_l1c_pset_bins.py

  • I also found a small bug where dims were reversed. That code is currently not in use so it never errored out.

Testing

Update test to work with new rejection logic. Add new tests for the fov restriction code.

Copy link
Copy Markdown
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

Adds an ULTRA L1C restricted-FOV acceptance gate so that pixels/events outside a reduced theta/phi window are excluded from L1C fine energy-bin products (counts, exposure, efficiency/GF/sensitivity), and updates tests accordingly.

Changes:

  • Introduce restricted-FOV acceptance logic (in_restricted_fov) and integrate it into L1C pixel acceptance and event filtering.
  • Replace/rename spun-scattering acceptance calculation to calculate_accepted_pixels and thread it through spacecraft/helio PSET generation.
  • Fix boundary scale factor indexing bug in efficiency/GF accumulation and update unit tests for new inputs/behavior.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
imap_processing/ultra/l1c/l1c_lookup_utils.py Adds restricted-FOV helper and expands “accepted pixels” logic to incorporate FOV restrictions.
imap_processing/ultra/l1c/spacecraft_pset.py Applies restricted-FOV filtering to event counts and uses new accepted-pixel logic for exposure/eff/GF.
imap_processing/ultra/l1c/helio_pset.py Same as spacecraft path but for helio PSET generation.
imap_processing/ultra/l1c/ultra_l1c_pset_bins.py Fixes BSF indexing when applying boundary scale factors during accumulation.
imap_processing/ultra/constants.py Adds restricted-FOV theta limits and feature toggles for L1C (FOV restriction, BSF, scattering rejection).
imap_processing/tests/ultra/unit/test_l1c_lookup_utils.py Adds unit tests for restricted-FOV logic and updated acceptance calculation.
imap_processing/tests/ultra/unit/test_ultra_l1c.py Updates fixtures to include theta/phi fields required by new filtering.
imap_processing/tests/ultra/unit/test_ultra_l1c_pset_bins.py Updates tests to use calculate_accepted_pixels.
imap_processing/tests/ultra/unit/test_spacecraft_pset.py Updates test datasets to include theta/phi fields required by new filtering.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +144 to +148
logger.info(
f"Restricted FOV counts filter: keeping {fov_accepted.sum()} / "
f"{len(fov_accepted)} events."
)
species_dataset = species_dataset.isel(epoch=fov_accepted)
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

After applying the restricted-FOV event filter, species_dataset can become empty; subsequent operations (velocity normalization, histogramming, and especially min/max on event_times) will raise. Add an early return (e.g., None) or produce a zero-filled dataset when no events remain after this filter.

Copilot uses AI. Check for mistakes.
f"Restricted FOV counts filter: keeping {fov_accepted.sum()} / "
f"{len(fov_accepted)} events."
)
species_dataset = species_dataset.isel(epoch=fov_accepted)
Copy link

Copilot AI Apr 8, 2026

Choose a reason for hiding this comment

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

After applying the restricted-FOV event filter, species_dataset can become empty; subsequent operations (velocity normalization, histogramming, and min/max on event_times) will raise. Add an early return (e.g., None) or produce a zero-filled dataset when no events remain after this filter.

Suggested change
species_dataset = species_dataset.isel(epoch=fov_accepted)
species_dataset = species_dataset.isel(epoch=fov_accepted)
if species_dataset.sizes.get("epoch", 0) == 0:
logger.info(
"No events remain after restricted FOV filtering; "
"skipping helio PSET generation."
)
return None

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor

@subagonsouth subagonsouth left a comment

Choose a reason for hiding this comment

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

This all looks good to me.

@lacoak21 lacoak21 merged commit a61dbd5 into IMAP-Science-Operations-Center:dev Apr 9, 2026
18 checks passed
@github-project-automation github-project-automation bot moved this to Done in IMAP Apr 9, 2026
@lacoak21 lacoak21 deleted the ultra_l1c_theta_limit_check branch April 9, 2026 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

ULTRA limit fov for 3month maps

3 participants