Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions imap_processing/codice/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,15 @@
"PLAN_ID": 16,
"PLAN_STEP": 4,
"VIEW_ID": 4,
"RGFO_HALF_SPIN": 6,
"NSO_HALF_SPIN": 6,
"SPARE_01": 1,
"SPARE_01": 8,
"RGFO_HALF_SPIN": 8,
"RGFO_SPIN_SECTOR": 8,
"RGFO_ENERGY_STEP": 8,
"NSO_HALF_SPIN": 8,
"NSO_SPIN_SECTOR": 8,
"NSO_ENERGY_STEP": 8,
"SPARE_02": 16,
"SPARE_03": 5,
"SUSPECT": 1,
"COMPRESSION": 3,
"BYTE_COUNT": 23,
Expand Down Expand Up @@ -72,8 +78,8 @@
"oplus7": 2.28,
"oplus8": 2.0,
"mg": 3.5,
"fe_loq": 3.85,
"fe_hiq": 7.25,
"fe_loq": 7.25,
"fe_hiq": 3.85,
}

HI_IALIRT_ELEVATION_ANGLE = np.array(
Expand Down
2 changes: 1 addition & 1 deletion imap_processing/ialirt/l0/process_codice.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
logger = logging.getLogger(__name__)

COD_LO_COUNTER = 232
COD_HI_COUNTER = 197
COD_HI_COUNTER = 199
COD_LO_RANGE = range(0, 15)
COD_HI_RANGE = range(0, 5)

Expand Down
46 changes: 42 additions & 4 deletions imap_processing/tests/ialirt/unit/test_process_codice.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
)
from imap_processing.codice.decompress import decompress
from imap_processing.ialirt.l0.process_codice import (
COD_HI_COUNTER,
COD_LO_COUNTER,
concatenate_bytes,
convert_to_intensities,
Expand All @@ -44,6 +43,27 @@

pytestmark = pytest.mark.external_test_data

OLD_IAL_BIT_STRUCTURE = {
"SHCOARSE": 32,
"PACKET_VERSION": 16,
"SPIN_PERIOD": 16,
"ACQ_START_SECONDS": 32,
"ACQ_START_SUBSECONDS": 20,
"SPARE_00": 8,
"ST_BIAS_GAIN_MODE": 2,
"SW_BIAS_GAIN_MODE": 2,
"TABLE_ID": 32,
"PLAN_ID": 16,
"PLAN_STEP": 4,
"VIEW_ID": 4,
"RGFO_HALF_SPIN": 6,
"NSO_HALF_SPIN": 6,
"SPARE_01": 1,
"SUSPECT": 1,
"COMPRESSION": 3,
"BYTE_COUNT": 23,
}


@pytest.fixture(scope="session")
def l0_test_file():
Expand Down Expand Up @@ -421,6 +441,10 @@ def test_create_xarray_dataset_basic(l1a_lut_path):


@pytest.mark.external_test_data
@patch(
"imap_processing.codice.constants.IAL_BIT_STRUCTURE",
OLD_IAL_BIT_STRUCTURE,
)
def test_group_and_decompress_ialirt_cod_lo(
cod_lo_test_dataset, cod_lo_decom_test_file, l1a_lut_path, cod_lo_l1a_test_data
):
Expand Down Expand Up @@ -507,25 +531,30 @@ def test_group_and_decompress_ialirt_cod_lo(


@pytest.mark.external_test_data
@patch(
"imap_processing.codice.constants.IAL_BIT_STRUCTURE",
OLD_IAL_BIT_STRUCTURE,
)
def test_group_and_decompress_ialirt_cod_hi(
cod_hi_test_dataset, cod_hi_decom_test_file, l1a_lut_path, cod_hi_l1a_test_data
):
"Test that I-ALiRT CoDICE-Hi data can be grouped and decompressed properly."

codice_hi_counter = 197
grouped_cod_hi_data = find_groups(
cod_hi_test_dataset, (0, COD_HI_COUNTER), "cod_hi_counter", "cod_hi_acq"
cod_hi_test_dataset, (0, codice_hi_counter), "cod_hi_counter", "cod_hi_acq"
)

# Verify that we grouped the values properly.
counter_values = cod_hi_test_dataset["cod_hi_counter"].data
valid_values = counter_values[counter_values != 255]
resets = np.where(valid_values == COD_HI_COUNTER)
resets = np.where(valid_values == codice_hi_counter)

count = increment = 0
for reset in resets[0]:
group = valid_values[increment : reset + 1]
np.testing.assert_array_equal(
group, np.arange(0, COD_HI_COUNTER + 1, dtype=np.uint8)
group, np.arange(0, codice_hi_counter + 1, dtype=np.uint8)
)
increment = reset + 1
count = count + 1
Expand Down Expand Up @@ -735,6 +764,10 @@ def test_l2_ialirt_cod_lo(


@pytest.mark.external_test_data
@patch(
"imap_processing.codice.constants.IAL_BIT_STRUCTURE",
OLD_IAL_BIT_STRUCTURE,
)
def test_process_codice_lo(
cod_lo_test_dataset,
l1a_lut_path,
Expand Down Expand Up @@ -776,6 +809,11 @@ def test_process_codice_lo(


@pytest.mark.external_test_data
@patch("imap_processing.ialirt.l0.process_codice.COD_HI_COUNTER", 197)
@patch(
"imap_processing.codice.constants.IAL_BIT_STRUCTURE",
OLD_IAL_BIT_STRUCTURE,
)
def test_process_codice_hi(
cod_hi_test_dataset, l1a_lut_path, l2_lut_path, cod_hi_l2_test_data
):
Expand Down