2510 hi goodtimes set up cli call to processing 1#2779
2510 hi goodtimes set up cli call to processing 1#2779subagonsouth wants to merge 5 commits intoIMAP-Science-Operations-Center:devfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR implements the top-level Hi goodtimes orchestrator function and integrates it with the CLI for IMAP-Hi L1C goodtimes processing. The goodtimes processing identifies and culls bad time intervals for Hi sensor data using 6 different filtering algorithms (incomplete spin sets, DRF times, overflow packets, and 3 statistical filters). The implementation includes repointing availability checks to ensure sufficient surrounding pointings exist for statistical analysis before proceeding with processing.
Changes:
- Added hi_goodtimes() orchestrator function and helper functions (_find_current_pointing_index, _apply_goodtimes_filters, _write_goodtimes_output) to manage the goodtimes culling workflow
- Integrated goodtimes processing into the CLI with proper dependency validation and CDF loading
- Updated sensor naming convention from "Hi45"/"Hi90" to "sensor45"/"sensor90" to maintain consistency
- Added comprehensive test coverage for the new orchestrator, helpers, and CLI integration
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| imap_processing/hi/hi_goodtimes.py | Adds hi_goodtimes() orchestrator and helper functions for goodtimes processing; updates sensor naming convention in create_goodtimes_dataset() |
| imap_processing/cli.py | Adds L1C goodtimes processing branch in Hi.do_processing() with dependency validation and CDF loading; refactors L1C pset processing into explicit elif branch |
| imap_processing/tests/hi/test_hi_goodtimes.py | Adds comprehensive test coverage for new functions (TestFindCurrentPointingIndex, TestWriteGoodtimesOutput, TestApplyGoodtimesFilters, TestHiGoodtimes); updates sensor names in existing tests |
| imap_processing/tests/test_cli.py | Adds test_hi_l1c_goodtimes for CLI integration testing; updates parametrize decorator in test_hi to include data_descriptor parameter |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| logger.info("Starting Hi goodtimes processing") | ||
|
|
||
| # Parse the current repoint ID and check if we can process yet | ||
| current_repoint_id = int(current_repointing.replace("repoint", "")) |
There was a problem hiding this comment.
The parsing of current_repointing at line 114 using simple string replacement could fail silently if the format is unexpected (e.g., if it doesn't start with "repoint"). Consider using a regex match or adding validation to raise a clear error if the format is invalid, rather than potentially creating an incorrect repoint_id.
| current_repoint_id = int(current_repointing.replace("repoint", "")) | |
| match = re.fullmatch(r"repoint(\d+)", current_repointing) | |
| if not match: | |
| msg = ( | |
| f"Invalid current_repointing format: {current_repointing!r}. " | |
| "Expected format 'repointNNNNN' where NNNNN are digits." | |
| ) | |
| logger.error(msg) | |
| raise ValueError(msg) | |
| current_repoint_id = int(match.group(1)) |
| def do_processing( # noqa: PLR0912 | ||
| self, dependencies: ProcessingInputCollection | ||
| ) -> list[xr.Dataset]: |
There was a problem hiding this comment.
The return type annotation for Hi.do_processing should be list[xr.Dataset | Path] instead of list[xr.Dataset] because the goodtimes processing path returns a list of Path objects (line 858). This is consistent with the Spacecraft instrument's do_processing method which also returns list[xr.Dataset | Path] and aligns with the post_processing method's signature which accepts list[xr.Dataset | Path].
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Change Summary
Overview
This PR adds the top-level hi_goodtimes orchestrator function and integrates it with the CLI for IMAP-Hi L1C goodtimes processing.
Changes
imap_processing/hi/hi_goodtimes.py
imap_processing/cli.py
imap_processing/tests/hi/test_hi_goodtimes.py
imap_processing/tests/test_cli.py
Design Decisions
Closes: #2510