imap-processing 0.12.0__py3-none-any.whl → 0.13.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of imap-processing might be problematic. Click here for more details.
- imap_processing/__init__.py +1 -0
- imap_processing/_version.py +2 -2
- imap_processing/ccsds/ccsds_data.py +1 -2
- imap_processing/ccsds/excel_to_xtce.py +1 -2
- imap_processing/cdf/config/imap_codice_global_cdf_attrs.yaml +18 -12
- imap_processing/cdf/config/imap_codice_l1a_variable_attrs.yaml +569 -0
- imap_processing/cdf/config/imap_codice_l1b_variable_attrs.yaml +1846 -128
- imap_processing/cdf/config/imap_hit_global_cdf_attrs.yaml +5 -5
- imap_processing/cdf/config/imap_idex_global_cdf_attrs.yaml +20 -1
- imap_processing/cdf/config/imap_idex_l1a_variable_attrs.yaml +6 -4
- imap_processing/cdf/config/imap_idex_l1b_variable_attrs.yaml +3 -3
- imap_processing/cdf/config/imap_mag_global_cdf_attrs.yaml +15 -0
- imap_processing/cdf/config/imap_swapi_variable_attrs.yaml +22 -0
- imap_processing/cdf/config/imap_swe_l1b_variable_attrs.yaml +16 -0
- imap_processing/cdf/config/imap_ultra_global_cdf_attrs.yaml +178 -5
- imap_processing/cdf/config/imap_ultra_l1a_variable_attrs.yaml +5045 -41
- imap_processing/cdf/config/imap_ultra_l1b_variable_attrs.yaml +33 -19
- imap_processing/cdf/config/imap_ultra_l1c_variable_attrs.yaml +8 -48
- imap_processing/cdf/utils.py +41 -33
- imap_processing/cli.py +463 -234
- imap_processing/codice/codice_l1a.py +260 -47
- imap_processing/codice/codice_l1b.py +51 -152
- imap_processing/codice/constants.py +38 -1
- imap_processing/ena_maps/ena_maps.py +658 -65
- imap_processing/ena_maps/utils/coordinates.py +1 -1
- imap_processing/ena_maps/utils/spatial_utils.py +10 -5
- imap_processing/glows/l1a/glows_l1a.py +28 -99
- imap_processing/glows/l1a/glows_l1a_data.py +2 -2
- imap_processing/glows/l1b/glows_l1b.py +1 -4
- imap_processing/glows/l1b/glows_l1b_data.py +1 -3
- imap_processing/glows/l2/glows_l2.py +2 -5
- imap_processing/hi/l1a/hi_l1a.py +31 -12
- imap_processing/hi/l1b/hi_l1b.py +80 -43
- imap_processing/hi/l1c/hi_l1c.py +12 -16
- imap_processing/hit/ancillary/imap_hit_l1b-to-l2-sector-dt0-factors_20250219_v002.csv +81 -0
- imap_processing/hit/hit_utils.py +93 -35
- imap_processing/hit/l0/decom_hit.py +3 -1
- imap_processing/hit/l1a/hit_l1a.py +30 -25
- imap_processing/hit/l1b/constants.py +6 -2
- imap_processing/hit/l1b/hit_l1b.py +279 -318
- imap_processing/hit/l2/constants.py +37 -0
- imap_processing/hit/l2/hit_l2.py +373 -264
- imap_processing/ialirt/l0/parse_mag.py +138 -10
- imap_processing/ialirt/l0/process_swapi.py +69 -0
- imap_processing/ialirt/l0/process_swe.py +318 -22
- imap_processing/ialirt/packet_definitions/ialirt.xml +216 -212
- imap_processing/ialirt/packet_definitions/ialirt_codicehi.xml +1 -1
- imap_processing/ialirt/packet_definitions/ialirt_codicelo.xml +1 -1
- imap_processing/ialirt/packet_definitions/ialirt_swapi.xml +14 -14
- imap_processing/ialirt/utils/grouping.py +1 -1
- imap_processing/idex/idex_constants.py +9 -1
- imap_processing/idex/idex_l0.py +22 -8
- imap_processing/idex/idex_l1a.py +75 -44
- imap_processing/idex/idex_l1b.py +9 -8
- imap_processing/idex/idex_l2a.py +79 -45
- imap_processing/idex/idex_l2b.py +120 -0
- imap_processing/idex/idex_variable_unpacking_and_eu_conversion.csv +33 -39
- imap_processing/idex/packet_definitions/idex_housekeeping_packet_definition.xml +9130 -0
- imap_processing/lo/l0/lo_science.py +1 -2
- imap_processing/lo/l1a/lo_l1a.py +1 -4
- imap_processing/lo/l1b/lo_l1b.py +527 -6
- imap_processing/lo/l1b/tof_conversions.py +11 -0
- imap_processing/lo/l1c/lo_l1c.py +1 -4
- imap_processing/mag/constants.py +43 -0
- imap_processing/mag/imap_mag_sdc_configuration_v001.py +8 -0
- imap_processing/mag/l1a/mag_l1a.py +2 -9
- imap_processing/mag/l1a/mag_l1a_data.py +10 -10
- imap_processing/mag/l1b/mag_l1b.py +84 -17
- imap_processing/mag/l1c/interpolation_methods.py +180 -3
- imap_processing/mag/l1c/mag_l1c.py +236 -70
- imap_processing/mag/l2/mag_l2.py +140 -0
- imap_processing/mag/l2/mag_l2_data.py +288 -0
- imap_processing/spacecraft/quaternions.py +1 -3
- imap_processing/spice/geometry.py +3 -3
- imap_processing/spice/kernels.py +0 -276
- imap_processing/spice/pointing_frame.py +257 -0
- imap_processing/spice/repoint.py +48 -19
- imap_processing/spice/spin.py +38 -33
- imap_processing/spice/time.py +24 -0
- imap_processing/swapi/l1/swapi_l1.py +16 -12
- imap_processing/swapi/l2/swapi_l2.py +116 -4
- imap_processing/swapi/swapi_utils.py +32 -0
- imap_processing/swe/l1a/swe_l1a.py +2 -9
- imap_processing/swe/l1a/swe_science.py +8 -11
- imap_processing/swe/l1b/swe_l1b.py +898 -23
- imap_processing/swe/l2/swe_l2.py +21 -77
- imap_processing/swe/utils/swe_constants.py +1 -0
- imap_processing/tests/ccsds/test_excel_to_xtce.py +1 -1
- imap_processing/tests/cdf/test_utils.py +14 -16
- imap_processing/tests/codice/conftest.py +44 -33
- imap_processing/tests/codice/data/validation/imap_codice_l1a_hi-pha_20241110193700_v0.0.0.cdf +0 -0
- imap_processing/tests/codice/data/validation/imap_codice_l1a_lo-pha_20241110193700_v0.0.0.cdf +0 -0
- imap_processing/tests/codice/test_codice_l1a.py +20 -11
- imap_processing/tests/codice/test_codice_l1b.py +6 -7
- imap_processing/tests/conftest.py +78 -22
- imap_processing/tests/ena_maps/test_ena_maps.py +462 -33
- imap_processing/tests/ena_maps/test_spatial_utils.py +1 -1
- imap_processing/tests/glows/conftest.py +10 -14
- imap_processing/tests/glows/test_glows_decom.py +4 -4
- imap_processing/tests/glows/test_glows_l1a_cdf.py +6 -27
- imap_processing/tests/glows/test_glows_l1a_data.py +6 -8
- imap_processing/tests/glows/test_glows_l1b.py +11 -11
- imap_processing/tests/glows/test_glows_l1b_data.py +5 -5
- imap_processing/tests/glows/test_glows_l2.py +2 -8
- imap_processing/tests/hi/conftest.py +1 -1
- imap_processing/tests/hi/test_hi_l1b.py +10 -12
- imap_processing/tests/hi/test_hi_l1c.py +27 -24
- imap_processing/tests/hi/test_l1a.py +7 -9
- imap_processing/tests/hi/test_science_direct_event.py +2 -2
- imap_processing/tests/hit/helpers/l1_validation.py +44 -43
- imap_processing/tests/hit/test_decom_hit.py +1 -1
- imap_processing/tests/hit/test_hit_l1a.py +9 -9
- imap_processing/tests/hit/test_hit_l1b.py +172 -217
- imap_processing/tests/hit/test_hit_l2.py +380 -118
- imap_processing/tests/hit/test_hit_utils.py +122 -55
- imap_processing/tests/hit/validation_data/hit_l1b_standard_sample2_nsrl_v4_3decimals.csv +62 -62
- imap_processing/tests/hit/validation_data/sci_sample_raw.csv +1 -1
- imap_processing/tests/ialirt/unit/test_decom_ialirt.py +16 -81
- imap_processing/tests/ialirt/unit/test_grouping.py +2 -2
- imap_processing/tests/ialirt/unit/test_parse_mag.py +71 -16
- imap_processing/tests/ialirt/unit/test_process_codicehi.py +3 -3
- imap_processing/tests/ialirt/unit/test_process_codicelo.py +3 -10
- imap_processing/tests/ialirt/unit/test_process_ephemeris.py +4 -4
- imap_processing/tests/ialirt/unit/test_process_hit.py +3 -3
- imap_processing/tests/ialirt/unit/test_process_swapi.py +24 -16
- imap_processing/tests/ialirt/unit/test_process_swe.py +115 -7
- imap_processing/tests/idex/conftest.py +72 -7
- imap_processing/tests/idex/test_data/imap_idex_l0_raw_20241206_v001.pkts +0 -0
- imap_processing/tests/idex/test_data/imap_idex_l0_raw_20250108_v001.pkts +0 -0
- imap_processing/tests/idex/test_idex_l0.py +33 -11
- imap_processing/tests/idex/test_idex_l1a.py +50 -23
- imap_processing/tests/idex/test_idex_l1b.py +104 -25
- imap_processing/tests/idex/test_idex_l2a.py +48 -32
- imap_processing/tests/idex/test_idex_l2b.py +93 -0
- imap_processing/tests/lo/test_lo_l1a.py +3 -3
- imap_processing/tests/lo/test_lo_l1b.py +371 -6
- imap_processing/tests/lo/test_lo_l1c.py +1 -1
- imap_processing/tests/lo/test_lo_science.py +6 -7
- imap_processing/tests/lo/test_star_sensor.py +1 -1
- imap_processing/tests/mag/conftest.py +58 -9
- imap_processing/tests/mag/test_mag_decom.py +4 -3
- imap_processing/tests/mag/test_mag_l1a.py +13 -7
- imap_processing/tests/mag/test_mag_l1b.py +9 -9
- imap_processing/tests/mag/test_mag_l1c.py +151 -47
- imap_processing/tests/mag/test_mag_l2.py +130 -0
- imap_processing/tests/mag/test_mag_validation.py +144 -7
- imap_processing/tests/mag/validation/L1c/T013/mag-l1b-l1c-t013-magi-normal-in.csv +1217 -0
- imap_processing/tests/mag/validation/L1c/T013/mag-l1b-l1c-t013-magi-normal-out.csv +1857 -0
- imap_processing/tests/mag/validation/L1c/T013/mag-l1b-l1c-t013-mago-normal-in.csv +1217 -0
- imap_processing/tests/mag/validation/L1c/T013/mag-l1b-l1c-t013-mago-normal-out.csv +1857 -0
- imap_processing/tests/mag/validation/L1c/T014/mag-l1b-l1c-t014-magi-normal-in.csv +1217 -0
- imap_processing/tests/mag/validation/L1c/T014/mag-l1b-l1c-t014-magi-normal-out.csv +1793 -0
- imap_processing/tests/mag/validation/L1c/T014/mag-l1b-l1c-t014-mago-normal-in.csv +1217 -0
- imap_processing/tests/mag/validation/L1c/T014/mag-l1b-l1c-t014-mago-normal-out.csv +1793 -0
- imap_processing/tests/mag/validation/L1c/T015/mag-l1b-l1c-t015-magi-burst-in.csv +2561 -0
- imap_processing/tests/mag/validation/L1c/T015/mag-l1b-l1c-t015-magi-normal-in.csv +961 -0
- imap_processing/tests/mag/validation/L1c/T015/mag-l1b-l1c-t015-magi-normal-out.csv +1539 -0
- imap_processing/tests/mag/validation/L1c/T015/mag-l1b-l1c-t015-mago-normal-in.csv +1921 -0
- imap_processing/tests/mag/validation/L1c/T015/mag-l1b-l1c-t015-mago-normal-out.csv +2499 -0
- imap_processing/tests/mag/validation/L1c/T016/mag-l1b-l1c-t016-magi-normal-in.csv +865 -0
- imap_processing/tests/mag/validation/L1c/T016/mag-l1b-l1c-t016-magi-normal-out.csv +1196 -0
- imap_processing/tests/mag/validation/L1c/T016/mag-l1b-l1c-t016-mago-normal-in.csv +1729 -0
- imap_processing/tests/mag/validation/L1c/T016/mag-l1b-l1c-t016-mago-normal-out.csv +3053 -0
- imap_processing/tests/mag/validation/L2/imap_mag_l1b_norm-mago_20251017_v002.cdf +0 -0
- imap_processing/tests/mag/validation/calibration/imap_mag_l2-calibration-matrices_20251017_v004.cdf +0 -0
- imap_processing/tests/mag/validation/calibration/imap_mag_l2-offsets-norm_20251017_20251017_v001.cdf +0 -0
- imap_processing/tests/spacecraft/test_quaternions.py +1 -1
- imap_processing/tests/spice/test_data/fake_repoint_data.csv +4 -4
- imap_processing/tests/spice/test_data/fake_spin_data.csv +11 -11
- imap_processing/tests/spice/test_geometry.py +3 -3
- imap_processing/tests/spice/test_kernels.py +1 -200
- imap_processing/tests/spice/test_pointing_frame.py +185 -0
- imap_processing/tests/spice/test_repoint.py +20 -10
- imap_processing/tests/spice/test_spin.py +50 -9
- imap_processing/tests/spice/test_time.py +14 -0
- imap_processing/tests/swapi/lut/imap_swapi_esa-unit-conversion_20250211_v000.csv +73 -0
- imap_processing/tests/swapi/lut/imap_swapi_lut-notes_20250211_v000.csv +1025 -0
- imap_processing/tests/swapi/test_swapi_l1.py +7 -9
- imap_processing/tests/swapi/test_swapi_l2.py +180 -8
- imap_processing/tests/swe/lut/checker-board-indices.csv +24 -0
- imap_processing/tests/swe/lut/imap_swe_esa-lut_20250301_v000.csv +385 -0
- imap_processing/tests/swe/lut/imap_swe_l1b-in-flight-cal_20240510_20260716_v000.csv +3 -0
- imap_processing/tests/swe/test_swe_l1a.py +6 -6
- imap_processing/tests/swe/test_swe_l1a_science.py +3 -3
- imap_processing/tests/swe/test_swe_l1b.py +162 -24
- imap_processing/tests/swe/test_swe_l2.py +82 -102
- imap_processing/tests/test_cli.py +171 -88
- imap_processing/tests/test_utils.py +2 -1
- imap_processing/tests/ultra/data/mock_data.py +49 -21
- imap_processing/tests/ultra/unit/conftest.py +53 -70
- imap_processing/tests/ultra/unit/test_badtimes.py +2 -4
- imap_processing/tests/ultra/unit/test_cullingmask.py +4 -6
- imap_processing/tests/ultra/unit/test_de.py +3 -10
- imap_processing/tests/ultra/unit/test_decom_apid_880.py +27 -76
- imap_processing/tests/ultra/unit/test_decom_apid_881.py +15 -16
- imap_processing/tests/ultra/unit/test_decom_apid_883.py +12 -10
- imap_processing/tests/ultra/unit/test_decom_apid_896.py +202 -55
- imap_processing/tests/ultra/unit/test_lookup_utils.py +23 -1
- imap_processing/tests/ultra/unit/test_spacecraft_pset.py +3 -4
- imap_processing/tests/ultra/unit/test_ultra_l1a.py +84 -307
- imap_processing/tests/ultra/unit/test_ultra_l1b.py +30 -12
- imap_processing/tests/ultra/unit/test_ultra_l1b_annotated.py +2 -2
- imap_processing/tests/ultra/unit/test_ultra_l1b_culling.py +4 -1
- imap_processing/tests/ultra/unit/test_ultra_l1b_extended.py +163 -29
- imap_processing/tests/ultra/unit/test_ultra_l1c.py +5 -5
- imap_processing/tests/ultra/unit/test_ultra_l1c_pset_bins.py +32 -43
- imap_processing/tests/ultra/unit/test_ultra_l2.py +230 -0
- imap_processing/ultra/constants.py +1 -1
- imap_processing/ultra/l0/decom_tools.py +21 -34
- imap_processing/ultra/l0/decom_ultra.py +168 -204
- imap_processing/ultra/l0/ultra_utils.py +152 -136
- imap_processing/ultra/l1a/ultra_l1a.py +55 -243
- imap_processing/ultra/l1b/badtimes.py +1 -4
- imap_processing/ultra/l1b/cullingmask.py +2 -6
- imap_processing/ultra/l1b/de.py +62 -47
- imap_processing/ultra/l1b/extendedspin.py +8 -4
- imap_processing/ultra/l1b/lookup_utils.py +72 -9
- imap_processing/ultra/l1b/ultra_l1b.py +3 -8
- imap_processing/ultra/l1b/ultra_l1b_culling.py +4 -4
- imap_processing/ultra/l1b/ultra_l1b_extended.py +236 -78
- imap_processing/ultra/l1c/histogram.py +2 -6
- imap_processing/ultra/l1c/spacecraft_pset.py +2 -4
- imap_processing/ultra/l1c/ultra_l1c.py +1 -5
- imap_processing/ultra/l1c/ultra_l1c_pset_bins.py +107 -60
- imap_processing/ultra/l2/ultra_l2.py +299 -0
- imap_processing/ultra/lookup_tables/Angular_Profiles_FM45_LeftSlit.csv +526 -0
- imap_processing/ultra/lookup_tables/Angular_Profiles_FM45_RightSlit.csv +526 -0
- imap_processing/ultra/lookup_tables/Angular_Profiles_FM90_LeftSlit.csv +526 -0
- imap_processing/ultra/lookup_tables/Angular_Profiles_FM90_RightSlit.csv +526 -0
- imap_processing/ultra/lookup_tables/FM45_Startup1_ULTRA_IMGPARAMS_20240719.csv +2 -2
- imap_processing/ultra/lookup_tables/FM90_Startup1_ULTRA_IMGPARAMS_20240719.csv +2 -0
- imap_processing/ultra/packet_definitions/README.md +38 -0
- imap_processing/ultra/packet_definitions/ULTRA_SCI_COMBINED.xml +15302 -482
- imap_processing/ultra/utils/ultra_l1_utils.py +13 -12
- imap_processing/utils.py +1 -1
- {imap_processing-0.12.0.dist-info → imap_processing-0.13.0.dist-info}/METADATA +3 -2
- {imap_processing-0.12.0.dist-info → imap_processing-0.13.0.dist-info}/RECORD +264 -225
- imap_processing/hi/l1b/hi_eng_unit_convert_table.csv +0 -154
- imap_processing/mag/imap_mag_sdc-configuration_v001.yaml +0 -6
- imap_processing/mag/l1b/__init__.py +0 -0
- imap_processing/swe/l1b/swe_esa_lookup_table.csv +0 -1441
- imap_processing/swe/l1b/swe_l1b_science.py +0 -699
- imap_processing/tests/swe/test_swe_l1b_science.py +0 -103
- imap_processing/ultra/lookup_tables/dps_sensitivity45.cdf +0 -0
- imap_processing/ultra/lookup_tables/ultra_90_dps_exposure_compressed.cdf +0 -0
- /imap_processing/idex/packet_definitions/{idex_packet_definition.xml → idex_science_packet_definition.xml} +0 -0
- /imap_processing/tests/ialirt/{test_data → data}/l0/20240827095047_SWE_IALIRT_packet.bin +0 -0
- /imap_processing/tests/ialirt/{test_data → data}/l0/461971383-404.bin +0 -0
- /imap_processing/tests/ialirt/{test_data → data}/l0/461971384-405.bin +0 -0
- /imap_processing/tests/ialirt/{test_data → data}/l0/461971385-406.bin +0 -0
- /imap_processing/tests/ialirt/{test_data → data}/l0/461971386-407.bin +0 -0
- /imap_processing/tests/ialirt/{test_data → data}/l0/461971387-408.bin +0 -0
- /imap_processing/tests/ialirt/{test_data → data}/l0/461971388-409.bin +0 -0
- /imap_processing/tests/ialirt/{test_data → data}/l0/461971389-410.bin +0 -0
- /imap_processing/tests/ialirt/{test_data → data}/l0/461971390-411.bin +0 -0
- /imap_processing/tests/ialirt/{test_data → data}/l0/461971391-412.bin +0 -0
- /imap_processing/tests/ialirt/{test_data → data}/l0/BinLog CCSDS_FRAG_TLM_20240826_152323Z_IALIRT_data_for_SDC.bin +0 -0
- /imap_processing/tests/ialirt/{test_data → data}/l0/IALiRT Raw Packet Telemetry.txt +0 -0
- /imap_processing/tests/ialirt/{test_data → data}/l0/apid01152.tlm +0 -0
- /imap_processing/tests/ialirt/{test_data → data}/l0/eu_SWP_IAL_20240826_152033.csv +0 -0
- /imap_processing/tests/ialirt/{test_data → data}/l0/hi_fsw_view_1_ccsds.bin +0 -0
- /imap_processing/tests/ialirt/{test_data → data}/l0/hit_ialirt_sample.ccsds +0 -0
- /imap_processing/tests/ialirt/{test_data → data}/l0/hit_ialirt_sample.csv +0 -0
- /imap_processing/tests/ialirt/{test_data → data}/l0/idle_export_eu.SWE_IALIRT_20240827_093852.csv +0 -0
- /imap_processing/tests/ialirt/{test_data → data}/l0/imap_codice_l1a_hi-ialirt_20240523200000_v0.0.0.cdf +0 -0
- /imap_processing/tests/ialirt/{test_data → data}/l0/imap_codice_l1a_lo-ialirt_20241110193700_v0.0.0.cdf +0 -0
- /imap_processing/tests/ialirt/{test_data → data}/l0/sample_decoded_i-alirt_data.csv +0 -0
- /imap_processing/tests/mag/validation/{imap_calibration_mag_20240229_v01.cdf → calibration/imap_mag_l1b-calibration_20240229_v001.cdf} +0 -0
- /imap_processing/{swe/l1b/engineering_unit_convert_table.csv → tests/swe/lut/imap_swe_eu-conversion_20240510_v000.csv} +0 -0
- {imap_processing-0.12.0.dist-info → imap_processing-0.13.0.dist-info}/LICENSE +0 -0
- {imap_processing-0.12.0.dist-info → imap_processing-0.13.0.dist-info}/WHEEL +0 -0
- {imap_processing-0.12.0.dist-info → imap_processing-0.13.0.dist-info}/entry_points.txt +0 -0
|
@@ -1,94 +1,29 @@
|
|
|
1
1
|
import pytest
|
|
2
2
|
|
|
3
3
|
from imap_processing import imap_module_directory
|
|
4
|
-
from imap_processing.decom import decom_packets
|
|
5
4
|
from imap_processing.utils import packet_file_to_datasets
|
|
6
5
|
|
|
7
6
|
IALIRT_PACKET_LENGTH = 1464
|
|
8
7
|
|
|
9
8
|
|
|
10
|
-
@pytest.
|
|
11
|
-
def
|
|
12
|
-
"""
|
|
13
|
-
return imap_module_directory / "ialirt" / "packet_definitions" / "ialirt.xml"
|
|
9
|
+
@pytest.mark.external_test_data
|
|
10
|
+
def test_generate_xarray():
|
|
11
|
+
"""Checks that xarray data is properly generated."""
|
|
14
12
|
|
|
15
|
-
|
|
16
|
-
@pytest.fixture()
|
|
17
|
-
def binary_packet_path(tmp_path):
|
|
18
|
-
"""
|
|
19
|
-
Creates a binary file from the text packet data, which is more representative
|
|
20
|
-
of the actual operational environment. The binary file is deleted after the
|
|
21
|
-
test session.
|
|
22
|
-
"""
|
|
13
|
+
apid = 478
|
|
23
14
|
packet_path = (
|
|
24
|
-
imap_module_directory
|
|
25
|
-
/ "tests"
|
|
26
|
-
/ "ialirt"
|
|
27
|
-
/ "test_data"
|
|
28
|
-
/ "l0"
|
|
29
|
-
/ "IALiRT Raw Packet Telemetry.txt"
|
|
15
|
+
imap_module_directory / "tests" / "ialirt" / "data" / "l0" / "apid_478.bin"
|
|
30
16
|
)
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
# Split the line by semicolons
|
|
38
|
-
# Discard the first value since it is only a counter
|
|
39
|
-
hex_values = line.strip().split(";")[1:]
|
|
40
|
-
# Convert hex to binary
|
|
41
|
-
binary_data = bytearray.fromhex("".join(hex_values))
|
|
42
|
-
binary_file.write(binary_data)
|
|
43
|
-
assert len(binary_data) * 8 == IALIRT_PACKET_LENGTH
|
|
44
|
-
|
|
45
|
-
return binary_file_path
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
@pytest.fixture()
|
|
49
|
-
def decom_packets_data(binary_packet_path, xtce_ialirt_path):
|
|
50
|
-
"""Read packet data from file using decom_packets"""
|
|
51
|
-
data_packet_list = decom_packets(binary_packet_path, xtce_ialirt_path)
|
|
52
|
-
return data_packet_list
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
def test_length(decom_packets_data):
|
|
56
|
-
"""Test if total packets in data file is correct"""
|
|
57
|
-
total_packets = 32
|
|
58
|
-
assert len(decom_packets_data) == total_packets
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
def test_enumerated(decom_packets_data):
|
|
62
|
-
"""Test if enumerated values derived correctly"""
|
|
63
|
-
|
|
64
|
-
for packet in decom_packets_data:
|
|
65
|
-
assert packet["SC_SWAPI_STATUS"] == "NOT_OPERATIONAL"
|
|
66
|
-
assert packet["SC_MAG_STATUS"] == "NOT_OPERATIONAL"
|
|
67
|
-
assert packet["SC_HIT_STATUS"] == "NOT_OPERATIONAL"
|
|
68
|
-
assert packet["SC_CODICE_STATUS"] == "NOT_OPERATIONAL"
|
|
69
|
-
assert packet["SC_LO_STATUS"] == "NOT_OPERATIONAL"
|
|
70
|
-
assert packet["SC_HI_45_STATUS"] == "NOT_OPERATIONAL"
|
|
71
|
-
assert packet["SC_HI_90_STATUS"] == "NOT_OPERATIONAL"
|
|
72
|
-
assert packet["SC_ULTRA_45_STATUS"] == "NOT_OPERATIONAL"
|
|
73
|
-
assert packet["SC_ULTRA_90_STATUS"] == "NOT_OPERATIONAL"
|
|
74
|
-
assert packet["SC_SWE_STATUS"] == "NOT_OPERATIONAL"
|
|
75
|
-
assert packet["SC_IDEX_STATUS"] == "NOT_OPERATIONAL"
|
|
76
|
-
assert packet["SC_GLOWS_STATUS"] == "NOT_OPERATIONAL"
|
|
77
|
-
assert packet["SC_SPINPERIODVALID"] == "INVALID"
|
|
78
|
-
assert packet["SC_SPINPHASEVALID"] == "INVALID"
|
|
79
|
-
assert packet["SC_ATTITUDE"] == "SUNSENSOR"
|
|
80
|
-
assert packet["SC_CATBEDHEATERFLAG"] == "ON"
|
|
81
|
-
assert packet["SC_AUTONOMY"] == "OPERATIONAL"
|
|
82
|
-
assert packet["HIT_STATUS"] == "OFF-NOMINAL"
|
|
83
|
-
assert packet["SWE_NOM_FLAG"] == "OFF-NOMINAL"
|
|
84
|
-
assert packet["SWE_OPS_FLAG"] == "NON-HVSCI"
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
def test_generate_xarray(binary_packet_path, xtce_ialirt_path, decom_packets_data):
|
|
88
|
-
"""This function checks that all instrument parameters are correct length."""
|
|
89
|
-
|
|
90
|
-
apid = 478
|
|
91
|
-
xarray_data = packet_file_to_datasets(binary_packet_path, xtce_ialirt_path)[apid]
|
|
17
|
+
xtce_ialirt_path = (
|
|
18
|
+
imap_module_directory / "ialirt" / "packet_definitions" / "ialirt.xml"
|
|
19
|
+
)
|
|
20
|
+
xarray_data = packet_file_to_datasets(
|
|
21
|
+
packet_path, xtce_ialirt_path, use_derived_value=True
|
|
22
|
+
)[apid]
|
|
92
23
|
|
|
93
24
|
for key in xarray_data.keys():
|
|
94
|
-
assert len(xarray_data[key]) ==
|
|
25
|
+
assert len(xarray_data[key]) == 44429
|
|
26
|
+
|
|
27
|
+
total_packet_length = xarray_data["pkt_len"].values[0] + 7
|
|
28
|
+
# Convert to bytes
|
|
29
|
+
assert total_packet_length * 8 == IALIRT_PACKET_LENGTH
|
|
@@ -7,7 +7,7 @@ import xarray as xr
|
|
|
7
7
|
from imap_processing.ialirt.utils.grouping import filter_valid_groups, find_groups
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
@pytest.fixture
|
|
10
|
+
@pytest.fixture
|
|
11
11
|
def test_data():
|
|
12
12
|
"""Creates grouped data for filter_valid_groups test."""
|
|
13
13
|
epoch = np.arange(12)
|
|
@@ -39,7 +39,7 @@ def test_data():
|
|
|
39
39
|
return test_data
|
|
40
40
|
|
|
41
41
|
|
|
42
|
-
@pytest.fixture
|
|
42
|
+
@pytest.fixture
|
|
43
43
|
def grouped_data():
|
|
44
44
|
"""Creates grouped data for filter_valid_groups test."""
|
|
45
45
|
epoch = np.arange(12)
|
|
@@ -1,15 +1,22 @@
|
|
|
1
|
+
"""Tests to support I-ALiRT MAG packet parsing."""
|
|
2
|
+
|
|
1
3
|
import numpy as np
|
|
2
4
|
import pandas as pd
|
|
3
5
|
import pytest
|
|
4
6
|
import xarray as xr
|
|
5
7
|
|
|
6
8
|
from imap_processing import imap_module_directory
|
|
9
|
+
from imap_processing.cdf.utils import load_cdf
|
|
7
10
|
from imap_processing.ialirt.l0.parse_mag import (
|
|
11
|
+
calculate_l1b,
|
|
8
12
|
extract_magnetic_vectors,
|
|
9
13
|
get_pkt_counter,
|
|
10
14
|
get_status_data,
|
|
11
15
|
get_time,
|
|
12
|
-
|
|
16
|
+
process_packet,
|
|
17
|
+
)
|
|
18
|
+
from imap_processing.mag.l1b.mag_l1b import (
|
|
19
|
+
retrieve_matrix_from_l1b_calibration,
|
|
13
20
|
)
|
|
14
21
|
from imap_processing.utils import packet_file_to_datasets
|
|
15
22
|
|
|
@@ -23,7 +30,7 @@ def xtce_mag_path():
|
|
|
23
30
|
@pytest.fixture(scope="session")
|
|
24
31
|
def binary_packet_path():
|
|
25
32
|
"""Returns the paths to the binary packets."""
|
|
26
|
-
directory = imap_module_directory / "tests" / "ialirt" / "
|
|
33
|
+
directory = imap_module_directory / "tests" / "ialirt" / "data" / "l0"
|
|
27
34
|
filenames = [
|
|
28
35
|
"461971383-404.bin",
|
|
29
36
|
"461971384-405.bin",
|
|
@@ -45,7 +52,7 @@ def mag_test_data():
|
|
|
45
52
|
imap_module_directory
|
|
46
53
|
/ "tests"
|
|
47
54
|
/ "ialirt"
|
|
48
|
-
/ "
|
|
55
|
+
/ "data"
|
|
49
56
|
/ "l0"
|
|
50
57
|
/ "sample_decoded_i-alirt_data.csv"
|
|
51
58
|
)
|
|
@@ -54,7 +61,7 @@ def mag_test_data():
|
|
|
54
61
|
return data
|
|
55
62
|
|
|
56
63
|
|
|
57
|
-
@pytest.fixture
|
|
64
|
+
@pytest.fixture
|
|
58
65
|
def xarray_data(binary_packet_path, xtce_mag_path):
|
|
59
66
|
"""Create xarray data for multiple packets."""
|
|
60
67
|
apid = 1001
|
|
@@ -68,7 +75,7 @@ def xarray_data(binary_packet_path, xtce_mag_path):
|
|
|
68
75
|
return merged_xarray_data
|
|
69
76
|
|
|
70
77
|
|
|
71
|
-
@pytest.fixture
|
|
78
|
+
@pytest.fixture
|
|
72
79
|
def grouped_data():
|
|
73
80
|
"""Creates grouped data for tests."""
|
|
74
81
|
epoch = np.arange(12)
|
|
@@ -107,6 +114,15 @@ def grouped_data():
|
|
|
107
114
|
return grouped_data
|
|
108
115
|
|
|
109
116
|
|
|
117
|
+
@pytest.fixture
|
|
118
|
+
def calibration_dataset():
|
|
119
|
+
"""Returns the calibration data."""
|
|
120
|
+
calibration_dataset = load_cdf(
|
|
121
|
+
imap_module_directory / "mag" / "l1b" / "imap_calibration_mag_20240229_v01.cdf"
|
|
122
|
+
)
|
|
123
|
+
return calibration_dataset
|
|
124
|
+
|
|
125
|
+
|
|
110
126
|
def test_get_pkt_counter(xarray_data):
|
|
111
127
|
"""Tests the get_pkt_counter function."""
|
|
112
128
|
status_values = xarray_data["mag_status"].values
|
|
@@ -127,15 +143,24 @@ def test_get_status_data(xarray_data, mag_test_data):
|
|
|
127
143
|
assert status_data[key] == matching_row[key.upper()].values[0]
|
|
128
144
|
|
|
129
145
|
|
|
130
|
-
def test_get_time(grouped_data):
|
|
146
|
+
def test_get_time(grouped_data, calibration_dataset):
|
|
131
147
|
"""Tests the get_time function."""
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
148
|
+
|
|
149
|
+
calibration_matrix_mago, time_shift_mago = retrieve_matrix_from_l1b_calibration(
|
|
150
|
+
calibration_dataset, is_mago=True
|
|
151
|
+
)
|
|
152
|
+
calibration_matrix_magi, time_shift_magi = retrieve_matrix_from_l1b_calibration(
|
|
153
|
+
calibration_dataset, is_mago=False
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
time_data = get_time(
|
|
157
|
+
grouped_data, 1, np.array([0, 1, 2, 3]), time_shift_mago, time_shift_magi
|
|
158
|
+
)
|
|
159
|
+
|
|
160
|
+
assert time_data["pri_coarsetm"] == 461971386
|
|
161
|
+
assert time_data["pri_fintm"] == 1500
|
|
162
|
+
assert time_data["sec_coarsetm"] == 461971386
|
|
163
|
+
assert time_data["sec_fintm"] == 1503
|
|
139
164
|
|
|
140
165
|
|
|
141
166
|
def test_extract_magnetic_vectors():
|
|
@@ -156,13 +181,43 @@ def test_extract_magnetic_vectors():
|
|
|
156
181
|
}
|
|
157
182
|
|
|
158
183
|
|
|
159
|
-
def
|
|
184
|
+
def test_calculate_l1b(grouped_data, xarray_data, calibration_dataset):
|
|
185
|
+
"""Tests the calculate_l1b function."""
|
|
186
|
+
|
|
187
|
+
pkt_counter = np.array([0.0, 1.0, 2.0, 3.0])
|
|
188
|
+
|
|
189
|
+
science_data = {
|
|
190
|
+
"pri_x": 1.0,
|
|
191
|
+
"pri_y": 2.0,
|
|
192
|
+
"pri_z": 3.0,
|
|
193
|
+
"sec_x": 4.0,
|
|
194
|
+
"sec_y": 5.0,
|
|
195
|
+
"sec_z": 6.0,
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
status_data = {
|
|
199
|
+
"fob_range": 1,
|
|
200
|
+
"fib_range": 1,
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
vec_mago, vec_magi, time_data = calculate_l1b(
|
|
204
|
+
grouped_data, 0, pkt_counter, science_data, status_data, calibration_dataset
|
|
205
|
+
)
|
|
206
|
+
|
|
207
|
+
assert vec_mago.shape == (4,)
|
|
208
|
+
assert vec_magi.shape == (4,)
|
|
209
|
+
assert "primary_epoch" in time_data
|
|
210
|
+
assert "secondary_epoch" in time_data
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
def test_process_packet(xarray_data, mag_test_data, calibration_dataset):
|
|
160
214
|
"""Tests the parse_packet function."""
|
|
161
|
-
parsed_packets =
|
|
215
|
+
parsed_packets = process_packet(xarray_data, calibration_dataset)
|
|
162
216
|
|
|
163
217
|
for packet in parsed_packets:
|
|
164
218
|
index = packet["pri_coarsetm"] == mag_test_data["PRI_COARSETM"]
|
|
165
219
|
matching_rows = mag_test_data[index]
|
|
166
220
|
|
|
167
221
|
for key in packet.keys():
|
|
168
|
-
|
|
222
|
+
if key.upper() in matching_rows.keys():
|
|
223
|
+
assert packet[key] == matching_rows[key.upper()].values[0]
|
|
@@ -26,7 +26,7 @@ def binary_packet_path():
|
|
|
26
26
|
imap_module_directory
|
|
27
27
|
/ "tests"
|
|
28
28
|
/ "ialirt"
|
|
29
|
-
/ "
|
|
29
|
+
/ "data"
|
|
30
30
|
/ "l0"
|
|
31
31
|
/ "hi_fsw_view_1_ccsds.bin"
|
|
32
32
|
)
|
|
@@ -39,7 +39,7 @@ def codicehi_validation_data():
|
|
|
39
39
|
imap_module_directory
|
|
40
40
|
/ "tests"
|
|
41
41
|
/ "ialirt"
|
|
42
|
-
/ "
|
|
42
|
+
/ "data"
|
|
43
43
|
/ "l0"
|
|
44
44
|
/ "imap_codice_l1a_hi-ialirt_20240523200000_v0.0.0.cdf"
|
|
45
45
|
)
|
|
@@ -48,7 +48,7 @@ def codicehi_validation_data():
|
|
|
48
48
|
return data
|
|
49
49
|
|
|
50
50
|
|
|
51
|
-
@pytest.fixture
|
|
51
|
+
@pytest.fixture
|
|
52
52
|
def codicehi_test_data(binary_packet_path, xtce_codicehi_path):
|
|
53
53
|
"""Create xarray data"""
|
|
54
54
|
apid = 1168
|
|
@@ -22,14 +22,7 @@ def xtce_codicelo_path():
|
|
|
22
22
|
@pytest.fixture(scope="session")
|
|
23
23
|
def binary_packet_path():
|
|
24
24
|
"""Returns the xtce directory."""
|
|
25
|
-
return
|
|
26
|
-
imap_module_directory
|
|
27
|
-
/ "tests"
|
|
28
|
-
/ "ialirt"
|
|
29
|
-
/ "test_data"
|
|
30
|
-
/ "l0"
|
|
31
|
-
/ "apid01152.tlm"
|
|
32
|
-
)
|
|
25
|
+
return imap_module_directory / "tests" / "ialirt" / "data" / "l0" / "apid01152.tlm"
|
|
33
26
|
|
|
34
27
|
|
|
35
28
|
@pytest.fixture(scope="session")
|
|
@@ -39,7 +32,7 @@ def codicelo_validation_data():
|
|
|
39
32
|
imap_module_directory
|
|
40
33
|
/ "tests"
|
|
41
34
|
/ "ialirt"
|
|
42
|
-
/ "
|
|
35
|
+
/ "data"
|
|
43
36
|
/ "l0"
|
|
44
37
|
/ "imap_codice_l1a_lo-ialirt_20241110193700_v0.0.0.cdf"
|
|
45
38
|
)
|
|
@@ -48,7 +41,7 @@ def codicelo_validation_data():
|
|
|
48
41
|
return data
|
|
49
42
|
|
|
50
43
|
|
|
51
|
-
@pytest.fixture
|
|
44
|
+
@pytest.fixture
|
|
52
45
|
def codicelo_test_data(binary_packet_path, xtce_codicelo_path):
|
|
53
46
|
"""Create xarray data"""
|
|
54
47
|
apid = 1152
|
|
@@ -7,7 +7,7 @@ from imap_processing.ialirt import process_ephemeris
|
|
|
7
7
|
from imap_processing.spice.time import str_to_et
|
|
8
8
|
|
|
9
9
|
|
|
10
|
-
@pytest.mark.external_kernel
|
|
10
|
+
@pytest.mark.external_kernel
|
|
11
11
|
def test_calculate_doppler(furnish_kernels):
|
|
12
12
|
"""
|
|
13
13
|
Test the calculate_doppler() function.
|
|
@@ -43,7 +43,7 @@ def test_calculate_doppler(furnish_kernels):
|
|
|
43
43
|
assert doppler_result is not None
|
|
44
44
|
|
|
45
45
|
|
|
46
|
-
@pytest.mark.external_kernel
|
|
46
|
+
@pytest.mark.external_kernel
|
|
47
47
|
def test_latitude_longitude_to_ecef(furnish_kernels):
|
|
48
48
|
"""
|
|
49
49
|
Test the latitude_longitude_to_ecef() function.
|
|
@@ -63,7 +63,7 @@ def test_latitude_longitude_to_ecef(furnish_kernels):
|
|
|
63
63
|
)
|
|
64
64
|
|
|
65
65
|
|
|
66
|
-
@pytest.mark.external_kernel
|
|
66
|
+
@pytest.mark.external_kernel
|
|
67
67
|
def test_calculate_azimuth_and_elevation(furnish_kernels):
|
|
68
68
|
"""
|
|
69
69
|
Test the calculate_azimuth_and_elevation() function.
|
|
@@ -101,7 +101,7 @@ def test_calculate_azimuth_and_elevation(furnish_kernels):
|
|
|
101
101
|
assert len(azimuth_result) == len(observation_time)
|
|
102
102
|
|
|
103
103
|
|
|
104
|
-
@pytest.mark.external_kernel
|
|
104
|
+
@pytest.mark.external_kernel
|
|
105
105
|
def test_build_output(furnish_kernels):
|
|
106
106
|
"""
|
|
107
107
|
Test the build_output() function.
|
|
@@ -25,7 +25,7 @@ def binary_packet_path():
|
|
|
25
25
|
imap_module_directory
|
|
26
26
|
/ "tests"
|
|
27
27
|
/ "ialirt"
|
|
28
|
-
/ "
|
|
28
|
+
/ "data"
|
|
29
29
|
/ "l0"
|
|
30
30
|
/ "hit_ialirt_sample.ccsds"
|
|
31
31
|
)
|
|
@@ -38,7 +38,7 @@ def hit_test_data():
|
|
|
38
38
|
imap_module_directory
|
|
39
39
|
/ "tests"
|
|
40
40
|
/ "ialirt"
|
|
41
|
-
/ "
|
|
41
|
+
/ "data"
|
|
42
42
|
/ "l0"
|
|
43
43
|
/ "hit_ialirt_sample.csv"
|
|
44
44
|
)
|
|
@@ -47,7 +47,7 @@ def hit_test_data():
|
|
|
47
47
|
return data
|
|
48
48
|
|
|
49
49
|
|
|
50
|
-
@pytest.fixture
|
|
50
|
+
@pytest.fixture
|
|
51
51
|
def xarray_data(binary_packet_path, xtce_hit_path):
|
|
52
52
|
"""Create xarray data"""
|
|
53
53
|
apid = 1253
|
|
@@ -3,6 +3,7 @@ import pandas as pd
|
|
|
3
3
|
import pytest
|
|
4
4
|
|
|
5
5
|
from imap_processing import imap_module_directory
|
|
6
|
+
from imap_processing.ialirt.l0.process_swapi import process_swapi_ialirt
|
|
6
7
|
from imap_processing.utils import packet_file_to_datasets
|
|
7
8
|
|
|
8
9
|
|
|
@@ -14,12 +15,12 @@ def xtce_swapi_path():
|
|
|
14
15
|
|
|
15
16
|
@pytest.fixture(scope="session")
|
|
16
17
|
def binary_packet_path():
|
|
17
|
-
"""Returns the
|
|
18
|
+
"""Returns the binary packet path."""
|
|
18
19
|
return (
|
|
19
20
|
imap_module_directory
|
|
20
21
|
/ "tests"
|
|
21
22
|
/ "ialirt"
|
|
22
|
-
/ "
|
|
23
|
+
/ "data"
|
|
23
24
|
/ "l0"
|
|
24
25
|
/ "BinLog CCSDS_FRAG_TLM_20240826_152323Z_IALIRT_data_for_SDC.bin"
|
|
25
26
|
)
|
|
@@ -27,12 +28,12 @@ def binary_packet_path():
|
|
|
27
28
|
|
|
28
29
|
@pytest.fixture(scope="session")
|
|
29
30
|
def swapi_test_data():
|
|
30
|
-
"""Returns the
|
|
31
|
+
"""Returns the l0 validation dataframe."""
|
|
31
32
|
data_path = (
|
|
32
33
|
imap_module_directory
|
|
33
34
|
/ "tests"
|
|
34
35
|
/ "ialirt"
|
|
35
|
-
/ "
|
|
36
|
+
/ "data"
|
|
36
37
|
/ "l0"
|
|
37
38
|
/ "eu_SWP_IAL_20240826_152033.csv"
|
|
38
39
|
)
|
|
@@ -41,34 +42,34 @@ def swapi_test_data():
|
|
|
41
42
|
return data
|
|
42
43
|
|
|
43
44
|
|
|
44
|
-
@pytest.fixture
|
|
45
|
+
@pytest.fixture
|
|
45
46
|
def xarray_data(binary_packet_path, xtce_swapi_path):
|
|
46
|
-
"""Create xarray
|
|
47
|
-
apid = 1187
|
|
47
|
+
"""Create SWAPI xarray dataset for testing."""
|
|
48
48
|
|
|
49
49
|
xarray_data = packet_file_to_datasets(
|
|
50
50
|
binary_packet_path, xtce_swapi_path, use_derived_value=True
|
|
51
|
-
)[
|
|
51
|
+
)[1187]
|
|
52
52
|
return xarray_data
|
|
53
53
|
|
|
54
54
|
|
|
55
55
|
def test_decom_packets(xarray_data, swapi_test_data):
|
|
56
|
-
"""
|
|
56
|
+
"""Check that all instrument parameters are accounted for after decom."""
|
|
57
57
|
|
|
58
58
|
# TODO: confirm w/ SWAPI team validity_enum flag can be
|
|
59
59
|
# consistent with other instruments.
|
|
60
60
|
fields_to_test = {
|
|
61
61
|
"swapi_flag": "I_ALIRT_STATUS",
|
|
62
62
|
"swapi_reserved": "INST_RES_ST",
|
|
63
|
-
"
|
|
63
|
+
"swapi_seq_number": "SEQ_NUMBER",
|
|
64
64
|
"swapi_version": "SWEEP_TABLE",
|
|
65
|
-
"
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"
|
|
65
|
+
"swapi_coin_cnt0": "COIN_CNT0",
|
|
66
|
+
"swapi_coin_cnt1": "COIN_CNT1",
|
|
67
|
+
"swapi_coin_cnt2": "COIN_CNT2",
|
|
68
|
+
"swapi_coin_cnt3": "COIN_CNT3",
|
|
69
|
+
"swapi_coin_cnt4": "COIN_CNT4",
|
|
70
|
+
"swapi_coin_cnt5": "COIN_CNT5",
|
|
71
71
|
"swapi_spare": "SPARE",
|
|
72
|
+
"swapi_shcoarse": "SHCOARSE",
|
|
72
73
|
}
|
|
73
74
|
_, index, test_index = np.intersect1d(
|
|
74
75
|
xarray_data["swapi_acq"], swapi_test_data["ACQ_TIME"], return_indices=True
|
|
@@ -83,3 +84,10 @@ def test_decom_packets(xarray_data, swapi_test_data):
|
|
|
83
84
|
f"Mismatch found in {xarray_field}: "
|
|
84
85
|
f"actual {actual_values}, expected {expected_values}"
|
|
85
86
|
)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
def test_process_swapi_ialirt(xarray_data):
|
|
90
|
+
"""Placeholder test for the process_swapi_ialirt function."""
|
|
91
|
+
|
|
92
|
+
swapi_result = process_swapi_ialirt(xarray_data)
|
|
93
|
+
assert swapi_result["met"] is not None
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
"""Tests to support I-ALiRT SWE packet parsing."""
|
|
2
|
+
|
|
1
3
|
from unittest.mock import patch
|
|
2
4
|
|
|
3
5
|
import numpy as np
|
|
@@ -7,10 +9,17 @@ import xarray as xr
|
|
|
7
9
|
|
|
8
10
|
from imap_processing import imap_module_directory
|
|
9
11
|
from imap_processing.ialirt.l0.process_swe import (
|
|
12
|
+
average_counts,
|
|
13
|
+
azimuthal_check_counterstreaming,
|
|
14
|
+
compute_bidirectional,
|
|
10
15
|
decompress_counts,
|
|
16
|
+
determine_streaming,
|
|
17
|
+
find_bin_offsets,
|
|
18
|
+
find_min_counts,
|
|
11
19
|
get_ialirt_energies,
|
|
12
20
|
normalize_counts,
|
|
13
21
|
phi_to_bin,
|
|
22
|
+
polar_check_counterstreaming,
|
|
14
23
|
prepare_raw_counts,
|
|
15
24
|
process_swe,
|
|
16
25
|
)
|
|
@@ -34,7 +43,7 @@ def binary_packet_path():
|
|
|
34
43
|
imap_module_directory
|
|
35
44
|
/ "tests"
|
|
36
45
|
/ "ialirt"
|
|
37
|
-
/ "
|
|
46
|
+
/ "data"
|
|
38
47
|
/ "l0"
|
|
39
48
|
/ "20240827095047_SWE_IALIRT_packet.bin"
|
|
40
49
|
)
|
|
@@ -47,7 +56,7 @@ def swe_test_data():
|
|
|
47
56
|
imap_module_directory
|
|
48
57
|
/ "tests"
|
|
49
58
|
/ "ialirt"
|
|
50
|
-
/ "
|
|
59
|
+
/ "data"
|
|
51
60
|
/ "l0"
|
|
52
61
|
/ "idle_export_eu.SWE_IALIRT_20240827_093852.csv"
|
|
53
62
|
)
|
|
@@ -56,7 +65,7 @@ def swe_test_data():
|
|
|
56
65
|
return data
|
|
57
66
|
|
|
58
67
|
|
|
59
|
-
@pytest.fixture
|
|
68
|
+
@pytest.fixture
|
|
60
69
|
def xarray_data(binary_packet_path, xtce_swe_path):
|
|
61
70
|
"""Create xarray data"""
|
|
62
71
|
apid = 1360
|
|
@@ -67,7 +76,7 @@ def xarray_data(binary_packet_path, xtce_swe_path):
|
|
|
67
76
|
return xarray_data
|
|
68
77
|
|
|
69
78
|
|
|
70
|
-
@pytest.fixture
|
|
79
|
+
@pytest.fixture
|
|
71
80
|
def fields_to_test():
|
|
72
81
|
"""Create a dictionary to convert names"""
|
|
73
82
|
fields_to_test = {
|
|
@@ -109,6 +118,25 @@ def fields_to_test():
|
|
|
109
118
|
return fields_to_test
|
|
110
119
|
|
|
111
120
|
|
|
121
|
+
@pytest.fixture
|
|
122
|
+
def summed_half_cycle():
|
|
123
|
+
"""Create test set with known peaks"""
|
|
124
|
+
|
|
125
|
+
summed_half_cycle = np.zeros((8, 30))
|
|
126
|
+
|
|
127
|
+
for i in range(8):
|
|
128
|
+
peak = i + 5
|
|
129
|
+
summed_half_cycle[i, peak] = 100
|
|
130
|
+
summed_half_cycle[i, (peak + 6) % 30] = 60 # +90 offset
|
|
131
|
+
summed_half_cycle[i, (peak + 8) % 30] = 80 # +90 offset
|
|
132
|
+
summed_half_cycle[i, (peak + 14) % 30] = 20 # +180 offset
|
|
133
|
+
summed_half_cycle[i, (peak + 16) % 30] = 40 # +180 offset
|
|
134
|
+
summed_half_cycle[i, (peak - 6) % 30] = 5 # -90 offset
|
|
135
|
+
summed_half_cycle[i, (peak - 8) % 30] = 15 # -90 offset
|
|
136
|
+
|
|
137
|
+
return summed_half_cycle
|
|
138
|
+
|
|
139
|
+
|
|
112
140
|
def test_get_energy():
|
|
113
141
|
"""Tests get_alirt_energies function."""
|
|
114
142
|
energies = get_ialirt_energies()
|
|
@@ -225,7 +253,7 @@ def test_prepare_raw_counts():
|
|
|
225
253
|
assert np.array_equal(raw_counts, expected)
|
|
226
254
|
|
|
227
255
|
|
|
228
|
-
def
|
|
256
|
+
def test_normalize_counts():
|
|
229
257
|
"""Tests normalize_counts function"""
|
|
230
258
|
|
|
231
259
|
# Shape (2, 7, 3) for a small test case
|
|
@@ -283,6 +311,79 @@ def test_norm_counts():
|
|
|
283
311
|
assert np.allclose(norm_counts, expected, atol=1e-9)
|
|
284
312
|
|
|
285
313
|
|
|
314
|
+
def test_find_bin_offsets():
|
|
315
|
+
"""Tests find_bin_offsets function"""
|
|
316
|
+
|
|
317
|
+
peak_bins = np.array([5, 6, 29])
|
|
318
|
+
bins = find_bin_offsets(peak_bins, (2, 3))
|
|
319
|
+
np.testing.assert_array_equal(bins, np.array([[7, 8, 1], [8, 9, 2]]))
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
def test_average_counts(summed_half_cycle):
|
|
323
|
+
"""Tests average_values_and_azimuth function"""
|
|
324
|
+
|
|
325
|
+
# Find the azimuth angle that corresponds to the maximum counts at each energy
|
|
326
|
+
peak_az_bin = np.argmax(summed_half_cycle, axis=1)
|
|
327
|
+
|
|
328
|
+
# Bins +6 and +8 correspond to +90 degrees.
|
|
329
|
+
counts_90 = average_counts(peak_az_bin, summed_half_cycle, (6, 8))
|
|
330
|
+
|
|
331
|
+
assert np.allclose(counts_90, np.full(8, 70), atol=1e-9)
|
|
332
|
+
|
|
333
|
+
|
|
334
|
+
def test_find_min_counts(summed_half_cycle):
|
|
335
|
+
"""Tests find_min_counts function"""
|
|
336
|
+
|
|
337
|
+
cpeak, cmin, counts = find_min_counts(summed_half_cycle)
|
|
338
|
+
np.testing.assert_array_equal(cpeak, np.full(8, 100))
|
|
339
|
+
np.testing.assert_array_equal(cmin, counts[0])
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
def test_determine_streaming_summed_cems():
|
|
343
|
+
"""Tests determine_streaming_summed_cems function."""
|
|
344
|
+
|
|
345
|
+
# Case where streaming should be True
|
|
346
|
+
cpeak = np.array([100, 80, 50, 60])
|
|
347
|
+
cmin = np.array([20, 70, 40, 60])
|
|
348
|
+
counts_180 = np.array([40, 60, 90, 110])
|
|
349
|
+
assert np.array_equal(
|
|
350
|
+
determine_streaming(cpeak, counts_180, cmin), np.array([1, 0, 0, 0])
|
|
351
|
+
)
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
def test_compute_bidirectional():
|
|
355
|
+
"""Tests compute_bidirectional function."""
|
|
356
|
+
|
|
357
|
+
first_half = np.array([1, 0, 0, 0, 1, 0, 0, 0])
|
|
358
|
+
second_half = np.array([1, 0, 0, 0, 1, 0, 0, 0])
|
|
359
|
+
assert compute_bidirectional(first_half, second_half) == (0, 0)
|
|
360
|
+
|
|
361
|
+
first_half = np.array([1, 1, 1, 0, 0, 0, 0, 0])
|
|
362
|
+
second_half = np.array([0, 0, 0, 0, 0, 0, 0, 0])
|
|
363
|
+
assert compute_bidirectional(first_half, second_half) == (1, 0)
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
def test_azimuthal_check_counterstreaming(summed_half_cycle):
|
|
367
|
+
"""Tests azimuthal_check_counterstreaming function."""
|
|
368
|
+
|
|
369
|
+
bde = azimuthal_check_counterstreaming(summed_half_cycle, summed_half_cycle)
|
|
370
|
+
|
|
371
|
+
assert bde == (1, 1)
|
|
372
|
+
|
|
373
|
+
|
|
374
|
+
def test_polar_check_counterstreaming():
|
|
375
|
+
"""Tests polar_check_counterstreaming function."""
|
|
376
|
+
|
|
377
|
+
# cem0 (cem1) and cem6 (cem7) have high values
|
|
378
|
+
# cem2, cem3, cem4 (cem3 to cem5) are low and used for cmin
|
|
379
|
+
row = np.array([100, 20, 5, 5, 5, 20, 100])
|
|
380
|
+
summed_half = np.tile(row, (8, 1))
|
|
381
|
+
|
|
382
|
+
bde = polar_check_counterstreaming(summed_half, summed_half)
|
|
383
|
+
|
|
384
|
+
assert bde == (1, 1)
|
|
385
|
+
|
|
386
|
+
|
|
286
387
|
@patch(
|
|
287
388
|
"imap_processing.ialirt.l0.process_swe.read_in_flight_cal_data",
|
|
288
389
|
return_value=pd.DataFrame(
|
|
@@ -306,6 +407,13 @@ def test_process_swe(mock_read_cal, swe_test_data, fields_to_test):
|
|
|
306
407
|
swe_test_data.index.name = "epoch"
|
|
307
408
|
ds = swe_test_data.to_xarray()
|
|
308
409
|
ds["src_seq_ctr"] = ("epoch", np.arange(len(ds["swe_shcoarse"])))
|
|
309
|
-
|
|
410
|
+
in_flight_cal_file = (
|
|
411
|
+
imap_module_directory
|
|
412
|
+
/ "tests/swe/lut/imap_swe_l1b-in-flight-cal_20240510_20260716_v000.csv"
|
|
413
|
+
)
|
|
414
|
+
swe_data = process_swe(ds, [in_flight_cal_file])
|
|
415
|
+
|
|
416
|
+
# TODO: add tests with test data here.
|
|
310
417
|
|
|
311
|
-
|
|
418
|
+
# Check that all groups in the data are accounted for.
|
|
419
|
+
assert len(swe_data) == 912 // 60
|