Skip to content

Commit 479bd91

Browse files
Harrison 3029/#54 - PMCL - CoDICE Lo DE: pass through esa_step from L1a lo-sw-priority
This is needed as the DEPEND_1 of half_spin_per_esa_step, and our `energy_bin` is in the opposite order.
1 parent e65966c commit 479bd91

6 files changed

Lines changed: 30 additions & 10 deletions

File tree

imap_l3_processing/cdf/config/imap_codice_l3a_lo-direct-events_variable_attrs.yaml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,4 +505,19 @@ nso_esa_step:
505505
VAR_NOTES: Indicates the energy step when No Scan Operation (NSO) was activated. In NSO, the ESA voltage is set to the first step in the scan and remains fixed until the next cycle boundary.
506506
VAR_TYPE: data
507507
VARIABLE_PURPOSE: ""
508-
RECORD_VARYING: RV
508+
RECORD_VARYING: RV
509+
510+
esa_step:
511+
NAME: esa_step
512+
DATA_TYPE: CDF_UINT1
513+
CATDESC: Energy per charge (E/q) sweeping step
514+
FIELDNAM: Energy Index
515+
FILLVAL: 255
516+
FORMAT: I3
517+
LABLAXIS: Energy Index
518+
SCALETYP: linear
519+
UNITS: " "
520+
VALIDMIN: 0
521+
VALIDMAX: 127
522+
VAR_TYPE: support_data
523+
RECORD_VARYING: NRV

imap_l3_processing/codice/l3/lo/codice_lo_processor.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,6 @@ def process_l3a_direct_event_data_product(self, dependencies: CodiceLoL3aDirectE
171171
codice_direct_events = dependencies.codice_l2_direct_events
172172
esa_energy_per_charge_lookup = dependencies.energy_lookup
173173

174-
event_buffer = codice_direct_events.tof[0].shape[-1]
175-
num_energies = codice_sw_priority_counts_l1a_data.p0_tcrs.shape[1]
176-
num_spin_sectors = 2*codice_sw_priority_counts_l1a_data.p0_tcrs.shape[2]
177174
mass_coefficient_lookup = dependencies.mass_coefficient_lookup
178175
priority_counts = [
179176
codice_sw_priority_counts_l1a_data.p0_tcrs,
@@ -184,7 +181,6 @@ def process_l3a_direct_event_data_product(self, dependencies: CodiceLoL3aDirectE
184181
codice_nsw_priority_counts_l1a_data.p5_heavies,
185182
codice_nsw_priority_counts_l1a_data.p6_hplus_heplusplus
186183
]
187-
num_priorities = len(priority_counts)
188184

189185
spin_angle_lut = SpinAngleLookup()
190186

@@ -232,6 +228,7 @@ def process_l3a_direct_event_data_product(self, dependencies: CodiceLoL3aDirectE
232228
nso_esa_step=codice_sw_priority_counts_l1a_data.nso_esa_step,
233229
normalization_per_event=normalization_per_event,
234230
spin_sector=codice_direct_events.spin_sector,
231+
esa_step=codice_sw_priority_counts_l1a_data.esa_step,
235232
)
236233

237234
def process_l3a_3d_distribution_product(self, dependencies: CodiceLoL3a3dDistributionsDependencies):

imap_l3_processing/codice/l3/lo/models.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ class CodiceLoL1aSWPriorityRates:
159159
rgfo_esa_step: np.ndarray
160160
nso_spin_sector: np.ndarray
161161
nso_esa_step: np.ndarray
162+
esa_step: np.ndarray
162163

163164
@classmethod
164165
def read_from_cdf(cls, cdf_path: Path):
@@ -185,6 +186,7 @@ def read_from_cdf(cls, cdf_path: Path):
185186
rgfo_esa_step=read_variable_and_mask_fill_values(cdf["rgfo_esa_step"]),
186187
nso_spin_sector=read_variable_and_mask_fill_values(cdf["nso_spin_sector"]),
187188
nso_esa_step=read_variable_and_mask_fill_values(cdf["nso_esa_step"]),
189+
esa_step=read_variable_and_mask_fill_values(cdf["esa_step"]),
188190
)
189191

190192

@@ -323,6 +325,7 @@ def to_data_product_variables(self) -> list[DataProductVariable]:
323325
RGFO_ESA_STEP_VAR_NAME = "rgfo_esa_step"
324326
NSO_SPIN_SECTOR_VAR_NAME = "nso_spin_sector"
325327
NSO_ESA_STEP_VAR_NAME = "nso_esa_step"
328+
ESA_STEP_VAR_NAME = "esa_step"
326329

327330

328331
@dataclass
@@ -386,8 +389,7 @@ class CodiceLoL3aDirectEventDataProduct(CodiceLoDirectEventData, DataProduct):
386389
nso_esa_step: np.ndarray
387390
spin_sector: np.ndarray
388391
normalization_per_event: np.ndarray
389-
390-
392+
esa_step: np.ndarray
391393

392394
def __post_init__(self):
393395
self.priority_index = np.arange(CODICE_LO_L2_NUM_PRIORITIES)
@@ -438,6 +440,7 @@ def to_data_product_variables(self) -> list[DataProductVariable]:
438440
DataProductVariable(RGFO_ESA_STEP_VAR_NAME, self.rgfo_esa_step),
439441
DataProductVariable(NSO_SPIN_SECTOR_VAR_NAME, self.nso_spin_sector),
440442
DataProductVariable(NSO_ESA_STEP_VAR_NAME, self.nso_esa_step),
443+
DataProductVariable(ESA_STEP_VAR_NAME, self.esa_step),
441444
]
442445

443446

tests/codice/l3/lo/test_codice_lo_processor.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,7 @@ def test_process_l3a_direct_events(self, mock_calculate_mass, mock_calculate_mas
534534
sw_priority_rates.rgfo_esa_step = rng.random(num_epochs)
535535
sw_priority_rates.nso_spin_sector = rng.random(num_epochs)
536536
sw_priority_rates.nso_esa_step = rng.random(num_epochs)
537+
sw_priority_rates.esa_step = np.arange(128)
537538

538539
nsw_priority_rates = create_dataclass_mock(CodiceLoL1aNSWPriorityRates)
539540
nsw_priority_rates.epoch = epochs
@@ -659,6 +660,7 @@ def test_process_l3a_direct_events(self, mock_calculate_mass, mock_calculate_mas
659660
np.testing.assert_array_equal(sw_priority_rates.rgfo_esa_step, l3a_direct_event_data_product.rgfo_esa_step)
660661
np.testing.assert_array_equal(sw_priority_rates.nso_spin_sector, l3a_direct_event_data_product.nso_spin_sector)
661662
np.testing.assert_array_equal(sw_priority_rates.nso_esa_step, l3a_direct_event_data_product.nso_esa_step)
663+
np.testing.assert_array_equal(sw_priority_rates.esa_step, l3a_direct_event_data_product.esa_step)
662664

663665
@patch('imap_l3_processing.codice.l3.lo.codice_lo_processor.convert_count_rate_to_intensity')
664666
@patch('imap_l3_processing.codice.l3.lo.codice_lo_processor.rebin_3d_distribution_azimuth_to_elevation')

tests/codice/l3/lo/test_models.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,7 @@ def test_codice_lo_l3a_direct_event_to_data_product(self):
373373
spin_angle = np.array([30, 60, 90])
374374
energy_step = np.array([5.5, 6.6, 7.7])
375375
priority = np.arange(CODICE_LO_L2_NUM_PRIORITIES)
376+
esa_step = np.arange(128)
376377

377378
direct_event = CodiceLoL3aDirectEventDataProduct(
378379
input_metadata=Mock(),
@@ -404,6 +405,7 @@ def test_codice_lo_l3a_direct_event_to_data_product(self):
404405
nso_spin_sector=rng.random(len(epoch)),
405406
nso_esa_step=rng.random(len(epoch)),
406407
normalization_per_event=rng.random((len(epoch), len(priority), len(energy_step), len(spin_angle))),
408+
esa_step=esa_step,
407409
)
408410

409411
np.testing.assert_array_equal(direct_event.event_index, np.arange(len(event_num)))
@@ -452,6 +454,7 @@ def test_codice_lo_l1a_sw_priority_read_from_instrument_team_cdf(self):
452454
np.testing.assert_array_equal(actual_l1a_sw_priority_rates.rgfo_esa_step, cdf["rgfo_esa_step"][...])
453455
np.testing.assert_array_equal(actual_l1a_sw_priority_rates.nso_spin_sector, cdf["nso_spin_sector"][...])
454456
np.testing.assert_array_equal(actual_l1a_sw_priority_rates.nso_esa_step, cdf["nso_esa_step"][...])
457+
np.testing.assert_array_equal(actual_l1a_sw_priority_rates.esa_step, cdf["esa_step"][...])
455458

456459
def test_codice_lo_l1a_nsw_priority_read_from_instrument_team_cdf(self):
457460
instrument_team_cdf_path = get_test_instrument_team_data_path(

tests/periodically_run_tests.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"test_l3bcde_first_time_processing": "2026-03-19T13:31:57.152750",
3-
"test_spectral_fit_against_validation_data": "2026-03-19T16:58:54.969370",
4-
"test_calculate_pickup_ions_with_minimize": "2026-03-16T08:50:14.379057",
5-
"test_ultra_all_sp_maps": "2026-03-19T17:01:07.391919",
3+
"test_spectral_fit_against_validation_data": "2026-03-23T10:37:49.828951",
4+
"test_calculate_pickup_ions_with_minimize": "2026-03-23T10:40:37.460017",
5+
"test_ultra_all_sp_maps": "2026-03-23T10:39:56.176185",
66
"test_ultra_combined_maps": null,
77
"test_ultra_combined_nsp_maps": "2026-03-20T14:32:30.413629",
88
"test_ultra_combined_sp_maps": "2026-03-20T14:33:10.459309",

0 commit comments

Comments
 (0)