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.

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")
Copy link

Copilot AI Dec 19, 2025

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.

Suggested change
sensor = self._obj.attrs.get("sensor", "45sensor")
sensor = self._obj.attrs.get("sensor", "Hi45")

Copilot uses AI. Check for mistakes.
Comment on lines +29 to +32
"""Cull reason codes for good/bad time classification."""

GOOD = 0
LOOSE = 1
Copy link

Copilot AI Dec 19, 2025

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.

Suggested change
"""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

Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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.

Hi Goodtimes - create goodtimes dataset helper code

1 participant