Skip to content

Commit b1e5936

Browse files
author
Menlo Innovations - CAVA Project
committed
Harrison - LFAR/PMCL - Adding integration test coverage for new codice L2s, excluding lo direct events
1 parent 97968dd commit b1e5936

10 files changed

Lines changed: 195 additions & 1 deletion

tests/integration/test_codice_processor_integration.py

Lines changed: 176 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
import logging
2+
import os
3+
import subprocess
4+
import sys
25
import unittest
36
from pathlib import Path
47
from unittest.mock import Mock, patch
@@ -8,6 +11,7 @@
811
from spacepy.pycdf import CDF
912

1013
import imap_l3_data_processor
14+
import imap_l3_processing
1115
import tests
1216
from tests.integration.integration_test_helpers import mock_imap_data_access
1317
from tests.test_helpers import get_run_local_data_path, get_test_data_path
@@ -18,7 +22,7 @@ class CodiceProcessorIntegration(unittest.TestCase):
1822
OUTPUT_DATA_DIR = get_run_local_data_path('codice_lo_integration')
1923

2024
@patch("imap_l3_data_processor._parse_cli_arguments")
21-
def test_codice_processor_integration(self, mock_parse_cli_arguments):
25+
def test_codice_processor_integration_lo_direct_events(self, mock_parse_cli_arguments):
2226
energy_per_charge_path = get_test_data_path('codice/imap_codice_lo-energy-per-charge_20241110_v001.csv')
2327
mass_coefficient_path = get_test_data_path('codice/imap_codice_mass-coefficient-lookup_20241110_v003.csv')
2428
input_files = [
@@ -68,3 +72,174 @@ def test_codice_processor_integration(self, mock_parse_cli_arguments):
6872

6973
with CDF(str(expected_map_path)) as cdf:
7074
self.assertEqual(expected_parents, set(cdf.attrs["Parents"]))
75+
76+
def test_codice_lo_partial_densities_and_sw_products(self):
77+
root_dir = Path(imap_l3_processing.__file__).parent.parent
78+
os.chdir(root_dir)
79+
OUTPUT_DATA_DIR = get_run_local_data_path("codice_integration")
80+
expected_pd_file_path = (
81+
OUTPUT_DATA_DIR / "imap/codice/l3a/2026/03/imap_codice_l3a_lo-partial-densities_20260301_v001.cdf"
82+
)
83+
expected_sw_ratios_file_path = (
84+
OUTPUT_DATA_DIR / "imap/codice/l3a/2026/03/imap_codice_l3a_lo-sw-ratios_20260301_v001.cdf"
85+
)
86+
expected_sw_csd_file_path = (
87+
OUTPUT_DATA_DIR / "imap/codice/l3a/2026/03/imap_codice_l3a_lo-sw-charge-state-distributions_20260301_v001.cdf"
88+
)
89+
90+
if expected_pd_file_path.parent.exists():
91+
expected_pd_file_path.unlink(missing_ok=True)
92+
expected_sw_ratios_file_path.unlink(missing_ok=True)
93+
expected_sw_csd_file_path.unlink(missing_ok=True)
94+
95+
input_files = [
96+
Path("tests/integration/test_data/codice/imap_codice_l2_lo-sw-species_20260301_v001.cdf"),
97+
Path("tests/integration/test_data/codice/imap_codice_mass-per-charge_20241110_v003.csv"),
98+
Path("tests/integration/test_data/codice/imap_codice_l3a_lo-partial-densities-25ccf871_20260301_v001.json"),
99+
Path("tests/integration/test_data/codice/imap_codice_l3a_lo-sw-ratios-25ccf871_20260301_v001.json"),
100+
]
101+
os.environ["IMAP_DATA_DIR"] = str(OUTPUT_DATA_DIR)
102+
with mock_imap_data_access(OUTPUT_DATA_DIR, input_files):
103+
pd_result = subprocess.run(
104+
[
105+
sys.executable,
106+
"imap_l3_data_processor.py",
107+
"--instrument",
108+
"codice",
109+
"--data-level",
110+
"l3a",
111+
"--descriptor",
112+
"lo-partial-densities",
113+
"--start-date",
114+
"20260301",
115+
"--version",
116+
"v001",
117+
"--dependency",
118+
"imap_codice_l3a_lo-partial-densities-25ccf871_20260301_v001.json",
119+
],
120+
)
121+
122+
self.assertEqual(0, pd_result.returncode)
123+
self.assertTrue(expected_pd_file_path.exists())
124+
125+
sw_ratios_result = subprocess.run(
126+
[
127+
sys.executable,
128+
"imap_l3_data_processor.py",
129+
"--instrument",
130+
"codice",
131+
"--data-level",
132+
"l3a",
133+
"--descriptor",
134+
"lo-sw-ratios",
135+
"--start-date",
136+
"20260301",
137+
"--version",
138+
"v001",
139+
"--dependency",
140+
"imap_codice_l3a_lo-sw-ratios-25ccf871_20260301_v001.json",
141+
],
142+
)
143+
144+
self.assertEqual(0, sw_ratios_result.returncode)
145+
self.assertTrue(expected_sw_ratios_file_path.exists())
146+
147+
sw_csd_result = subprocess.run(
148+
[
149+
sys.executable,
150+
"imap_l3_data_processor.py",
151+
"--instrument",
152+
"codice",
153+
"--data-level",
154+
"l3a",
155+
"--descriptor",
156+
"lo-sw-charge-state-distributions",
157+
"--start-date",
158+
"20260301",
159+
"--version",
160+
"v001",
161+
"--dependency",
162+
"imap_codice_l3a_lo-sw-ratios-25ccf871_20260301_v001.json",
163+
],
164+
)
165+
166+
self.assertEqual(0, sw_csd_result.returncode)
167+
self.assertTrue(expected_sw_csd_file_path.exists())
168+
169+
def test_codice_hi_direct_events(self):
170+
root_dir = Path(imap_l3_processing.__file__).parent.parent
171+
os.chdir(root_dir)
172+
OUTPUT_DATA_DIR = get_run_local_data_path("codice_integration")
173+
expected_output_path = (
174+
OUTPUT_DATA_DIR / "imap/codice/l3a/2026/03/imap_codice_l3a_hi-direct-events_20260301_v001.cdf"
175+
)
176+
if expected_output_path.parent.exists():
177+
expected_output_path.unlink(missing_ok=True)
178+
179+
input_files = [
180+
Path("tests/integration/test_data/codice/imap_codice_l2_hi-direct-events_20260301_v003.cdf"),
181+
Path("tests/integration/test_data/codice/imap_codice_l3a_hi-direct-events-e968219e_20260301_v001.json"),
182+
]
183+
os.environ["IMAP_DATA_DIR"] = str(OUTPUT_DATA_DIR)
184+
with mock_imap_data_access(OUTPUT_DATA_DIR, input_files):
185+
result = subprocess.run(
186+
[
187+
sys.executable,
188+
"imap_l3_data_processor.py",
189+
"--instrument",
190+
"codice",
191+
"--data-level",
192+
"l3a",
193+
"--descriptor",
194+
"hi-direct-events",
195+
"--start-date",
196+
"20260301",
197+
"--version",
198+
"v001",
199+
"--dependency",
200+
"imap_codice_l3a_hi-direct-events-e968219e_20260301_v001.json",
201+
],
202+
)
203+
204+
self.assertEqual(0, result.returncode)
205+
self.assertTrue(expected_output_path.exists())
206+
207+
def test_codice_hi_pitch_angle(self):
208+
root_dir = Path(imap_l3_processing.__file__).parent.parent
209+
os.chdir(root_dir)
210+
OUTPUT_DATA_DIR = get_run_local_data_path("codice_integration")
211+
expected_output_path = (
212+
OUTPUT_DATA_DIR / "imap/codice/l3b/2026/01/imap_codice_l3b_hi-pitch-angle_20260120_v001.cdf"
213+
)
214+
if expected_output_path.parent.exists():
215+
expected_output_path.unlink(missing_ok=True)
216+
217+
input_files = [
218+
Path("tests/integration/test_data/codice/imap_codice_l2_hi-sectored_20260120_v003.cdf"),
219+
Path("tests/integration/test_data/codice/imap_mag_l1d_norm-dsrf_20260120_v002.cdf"),
220+
Path(
221+
"tests/integration/test_data/codice/imap_codice_l3b_hi-pitch-angle-25ccf871_20260120_v001.json"),
222+
]
223+
os.environ["IMAP_DATA_DIR"] = str(OUTPUT_DATA_DIR)
224+
with mock_imap_data_access(OUTPUT_DATA_DIR, input_files):
225+
result = subprocess.run(
226+
[
227+
sys.executable,
228+
"imap_l3_data_processor.py",
229+
"--instrument",
230+
"codice",
231+
"--data-level",
232+
"l3b",
233+
"--descriptor",
234+
"hi-pitch-angle",
235+
"--start-date",
236+
"20260120",
237+
"--version",
238+
"v001",
239+
"--dependency",
240+
"imap_codice_l3b_hi-pitch-angle-25ccf871_20260120_v001.json",
241+
],
242+
)
243+
244+
self.assertEqual(0, result.returncode)
245+
self.assertTrue(expected_output_path.exists())
Binary file not shown.
Binary file not shown.
Binary file not shown.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[{"type": "science", "files": ["imap_codice_l2_hi-direct-events_20260301_v003.cdf"]}]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[{"type": "science", "files": ["imap_codice_l2_lo-sw-species_20260301_v001.cdf"]}, {"type": "ancillary", "files": ["imap_codice_mass-per-charge_20241110_v003.csv"]}]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[{"type": "science", "files": ["imap_codice_l3a_lo-partial-densities_20260301_v001.cdf"]}]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[{"type": "science", "files": ["imap_codice_l2_hi-sectored_20260120_v003.cdf"]}, {"type": "science", "files": ["imap_mag_l1d_norm-dsrf_20260120_v002.cdf"]}]
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Index,Species,m/q (AMU/e)
2+
1,H+,1
3+
2,He++,2
4+
3,C+4,3
5+
4,C+5,2.4
6+
5,C+6,2
7+
6,O+5,3.2
8+
7,O+6,2.7
9+
8,O+7,2.28
10+
9,O+8,2
11+
10,Ne,3.6
12+
11,Mg,3.5
13+
12,Si,4
14+
13,Fe (high Q),3.85
15+
14,Fe (low Q),7.25
Binary file not shown.

0 commit comments

Comments
 (0)