Skip to content

Commit 10e19f4

Browse files
authored
CoDICE l1b lo and hi priority rates (#2451)
* validated priority rates l1b for lo and hi * raised tolerance * l1b constant * fix test data path
1 parent 3e2d13a commit 10e19f4

File tree

3 files changed

+108
-1
lines changed

3 files changed

+108
-1
lines changed

imap_processing/codice/constants.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -758,6 +758,13 @@
758758
# TODO: in the future, read from sci-lut
759759
LO_SW_ANGULAR_VARIABLE_NAMES = ["hplus", "heplusplus", "oplus6", "fe_loq"]
760760
LO_NSW_ANGULAR_VARIABLE_NAMES = ["heplusplus"]
761+
LO_SW_PRIORITY_VARIABLE_NAMES = [
762+
"p0_tcrs",
763+
"p1_hplus",
764+
"p2_heplusplus",
765+
"p3_heavies",
766+
"p4_dcrs",
767+
]
761768
LO_NSW_PRIORITY_VARIABLE_NAMES = ["p5_heavies", "p6_hplus_heplusplus"]
762769
LO_SW_SPECIES_VARIABLE_NAMES = [
763770
"hplus",
@@ -868,6 +875,14 @@
868875
]
869876
HI_OMNI_VARIABLE_NAMES = ["h", "he3", "he4", "c", "o", "ne_mg_si", "fe", "uh", "junk"]
870877
HI_SECTORED_VARIABLE_NAMES = ["h", "he3he4", "cno", "fe"]
878+
HI_PRIORITY_VARIABLE_NAMES = [
879+
"priority0",
880+
"priority1",
881+
"priority2",
882+
"priority3",
883+
"priority4",
884+
"priority5",
885+
]
871886
# Lookup table for CoDICE-Lo despinning pixel orientations
872887
# See section 9.3.4 of the algorithm document for further information
873888
PIXEL_ORIENTATIONS = {

imap_processing/tests/codice/test_codice_l1b.py

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,3 +300,95 @@ def test_l1b_hi_sectored(mock_get_file_paths, codice_lut_path):
300300
assert (
301301
cdf_file.name == f"imap_codice_l1b_hi-sectored_{VALIDATION_FILE_DATE}_v999.cdf"
302302
)
303+
304+
305+
@patch("imap_data_access.processing_input.ProcessingInputCollection.get_file_paths")
306+
def test_l1b_hi_priorities(mock_get_file_paths, codice_lut_path):
307+
mock_get_file_paths.side_effect = [
308+
codice_lut_path(descriptor="hi-priorities", data_type="l0"),
309+
codice_lut_path(descriptor="l1a-sci-lut"),
310+
]
311+
val_path = (
312+
imap_module_directory
313+
/ "tests/codice/data/l1b_validation/"
314+
/ f"imap_codice_l1b_hi-priority_{VALIDATION_FILE_DATE}"
315+
f"_{VALIDATION_FILE_VERSION}.cdf"
316+
)
317+
l1a_ds = process_l1a(ProcessingInputCollection())[0]
318+
l1a_file_path = write_cdf(l1a_ds)
319+
val_data = load_cdf(val_path)
320+
processed_data = process_codice_l1b(file_path=l1a_file_path)
321+
for variable in val_data.data_vars:
322+
np.testing.assert_allclose(
323+
processed_data[variable].values,
324+
val_data[variable].values,
325+
rtol=1.2e-5,
326+
err_msg=f"Mismatch in variable '{variable}'",
327+
)
328+
329+
cdf_file = write_cdf(processed_data)
330+
assert (
331+
cdf_file.name == f"imap_codice_l1b_hi-priority_{VALIDATION_FILE_DATE}_v999.cdf"
332+
)
333+
334+
335+
@patch("imap_data_access.processing_input.ProcessingInputCollection.get_file_paths")
336+
def test_l1b_nsw_lo_priorities(mock_get_file_paths, codice_lut_path):
337+
mock_get_file_paths.side_effect = [
338+
codice_lut_path(descriptor="lo-nsw-priority", data_type="l0"),
339+
codice_lut_path(descriptor="l1a-sci-lut"),
340+
]
341+
val_path = (
342+
imap_module_directory
343+
/ "tests/codice/data/l1b_validation/"
344+
/ f"imap_codice_l1b_lo-nsw-priority_{VALIDATION_FILE_DATE}"
345+
f"_{VALIDATION_FILE_VERSION}.cdf"
346+
)
347+
l1a_ds = process_l1a(ProcessingInputCollection())[0]
348+
l1a_file_path = write_cdf(l1a_ds)
349+
val_data = load_cdf(val_path)
350+
processed_data = process_codice_l1b(file_path=l1a_file_path)
351+
for variable in val_data.data_vars:
352+
np.testing.assert_allclose(
353+
processed_data[variable].values,
354+
val_data[variable].values,
355+
rtol=1e-5,
356+
err_msg=f"Mismatch in variable '{variable}'",
357+
)
358+
359+
cdf_file = write_cdf(processed_data)
360+
assert (
361+
cdf_file.name
362+
== f"imap_codice_l1b_lo-nsw-priority_{VALIDATION_FILE_DATE}_v999.cdf"
363+
)
364+
365+
366+
@patch("imap_data_access.processing_input.ProcessingInputCollection.get_file_paths")
367+
def test_l1b_sw_lo_priorities(mock_get_file_paths, codice_lut_path):
368+
mock_get_file_paths.side_effect = [
369+
codice_lut_path(descriptor="lo-sw-priority", data_type="l0"),
370+
codice_lut_path(descriptor="l1a-sci-lut"),
371+
]
372+
val_path = (
373+
imap_module_directory
374+
/ "tests/codice/data/l1b_validation/"
375+
/ f"imap_codice_l1b_lo-sw-priority_{VALIDATION_FILE_DATE}"
376+
f"_{VALIDATION_FILE_VERSION}.cdf"
377+
)
378+
l1a_ds = process_l1a(ProcessingInputCollection())[0]
379+
l1a_file_path = write_cdf(l1a_ds)
380+
val_data = load_cdf(val_path)
381+
processed_data = process_codice_l1b(file_path=l1a_file_path)
382+
for variable in val_data.data_vars:
383+
np.testing.assert_allclose(
384+
processed_data[variable].values,
385+
val_data[variable].values,
386+
rtol=1e-5,
387+
err_msg=f"Mismatch in variable '{variable}'",
388+
)
389+
390+
cdf_file = write_cdf(processed_data)
391+
assert (
392+
cdf_file.name
393+
== f"imap_codice_l1b_lo-sw-priority_{VALIDATION_FILE_DATE}_v999.cdf"
394+
)

imap_processing/tests/external_test_data_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
(f"imap_codice_l1b_hi-counters-singles_{VALIDATION_FILE_DATE}_{VALIDATION_FILE_VERSION}.cdf", "codice/data/l1b_validation"),
6464
(f"imap_codice_l1b_hi-ialirt_{VALIDATION_FILE_DATE}_{VALIDATION_FILE_VERSION}.cdf", "codice/data/l1b_validation"),
6565
(f"imap_codice_l1b_hi-omni_{VALIDATION_FILE_DATE}_{VALIDATION_FILE_VERSION}.cdf", "codice/data/l1b_validation"),
66-
(f"imap_codice_l1b_hi-priorities_{VALIDATION_FILE_DATE}_{VALIDATION_FILE_VERSION}.cdf", "codice/data/l1b_validation"),
66+
(f"imap_codice_l1b_hi-priority_{VALIDATION_FILE_DATE}_{VALIDATION_FILE_VERSION}.cdf", "codice/data/l1b_validation"),
6767
(f"imap_codice_l1b_hi-sectored_{VALIDATION_FILE_DATE}_{VALIDATION_FILE_VERSION}.cdf", "codice/data/l1b_validation"),
6868
(f"imap_codice_l1b_lo-counters-aggregated_{VALIDATION_FILE_DATE}_{VALIDATION_FILE_VERSION}.cdf", "codice/data/l1b_validation"),
6969
(f"imap_codice_l1b_lo-counters-singles_{VALIDATION_FILE_DATE}_{VALIDATION_FILE_VERSION}.cdf", "codice/data/l1b_validation"),

0 commit comments

Comments
 (0)