-
Notifications
You must be signed in to change notification settings - Fork 22
CODICE l2 lo direct events #2509
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?
CODICE l2 lo direct events #2509
Conversation
20f47af to
b579ab7
Compare
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 implements L2 direct event data processing for CoDICE LO (Low energy) sensor, converting raw L1A event data to physical units. The implementation includes new lookup table utilities for energy and time-of-flight conversions, processing logic for direct event data, CDF attribute definitions, and comprehensive test coverage with validation data.
- Adds three new lookup table (LUT) retrieval functions to convert onboard MPQ calibration values, energy table indices, and TOF bit values to physical units
- Implements
process_lo_direct_events()function that transforms L1A direct event data to L2, including elevation angle calculation, spin angle computation, APD energy conversion, TOF conversion to nanoseconds, and energy-per-charge calculation - Removes duplicate
lo-low_tof_cutoffattribute definition from L1A configuration
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| imap_processing/codice/codice_l2.py | Added LUT retrieval functions and process_lo_direct_events() processing logic; removed unused Path import (but Path is still used in other functions - bug) |
| imap_processing/cdf/config/imap_codice_l2-lo-direct-events_variable_attrs.yaml | New file defining CDF variable attributes for lo-direct-events L2 data product |
| imap_processing/cdf/config/imap_codice_l1a_variable_attrs.yaml | Fixed duplicate lo-low_tof_cutoff attribute definition |
| imap_processing/tests/codice/test_codice_l2.py | Added tests for new LUT functions and complete lo-direct-events processing with validation |
| imap_processing/tests/codice/conftest.py | Updated validation file version to v012 and added fixture paths for new LUT files |
| imap_processing/tests/external_test_data_config.py | Added new LUT files and validation CDF files to external test data configuration |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| def get_geometric_factor_lut( | ||
| dependencies: ProcessingInputCollection | None, | ||
| path: Path | None = None, |
Copilot
AI
Dec 12, 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 Path import was removed from this file, but Path is still used in this function (line 160) and in get_efficiency_lut (line 206). This will cause a NameError at runtime. Add back the import statement: from pathlib import Path
| expected_tof_ns = mpq_df.loc[5, 4:].to_numpy().astype(np.float64) | ||
| # Calculated values should be more precise than LUT but should be close | ||
| np.testing.assert_allclose(energy_kev, expected_tof_ns, rtol=0.01) |
Copilot
AI
Dec 12, 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 variable name "expected_tof_ns" is misleading here since this test is for energy conversion (get_mpq_calc_energy_conversion_vals), not TOF. Consider renaming to "expected_energy_kev" to match the actual data being tested and improve code clarity.
| expected_tof_ns = mpq_df.loc[5, 4:].to_numpy().astype(np.float64) | |
| # Calculated values should be more precise than LUT but should be close | |
| np.testing.assert_allclose(energy_kev, expected_tof_ns, rtol=0.01) | |
| expected_energy_kev = mpq_df.loc[5, 4:].to_numpy().astype(np.float64) | |
| # Calculated values should be more precise than LUT but should be close | |
| np.testing.assert_allclose(energy_kev, expected_energy_kev, rtol=0.01) |
| TEST_DATA_L0_PATH = TEST_DATA_PATH / "l0_data" | ||
| TEST_L0_FILE = TEST_DATA_L0_PATH / "imap_codice_l0_raw_20241110_v001.pkts" | ||
|
|
||
| VALIDATION_FILE_DATE = "20250814" |
Copilot
AI
Dec 12, 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 VALIDATION_FILE_VERSION was updated from v011 to v012. Consider adding a comment explaining why the version was bumped (e.g., "Updated to v012 to include lo-direct-events and hi-direct-events validation data") to help future maintainers understand the change.
| VALIDATION_FILE_DATE = "20250814" | |
| VALIDATION_FILE_DATE = "20250814" | |
| # Updated to v012 to include lo-direct-events and hi-direct-events validation data |
Change Summary
closes #2118
Overview
Direct Event data processing for CoDICE lo. I added new validation files as well. CoDICE hi direct events will be in a new PR
Updated Files
Testing
Test lookup utils and validate processing