Skip to content

BUG - CoDICE Lo Direct Events fails when spin sector is fill - Card 3269 #119

@pleasant-menlo

Description

@pleasant-menlo

Description of the issue

When a value in the spin sector array is a fill val, an error is thrown.

Steps to reproduce the issue

uv run imap_l3_data_processor.py --instrument codice --data-level l3a --descriptor lo-direct-events --start-date 20251102 --version v001 --dependency imap_codice_l3a_lo-direct-events-4fb15050_20251102_v001.json

Expected vs Actual behavior

...
  File "/Users/harrison/Development/imap_L3_processing/imap_l3_processing/codice/l3/lo/codice_lo_processor.py", line 39, in process
    data_product = self.process_l3a_direct_event_data_product(dependencies)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/harrison/Development/imap_L3_processing/imap_l3_processing/codice/l3/lo/codice_lo_processor.py", line 220, in process_l3a_direct_event_data_product
    normalization = calculate_normalization_factor(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/harrison/Development/imap_L3_processing/imap_l3_processing/codice/l3/lo/science/codice_lo_calculations.py", line 93, in calculate_normalization_factor
    denominator = rebin_direct_events_for_normalization(num_events, spin_sectors, energy_steps, num_spin_sectors,
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/harrison/Development/imap_L3_processing/imap_l3_processing/codice/l3/lo/science/codice_lo_calculations.py", line 57, in rebin_direct_events_for_normalization
    base_counts = rebin_direct_events_by_energy_and_spin_sector(num_events, spin_sector, energy_step, num_spin_sectors,
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/harrison/Development/imap_L3_processing/imap_l3_processing/codice/l3/lo/science/codice_lo_calculations.py", line 84, in rebin_direct_events_by_energy_and_spin_sector
    np.add.at(rebinned_output[time_index, priority_index], (energy_indices, spin_sectors), 1)
IndexError: index 255 is out of bounds for axis 1 with size 24

We would expect that any event where the energy index or spin sector is fill, should be skipped without throwing errors and crashing processing.

Code Snippet (If applicable)

Code

Additional notes, affected areas, and suggested fixes

This appears to affect the following dates:

2025-11-02, 2026-01-14, 2026-02-13, 2026-03-15, 2026-04-14, 2026-05-14

Metadata

Metadata

Labels

Ins: CoDICERelated to the CoDICE instrumentbugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

Status
Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions