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,14 +1,22 @@
|
|
|
1
|
+
from unittest import mock
|
|
2
|
+
|
|
1
3
|
import numpy as np
|
|
2
4
|
import pytest
|
|
3
5
|
import xarray as xr
|
|
4
6
|
|
|
5
7
|
from imap_processing import imap_module_directory
|
|
6
8
|
from imap_processing.idex.idex_l1a import PacketParser
|
|
9
|
+
from imap_processing.idex.idex_l1b import idex_l1b
|
|
10
|
+
from imap_processing.idex.idex_l2a import idex_l2a
|
|
7
11
|
|
|
8
12
|
TEST_DATA_PATH = imap_module_directory / "tests" / "idex" / "test_data"
|
|
9
13
|
|
|
10
|
-
|
|
14
|
+
TEST_L0_FILE_SCI = TEST_DATA_PATH / "imap_idex_l0_raw_20231218_v001.pkts"
|
|
15
|
+
TEST_L0_FILE_EVT = TEST_DATA_PATH / "imap_idex_l0_raw_20250108_v001.pkts" # 1418
|
|
16
|
+
TEST_L0_FILE_CATLST = TEST_DATA_PATH / "imap_idex_l0_raw_20241206_v001.pkts" # 1419
|
|
17
|
+
|
|
11
18
|
L1A_EXAMPLE_FILE = TEST_DATA_PATH / "idex_l1a_validation_file.h5"
|
|
19
|
+
L1B_EXAMPLE_FILE = TEST_DATA_PATH / "idex_l1b_validation_file.h5"
|
|
12
20
|
|
|
13
21
|
pytestmark = pytest.mark.external_test_data
|
|
14
22
|
|
|
@@ -26,19 +34,43 @@ SPICE_ARRAYS = [
|
|
|
26
34
|
]
|
|
27
35
|
|
|
28
36
|
|
|
29
|
-
@pytest.fixture
|
|
30
|
-
def
|
|
37
|
+
@pytest.fixture
|
|
38
|
+
def decom_test_data_sci() -> xr.Dataset:
|
|
31
39
|
"""Return a ``xarray`` dataset containing test data.
|
|
32
40
|
|
|
33
41
|
Returns
|
|
34
42
|
-------
|
|
35
43
|
dataset : xarray.Dataset
|
|
36
|
-
A ``xarray`` dataset containing the test data
|
|
44
|
+
A ``xarray`` dataset containing the science test data
|
|
45
|
+
"""
|
|
46
|
+
return PacketParser(TEST_L0_FILE_SCI).data[0]
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
@pytest.fixture
|
|
50
|
+
def decom_test_data_catlst() -> xr.Dataset:
|
|
51
|
+
"""Return a ``xarray`` dataset containing the catalog list summary data.
|
|
52
|
+
|
|
53
|
+
Returns
|
|
54
|
+
-------
|
|
55
|
+
dataset : xarray.Dataset
|
|
56
|
+
A ``xarray`` dataset containing the catalog list summary data.
|
|
57
|
+
"""
|
|
58
|
+
return PacketParser(TEST_L0_FILE_CATLST).data[0]
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
@pytest.fixture
|
|
62
|
+
def decom_test_data_evt() -> xr.Dataset:
|
|
63
|
+
"""Return a ``xarray`` dataset containing the event log data.
|
|
64
|
+
|
|
65
|
+
Returns
|
|
66
|
+
-------
|
|
67
|
+
dataset : xarray.Dataset
|
|
68
|
+
A ``xarray`` dataset containing the event log data.
|
|
37
69
|
"""
|
|
38
|
-
return PacketParser(
|
|
70
|
+
return PacketParser(TEST_L0_FILE_EVT).data[0]
|
|
39
71
|
|
|
40
72
|
|
|
41
|
-
@pytest.fixture
|
|
73
|
+
@pytest.fixture
|
|
42
74
|
def l1a_example_data(_download_test_data):
|
|
43
75
|
"""
|
|
44
76
|
Pytest fixture to load example L1A data (produced by the IDEX team) for testing.
|
|
@@ -51,6 +83,39 @@ def l1a_example_data(_download_test_data):
|
|
|
51
83
|
return load_hdf_file(L1A_EXAMPLE_FILE)
|
|
52
84
|
|
|
53
85
|
|
|
86
|
+
@pytest.fixture
|
|
87
|
+
def l2a_dataset(decom_test_data_sci: xr.Dataset) -> xr.Dataset:
|
|
88
|
+
"""Return a ``xarray`` dataset containing test data.
|
|
89
|
+
|
|
90
|
+
Returns
|
|
91
|
+
-------
|
|
92
|
+
dataset : xr.Dataset
|
|
93
|
+
A ``xarray`` dataset containing the test data
|
|
94
|
+
"""
|
|
95
|
+
spin_phase_angles = xr.DataArray(
|
|
96
|
+
np.random.randint(0, 360, len(decom_test_data_sci.epoch))
|
|
97
|
+
)
|
|
98
|
+
with mock.patch(
|
|
99
|
+
"imap_processing.idex.idex_l1b.get_spice_data",
|
|
100
|
+
return_value={"spin_phase": spin_phase_angles},
|
|
101
|
+
):
|
|
102
|
+
dataset = idex_l2a(idex_l1b(decom_test_data_sci))
|
|
103
|
+
return dataset
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
@pytest.fixture
|
|
107
|
+
def l1b_example_data(_download_test_data):
|
|
108
|
+
"""
|
|
109
|
+
Pytest fixture to load example L1B data (produced by the IDEX team) for testing.
|
|
110
|
+
|
|
111
|
+
Returns
|
|
112
|
+
-------
|
|
113
|
+
dict
|
|
114
|
+
A dictionary containing the 6 waveform and telemetry arrays
|
|
115
|
+
"""
|
|
116
|
+
return load_hdf_file(L1B_EXAMPLE_FILE)
|
|
117
|
+
|
|
118
|
+
|
|
54
119
|
def get_spice_data_side_effect_func(l1a_ds, idex_attrs):
|
|
55
120
|
# Create a mock dictionary of spice arrays
|
|
56
121
|
|
|
@@ -95,7 +160,7 @@ def load_hdf_file(path: str) -> xr.Dataset:
|
|
|
95
160
|
ds = tree.to_dataset()
|
|
96
161
|
# Sort dimensions by shape. The high sampling time dimension is always less
|
|
97
162
|
# than the low sampling time.
|
|
98
|
-
dims = [k for k, v in sorted(ds.
|
|
163
|
+
dims = [k for k, v in sorted(ds.sizes.items(), key=lambda item: item[1])]
|
|
99
164
|
ds = ds.rename({dims[0]: "time_low", dims[1]: "time_high"}).expand_dims(
|
|
100
165
|
{"event": [event_num]}
|
|
101
166
|
)
|
|
Binary file
|
|
Binary file
|
|
@@ -6,38 +6,38 @@ import xarray as xr
|
|
|
6
6
|
from imap_processing import imap_module_directory
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
def test_idex_decom_length(
|
|
9
|
+
def test_idex_decom_length(decom_test_data_sci: xr.Dataset):
|
|
10
10
|
"""Verify that the output data has the expected number of data variables.
|
|
11
11
|
|
|
12
12
|
Parameters
|
|
13
13
|
----------
|
|
14
|
-
|
|
14
|
+
decom_test_data_sci : xarray.Dataset
|
|
15
15
|
The dataset to test with
|
|
16
16
|
"""
|
|
17
|
-
assert len(
|
|
17
|
+
assert len(decom_test_data_sci) == 110
|
|
18
18
|
|
|
19
19
|
|
|
20
|
-
def test_idex_decom_event_num(
|
|
20
|
+
def test_idex_decom_event_num(decom_test_data_sci: xr.Dataset):
|
|
21
21
|
"""Verify that 14 impacts were gathered by the test data.
|
|
22
22
|
|
|
23
23
|
Parameters
|
|
24
24
|
----------
|
|
25
|
-
|
|
25
|
+
decom_test_data_sci : xarray.Dataset
|
|
26
26
|
The dataset to test with
|
|
27
27
|
"""
|
|
28
|
-
for var in
|
|
29
|
-
if "epoch" in
|
|
30
|
-
assert len(
|
|
28
|
+
for var in decom_test_data_sci:
|
|
29
|
+
if "epoch" in decom_test_data_sci[var].dims:
|
|
30
|
+
assert len(decom_test_data_sci[var]) == 14
|
|
31
31
|
|
|
32
32
|
|
|
33
|
-
def test_idex_tof_high_data(
|
|
33
|
+
def test_idex_tof_high_data(decom_test_data_sci: xr.Dataset):
|
|
34
34
|
"""Verify that a sample of the data is correct.
|
|
35
35
|
|
|
36
36
|
``impact_14_tof_high_data.txt`` has been verified correct by the IDEX team
|
|
37
37
|
|
|
38
38
|
Parameters
|
|
39
39
|
----------
|
|
40
|
-
|
|
40
|
+
decom_test_data_sci : xarray.Dataset
|
|
41
41
|
The dataset to test with
|
|
42
42
|
"""
|
|
43
43
|
|
|
@@ -45,4 +45,26 @@ def test_idex_tof_high_data(decom_test_data: xr.Dataset):
|
|
|
45
45
|
f"{imap_module_directory}/tests/idex/test_data/impact_14_tof_high_data.txt"
|
|
46
46
|
) as f:
|
|
47
47
|
data = np.array([int(line.rstrip("\n")) for line in f])
|
|
48
|
-
assert (
|
|
48
|
+
assert (decom_test_data_sci["TOF_High"][13].data == data).all()
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def test_catlst_event_num(decom_test_data_catlst: xr.Dataset):
|
|
52
|
+
"""Verify that a sample of the data is correct.
|
|
53
|
+
|
|
54
|
+
Parameters
|
|
55
|
+
----------
|
|
56
|
+
decom_test_data_catlst : xarray.Dataset
|
|
57
|
+
The dataset to test with
|
|
58
|
+
"""
|
|
59
|
+
assert len(decom_test_data_catlst["epoch"]) == 1
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def test_evt_event_num(decom_test_data_evt: xr.Dataset):
|
|
63
|
+
"""Verify that a sample of the data is correct.
|
|
64
|
+
|
|
65
|
+
Parameters
|
|
66
|
+
----------
|
|
67
|
+
decom_test_data_evt : xarray.Dataset
|
|
68
|
+
The dataset to test with
|
|
69
|
+
"""
|
|
70
|
+
assert len(decom_test_data_evt["epoch"]) == 28
|
|
@@ -14,44 +14,44 @@ from imap_processing.idex.decode import _decode_sub_frame, read_bits, rice_decod
|
|
|
14
14
|
from imap_processing.idex.idex_l1a import PacketParser
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
def test_idex_cdf_file(
|
|
17
|
+
def test_idex_cdf_file(decom_test_data_sci: xr.Dataset):
|
|
18
18
|
"""Verify the CDF file can be created with no errors.
|
|
19
19
|
|
|
20
20
|
Parameters
|
|
21
21
|
----------
|
|
22
|
-
|
|
22
|
+
decom_test_data_sci : xarray.Dataset
|
|
23
23
|
The dataset to test with
|
|
24
24
|
"""
|
|
25
|
-
file_name = write_cdf(
|
|
25
|
+
file_name = write_cdf(decom_test_data_sci)
|
|
26
26
|
|
|
27
27
|
assert file_name.exists()
|
|
28
|
-
assert file_name.name == "imap_idex_l1a_sci-
|
|
28
|
+
assert file_name.name == "imap_idex_l1a_sci-1week_20231218_v999.cdf"
|
|
29
29
|
|
|
30
30
|
|
|
31
|
-
def test_bad_cdf_attributes(
|
|
31
|
+
def test_bad_cdf_attributes(decom_test_data_sci: xr.Dataset):
|
|
32
32
|
"""Ensure an ``ISTPError`` is raised when using bad CDF attributes.
|
|
33
33
|
|
|
34
34
|
Parameters
|
|
35
35
|
----------
|
|
36
|
-
|
|
36
|
+
decom_test_data_sci : xarray.Dataset
|
|
37
37
|
The dataset to test with
|
|
38
38
|
"""
|
|
39
|
-
tof_catdesc =
|
|
40
|
-
del
|
|
39
|
+
tof_catdesc = decom_test_data_sci["TOF_High"].attrs["CATDESC"]
|
|
40
|
+
del decom_test_data_sci["TOF_High"].attrs["CATDESC"]
|
|
41
41
|
|
|
42
42
|
with pytest.raises(ISTPError):
|
|
43
|
-
write_cdf(
|
|
43
|
+
write_cdf(decom_test_data_sci, istp=True, terminate_on_warning=True)
|
|
44
44
|
|
|
45
45
|
# Add attributes back so future tests do not fail
|
|
46
|
-
|
|
46
|
+
decom_test_data_sci["TOF_High"].attrs["CATDESC"] = tof_catdesc
|
|
47
47
|
|
|
48
48
|
|
|
49
|
-
def test_bad_cdf_file_data(
|
|
49
|
+
def test_bad_cdf_file_data(decom_test_data_sci: xr.Dataset):
|
|
50
50
|
"""Ensure an ``ISTPError`` is raised when using bad data.
|
|
51
51
|
|
|
52
52
|
Parameters
|
|
53
53
|
----------
|
|
54
|
-
|
|
54
|
+
decom_test_data_sci : xarray.Dataset
|
|
55
55
|
The dataset to test with
|
|
56
56
|
"""
|
|
57
57
|
bad_data_attrs = {
|
|
@@ -75,22 +75,22 @@ def test_bad_cdf_file_data(decom_test_data: xr.Dataset):
|
|
|
75
75
|
dims=("bad_data"),
|
|
76
76
|
attrs=bad_data_attrs,
|
|
77
77
|
)
|
|
78
|
-
|
|
78
|
+
decom_test_data_sci["Bad_data"] = bad_data_xr
|
|
79
79
|
|
|
80
80
|
with pytest.raises(ISTPError):
|
|
81
|
-
write_cdf(
|
|
81
|
+
write_cdf(decom_test_data_sci, istp=True, terminate_on_warning=True)
|
|
82
82
|
|
|
83
|
-
del
|
|
83
|
+
del decom_test_data_sci["Bad_data"]
|
|
84
84
|
|
|
85
85
|
|
|
86
|
-
def test_idex_tof_high_data_from_cdf(
|
|
86
|
+
def test_idex_tof_high_data_from_cdf(decom_test_data_sci: xr.Dataset):
|
|
87
87
|
"""Verify that a sample of the data is correct inside the CDF file.
|
|
88
88
|
|
|
89
89
|
``impact_14_tof_high_data.txt`` has been verified correct by the IDEX team
|
|
90
90
|
|
|
91
91
|
Parameters
|
|
92
92
|
----------
|
|
93
|
-
|
|
93
|
+
decom_test_data_sci : xarray.Dataset
|
|
94
94
|
The dataset to test with
|
|
95
95
|
"""
|
|
96
96
|
with open(
|
|
@@ -98,13 +98,14 @@ def test_idex_tof_high_data_from_cdf(decom_test_data: xr.Dataset):
|
|
|
98
98
|
) as f:
|
|
99
99
|
data = np.array([int(line.rstrip()) for line in f])
|
|
100
100
|
|
|
101
|
-
file_name = write_cdf(
|
|
101
|
+
file_name = write_cdf(decom_test_data_sci)
|
|
102
102
|
l1_data = load_cdf(file_name)
|
|
103
103
|
assert (l1_data["TOF_High"][13].data == data).all()
|
|
104
104
|
|
|
105
105
|
|
|
106
|
+
@pytest.mark.external_test_data
|
|
106
107
|
def test_validate_l1a_idex_data_variables(
|
|
107
|
-
|
|
108
|
+
decom_test_data_sci: xr.Dataset, l1a_example_data: xr.Dataset
|
|
108
109
|
):
|
|
109
110
|
"""
|
|
110
111
|
Verify that each of the 6 waveform and telemetry arrays are equal to the
|
|
@@ -113,7 +114,7 @@ def test_validate_l1a_idex_data_variables(
|
|
|
113
114
|
|
|
114
115
|
Parameters
|
|
115
116
|
----------
|
|
116
|
-
|
|
117
|
+
decom_test_data_sci : xarray.Dataset
|
|
117
118
|
The dataset to test with
|
|
118
119
|
l1a_example_data: xarray.Dataset
|
|
119
120
|
A dataset containing the 6 waveform and telemetry arrays
|
|
@@ -141,7 +142,7 @@ def test_validate_l1a_idex_data_variables(
|
|
|
141
142
|
cdf_var = match_variables.get(var, var.lower())
|
|
142
143
|
|
|
143
144
|
np.testing.assert_array_equal(
|
|
144
|
-
|
|
145
|
+
decom_test_data_sci[cdf_var],
|
|
145
146
|
l1a_example_data[var],
|
|
146
147
|
f"The array '{cdf_var}' does not equal the expected example "
|
|
147
148
|
f"array '{var}' produced by the IDEX team",
|
|
@@ -157,8 +158,8 @@ def test_compressed_packet():
|
|
|
157
158
|
compressed = Path(f"{test_data_dir}/compressed_2023_102_14_24_55.pkts")
|
|
158
159
|
non_compressed = Path(f"{test_data_dir}/non_compressed_2023_102_14_22_26.pkts")
|
|
159
160
|
|
|
160
|
-
decompressed = PacketParser(compressed
|
|
161
|
-
expected = PacketParser(non_compressed
|
|
161
|
+
decompressed = PacketParser(compressed).data[0]
|
|
162
|
+
expected = PacketParser(non_compressed).data[0]
|
|
162
163
|
|
|
163
164
|
waveforms = [
|
|
164
165
|
"TOF_High",
|
|
@@ -289,3 +290,29 @@ def test_decode_sub_frame_psel_3():
|
|
|
289
290
|
bstring = warmup1 + warmup2 + residual_1 + residual_2 + residual_3
|
|
290
291
|
ints, bp = _decode_sub_frame(bstring, bp=0, psel=psel, k=k, n_bits=10)
|
|
291
292
|
assert ints == [1, 2, 4, 1, 5]
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
def test_cdf_creation_catlst(decom_test_data_catlst: xr.Dataset):
|
|
296
|
+
"""Verify that a sample of the data can be written to a cdf without errors.
|
|
297
|
+
|
|
298
|
+
Parameters
|
|
299
|
+
----------
|
|
300
|
+
decom_test_data_catlst : xarray.Dataset
|
|
301
|
+
The dataset to test with
|
|
302
|
+
"""
|
|
303
|
+
filename = write_cdf(decom_test_data_catlst)
|
|
304
|
+
|
|
305
|
+
assert filename.name == "imap_idex_l1a_catlst_20241206_v999.cdf"
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
def test_cdf_creation_evt(decom_test_data_evt: xr.Dataset):
|
|
309
|
+
"""Verify that a sample of the data can be written to a cdf without errors.
|
|
310
|
+
|
|
311
|
+
Parameters
|
|
312
|
+
----------
|
|
313
|
+
decom_test_data_evt : xarray.Dataset
|
|
314
|
+
The dataset to test with
|
|
315
|
+
"""
|
|
316
|
+
filename = write_cdf(decom_test_data_evt)
|
|
317
|
+
|
|
318
|
+
assert filename.name == "imap_idex_l1a_evt_20250108_v999.cdf"
|
|
@@ -20,9 +20,9 @@ from imap_processing.tests.idex import conftest
|
|
|
20
20
|
from imap_processing.tests.idex.conftest import get_spice_data_side_effect_func
|
|
21
21
|
|
|
22
22
|
|
|
23
|
-
@pytest.fixture
|
|
23
|
+
@pytest.fixture
|
|
24
24
|
@mock.patch("imap_processing.idex.idex_l1b.get_spice_data")
|
|
25
|
-
def l1b_dataset(mock_get_spice_data,
|
|
25
|
+
def l1b_dataset(mock_get_spice_data, decom_test_data_sci: xr.Dataset) -> xr.Dataset:
|
|
26
26
|
"""Return a ``xarray`` dataset containing test data.
|
|
27
27
|
|
|
28
28
|
Returns
|
|
@@ -32,12 +32,11 @@ def l1b_dataset(mock_get_spice_data, decom_test_data: xr.Dataset) -> xr.Dataset:
|
|
|
32
32
|
"""
|
|
33
33
|
|
|
34
34
|
mock_get_spice_data.side_effect = get_spice_data_side_effect_func
|
|
35
|
-
|
|
36
|
-
dataset = idex_l1b(decom_test_data, data_version="001")
|
|
35
|
+
dataset = idex_l1b(decom_test_data_sci)
|
|
37
36
|
return dataset
|
|
38
37
|
|
|
39
38
|
|
|
40
|
-
@pytest.fixture
|
|
39
|
+
@pytest.fixture
|
|
41
40
|
def mock_spice_functions():
|
|
42
41
|
"""Mock spice functions to avoid loading kernels."""
|
|
43
42
|
with (
|
|
@@ -56,7 +55,7 @@ def mock_spice_functions():
|
|
|
56
55
|
yield mock_state, mock_pointing, mock_lon
|
|
57
56
|
|
|
58
57
|
|
|
59
|
-
def
|
|
58
|
+
def test_l1b_logical_source(l1b_dataset: xr.Dataset):
|
|
60
59
|
"""Tests that the ``idex_l1b`` function generates datasets
|
|
61
60
|
with the expected logical source.
|
|
62
61
|
|
|
@@ -81,7 +80,7 @@ def test_idex_cdf_file(l1b_dataset: xr.Dataset):
|
|
|
81
80
|
file_name = write_cdf(l1b_dataset)
|
|
82
81
|
|
|
83
82
|
assert file_name.exists()
|
|
84
|
-
assert file_name.name == "imap_idex_l1b_sci-
|
|
83
|
+
assert file_name.name == "imap_idex_l1b_sci-1week_20231218_v999.cdf"
|
|
85
84
|
|
|
86
85
|
|
|
87
86
|
def test_idex_waveform_units(l1b_dataset: xr.Dataset):
|
|
@@ -156,27 +155,27 @@ def test_unpack_instrument_settings():
|
|
|
156
155
|
assert np.all(unpacked_dict["test_var1"] == 4)
|
|
157
156
|
|
|
158
157
|
|
|
159
|
-
def test_get_trigger_settings_success(
|
|
158
|
+
def test_get_trigger_settings_success(decom_test_data_sci):
|
|
160
159
|
"""
|
|
161
160
|
Check that the output to 'get_trigger_mode_and_level' matches expected arrays.
|
|
162
161
|
|
|
163
162
|
Parameters
|
|
164
163
|
----------
|
|
165
|
-
|
|
164
|
+
decom_test_data_sci : xarray.Dataset
|
|
166
165
|
L1a dataset
|
|
167
166
|
"""
|
|
168
167
|
# Change the trigger mode and level for the first event to check that output is
|
|
169
168
|
# correct when the modes and levels vary from event to event
|
|
170
|
-
|
|
171
|
-
|
|
169
|
+
decom_test_data_sci["idx__txhdrmgtrigmode"][0] = 1
|
|
170
|
+
decom_test_data_sci["idx__txhdrhgtrigmode"][0] = 0
|
|
172
171
|
|
|
173
|
-
n_epochs = len(
|
|
174
|
-
trigger_settings = get_trigger_mode_and_level(
|
|
172
|
+
n_epochs = len(decom_test_data_sci["epoch"])
|
|
173
|
+
trigger_settings = get_trigger_mode_and_level(decom_test_data_sci)
|
|
175
174
|
|
|
176
175
|
expected_modes = np.full(n_epochs, "HGThreshold")
|
|
177
176
|
expected_modes[0] = "MGThreshold"
|
|
178
177
|
expected_levels = np.full(n_epochs, 0.16762)
|
|
179
|
-
expected_levels[0] = 1023.0
|
|
178
|
+
expected_levels[0] = 1023.0 * 1.13e-2
|
|
180
179
|
|
|
181
180
|
assert (trigger_settings["triggermode"].data == expected_modes).all(), (
|
|
182
181
|
f"The dict entry 'triggermode' values did not match the expected values: "
|
|
@@ -185,22 +184,22 @@ def test_get_trigger_settings_success(decom_test_data):
|
|
|
185
184
|
|
|
186
185
|
assert (trigger_settings["triggerlevel"].data == expected_levels).all(), (
|
|
187
186
|
f"The dict entry 'triggerlevel' values did not match the expected values: "
|
|
188
|
-
f"{expected_levels}. Found: {trigger_settings['
|
|
187
|
+
f"{expected_levels}. Found: {trigger_settings['triggerlevel'].data}"
|
|
189
188
|
)
|
|
190
189
|
|
|
191
190
|
|
|
192
|
-
def test_get_trigger_settings_failure(
|
|
191
|
+
def test_get_trigger_settings_failure(decom_test_data_sci):
|
|
193
192
|
"""
|
|
194
193
|
Check that an error is thrown when there are more than one valid trigger for an
|
|
195
194
|
event
|
|
196
195
|
|
|
197
196
|
Parameters
|
|
198
197
|
----------
|
|
199
|
-
|
|
198
|
+
decom_test_data_sci : xarray.Dataset
|
|
200
199
|
L1a dataset
|
|
201
200
|
"""
|
|
202
|
-
|
|
203
|
-
|
|
201
|
+
decom_test_data_sci["idx__txhdrhgtrigmode"][0] = 1
|
|
202
|
+
decom_test_data_sci["idx__txhdrmgtrigmode"][0] = 2
|
|
204
203
|
|
|
205
204
|
error_ms = (
|
|
206
205
|
"Only one channel can trigger a dust event. Please make sure there is "
|
|
@@ -210,14 +209,14 @@ def test_get_trigger_settings_failure(decom_test_data):
|
|
|
210
209
|
)
|
|
211
210
|
|
|
212
211
|
with pytest.raises(ValueError, match=error_ms):
|
|
213
|
-
get_trigger_mode_and_level(
|
|
212
|
+
get_trigger_mode_and_level(decom_test_data_sci)
|
|
214
213
|
|
|
215
214
|
|
|
216
215
|
@pytest.mark.usefixtures("use_fake_spin_data_for_time")
|
|
217
216
|
def test_get_spice_data(
|
|
218
217
|
mock_spice_functions,
|
|
219
218
|
use_fake_spin_data_for_time,
|
|
220
|
-
|
|
219
|
+
decom_test_data_sci,
|
|
221
220
|
furnish_kernels,
|
|
222
221
|
):
|
|
223
222
|
"""
|
|
@@ -225,11 +224,11 @@ def test_get_spice_data(
|
|
|
225
224
|
|
|
226
225
|
Parameters
|
|
227
226
|
----------
|
|
228
|
-
|
|
227
|
+
decom_test_data_sci : xarray.Dataset
|
|
229
228
|
L1a dataset
|
|
230
229
|
"""
|
|
231
230
|
kernels = ["naif0012.tls"]
|
|
232
|
-
times =
|
|
231
|
+
times = decom_test_data_sci["shcoarse"].data
|
|
233
232
|
use_fake_spin_data_for_time(np.min(times), np.max(times))
|
|
234
233
|
|
|
235
234
|
# Mock attribute manager variable attrs
|
|
@@ -241,8 +240,88 @@ def test_get_spice_data(
|
|
|
241
240
|
):
|
|
242
241
|
mock_attrs.return_value = {"CATDESC": "Test var"}
|
|
243
242
|
|
|
244
|
-
spice_data = get_spice_data(
|
|
243
|
+
spice_data = get_spice_data(decom_test_data_sci, idex_attrs)
|
|
245
244
|
|
|
246
245
|
for array in conftest.SPICE_ARRAYS:
|
|
247
246
|
assert array in spice_data
|
|
248
|
-
assert len(spice_data[array]) == len(
|
|
247
|
+
assert len(spice_data[array]) == len(decom_test_data_sci["epoch"])
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
@pytest.mark.external_test_data
|
|
251
|
+
def test_validate_l1b_idex_data_variables(
|
|
252
|
+
l1b_dataset: xr.Dataset, l1b_example_data: xr.Dataset
|
|
253
|
+
):
|
|
254
|
+
"""
|
|
255
|
+
Verify that each of the 6 waveform and telemetry arrays are equal to the
|
|
256
|
+
corresponding array produced by the IDEX team using the same l0 file.
|
|
257
|
+
|
|
258
|
+
Parameters
|
|
259
|
+
----------
|
|
260
|
+
l1b_dataset : xarray.Dataset
|
|
261
|
+
The dataset to test with
|
|
262
|
+
l1b_example_data: xr.Dataset
|
|
263
|
+
A dataset containing the 6 waveform and telemetry arrays
|
|
264
|
+
"""
|
|
265
|
+
# Lookup table to match the SDC array names to the Idex Team array names
|
|
266
|
+
|
|
267
|
+
match_variables = {
|
|
268
|
+
"TOF L": "TOF_Low",
|
|
269
|
+
"TOF H": "TOF_High",
|
|
270
|
+
"TOF M": "TOF_Mid",
|
|
271
|
+
"Target H": "Target_High",
|
|
272
|
+
"Target L": "Target_Low",
|
|
273
|
+
"Ion Grid": "Ion_Grid",
|
|
274
|
+
"Time (high sampling)": "time_high_sample_rate",
|
|
275
|
+
"Time (low sampling)": "time_low_sample_rate",
|
|
276
|
+
"current_2V5_bus": "current_2p5v_bus",
|
|
277
|
+
"current_3V3_bus": "current_3p3v_bus",
|
|
278
|
+
"current_neg2V5_bus": "current_neg2p5v_bus",
|
|
279
|
+
"voltage_3V3_op_ref": "voltage_3p3_op_ref",
|
|
280
|
+
"voltage_3V3_ref": "voltage_3p3_ref",
|
|
281
|
+
"voltage_pos3V3_bus": "voltage_pos3p3v_bus",
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
# The Engineering data is converting to UTC, and the SDC is converting to J2000,
|
|
285
|
+
# for 'epoch' and 'Timestamp' so this test is using the raw time value 'SCHOARSE' to
|
|
286
|
+
# validate time
|
|
287
|
+
# SPICE data is mocked.
|
|
288
|
+
arrays_to_skip = [
|
|
289
|
+
"Timestamp",
|
|
290
|
+
"Epoch",
|
|
291
|
+
"Pitch",
|
|
292
|
+
"Roll",
|
|
293
|
+
"Yaw",
|
|
294
|
+
"Declination",
|
|
295
|
+
"PositionX",
|
|
296
|
+
"PositionY",
|
|
297
|
+
"PositionZ",
|
|
298
|
+
"VelocityX",
|
|
299
|
+
"VelocityY",
|
|
300
|
+
"VelocityZ",
|
|
301
|
+
"RightAscension",
|
|
302
|
+
]
|
|
303
|
+
# Compare each corresponding variable
|
|
304
|
+
for var in l1b_example_data.data_vars:
|
|
305
|
+
if var not in arrays_to_skip:
|
|
306
|
+
# Get the corresponding array name
|
|
307
|
+
cdf_var = match_variables.get(var, var.lower().replace(".", "p"))
|
|
308
|
+
|
|
309
|
+
warning = (
|
|
310
|
+
f"The array '{cdf_var}' does not equal the expected example array "
|
|
311
|
+
)
|
|
312
|
+
f"'{var}' produced by the IDEX team"
|
|
313
|
+
|
|
314
|
+
if l1b_dataset[cdf_var].dtype == object:
|
|
315
|
+
assert (l1b_dataset[cdf_var].data == l1b_example_data[var]).all(), (
|
|
316
|
+
warning
|
|
317
|
+
)
|
|
318
|
+
|
|
319
|
+
else:
|
|
320
|
+
(
|
|
321
|
+
np.testing.assert_array_almost_equal(
|
|
322
|
+
l1b_dataset[cdf_var].data,
|
|
323
|
+
l1b_example_data[var],
|
|
324
|
+
decimal=1e-04,
|
|
325
|
+
),
|
|
326
|
+
warning,
|
|
327
|
+
)
|