|
| 1 | +import numpy as np |
| 2 | +import pandas as pd |
| 3 | +import pytest |
| 4 | + |
| 5 | +from imap_processing import imap_module_directory |
| 6 | + |
| 7 | + |
| 8 | +@pytest.mark.parametrize( |
| 9 | + "decom_test_data", |
| 10 | + [ |
| 11 | + pytest.param( |
| 12 | + { |
| 13 | + "apid": 899, |
| 14 | + "filename": "FM45_UltraFM45Extra_TV_Tests_" |
| 15 | + "2024-01-22T0930_20240122T093008.CCSDS", |
| 16 | + } |
| 17 | + ) |
| 18 | + ], |
| 19 | + indirect=True, |
| 20 | +) |
| 21 | +@pytest.mark.external_test_data |
| 22 | +def test_image_raw_events_decom(decom_test_data, xtce_path): |
| 23 | + """This function reads validation data and checks that decom data |
| 24 | + matches validation data for image rate packet""" |
| 25 | + filename = ( |
| 26 | + "ultra45_raw_sc_imgpriority2evnt_FM45_UltraFM45Extra_TV_Tests_" |
| 27 | + "2024-01-22T0930_20240122T093008.csv" |
| 28 | + ) |
| 29 | + priority_2_events_test_path = ( |
| 30 | + imap_module_directory / "tests" / "ultra" / "data" / "l0" / filename |
| 31 | + ) |
| 32 | + |
| 33 | + decom_ultra = decom_test_data |
| 34 | + df = pd.read_csv(priority_2_events_test_path, index_col="MET") |
| 35 | + |
| 36 | + vars_to_compare = { |
| 37 | + "SID": "sid", |
| 38 | + "Spin": "spin", |
| 39 | + "AbortFlag": "abortflag", |
| 40 | + "StartDelay": "startdelay", |
| 41 | + "Count": "count", |
| 42 | + "CoinType": "coin_type", |
| 43 | + "StartType": "start_type", |
| 44 | + "StopType": "stop_type", |
| 45 | + "StartPosTDC": "start_pos_tdc", |
| 46 | + "StopNorthTDC": "stop_north_tdc", |
| 47 | + "StopEastTDC": "stop_east_tdc", |
| 48 | + "StopSouthTDC": "stop_south_tdc", |
| 49 | + "StopWestTDC": "stop_west_tdc", |
| 50 | + "CoinNorthTDC": "coin_north_tdc", |
| 51 | + "CoinSouthTDC": "coin_south_tdc", |
| 52 | + "CoinDiscreteTDC": "coin_discrete_tdc", |
| 53 | + "EnergyOrPH": "energy_ph", |
| 54 | + "PulseWidth": "pulse_width", |
| 55 | + "PhaseAngle": "phase_angle", |
| 56 | + "Bin": "bin", |
| 57 | + } |
| 58 | + |
| 59 | + for df_var, xr_var in vars_to_compare.items(): |
| 60 | + good_values = df[df_var].values != -1 |
| 61 | + np.testing.assert_array_equal( |
| 62 | + df[df_var].values[good_values], |
| 63 | + decom_ultra[xr_var].values[good_values], |
| 64 | + ) |
0 commit comments