-
Notifications
You must be signed in to change notification settings - Fork 22
2510 hi goodtimes Add xarray accessor for handling goodtimes #2529
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
2510 hi goodtimes Add xarray accessor for handling goodtimes #2529
Conversation
…s data through processing and writing goodtimes text file
There was a problem hiding this 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
CullCodeenum 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.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
greglucas
left a comment
There was a problem hiding this 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.
imap_processing/hi/hi_goodtimes.py
Outdated
| ("spin_bin_low", np.int32), | ||
| ("spin_bin_high", np.int32), |
There was a problem hiding this comment.
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.
| if np.any((bins_array < 0) | (bins_array >= 90)): | ||
| raise ValueError("Spin bins must be in range [0, 89]") |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
4c3c135
into
IMAP-Science-Operations-Center:dev
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
Closes: #2528