Skip to content

Conversation

@subagonsouth
Copy link
Contributor

Change Summary

Overview

This just contains some foundational code to be used throughout the Hi Goodtimes processing. Basically, I just added a custom xarray.Dataset accessor that has some functions useful for keeping track of the Goodtimes for a Pointing as various checks are performed to identify what times to remove from the goodtimes dataset.

The goodtimes dataset is initialized using a hi_l1a_de dataset and starts with all times in the Pointing considered good. Through the goodtimes processing, checks will be made that mark 8-spin sets as bad. Finally, the Goodtimes text file will be written out.

New Files

  • imap_processing/hi/hi_goodtimes.py
    • Add CullCode enum
    • Add function that initializes the goodtimes dataset from a l1a_de dataset.
    • Add goodtimes accessor that has functions for:
      • remove_times
      • get_good_intervals
      • get_cull_statistics (may not be used but Claude implemented it and it could be useful for logging)
      • write_txt
  • imap_processing/tests/hi/test_hi_goodtimes.py
    • Full test coverage for new hi goodtimes code

Closes: #2528

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 PR introduces foundational code for handling "goodtimes" in IMAP-HI processing. The implementation adds a custom xarray.Dataset accessor that tracks good/bad time intervals for a Pointing as various validation checks are performed.

Key changes:

  • Adds CullCode enum for classifying good/bad times with reason codes
  • Implements dataset initialization from L1A Direct Event data with automatic filtering of incomplete 8-spin periods
  • Provides xarray accessor methods for flagging bad times, extracting good intervals, and writing output files

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.

File Description
imap_processing/hi/hi_goodtimes.py New module implementing goodtimes dataset creation, CullCode enum, and GoodtimesAccessor with methods for time management and output generation
imap_processing/tests/hi/test_hi_goodtimes.py Comprehensive test suite with 530 lines covering all goodtimes functionality including edge cases and error conditions

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

subagonsouth and others added 2 commits December 19, 2025 11:46
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Collaborator

@greglucas greglucas left a comment

Choose a reason for hiding this comment

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

This is a nice way to do this with the xarray accessor!

This makes me think that we could potentially use accessors within the map projection code area. Just noting this for potential future ideas in refactoring later on.

Comment on lines 20 to 21
("spin_bin_low", np.int32),
("spin_bin_high", np.int32),
Copy link
Collaborator

Choose a reason for hiding this comment

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

uint16? I think we only have 3600 spin bins and they are all positive integers.

Comment on lines +249 to +250
if np.any((bins_array < 0) | (bins_array >= 90)):
raise ValueError("Spin bins must be in range [0, 89]")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Lo is using 60 spin bins (6 degree bins), does this need to be similar between the different instruments?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think so. For Hi, this corresponds to the number of bins in the histogram packets and thus cannot be changed.

@subagonsouth subagonsouth merged commit 4c3c135 into IMAP-Science-Operations-Center:dev Dec 23, 2025
14 checks passed
@subagonsouth subagonsouth deleted the 2510-hi-goodtimes---set-up-cli-call-to-processing branch December 23, 2025 17:35
@github-project-automation github-project-automation bot moved this to Done in IMAP Dec 23, 2025
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.

Hi Goodtimes - create goodtimes dataset helper code

2 participants