Skip to content

Conversation

@lacoak21
Copy link
Contributor

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

  • imap_processing/cdf/config/imap_codice_l1a_variable_attrs.yaml
    • Duplicate attribute
  • imap_processing/cdf/config/imap_codice_l2-lo-direct-events_variable_attrs.yaml
    • attrs (Most of them were derived from the validation CDFs
  • imap_processing/codice/codice_l2.py
    • add handling for lookup tables and de processing code

Testing

Test lookup utils and validate processing

@lacoak21 lacoak21 added this to the December 2025 milestone Dec 12, 2025
@lacoak21 lacoak21 self-assigned this Dec 12, 2025
@lacoak21 lacoak21 added this to IMAP Dec 12, 2025
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 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_cutoff attribute 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.

Comment on lines 138 to 140
def get_geometric_factor_lut(
dependencies: ProcessingInputCollection | None,
path: Path | None = None,
Copy link

Copilot AI Dec 12, 2025

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

Copilot uses AI. Check for mistakes.
Comment on lines +197 to +199
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)
Copy link

Copilot AI Dec 12, 2025

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.

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

Copilot uses AI. Check for mistakes.
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"
Copy link

Copilot AI Dec 12, 2025

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.

Suggested change
VALIDATION_FILE_DATE = "20250814"
VALIDATION_FILE_DATE = "20250814"
# Updated to v012 to include lo-direct-events and hi-direct-events validation data

Copilot uses AI. Check for mistakes.
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.

CoDICE: L2 Implement Lo direct events data products

1 participant