From 9b7c1acddcd266d27ddedd6242e8ed36fde4f26a Mon Sep 17 00:00:00 2001 From: Luisa Date: Wed, 11 Mar 2026 10:34:06 -0600 Subject: [PATCH 1/2] add aid --- .../cdf/config/imap_idex_l1a_variable_attrs.yaml | 2 +- imap_processing/idex/idex_l1a.py | 9 ++++++++- imap_processing/idex/idex_l1b.py | 2 +- imap_processing/tests/idex/test_idex_l1a.py | 3 +++ imap_processing/tests/idex/test_idex_l1b.py | 2 ++ 5 files changed, 15 insertions(+), 3 deletions(-) diff --git a/imap_processing/cdf/config/imap_idex_l1a_variable_attrs.yaml b/imap_processing/cdf/config/imap_idex_l1a_variable_attrs.yaml index 8765d2e6a7..a95396315d 100644 --- a/imap_processing/cdf/config/imap_idex_l1a_variable_attrs.yaml +++ b/imap_processing/cdf/config/imap_idex_l1a_variable_attrs.yaml @@ -214,7 +214,7 @@ checksum: FIELDNAM: Checksum UNITS: " " -idx__sci0aid: +aid: <<: *trigger_base CATDESC: Accountability identifier for this event FIELDNAM: Accountability identifier diff --git a/imap_processing/idex/idex_l1a.py b/imap_processing/idex/idex_l1a.py index c3d735d46b..41f8f270aa 100644 --- a/imap_processing/idex/idex_l1a.py +++ b/imap_processing/idex/idex_l1a.py @@ -651,8 +651,15 @@ def process(self) -> Dataset | None: # Gather the huge amount of metadata info trigger_vars = {} for var, value in self.telemetry_items.items(): + # SCI0AID is not updated properly. To this end, TXHDRFSWAIDCOPY must be + # used as the proper AID. + if var == "idx__sci0aid": + continue + # rename idx__txhdrfswaidcopy to aid for better readability in the final + # dataset + var_name = "aid" if var == "idx__txhdrfswaidcopy" else var trigger_vars[var] = xr.DataArray( - name=var, + name=var_name, data=[value], dims=("epoch"), attrs=idex_attrs.get_variable_attributes(var), diff --git a/imap_processing/idex/idex_l1b.py b/imap_processing/idex/idex_l1b.py index 5824d134a1..c271af1f85 100644 --- a/imap_processing/idex/idex_l1b.py +++ b/imap_processing/idex/idex_l1b.py @@ -146,7 +146,7 @@ def idex_l1b(l1a_dataset: xr.Dataset) -> xr.Dataset: l1a_dataset["idx__txhdrtrigid"].data, idex_attrs ) # Create l1b Dataset - prefixes = ["shcoarse", "shfine", "time_high_sample", "time_low_sample"] + prefixes = ["shcoarse", "shfine", "time_high_sample", "time_low_sample", "aid"] data_vars = ( processed_vars | waveforms_converted diff --git a/imap_processing/tests/idex/test_idex_l1a.py b/imap_processing/tests/idex/test_idex_l1a.py index b80e960a60..2ef70be8e1 100644 --- a/imap_processing/tests/idex/test_idex_l1a.py +++ b/imap_processing/tests/idex/test_idex_l1a.py @@ -156,6 +156,7 @@ def test_validate_l1a_idex_data_variables( "Ion Grid": "Ion_Grid", "Time (high sampling)": "time_high_sample_rate", "Time (low sampling)": "time_low_sample_rate", + "idx__txhdrfswaidcopy": "aid", } # The Engineering data is converting to UTC, and the SDC is converting to J2000, # for 'epoch' and 'Timestamp' so this test is using the raw time value 'SCHOARSE' to @@ -168,6 +169,8 @@ def test_validate_l1a_idex_data_variables( "event", "Time (high sampling)", "Time (low sampling)", + "IDX__SCI0AID", # This is dropped because it is invalid + "IDX__TXHDRFSWAIDCOPY", # this is renamed to aid ] # loop through all keys from the l1a example dict diff --git a/imap_processing/tests/idex/test_idex_l1b.py b/imap_processing/tests/idex/test_idex_l1b.py index f113b595a4..2b95b28dc1 100644 --- a/imap_processing/tests/idex/test_idex_l1b.py +++ b/imap_processing/tests/idex/test_idex_l1b.py @@ -325,6 +325,8 @@ def test_validate_l1b_idex_data_variables( "FIFODelay_M", "HSPosttriggerBlocks", ] + # assert that "aid" is in l1b + assert "aid" in l1b_dataset, "The array 'aid' is missing from the l1b dataset." # select only the first n events l1b_example_data = l1b_example_data.isel( event=np.arange(l1b_dataset.sizes["epoch"]) From 5605747830301017a1ebe59dedf527c788707357 Mon Sep 17 00:00:00 2001 From: Luisa Date: Wed, 11 Mar 2026 10:49:48 -0600 Subject: [PATCH 2/2] fix test --- imap_processing/idex/idex_l1a.py | 2 +- imap_processing/tests/idex/test_idex_l0.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/imap_processing/idex/idex_l1a.py b/imap_processing/idex/idex_l1a.py index 41f8f270aa..518684d8dd 100644 --- a/imap_processing/idex/idex_l1a.py +++ b/imap_processing/idex/idex_l1a.py @@ -658,7 +658,7 @@ def process(self) -> Dataset | None: # rename idx__txhdrfswaidcopy to aid for better readability in the final # dataset var_name = "aid" if var == "idx__txhdrfswaidcopy" else var - trigger_vars[var] = xr.DataArray( + trigger_vars[var_name] = xr.DataArray( name=var_name, data=[value], dims=("epoch"), diff --git a/imap_processing/tests/idex/test_idex_l0.py b/imap_processing/tests/idex/test_idex_l0.py index 736c0565df..ea4ebf12a7 100644 --- a/imap_processing/tests/idex/test_idex_l0.py +++ b/imap_processing/tests/idex/test_idex_l0.py @@ -14,7 +14,7 @@ def test_idex_decom_length(decom_test_data_sci: xr.Dataset): decom_test_data_sci : xarray.Dataset The dataset to test with """ - assert len(decom_test_data_sci) == 110 + assert len(decom_test_data_sci) == 109 def test_idex_decom_event_num(decom_test_data_sci: xr.Dataset):