From 1b5e1ccd111b909b512b4ace46a54bdc7aadec61 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 3 Mar 2026 19:55:54 +0000 Subject: [PATCH 1/2] Initial plan From 81f17cfa776f9f742ac90a878aa8d7391150f041 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 3 Mar 2026 20:12:42 +0000 Subject: [PATCH 2/2] Fix SWE L1b failure: handle None return from swe_l1b_science in swe_l1b When all science data is in-flight calibration data (esa_table_num != 0), swe_l1b_science returns None due to the early return for no full cycles. The calling swe_l1b function was unconditionally appending this None to processed_datasets, causing failures in post-processing. Add a None check before appending to prevent propagation of None downstream. Co-authored-by: tech3371 <36522642+tech3371@users.noreply.github.com> --- imap_processing/swe/l1b/swe_l1b.py | 3 ++- imap_processing/tests/swe/test_swe_l1b.py | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/imap_processing/swe/l1b/swe_l1b.py b/imap_processing/swe/l1b/swe_l1b.py index 046d4db833..34452a17fd 100644 --- a/imap_processing/swe/l1b/swe_l1b.py +++ b/imap_processing/swe/l1b/swe_l1b.py @@ -948,7 +948,8 @@ def swe_l1b(dependencies: ProcessingInputCollection) -> list[xr.Dataset]: if has_science_data: # Process science data to L1B science_dataset = swe_l1b_science(dependencies) - processed_datasets.append(science_dataset) + if science_dataset is not None: + processed_datasets.append(science_dataset) # Process HK data using L0 file l0_files = dependencies.get_file_paths(descriptor="raw") diff --git a/imap_processing/tests/swe/test_swe_l1b.py b/imap_processing/tests/swe/test_swe_l1b.py index cb9addeff3..6bfff05222 100644 --- a/imap_processing/tests/swe/test_swe_l1b.py +++ b/imap_processing/tests/swe/test_swe_l1b.py @@ -52,6 +52,26 @@ def test_get_full_cycle_data_indices(): np.testing.assert_array_equal(filtered_q, np.array([])) +def test_swe_l1b_no_full_cycles(): + """Test that swe_l1b handles None from swe_l1b_science (no full cycles). + + When all science data is in-flight calibration data, swe_l1b_science + returns None. swe_l1b should not include None in its returned list. + """ + with patch( + "imap_processing.swe.l1b.swe_l1b.swe_l1b_science", return_value=None + ): + with patch( + "imap_data_access.processing_input.ProcessingInputCollection.get_file_paths" + ) as mock_get: + mock_get.side_effect = lambda descriptor: ( + ["dummy.cdf"] if descriptor == "sci" else [] + ) + dependencies = ProcessingInputCollection() + datasets = swe_l1b(dependencies) + assert all(ds is not None for ds in datasets) + + def test_in_flight_calibration_factor(l1a_test_data): """Test that the L1B processing is working as expected.""" # create sample data