-
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
base: dev
Are you sure you want to change the base?
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.
| with open(output_path, "w") as f: | ||
| for interval in intervals: | ||
| pointing = self._obj.attrs.get("pointing", 0) | ||
| sensor = self._obj.attrs.get("sensor", "45sensor") |
Copilot
AI
Dec 19, 2025
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.
The default sensor value "45sensor" in the fallback does not match the format used when actually setting the attribute ("Hi45" format on line 117). For consistency, this should be "Hi45" or handle the sensor extraction more robustly.
| sensor = self._obj.attrs.get("sensor", "45sensor") | |
| sensor = self._obj.attrs.get("sensor", "Hi45") |
| """Cull reason codes for good/bad time classification.""" | ||
|
|
||
| GOOD = 0 | ||
| LOOSE = 1 |
Copilot
AI
Dec 19, 2025
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.
The CullCode enum only defines GOOD and LOOSE values. However, throughout the code and tests, additional numeric cull codes (like 2) are used without being defined in the enum. Consider either adding more descriptive enum values for these additional codes or documenting that any non-zero integer is valid.
| """Cull reason codes for good/bad time classification.""" | |
| GOOD = 0 | |
| LOOSE = 1 | |
| """ | |
| Cull reason codes for good/bad time classification. | |
| Notes | |
| ----- | |
| - GOOD (0) indicates data that has not been culled. | |
| - Any non-zero integer value indicates data that has been culled for some reason. | |
| - Specific non-zero codes are provided here for readability; additional non-zero | |
| integer codes may be used elsewhere in the code base as needed. | |
| """ | |
| GOOD = 0 | |
| LOOSE = 1 | |
| OTHER = 2 |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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