From 9c56774cad032d4da70a57ae7160a56365b627c7 Mon Sep 17 00:00:00 2001 From: Luisa Coakley Date: Thu, 5 Nov 2026 12:09:39 -0700 Subject: [PATCH 1/4] update temp conversion --- ...x_variable_unpacking_and_eu_conversion.csv | 72 ++++++++++--------- imap_processing/tests/idex/test_idex_l1b.py | 48 +++++++++++++ imap_processing/utils.py | 4 +- 3 files changed, 90 insertions(+), 34 deletions(-) diff --git a/imap_processing/idex/idex_variable_unpacking_and_eu_conversion.csv b/imap_processing/idex/idex_variable_unpacking_and_eu_conversion.csv index 80927ecbe2..759655673c 100644 --- a/imap_processing/idex/idex_variable_unpacking_and_eu_conversion.csv +++ b/imap_processing/idex/idex_variable_unpacking_and_eu_conversion.csv @@ -1,33 +1,39 @@ -index,mnemonic,var_name,starting_bit,nbits_padding_before,unsigned_nbits,unit,c0,c1,c2,c3,c4,c5,c6,c7,convertAs,packetName -1,current_1v_pol,idx__txhdrprochkch01,4,4,12,mA,0,0.9029253,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI -2,current_1p9v_pol,idx__txhdrprochkch01,20,4,12,mA,0,0.9029253,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI -3,temperature_1,idx__txhdrprochkch23,4,4,12,C,162.8276,-0.2668687,0.0003323794,-0.000000243153,9.034532e-11,-1.327735E-14,0,0,UNSEGMENTED_POLY,IDEX_SCI -4,temperature_2,idx__txhdrprochkch23,20,4,12,C,162.8276,-0.2668687,0.0003323794,-0.000000243153,9.034532e-11,-1.327735E-14,0,0,UNSEGMENTED_POLY,IDEX_SCI -5,voltage_1v_bus,idx__txhdrprochkch45,4,4,12,V,0,0.000805861,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI -6,fpga_temperature,idx__txhdrprochkch45,20,4,12,C,358.31,-0.1187104,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI -7,voltage_1p9v_bus,idx__txhdrprochkch67,4,4,12,V,0,0.000805861,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI -8,voltage_3p3v_bus,idx__txhdrprochkch67,20,4,12,V,0,0.001611722,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI -9,detector_voltage,idx__txhdrhvpshkch01,4,4,12,V,0,1.4652,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI -10,sensor_voltage,idx__txhdrhvpshkch01,20,4,12,V,0,1.4652,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI -11,target_voltage,idx__txhdrhvpshkch23,4,4,12,V,0,1.4652,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI -12,rejection_voltage,idx__txhdrhvpshkch23,20,4,12,V,0,1.4652,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI -13,reflectron_voltage,idx__txhdrhvpshkch45,4,4,12,V,0,1.4652,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI -14,current_hvps_sensor,idx__txhdrhvpshkch45,20,4,12,mA,0,0.000007326,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI -15,positive_current_hvps,idx__txhdrhvpshkch67,4,4,12,mA,0,0.000024339,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI -16,negative_current_hvps,idx__txhdrhvpshkch67,20,4,12,mA,0,0.000024339,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI -17,voltage_3p3_ref,idx__txhdrlvhk0ch01,4,4,12,V,0,0.00161172,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI -18,voltage_3p3_op_ref,idx__txhdrlvhk0ch01,20,4,12,V,0,0.00161172,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI -19,voltage_neg6v_bus,idx__txhdrlvhk0ch23,4,4,12,V,-33,0.00886447,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI -20,voltage_pos6v_bus,idx__txhdrlvhk0ch23,20,4,12,V,0,0.00241758,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI -21,voltage_pos16v_bus,idx__txhdrlvhk0ch45,4,4,12,V,0,0.00482711,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI -22,voltage_pos3p3v_bus,idx__txhdrlvhk0ch45,20,4,12,V,0,0.00161172,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI -23,voltage_neg5v_bus,idx__txhdrlvhk0ch67,4,4,12,V,-33,0.00886447,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI -24,voltage_pos5v_bus,idx__txhdrlvhk0ch67,20,4,12,V,0,0.00161172,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI -25,current_3p3v_bus,idx__txhdrlvhk1ch01,4,4,12,A,0,0.00161172,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI -26,current_16v_bus,idx__txhdrlvhk1ch01,20,4,12,A,0,0.000161172,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI -27,current_6v_bus,idx__txhdrlvhk1ch23,4,4,12,A,0,0.0000805861,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI -28,current_neg6v_bus,idx__txhdrlvhk1ch23,20,4,12,A,0,-0.0000805861,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI -29,current_5v_bus,idx__txhdrlvhk1ch45,4,4,12,A,0,0.00004029304,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI -30,current_neg5v_bus,idx__txhdrlvhk1ch45,20,4,12,A,0,-0.0000201465,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI -31,current_2p5v_bus,idx__txhdrlvhk1ch67,4,4,12,A,0,0.00161172,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI -32,current_neg2p5v_bus,idx__txhdrlvhk1ch67,20,4,12,A,0,-0.000040293,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI \ No newline at end of file +index,mnemonic,var_name,starting_bit,nbits_padding_before,unsigned_nbits,unit,dn_range_start,dn_range_stop,c0,c1,c2,c3,c4,c5,c6,c7,convertAs,packetName +1,current_1v_pol,idx__txhdrprochkch01,4,4,12,mA,,,0,0.9029253,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI +2,current_1p9v_pol,idx__txhdrprochkch01,20,4,12,mA,,,0,0.9029253,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI +3,temperature_1,idx__txhdrprochkch23,4,4,12,C,0,2063,162.8276,-0.2668687,0.0003323794,-2.43153e-07,9.034532e-11,-1.327735e-14,0,0,SEGMENTED_POLY,IDEX_SCI +3,temperature_1,idx__txhdrprochkch23,4,4,12,C,2064,3853,714.2124,-1.194011,0.0008599094,-3.145266e-07,5.745416e-11,-4.208231e-15,0,0,SEGMENTED_POLY,IDEX_SCI +3,temperature_1,idx__txhdrprochkch23,4,4,12,C,3854,4051,136881.2,-105.4644,0.02710281,-2.323543e-06,0,0,0,0,SEGMENTED_POLY,IDEX_SCI +3,temperature_1,idx__txhdrprochkch23,4,4,12,C,4052,4095,-100809.9,50.03809,-0.00621209,0,0,0,0,0,SEGMENTED_POLY,IDEX_SCI +4,temperature_2,idx__txhdrprochkch23,20,4,12,C,0,2063,162.8276,-0.2668687,0.0003323794,-2.43153e-07,9.034532e-11,-1.327735e-14,0,0,SEGMENTED_POLY,IDEX_SCI +4,temperature_2,idx__txhdrprochkch23,20,4,12,C,2064,3853,714.2124,-1.194011,0.0008599094,-3.145266e-07,5.745416e-11,-4.208231e-15,0,0,SEGMENTED_POLY,IDEX_SCI +4,temperature_2,idx__txhdrprochkch23,20,4,12,C,3854,4051,136881.2,-105.4644,0.02710281,-2.323543e-06,0,0,0,0,SEGMENTED_POLY,IDEX_SCI +4,temperature_2,idx__txhdrprochkch23,20,4,12,C,4052,4095,-100809.9,50.03809,-0.00621209,0,0,0,0,0,SEGMENTED_POLY,IDEX_SCI +5,voltage_1v_bus,idx__txhdrprochkch45,4,4,12,V,,,0,0.000805861,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI +6,fpga_temperature,idx__txhdrprochkch45,20,4,12,C,,,358.31,-0.1187104,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI +7,voltage_1p9v_bus,idx__txhdrprochkch67,4,4,12,V,,,0,0.000805861,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI +8,voltage_3p3v_bus,idx__txhdrprochkch67,20,4,12,V,,,0,0.001611722,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI +9,detector_voltage,idx__txhdrhvpshkch01,4,4,12,V,,,0,1.4652,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI +10,sensor_voltage,idx__txhdrhvpshkch01,20,4,12,V,,,0,1.4652,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI +11,target_voltage,idx__txhdrhvpshkch23,4,4,12,V,,,0,1.4652,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI +12,rejection_voltage,idx__txhdrhvpshkch23,20,4,12,V,,,0,1.4652,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI +13,reflectron_voltage,idx__txhdrhvpshkch45,4,4,12,V,,,0,1.4652,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI +14,current_hvps_sensor,idx__txhdrhvpshkch45,20,4,12,mA,,,0,0.000007326,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI +15,positive_current_hvps,idx__txhdrhvpshkch67,4,4,12,mA,,,0,0.000024339,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI +16,negative_current_hvps,idx__txhdrhvpshkch67,20,4,12,mA,,,0,0.000024339,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI +17,voltage_3p3_ref,idx__txhdrlvhk0ch01,4,4,12,V,,,0,0.00161172,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI +18,voltage_3p3_op_ref,idx__txhdrlvhk0ch01,20,4,12,V,,,0,0.00161172,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI +19,voltage_neg6v_bus,idx__txhdrlvhk0ch23,4,4,12,V,,,-33,0.00886447,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI +20,voltage_pos6v_bus,idx__txhdrlvhk0ch23,20,4,12,V,,,0,0.00241758,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI +21,voltage_pos16v_bus,idx__txhdrlvhk0ch45,4,4,12,V,,,0,0.00482711,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI +22,voltage_pos3p3v_bus,idx__txhdrlvhk0ch45,20,4,12,V,,,0,0.00161172,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI +23,voltage_neg5v_bus,idx__txhdrlvhk0ch67,4,4,12,V,,,-33,0.00886447,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI +24,voltage_pos5v_bus,idx__txhdrlvhk0ch67,20,4,12,V,,,0,0.00161172,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI +25,current_3p3v_bus,idx__txhdrlvhk1ch01,4,4,12,A,,,0,0.00161172,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI +26,current_16v_bus,idx__txhdrlvhk1ch01,20,4,12,A,,,0,0.000161172,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI +27,current_6v_bus,idx__txhdrlvhk1ch23,4,4,12,A,,,0,0.0000805861,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI +28,current_neg6v_bus,idx__txhdrlvhk1ch23,20,4,12,A,,,0,-0.0000805861,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI +29,current_5v_bus,idx__txhdrlvhk1ch45,4,4,12,A,,,0,0.00004029304,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI +30,current_neg5v_bus,idx__txhdrlvhk1ch45,20,4,12,A,,,0,-0.0000201465,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI +31,current_2p5v_bus,idx__txhdrlvhk1ch67,4,4,12,A,,,0,0.00161172,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI +32,current_neg2p5v_bus,idx__txhdrlvhk1ch67,20,4,12,A,,,0,-0.000040293,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI diff --git a/imap_processing/tests/idex/test_idex_l1b.py b/imap_processing/tests/idex/test_idex_l1b.py index fc7972063d..c8fd97aad7 100644 --- a/imap_processing/tests/idex/test_idex_l1b.py +++ b/imap_processing/tests/idex/test_idex_l1b.py @@ -26,6 +26,7 @@ from imap_processing.idex.idex_utils import get_idex_attrs from imap_processing.spice.time import ttj2000ns_to_met from imap_processing.tests.idex import conftest +from imap_processing.utils import convert_raw_to_eu @pytest.fixture @@ -153,6 +154,53 @@ def test_unpack_instrument_settings(): assert np.all(unpacked_dict["test_var1"] == 4) +@pytest.mark.parametrize("temperature_var", ["temperature_1", "temperature_2"]) +def test_processor_board_temperature_conversion(temperature_var): + """Check the piecewise polynomial conversion of the processor board temps.""" + # DN values on either side of each segment boundary, plus the range ends + dn = np.array([0, 2063, 2064, 3853, 3854, 4051, 4052, 4095], dtype=np.uint32) + segment_coeffs = [ + [ + 162.8276, + -0.2668687, + 0.0003323794, + -2.43153e-07, + 9.034532e-11, + -1.327735e-14, + ], + [ + 714.2124, + -1.194011, + 0.0008599094, + -3.145266e-07, + 5.745416e-11, + -4.208231e-15, + ], + [136881.2, -105.4644, 0.02710281, -2.323543e-06], + [-100809.9, 50.03809, -0.00621209], + ] + # Each pair of DN values falls in one segment + expected = np.concatenate( + [ + np.polyval(coeffs[::-1], dn[2 * i : 2 * i + 2]) + for i, coeffs in enumerate(segment_coeffs) + ] + ) + + test_ds = xr.Dataset({temperature_var: xr.DataArray(dn, dims="epoch")}) + converted = convert_raw_to_eu( + test_ds, + conversion_table_path=f"{imap_module_directory}/idex/" + f"idex_variable_unpacking_and_eu_conversion.csv", + packet_name="IDEX_SCI", + ) + + assert converted[temperature_var].dtype == np.float64 + np.testing.assert_allclose(converted[temperature_var].data, expected) + # Upper segments are below zero and must not wrap around + assert np.all(converted[temperature_var].data[3:] < 0) + + def test_get_trigger_settings_success(decom_test_data_sci): """ Check that the output to 'get_trigger_mode_and_level' matches expected arrays. diff --git a/imap_processing/utils.py b/imap_processing/utils.py index 72d76f8f4a..94b60b3b03 100644 --- a/imap_processing/utils.py +++ b/imap_processing/utils.py @@ -113,7 +113,9 @@ def convert_raw_to_eu( dataset[var].data = np.polyval(coeff_values, dataset[var].data) elif np.all(packet_df["convertAs"] == "SEGMENTED_POLY"): - data = dataset[var].data + # np.piecewise output takes the input dtype, so cast to float to avoid + # truncating (or wrapping negative) values for integer raw DNs + data = dataset[var].data.astype(np.float64) # Check if any of the raw DN values fall outside the ranges bad_mask = np.logical_or( data < packet_df["dn_range_start"].min(), From f6ef89488f79e4aadecd994dab14003407615a7a Mon Sep 17 00:00:00 2001 From: Luisa Coakley Date: Thu, 5 Nov 2026 12:17:39 -0700 Subject: [PATCH 2/4] remove test --- imap_processing/tests/idex/test_idex_l1b.py | 48 --------------------- 1 file changed, 48 deletions(-) diff --git a/imap_processing/tests/idex/test_idex_l1b.py b/imap_processing/tests/idex/test_idex_l1b.py index c8fd97aad7..fc7972063d 100644 --- a/imap_processing/tests/idex/test_idex_l1b.py +++ b/imap_processing/tests/idex/test_idex_l1b.py @@ -26,7 +26,6 @@ from imap_processing.idex.idex_utils import get_idex_attrs from imap_processing.spice.time import ttj2000ns_to_met from imap_processing.tests.idex import conftest -from imap_processing.utils import convert_raw_to_eu @pytest.fixture @@ -154,53 +153,6 @@ def test_unpack_instrument_settings(): assert np.all(unpacked_dict["test_var1"] == 4) -@pytest.mark.parametrize("temperature_var", ["temperature_1", "temperature_2"]) -def test_processor_board_temperature_conversion(temperature_var): - """Check the piecewise polynomial conversion of the processor board temps.""" - # DN values on either side of each segment boundary, plus the range ends - dn = np.array([0, 2063, 2064, 3853, 3854, 4051, 4052, 4095], dtype=np.uint32) - segment_coeffs = [ - [ - 162.8276, - -0.2668687, - 0.0003323794, - -2.43153e-07, - 9.034532e-11, - -1.327735e-14, - ], - [ - 714.2124, - -1.194011, - 0.0008599094, - -3.145266e-07, - 5.745416e-11, - -4.208231e-15, - ], - [136881.2, -105.4644, 0.02710281, -2.323543e-06], - [-100809.9, 50.03809, -0.00621209], - ] - # Each pair of DN values falls in one segment - expected = np.concatenate( - [ - np.polyval(coeffs[::-1], dn[2 * i : 2 * i + 2]) - for i, coeffs in enumerate(segment_coeffs) - ] - ) - - test_ds = xr.Dataset({temperature_var: xr.DataArray(dn, dims="epoch")}) - converted = convert_raw_to_eu( - test_ds, - conversion_table_path=f"{imap_module_directory}/idex/" - f"idex_variable_unpacking_and_eu_conversion.csv", - packet_name="IDEX_SCI", - ) - - assert converted[temperature_var].dtype == np.float64 - np.testing.assert_allclose(converted[temperature_var].data, expected) - # Upper segments are below zero and must not wrap around - assert np.all(converted[temperature_var].data[3:] < 0) - - def test_get_trigger_settings_success(decom_test_data_sci): """ Check that the output to 'get_trigger_mode_and_level' matches expected arrays. From dba154f8db93510ba12f18b0eaa5d0cd7d72f311 Mon Sep 17 00:00:00 2001 From: Luisa Coakley Date: Mon, 9 Nov 2026 12:45:11 -0700 Subject: [PATCH 3/4] update incides --- ...x_variable_unpacking_and_eu_conversion.csv | 70 +++++++++---------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/imap_processing/idex/idex_variable_unpacking_and_eu_conversion.csv b/imap_processing/idex/idex_variable_unpacking_and_eu_conversion.csv index 759655673c..3206c3847d 100644 --- a/imap_processing/idex/idex_variable_unpacking_and_eu_conversion.csv +++ b/imap_processing/idex/idex_variable_unpacking_and_eu_conversion.csv @@ -2,38 +2,38 @@ 1,current_1v_pol,idx__txhdrprochkch01,4,4,12,mA,,,0,0.9029253,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI 2,current_1p9v_pol,idx__txhdrprochkch01,20,4,12,mA,,,0,0.9029253,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI 3,temperature_1,idx__txhdrprochkch23,4,4,12,C,0,2063,162.8276,-0.2668687,0.0003323794,-2.43153e-07,9.034532e-11,-1.327735e-14,0,0,SEGMENTED_POLY,IDEX_SCI -3,temperature_1,idx__txhdrprochkch23,4,4,12,C,2064,3853,714.2124,-1.194011,0.0008599094,-3.145266e-07,5.745416e-11,-4.208231e-15,0,0,SEGMENTED_POLY,IDEX_SCI -3,temperature_1,idx__txhdrprochkch23,4,4,12,C,3854,4051,136881.2,-105.4644,0.02710281,-2.323543e-06,0,0,0,0,SEGMENTED_POLY,IDEX_SCI -3,temperature_1,idx__txhdrprochkch23,4,4,12,C,4052,4095,-100809.9,50.03809,-0.00621209,0,0,0,0,0,SEGMENTED_POLY,IDEX_SCI -4,temperature_2,idx__txhdrprochkch23,20,4,12,C,0,2063,162.8276,-0.2668687,0.0003323794,-2.43153e-07,9.034532e-11,-1.327735e-14,0,0,SEGMENTED_POLY,IDEX_SCI -4,temperature_2,idx__txhdrprochkch23,20,4,12,C,2064,3853,714.2124,-1.194011,0.0008599094,-3.145266e-07,5.745416e-11,-4.208231e-15,0,0,SEGMENTED_POLY,IDEX_SCI -4,temperature_2,idx__txhdrprochkch23,20,4,12,C,3854,4051,136881.2,-105.4644,0.02710281,-2.323543e-06,0,0,0,0,SEGMENTED_POLY,IDEX_SCI -4,temperature_2,idx__txhdrprochkch23,20,4,12,C,4052,4095,-100809.9,50.03809,-0.00621209,0,0,0,0,0,SEGMENTED_POLY,IDEX_SCI -5,voltage_1v_bus,idx__txhdrprochkch45,4,4,12,V,,,0,0.000805861,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI -6,fpga_temperature,idx__txhdrprochkch45,20,4,12,C,,,358.31,-0.1187104,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI -7,voltage_1p9v_bus,idx__txhdrprochkch67,4,4,12,V,,,0,0.000805861,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI -8,voltage_3p3v_bus,idx__txhdrprochkch67,20,4,12,V,,,0,0.001611722,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI -9,detector_voltage,idx__txhdrhvpshkch01,4,4,12,V,,,0,1.4652,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI -10,sensor_voltage,idx__txhdrhvpshkch01,20,4,12,V,,,0,1.4652,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI -11,target_voltage,idx__txhdrhvpshkch23,4,4,12,V,,,0,1.4652,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI -12,rejection_voltage,idx__txhdrhvpshkch23,20,4,12,V,,,0,1.4652,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI -13,reflectron_voltage,idx__txhdrhvpshkch45,4,4,12,V,,,0,1.4652,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI -14,current_hvps_sensor,idx__txhdrhvpshkch45,20,4,12,mA,,,0,0.000007326,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI -15,positive_current_hvps,idx__txhdrhvpshkch67,4,4,12,mA,,,0,0.000024339,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI -16,negative_current_hvps,idx__txhdrhvpshkch67,20,4,12,mA,,,0,0.000024339,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI -17,voltage_3p3_ref,idx__txhdrlvhk0ch01,4,4,12,V,,,0,0.00161172,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI -18,voltage_3p3_op_ref,idx__txhdrlvhk0ch01,20,4,12,V,,,0,0.00161172,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI -19,voltage_neg6v_bus,idx__txhdrlvhk0ch23,4,4,12,V,,,-33,0.00886447,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI -20,voltage_pos6v_bus,idx__txhdrlvhk0ch23,20,4,12,V,,,0,0.00241758,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI -21,voltage_pos16v_bus,idx__txhdrlvhk0ch45,4,4,12,V,,,0,0.00482711,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI -22,voltage_pos3p3v_bus,idx__txhdrlvhk0ch45,20,4,12,V,,,0,0.00161172,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI -23,voltage_neg5v_bus,idx__txhdrlvhk0ch67,4,4,12,V,,,-33,0.00886447,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI -24,voltage_pos5v_bus,idx__txhdrlvhk0ch67,20,4,12,V,,,0,0.00161172,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI -25,current_3p3v_bus,idx__txhdrlvhk1ch01,4,4,12,A,,,0,0.00161172,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI -26,current_16v_bus,idx__txhdrlvhk1ch01,20,4,12,A,,,0,0.000161172,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI -27,current_6v_bus,idx__txhdrlvhk1ch23,4,4,12,A,,,0,0.0000805861,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI -28,current_neg6v_bus,idx__txhdrlvhk1ch23,20,4,12,A,,,0,-0.0000805861,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI -29,current_5v_bus,idx__txhdrlvhk1ch45,4,4,12,A,,,0,0.00004029304,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI -30,current_neg5v_bus,idx__txhdrlvhk1ch45,20,4,12,A,,,0,-0.0000201465,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI -31,current_2p5v_bus,idx__txhdrlvhk1ch67,4,4,12,A,,,0,0.00161172,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI -32,current_neg2p5v_bus,idx__txhdrlvhk1ch67,20,4,12,A,,,0,-0.000040293,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI +4,temperature_1,idx__txhdrprochkch23,4,4,12,C,2064,3853,714.2124,-1.194011,0.0008599094,-3.145266e-07,5.745416e-11,-4.208231e-15,0,0,SEGMENTED_POLY,IDEX_SCI +5,temperature_1,idx__txhdrprochkch23,4,4,12,C,3854,4051,136881.2,-105.4644,0.02710281,-2.323543e-06,0,0,0,0,SEGMENTED_POLY,IDEX_SCI +6,temperature_1,idx__txhdrprochkch23,4,4,12,C,4052,4095,-100809.9,50.03809,-0.00621209,0,0,0,0,0,SEGMENTED_POLY,IDEX_SCI +7,temperature_2,idx__txhdrprochkch23,20,4,12,C,0,2063,162.8276,-0.2668687,0.0003323794,-2.43153e-07,9.034532e-11,-1.327735e-14,0,0,SEGMENTED_POLY,IDEX_SCI +8,temperature_2,idx__txhdrprochkch23,20,4,12,C,2064,3853,714.2124,-1.194011,0.0008599094,-3.145266e-07,5.745416e-11,-4.208231e-15,0,0,SEGMENTED_POLY,IDEX_SCI +9,temperature_2,idx__txhdrprochkch23,20,4,12,C,3854,4051,136881.2,-105.4644,0.02710281,-2.323543e-06,0,0,0,0,SEGMENTED_POLY,IDEX_SCI +10,temperature_2,idx__txhdrprochkch23,20,4,12,C,4052,4095,-100809.9,50.03809,-0.00621209,0,0,0,0,0,SEGMENTED_POLY,IDEX_SCI +11,voltage_1v_bus,idx__txhdrprochkch45,4,4,12,V,,,0,0.000805861,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI +12,fpga_temperature,idx__txhdrprochkch45,20,4,12,C,,,358.31,-0.1187104,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI +13,voltage_1p9v_bus,idx__txhdrprochkch67,4,4,12,V,,,0,0.000805861,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI +14,voltage_3p3v_bus,idx__txhdrprochkch67,20,4,12,V,,,0,0.001611722,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI +15,detector_voltage,idx__txhdrhvpshkch01,4,4,12,V,,,0,1.4652,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI +16,sensor_voltage,idx__txhdrhvpshkch01,20,4,12,V,,,0,1.4652,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI +17,target_voltage,idx__txhdrhvpshkch23,4,4,12,V,,,0,1.4652,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI +18,rejection_voltage,idx__txhdrhvpshkch23,20,4,12,V,,,0,1.4652,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI +19,reflectron_voltage,idx__txhdrhvpshkch45,4,4,12,V,,,0,1.4652,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI +20,current_hvps_sensor,idx__txhdrhvpshkch45,20,4,12,mA,,,0,0.000007326,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI +21,positive_current_hvps,idx__txhdrhvpshkch67,4,4,12,mA,,,0,0.000024339,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI +22,negative_current_hvps,idx__txhdrhvpshkch67,20,4,12,mA,,,0,0.000024339,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI +23,voltage_3p3_ref,idx__txhdrlvhk0ch01,4,4,12,V,,,0,0.00161172,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI +24,voltage_3p3_op_ref,idx__txhdrlvhk0ch01,20,4,12,V,,,0,0.00161172,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI +25,voltage_neg6v_bus,idx__txhdrlvhk0ch23,4,4,12,V,,,-33,0.00886447,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI +26,voltage_pos6v_bus,idx__txhdrlvhk0ch23,20,4,12,V,,,0,0.00241758,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI +27,voltage_pos16v_bus,idx__txhdrlvhk0ch45,4,4,12,V,,,0,0.00482711,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI +28,voltage_pos3p3v_bus,idx__txhdrlvhk0ch45,20,4,12,V,,,0,0.00161172,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI +29,voltage_neg5v_bus,idx__txhdrlvhk0ch67,4,4,12,V,,,-33,0.00886447,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI +30,voltage_pos5v_bus,idx__txhdrlvhk0ch67,20,4,12,V,,,0,0.00161172,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI +31,current_3p3v_bus,idx__txhdrlvhk1ch01,4,4,12,A,,,0,0.00161172,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI +32,current_16v_bus,idx__txhdrlvhk1ch01,20,4,12,A,,,0,0.000161172,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI +33,current_6v_bus,idx__txhdrlvhk1ch23,4,4,12,A,,,0,0.0000805861,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI +34,current_neg6v_bus,idx__txhdrlvhk1ch23,20,4,12,A,,,0,-0.0000805861,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI +35,current_5v_bus,idx__txhdrlvhk1ch45,4,4,12,A,,,0,0.00004029304,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI +36,current_neg5v_bus,idx__txhdrlvhk1ch45,20,4,12,A,,,0,-0.0000201465,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI +37,current_2p5v_bus,idx__txhdrlvhk1ch67,4,4,12,A,,,0,0.00161172,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI +38,current_neg2p5v_bus,idx__txhdrlvhk1ch67,20,4,12,A,,,0,-0.000040293,0,0,0,0,0,0,UNSEGMENTED_POLY,IDEX_SCI From a6bad2730ce568fe48451f578412e9debd82c0fe Mon Sep 17 00:00:00 2001 From: Luisa Coakley Date: Mon, 9 Nov 2026 13:34:23 -0700 Subject: [PATCH 4/4] make test more robust. Field two should have some fractional and negative converted values --- imap_processing/tests/test_utils.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/imap_processing/tests/test_utils.py b/imap_processing/tests/test_utils.py index f1e5ded165..34c5502bff 100644 --- a/imap_processing/tests/test_utils.py +++ b/imap_processing/tests/test_utils.py @@ -32,13 +32,13 @@ def test_convert_raw_to_eu(tmp_path): ], "dn_range_start": [0, 0, 1, dn_cutoff + 1, 0], "dn_range_stop": [0, 0, dn_cutoff, 4, 0], - "c0": [0, 1, 3, 4, 2], - "c1": [0, 1, 3, 4, 2], - "c2": [0, 0, 3, 4, 2], - "c3": [0, 0, 3, 4, 2], - "c5": [0, 1, 3, 4, 2], - "c6": [0, 0, 3, 4, 2], - "c7": [0, 0, 3, 4, 2], + "c0": [0, 1, -3.5, 1.5, 2], + "c1": [0, 1, 0.25, -0.75, 2], + "c2": [0, 0, 0, 4, 2], + "c3": [0, 0, 0, 0, 2], + "c5": [0, 1, 0, 0, 2], + "c6": [0, 0, 0, 0, 2], + "c7": [0, 0, 0, 0, 2], "unit": ["a", "b", "d", "d", "c"], } ) @@ -49,9 +49,11 @@ def test_convert_raw_to_eu(tmp_path): # Generate a fake dataset for testing n_packets = 3 - field_0 = np.arange(n_packets) - field_1 = np.arange(n_packets) + 10 - field_2 = np.arange(n_packets) + 1 + field_0 = np.arange(n_packets).astype( + np.uint16 + ) # Use unsigned integer to mock packet data. + field_1 = np.arange(n_packets).astype(np.uint16) + 10 + field_2 = np.arange(n_packets).astype(np.uint16) + 1 time = np.arange(n_packets) + 1000 dn_dataset = xr.Dataset( data_vars=dict(