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
|
@@ -7,7 +7,7 @@ import pytest
|
|
|
7
7
|
from imap_processing.ena_maps.utils import spatial_utils
|
|
8
8
|
|
|
9
9
|
# Parameterize with spacings (degrees here):
|
|
10
|
-
valid_spacings = [0.25, 0.5, 1, 5, 10, 20]
|
|
10
|
+
valid_spacings = [0.25, 0.5, 1, 5, 6, 6.666666666666667, 10, 20]
|
|
11
11
|
invalid_spacings = [0, -1, 11]
|
|
12
12
|
invalid_spacings_match_str = [
|
|
13
13
|
"Spacing must be positive valued, non-zero.",
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
from functools import reduce
|
|
2
1
|
from pathlib import Path
|
|
3
2
|
|
|
4
3
|
import pytest
|
|
@@ -10,13 +9,13 @@ from imap_processing.glows.l1b.glows_l1b import glows_l1b
|
|
|
10
9
|
from imap_processing.glows.l2.glows_l2 import glows_l2
|
|
11
10
|
|
|
12
11
|
|
|
13
|
-
@pytest.fixture
|
|
12
|
+
@pytest.fixture
|
|
14
13
|
def packet_path():
|
|
15
14
|
current_directory = Path(__file__).parent
|
|
16
15
|
return current_directory / "validation_data" / "glows_test_packet_20110921_v01.pkts"
|
|
17
16
|
|
|
18
17
|
|
|
19
|
-
@pytest.fixture
|
|
18
|
+
@pytest.fixture
|
|
20
19
|
def decom_test_data(packet_path):
|
|
21
20
|
"""Read test data from file"""
|
|
22
21
|
|
|
@@ -24,31 +23,28 @@ def decom_test_data(packet_path):
|
|
|
24
23
|
return data_packet_list
|
|
25
24
|
|
|
26
25
|
|
|
27
|
-
@pytest.fixture
|
|
26
|
+
@pytest.fixture
|
|
28
27
|
def l1a_test_data(decom_test_data):
|
|
29
28
|
hist_l1a = []
|
|
30
29
|
|
|
31
30
|
for hist in decom_test_data[0]:
|
|
32
31
|
hist_l1a.append(HistogramL1A(hist))
|
|
33
32
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
# Flatten the dictionary to one list of DE values
|
|
37
|
-
de_l1a = reduce(list.__add__, [value for value in de_l1a_dict.values()])
|
|
33
|
+
de_l1a = process_de_l0(decom_test_data[1])
|
|
38
34
|
|
|
39
35
|
return hist_l1a, de_l1a
|
|
40
36
|
|
|
41
37
|
|
|
42
|
-
@pytest.fixture
|
|
38
|
+
@pytest.fixture
|
|
43
39
|
def l1a_dataset(packet_path):
|
|
44
|
-
return glows_l1a(packet_path
|
|
40
|
+
return glows_l1a(packet_path)
|
|
45
41
|
|
|
46
42
|
|
|
47
|
-
@pytest.fixture
|
|
43
|
+
@pytest.fixture
|
|
48
44
|
def l1b_hist_dataset(l1a_dataset):
|
|
49
|
-
return glows_l1b(l1a_dataset[
|
|
45
|
+
return glows_l1b(l1a_dataset[0])
|
|
50
46
|
|
|
51
47
|
|
|
52
|
-
@pytest.fixture
|
|
48
|
+
@pytest.fixture
|
|
53
49
|
def l2_hist_dataset(l1b_datasets):
|
|
54
|
-
return glows_l2(l1b_datasets
|
|
50
|
+
return glows_l2(l1b_datasets)
|
|
@@ -45,14 +45,14 @@ def test_glows_hist_data(decom_test_data):
|
|
|
45
45
|
"ELVAR": 0,
|
|
46
46
|
"EVENTS": 95978,
|
|
47
47
|
}
|
|
48
|
-
for key in expected_data.
|
|
49
|
-
assert getattr(decom_test_data[0][0], key) ==
|
|
48
|
+
for key, expected_val in expected_data.items():
|
|
49
|
+
assert getattr(decom_test_data[0][0], key) == expected_val
|
|
50
50
|
|
|
51
51
|
|
|
52
52
|
def test_glows_de_data(decom_test_data):
|
|
53
53
|
expected_data = {"MET": 54233694, "SEC": 54232338, "LEN": 1, "SEQ": 0}
|
|
54
|
-
for key in expected_data.
|
|
55
|
-
assert getattr(decom_test_data[1][0], key) ==
|
|
54
|
+
for key, expected_val in expected_data.items():
|
|
55
|
+
assert getattr(decom_test_data[1][0], key) == expected_val
|
|
56
56
|
|
|
57
57
|
|
|
58
58
|
def test_bad_header():
|
|
@@ -1,39 +1,18 @@
|
|
|
1
1
|
import dataclasses
|
|
2
|
-
from functools import reduce
|
|
3
2
|
|
|
4
3
|
import numpy as np
|
|
5
|
-
import pytest
|
|
6
4
|
|
|
7
|
-
from imap_processing.glows.l0 import decom_glows
|
|
8
5
|
from imap_processing.glows.l1a.glows_l1a import (
|
|
9
6
|
create_glows_attr_obj,
|
|
10
7
|
generate_de_dataset,
|
|
11
8
|
generate_histogram_dataset,
|
|
12
|
-
process_de_l0,
|
|
13
9
|
)
|
|
14
|
-
from imap_processing.glows.l1a.glows_l1a_data import HistogramL1A
|
|
15
10
|
from imap_processing.glows.utils.constants import TimeTuple
|
|
16
11
|
|
|
17
12
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
histogram_l0, de_l0 = decom_glows.decom_packets(packet_path)
|
|
23
|
-
|
|
24
|
-
histogram_l1a = [HistogramL1A(hist) for hist in histogram_l0]
|
|
25
|
-
|
|
26
|
-
de_l1a_dict = process_de_l0(de_l0)
|
|
27
|
-
|
|
28
|
-
# Flatten the dictionary to one list of DE values
|
|
29
|
-
de_l1a = reduce(list.__add__, [value for value in de_l1a_dict.values()])
|
|
30
|
-
|
|
31
|
-
return (histogram_l1a, de_l1a)
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
def test_generate_histogram_dataset(l1a_data):
|
|
35
|
-
histogram_l1a, _ = l1a_data
|
|
36
|
-
glows_attrs = create_glows_attr_obj("v001")
|
|
13
|
+
def test_generate_histogram_dataset(l1a_test_data):
|
|
14
|
+
histogram_l1a, _ = l1a_test_data
|
|
15
|
+
glows_attrs = create_glows_attr_obj()
|
|
37
16
|
dataset = generate_histogram_dataset(histogram_l1a, glows_attrs)
|
|
38
17
|
|
|
39
18
|
assert (dataset["histogram"].data[0] == histogram_l1a[0].histogram).all()
|
|
@@ -62,9 +41,9 @@ def test_generate_histogram_dataset(l1a_data):
|
|
|
62
41
|
assert (dataset["histogram"].data[i] == histogram_l1a[i].histogram).all()
|
|
63
42
|
|
|
64
43
|
|
|
65
|
-
def test_generate_de_dataset(
|
|
66
|
-
_, de_l1a =
|
|
67
|
-
glows_attrs = create_glows_attr_obj(
|
|
44
|
+
def test_generate_de_dataset(l1a_test_data):
|
|
45
|
+
_, de_l1a = l1a_test_data
|
|
46
|
+
glows_attrs = create_glows_attr_obj()
|
|
68
47
|
dataset = generate_de_dataset(de_l1a, glows_attrs)
|
|
69
48
|
assert len(dataset["epoch"].values) == len(de_l1a)
|
|
70
49
|
|
|
@@ -18,14 +18,14 @@ from imap_processing.glows.utils.constants import DirectEvent, GlowsConstants, T
|
|
|
18
18
|
from imap_processing.spice.time import met_to_ttj2000ns
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
@pytest.fixture
|
|
21
|
+
@pytest.fixture
|
|
22
22
|
def histogram_test_data(decom_test_data):
|
|
23
23
|
histl0 = decom_test_data[0][0]
|
|
24
24
|
hist = HistogramL1A(histl0)
|
|
25
25
|
return hist
|
|
26
26
|
|
|
27
27
|
|
|
28
|
-
@pytest.fixture
|
|
28
|
+
@pytest.fixture
|
|
29
29
|
def de_test_data(decom_test_data):
|
|
30
30
|
del0 = decom_test_data[1][0]
|
|
31
31
|
de = DirectEventL1A(del0)
|
|
@@ -41,19 +41,17 @@ def test_histogram_list(histogram_test_data, decom_test_data):
|
|
|
41
41
|
|
|
42
42
|
|
|
43
43
|
def test_histogram_obs_day(packet_path):
|
|
44
|
-
l1a = glows_l1a(packet_path
|
|
44
|
+
l1a = glows_l1a(packet_path)
|
|
45
45
|
|
|
46
|
-
assert len(l1a) ==
|
|
46
|
+
assert len(l1a) == 2
|
|
47
47
|
|
|
48
48
|
assert "hist" in l1a[0].attrs["Logical_source"]
|
|
49
|
-
assert "hist" in l1a[1].attrs["Logical_source"]
|
|
50
49
|
|
|
51
50
|
# Numbers pulled from the validation data.
|
|
52
51
|
# this test assumes that the "is_night" flag switching from true to false is the
|
|
53
52
|
# start of the observation day.
|
|
54
53
|
|
|
55
54
|
assert np.array_equal(l1a[0]["imap_start_time"].data[0], 54232215.0)
|
|
56
|
-
assert np.array_equal(l1a[1]["imap_start_time"].data[0], 54232455.0)
|
|
57
55
|
|
|
58
56
|
|
|
59
57
|
def test_histogram_attributes(histogram_test_data):
|
|
@@ -270,7 +268,7 @@ def test_combine_direct_events(decom_test_data):
|
|
|
270
268
|
de1 = DirectEventL1A(de0_first)
|
|
271
269
|
assert not de1.direct_events
|
|
272
270
|
if not de1.direct_events:
|
|
273
|
-
de1.
|
|
271
|
+
de1.merge_de_packets(de0_second)
|
|
274
272
|
|
|
275
273
|
assert de1.direct_events
|
|
276
274
|
|
|
@@ -293,7 +291,7 @@ def test_combine_direct_events_with_missing(decom_test_data):
|
|
|
293
291
|
de1 = DirectEventL1A(de0_first)
|
|
294
292
|
assert not de1.direct_events
|
|
295
293
|
if not de1.direct_events:
|
|
296
|
-
de1.
|
|
294
|
+
de1.merge_de_packets(de0_second)
|
|
297
295
|
|
|
298
296
|
assert de1.direct_events
|
|
299
297
|
# Missing one value
|
|
@@ -15,7 +15,7 @@ from imap_processing.glows.l1b.glows_l1b_data import (
|
|
|
15
15
|
)
|
|
16
16
|
|
|
17
17
|
|
|
18
|
-
@pytest.fixture
|
|
18
|
+
@pytest.fixture
|
|
19
19
|
def hist_dataset():
|
|
20
20
|
variables = {
|
|
21
21
|
"flight_software_version": np.zeros((20,)),
|
|
@@ -64,13 +64,13 @@ def hist_dataset():
|
|
|
64
64
|
coords={"epoch": epoch, "bins": bins},
|
|
65
65
|
)
|
|
66
66
|
|
|
67
|
-
for var in variables:
|
|
68
|
-
ds[var] = xr.DataArray(
|
|
67
|
+
for var, data in variables.items():
|
|
68
|
+
ds[var] = xr.DataArray(data, dims=["epoch"], coords={"epoch": epoch})
|
|
69
69
|
|
|
70
70
|
return ds
|
|
71
71
|
|
|
72
72
|
|
|
73
|
-
@pytest.fixture
|
|
73
|
+
@pytest.fixture
|
|
74
74
|
def de_dataset():
|
|
75
75
|
variables = {
|
|
76
76
|
"seq_count_in_pkts_file": np.zeros((20,)),
|
|
@@ -139,13 +139,13 @@ def de_dataset():
|
|
|
139
139
|
},
|
|
140
140
|
)
|
|
141
141
|
|
|
142
|
-
for var in variables:
|
|
143
|
-
ds[var] = xr.DataArray(
|
|
142
|
+
for var, data in variables.items():
|
|
143
|
+
ds[var] = xr.DataArray(data, dims=["epoch"], coords={"epoch": epoch})
|
|
144
144
|
|
|
145
145
|
return ds
|
|
146
146
|
|
|
147
147
|
|
|
148
|
-
@pytest.fixture
|
|
148
|
+
@pytest.fixture
|
|
149
149
|
def ancillary_dict():
|
|
150
150
|
dictionary = {
|
|
151
151
|
"description": "Table for conversion/decoding ancillary parameters collected "
|
|
@@ -289,7 +289,7 @@ def test_process_de(de_dataset, ancillary_dict):
|
|
|
289
289
|
|
|
290
290
|
|
|
291
291
|
def test_glows_l1b(de_dataset, hist_dataset):
|
|
292
|
-
hist_output = glows_l1b(hist_dataset
|
|
292
|
+
hist_output = glows_l1b(hist_dataset)
|
|
293
293
|
|
|
294
294
|
assert hist_output["histogram"].dims == ("epoch", "bins")
|
|
295
295
|
assert hist_output["histogram"].shape == (20, 3600)
|
|
@@ -341,7 +341,7 @@ def test_glows_l1b(de_dataset, hist_dataset):
|
|
|
341
341
|
for key in expected_hist_data:
|
|
342
342
|
assert key in hist_output
|
|
343
343
|
|
|
344
|
-
de_output = glows_l1b(de_dataset
|
|
344
|
+
de_output = glows_l1b(de_dataset)
|
|
345
345
|
|
|
346
346
|
# From table 15 in the algorithm document
|
|
347
347
|
expected_de_data = [
|
|
@@ -364,14 +364,14 @@ def test_glows_l1b(de_dataset, hist_dataset):
|
|
|
364
364
|
|
|
365
365
|
|
|
366
366
|
def test_generate_histogram_dataset(hist_dataset):
|
|
367
|
-
l1b_data = glows_l1b(hist_dataset
|
|
367
|
+
l1b_data = glows_l1b(hist_dataset)
|
|
368
368
|
output_path = write_cdf(l1b_data)
|
|
369
369
|
|
|
370
370
|
assert Path.exists(output_path)
|
|
371
371
|
|
|
372
372
|
|
|
373
373
|
def test_generate_de_dataset(de_dataset):
|
|
374
|
-
l1b_data = glows_l1b(de_dataset
|
|
374
|
+
l1b_data = glows_l1b(de_dataset)
|
|
375
375
|
|
|
376
376
|
output_path = write_cdf(l1b_data)
|
|
377
377
|
|
|
@@ -48,8 +48,8 @@ def test_glows_l1b_ancillary_file():
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
ancillary = AncillaryParameters(fake_good_input)
|
|
51
|
-
for key in fake_good_input:
|
|
52
|
-
assert getattr(ancillary, key) ==
|
|
51
|
+
for key, data in fake_good_input.items():
|
|
52
|
+
assert getattr(ancillary, key) == data
|
|
53
53
|
|
|
54
54
|
fake_bad_input = {
|
|
55
55
|
"version": "0.1",
|
|
@@ -80,7 +80,7 @@ def test_glows_l1b_de():
|
|
|
80
80
|
|
|
81
81
|
|
|
82
82
|
def test_validation_data_histogram(l1a_dataset):
|
|
83
|
-
l1b = [glows_l1b(l1a_dataset[0]
|
|
83
|
+
l1b = [glows_l1b(l1a_dataset[0]), glows_l1b(l1a_dataset[1])]
|
|
84
84
|
end_time = l1b[0]["epoch"].data[-1]
|
|
85
85
|
|
|
86
86
|
validation_data = (
|
|
@@ -147,9 +147,9 @@ def test_validation_data_histogram(l1a_dataset):
|
|
|
147
147
|
|
|
148
148
|
|
|
149
149
|
def test_validation_data_de(l1a_dataset):
|
|
150
|
-
de_data = l1a_dataset[
|
|
150
|
+
de_data = l1a_dataset[1]
|
|
151
151
|
|
|
152
|
-
l1b = glows_l1b(de_data
|
|
152
|
+
l1b = glows_l1b(de_data)
|
|
153
153
|
validation_data = (
|
|
154
154
|
Path(__file__).parent / "validation_data" / "imap_glows_l1b_de_output.json"
|
|
155
155
|
)
|
|
@@ -10,7 +10,7 @@ from imap_processing.glows.l2.glows_l2 import (
|
|
|
10
10
|
from imap_processing.glows.l2.glows_l2_data import DailyLightcurve
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
@pytest.fixture
|
|
13
|
+
@pytest.fixture
|
|
14
14
|
def l1b_hists():
|
|
15
15
|
epoch = xr.DataArray(np.arange(4), name="epoch", dims=["epoch"])
|
|
16
16
|
bins = xr.DataArray(np.arange(5), name="bins", dims=["bins"])
|
|
@@ -29,18 +29,12 @@ def l1b_hists():
|
|
|
29
29
|
|
|
30
30
|
|
|
31
31
|
def test_glows_l2(l1b_hist_dataset):
|
|
32
|
-
l2 = glows_l2(l1b_hist_dataset
|
|
32
|
+
l2 = glows_l2(l1b_hist_dataset)[0]
|
|
33
33
|
assert l2.attrs["Logical_source"] == "imap_glows_l2_hist"
|
|
34
34
|
|
|
35
35
|
assert np.allclose(l2["filter_temperature_average"].values, [57.6], rtol=0.1)
|
|
36
36
|
|
|
37
37
|
|
|
38
|
-
@pytest.mark.skip(reason="Spin table not yet complete")
|
|
39
|
-
def test_split_by_observational_day(l1b_hist_dataset):
|
|
40
|
-
# TODO: Complete test when spin table is complete
|
|
41
|
-
raise NotImplementedError
|
|
42
|
-
|
|
43
|
-
|
|
44
38
|
def test_filter_good_times():
|
|
45
39
|
active_flags = np.ones((17,))
|
|
46
40
|
active_flags[16] = 0
|
|
@@ -48,7 +48,7 @@ def check_sum(bits_size):
|
|
|
48
48
|
return f"{0:0{bits_size}b}"
|
|
49
49
|
|
|
50
50
|
|
|
51
|
-
@pytest.fixture
|
|
51
|
+
@pytest.fixture
|
|
52
52
|
def create_de_data(tmp_path):
|
|
53
53
|
"""Fixture to create fake direct event data. Note that there has been no
|
|
54
54
|
effort to make simulate this data meaning that packets are not self
|
|
@@ -7,7 +7,6 @@ import pytest
|
|
|
7
7
|
import xarray as xr
|
|
8
8
|
|
|
9
9
|
from imap_processing.cdf.utils import load_cdf
|
|
10
|
-
from imap_processing.hi.l1a.hi_l1a import hi_l1a
|
|
11
10
|
from imap_processing.hi.l1b.hi_l1b import (
|
|
12
11
|
compute_coincidence_type_and_tofs,
|
|
13
12
|
compute_hae_coordinates,
|
|
@@ -24,15 +23,14 @@ def test_hi_l1b_hk(hi_l0_test_data_path):
|
|
|
24
23
|
housekeeping L1A as input"""
|
|
25
24
|
# TODO: once things are more stable, check in an L1A HK file as test data
|
|
26
25
|
bin_data_path = hi_l0_test_data_path / "H90_NHK_20241104.bin"
|
|
27
|
-
data_version = "001"
|
|
28
|
-
processed_data = hi_l1a(packet_file_path=bin_data_path, data_version=data_version)
|
|
29
26
|
|
|
30
|
-
|
|
31
|
-
assert
|
|
27
|
+
l1b_datasets = hi_l1b(bin_data_path)
|
|
28
|
+
assert len(l1b_datasets) == 1
|
|
29
|
+
assert l1b_datasets[0].attrs["Logical_source"] == "imap_hi_l1b_90sensor-hk"
|
|
32
30
|
|
|
33
31
|
|
|
34
|
-
@pytest.mark.external_test_data
|
|
35
|
-
@pytest.mark.external_kernel
|
|
32
|
+
@pytest.mark.external_test_data
|
|
33
|
+
@pytest.mark.external_kernel
|
|
36
34
|
@pytest.mark.use_test_metakernel("imap_ena_sim_metakernel.template")
|
|
37
35
|
def test_hi_l1b_de(
|
|
38
36
|
hi_l1_test_data_path, spice_test_data_path, use_fake_spin_data_for_time
|
|
@@ -45,15 +43,15 @@ def test_hi_l1b_de(
|
|
|
45
43
|
hi_l1_test_data_path / "imap_hi_l1a_45sensor-de_20250415_v999.cdf"
|
|
46
44
|
)
|
|
47
45
|
# Process using test data
|
|
48
|
-
data_version = "001"
|
|
49
46
|
l1a_dataset = load_cdf(l1a_test_file_path)
|
|
50
47
|
|
|
51
|
-
|
|
52
|
-
assert
|
|
53
|
-
assert
|
|
48
|
+
l1b_datasets = hi_l1b(l1a_dataset)
|
|
49
|
+
assert len(l1b_datasets) == 1
|
|
50
|
+
assert l1b_datasets[0].attrs["Logical_source"] == "imap_hi_l1b_45sensor-de"
|
|
51
|
+
assert len(l1b_datasets[0].data_vars) == 15
|
|
54
52
|
|
|
55
53
|
|
|
56
|
-
@pytest.fixture
|
|
54
|
+
@pytest.fixture
|
|
57
55
|
def synthetic_trigger_id_and_tof_data():
|
|
58
56
|
"""Create synthetic minimum dataset for testing the
|
|
59
57
|
coincidence_type_and_time_deltas algorithm."""
|
|
@@ -27,21 +27,20 @@ def hi_test_cal_prod_config_path(hi_l1_test_data_path):
|
|
|
27
27
|
@mock.patch("imap_processing.hi.l1c.hi_l1c.generate_pset_dataset")
|
|
28
28
|
def test_hi_l1c(mock_generate_pset_dataset, hi_test_cal_prod_config_path):
|
|
29
29
|
"""Test coverage for hi_l1c function"""
|
|
30
|
-
mock_generate_pset_dataset.return_value = xr.Dataset(
|
|
31
|
-
pset = hi_l1c.hi_l1c(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
assert pset.attrs["Data_version"] == "99"
|
|
30
|
+
mock_generate_pset_dataset.return_value = xr.Dataset()
|
|
31
|
+
pset = hi_l1c.hi_l1c([xr.Dataset(), hi_test_cal_prod_config_path])[0]
|
|
32
|
+
# Empty attributes, global values get added in post-processing
|
|
33
|
+
assert pset.attrs == {}
|
|
35
34
|
|
|
36
35
|
|
|
37
36
|
def test_hi_l1c_not_implemented():
|
|
38
37
|
"""Test coverage for hi_l1c function with unrecognized dependencies"""
|
|
39
38
|
with pytest.raises(NotImplementedError):
|
|
40
|
-
hi_l1c.hi_l1c([None, None]
|
|
39
|
+
hi_l1c.hi_l1c([None, None])
|
|
41
40
|
|
|
42
41
|
|
|
43
|
-
@pytest.mark.external_test_data
|
|
44
|
-
@pytest.mark.external_kernel
|
|
42
|
+
@pytest.mark.external_test_data
|
|
43
|
+
@pytest.mark.external_kernel
|
|
45
44
|
@pytest.mark.use_test_metakernel("imap_ena_sim_metakernel.template")
|
|
46
45
|
def test_generate_pset_dataset(
|
|
47
46
|
hi_l1_test_data_path, hi_test_cal_prod_config_path, use_fake_spin_data_for_time
|
|
@@ -54,9 +53,7 @@ def test_generate_pset_dataset(
|
|
|
54
53
|
l1b_dataset, hi_test_cal_prod_config_path
|
|
55
54
|
)
|
|
56
55
|
|
|
57
|
-
assert l1c_dataset.epoch.data[0] ==
|
|
58
|
-
np.int64
|
|
59
|
-
)
|
|
56
|
+
assert l1c_dataset.epoch.data[0] == l1b_dataset.epoch.data[0].astype(np.int64)
|
|
60
57
|
|
|
61
58
|
np.testing.assert_array_equal(l1c_dataset.despun_z.data.shape, (1, 3))
|
|
62
59
|
np.testing.assert_array_equal(l1c_dataset.hae_latitude.data.shape, (1, 3600))
|
|
@@ -70,7 +67,6 @@ def test_generate_pset_dataset(
|
|
|
70
67
|
np.testing.assert_array_equal(l1c_dataset[var].data.shape, (1, 9, 2, 3600))
|
|
71
68
|
|
|
72
69
|
# Test ISTP compliance by writing CDF
|
|
73
|
-
l1c_dataset.attrs["Data_version"] = 1
|
|
74
70
|
write_cdf(l1c_dataset)
|
|
75
71
|
|
|
76
72
|
|
|
@@ -81,7 +77,7 @@ def test_empty_pset_dataset():
|
|
|
81
77
|
n_calibration_prods = 5
|
|
82
78
|
sensor_str = HIAPID.H90_SCI_DE.sensor
|
|
83
79
|
dataset = hi_l1c.empty_pset_dataset(
|
|
84
|
-
l1b_esa_energy_steps, n_calibration_prods, sensor_str
|
|
80
|
+
100, l1b_esa_energy_steps, n_calibration_prods, sensor_str
|
|
85
81
|
)
|
|
86
82
|
|
|
87
83
|
assert dataset.epoch.size == 1
|
|
@@ -138,7 +134,7 @@ def test_pset_geometry(mock_frame_transform, mock_geom_frame_transform, sensor_s
|
|
|
138
134
|
)
|
|
139
135
|
|
|
140
136
|
|
|
141
|
-
@pytest.mark.external_test_data
|
|
137
|
+
@pytest.mark.external_test_data
|
|
142
138
|
def test_pset_counts(hi_l1_test_data_path, hi_test_cal_prod_config_path):
|
|
143
139
|
"""Test coverage for pset_counts function."""
|
|
144
140
|
l1b_de_path = hi_l1_test_data_path / "imap_hi_l1b_45sensor-de_20250415_v999.cdf"
|
|
@@ -147,6 +143,7 @@ def test_pset_counts(hi_l1_test_data_path, hi_test_cal_prod_config_path):
|
|
|
147
143
|
hi_test_cal_prod_config_path
|
|
148
144
|
)
|
|
149
145
|
empty_pset = hi_l1c.empty_pset_dataset(
|
|
146
|
+
100,
|
|
150
147
|
l1b_dataset.esa_energy_step.data,
|
|
151
148
|
cal_config_df.cal_prod_config.number_of_products,
|
|
152
149
|
HIAPID.H90_SCI_DE.sensor,
|
|
@@ -213,7 +210,7 @@ def test_pset_exposure(
|
|
|
213
210
|
):
|
|
214
211
|
"""Test coverage for pset_exposure function"""
|
|
215
212
|
empty_pset = hi_l1c.empty_pset_dataset(
|
|
216
|
-
np.arange(2) + 1, 2, HIAPID.H90_SCI_DE.sensor
|
|
213
|
+
100, np.arange(2) + 1, 2, HIAPID.H90_SCI_DE.sensor
|
|
217
214
|
)
|
|
218
215
|
# Set the mock of find_second_de_packet_data to return a xr.Dataset
|
|
219
216
|
# with some dummy data. ESA 1 will get binned data once, ESA 2 will get
|
|
@@ -245,7 +242,7 @@ def test_pset_exposure(
|
|
|
245
242
|
# All the setup is done, call the pset_exposure function
|
|
246
243
|
exposure_dict = hi_l1c.pset_exposure(empty_pset.coords, l1b_dataset)
|
|
247
244
|
|
|
248
|
-
# Based on the spin phase and clock_tick mocks, the expected
|
|
245
|
+
# Based on the spin phase and clock_tick mocks, the expected clock ticks are:
|
|
249
246
|
# - Repeated values of 3, 1 for the first half of the spin bins
|
|
250
247
|
# - Repeated values of 3, 2 for the second half of the spin bins
|
|
251
248
|
expected_values = np.stack(
|
|
@@ -253,8 +250,14 @@ def test_pset_exposure(
|
|
|
253
250
|
np.tile([3, 1], hi_l1c.N_SPIN_BINS // 2),
|
|
254
251
|
np.tile([6, 2], hi_l1c.N_SPIN_BINS // 2),
|
|
255
252
|
]
|
|
256
|
-
)[None, :, :]
|
|
257
|
-
|
|
253
|
+
).astype(float)[None, :, :]
|
|
254
|
+
# Convert expected clock ticks to seconds
|
|
255
|
+
expected_values *= DE_CLOCK_TICK_S
|
|
256
|
+
np.testing.assert_allclose(
|
|
257
|
+
exposure_dict["exposure_times"].data,
|
|
258
|
+
expected_values,
|
|
259
|
+
atol=DE_CLOCK_TICK_S / 100,
|
|
260
|
+
)
|
|
258
261
|
|
|
259
262
|
|
|
260
263
|
def test_find_second_de_packet_data():
|
|
@@ -296,7 +299,7 @@ def fake_spin_df():
|
|
|
296
299
|
# Generate some spin periods that vary by a random fraction of a second
|
|
297
300
|
spin_period = np.full(10, 15) + np.random.randn(10) / 10
|
|
298
301
|
d = {
|
|
299
|
-
"
|
|
302
|
+
"spin_start_met": np.add.accumulate(spin_period),
|
|
300
303
|
"spin_period_sec": spin_period,
|
|
301
304
|
}
|
|
302
305
|
spin_df = pd.DataFrame.from_dict(d)
|
|
@@ -310,8 +313,8 @@ def test_get_de_clock_ticks_for_esa_step(fake_spin_df):
|
|
|
310
313
|
# the end spin in the table + 1/2 spin period
|
|
311
314
|
for _, spin_row in fake_spin_df.iloc[8:].iterrows():
|
|
312
315
|
for ccsds_met in np.linspace(
|
|
313
|
-
spin_row.
|
|
314
|
-
spin_row.
|
|
316
|
+
spin_row.spin_start_met,
|
|
317
|
+
spin_row.spin_start_met + np.floor(spin_row.spin_period_sec / 2),
|
|
315
318
|
10,
|
|
316
319
|
):
|
|
317
320
|
clock_tick_mets, clock_tick_weights = (
|
|
@@ -321,7 +324,7 @@ def test_get_de_clock_ticks_for_esa_step(fake_spin_df):
|
|
|
321
324
|
# Verify last weight entry
|
|
322
325
|
exp_final_weight = (
|
|
323
326
|
np.absolute(
|
|
324
|
-
fake_spin_df.
|
|
327
|
+
fake_spin_df.spin_start_met.to_numpy() - clock_tick_mets[-1]
|
|
325
328
|
).min()
|
|
326
329
|
/ DE_CLOCK_TICK_S
|
|
327
330
|
)
|
|
@@ -333,7 +336,7 @@ def test_get_de_clock_ticks_for_esa_step_exceptions(fake_spin_df):
|
|
|
333
336
|
"""Test the exception logic in the get_de_clock_ticks_for_esa_step function."""
|
|
334
337
|
# Test the ccsds_met being > 1/2 spin period past the spin start
|
|
335
338
|
bad_ccsds_met = (
|
|
336
|
-
fake_spin_df.iloc[8].
|
|
339
|
+
fake_spin_df.iloc[8].spin_start_met
|
|
337
340
|
+ fake_spin_df.iloc[8].spin_period_sec / 2
|
|
338
341
|
+ 0.1
|
|
339
342
|
)
|
|
@@ -343,7 +346,7 @@ def test_get_de_clock_ticks_for_esa_step_exceptions(fake_spin_df):
|
|
|
343
346
|
hi_l1c.get_de_clock_ticks_for_esa_step(bad_ccsds_met, fake_spin_df)
|
|
344
347
|
|
|
345
348
|
# Test the ccsds_met being too close to the start of the spin table
|
|
346
|
-
bad_ccsds_met = fake_spin_df.iloc[7].
|
|
349
|
+
bad_ccsds_met = fake_spin_df.iloc[7].spin_start_met
|
|
347
350
|
with pytest.raises(
|
|
348
351
|
ValueError, match="Error determining start/end time for exposure time"
|
|
349
352
|
):
|
|
@@ -11,15 +11,14 @@ def test_sci_de_decom(hi_l0_test_data_path):
|
|
|
11
11
|
"""Test science direct event data"""
|
|
12
12
|
|
|
13
13
|
bin_data_path = hi_l0_test_data_path / "H90_sci_de_20241104.bin"
|
|
14
|
-
processed_data = hi_l1a(bin_data_path
|
|
14
|
+
processed_data = hi_l1a(bin_data_path)
|
|
15
15
|
|
|
16
16
|
assert processed_data[0].attrs["Logical_source"] == "imap_hi_l1a_90sensor-de"
|
|
17
|
-
assert processed_data[0].attrs["Data_version"] == "001"
|
|
18
17
|
|
|
19
18
|
# TODO: Verify correct unpacking of sample data. Issue: #1186
|
|
20
19
|
|
|
21
20
|
# Write to CDF
|
|
22
|
-
cdf_filename = "imap_hi_l1a_90sensor-
|
|
21
|
+
cdf_filename = "imap_hi_l1a_90sensor-de_20241105_v999.cdf"
|
|
23
22
|
cdf_filepath = write_cdf(processed_data[0])
|
|
24
23
|
assert cdf_filepath.name == cdf_filename
|
|
25
24
|
|
|
@@ -27,10 +26,10 @@ def test_sci_de_decom(hi_l0_test_data_path):
|
|
|
27
26
|
def test_diag_fee_decom(hi_l0_test_data_path):
|
|
28
27
|
"""Test diag_fee data"""
|
|
29
28
|
bin_data_path = hi_l0_test_data_path / "H45_diag_fee_20250208.bin"
|
|
30
|
-
processed_data = hi_l1a(packet_file_path=bin_data_path
|
|
29
|
+
processed_data = hi_l1a(packet_file_path=bin_data_path)
|
|
31
30
|
dataset = processed_data[0]
|
|
32
31
|
cdf_filepath = write_cdf(processed_data[0], istp=False)
|
|
33
|
-
assert cdf_filepath.name == "imap_hi_l1a_45sensor-
|
|
32
|
+
assert cdf_filepath.name == "imap_hi_l1a_45sensor-diagfee_20250208_v999.cdf"
|
|
34
33
|
|
|
35
34
|
assert np.unique(processed_data[0]["pkt_apid"].values) == HIAPID.H45_DIAG_FEE.value
|
|
36
35
|
|
|
@@ -58,11 +57,10 @@ def test_app_nhk_decom(hi_l0_test_data_path):
|
|
|
58
57
|
|
|
59
58
|
# Unpack housekeeping data
|
|
60
59
|
bin_data_path = hi_l0_test_data_path / "H90_NHK_20241104.bin"
|
|
61
|
-
processed_data = hi_l1a(packet_file_path=bin_data_path
|
|
60
|
+
processed_data = hi_l1a(packet_file_path=bin_data_path)
|
|
62
61
|
|
|
63
62
|
assert np.unique(processed_data[0]["pkt_apid"].values) == HIAPID.H90_APP_NHK.value
|
|
64
63
|
assert processed_data[0].attrs["Logical_source"] == "imap_hi_l1a_90sensor-hk"
|
|
65
|
-
assert processed_data[0].attrs["Data_version"] == "001"
|
|
66
64
|
# TODO: compare with validation data once we have it. Issue: #1184
|
|
67
65
|
|
|
68
66
|
# Write CDF
|
|
@@ -70,13 +68,13 @@ def test_app_nhk_decom(hi_l0_test_data_path):
|
|
|
70
68
|
|
|
71
69
|
# TODO: ask Vivek about this date mismatch between the file name
|
|
72
70
|
# and the data. May get resolved when we have good sample data.
|
|
73
|
-
assert cem_raw_cdf_filepath.name == "imap_hi_l1a_90sensor-
|
|
71
|
+
assert cem_raw_cdf_filepath.name == "imap_hi_l1a_90sensor-hk_20241105_v999.cdf"
|
|
74
72
|
|
|
75
73
|
|
|
76
74
|
def test_app_hist_decom(hi_l0_test_data_path):
|
|
77
75
|
"""Test histogram (SCI_CNT) data"""
|
|
78
76
|
bin_data_path = hi_l0_test_data_path / "H90_sci_cnt_20241104.bin"
|
|
79
|
-
processed_data = hi_l1a(packet_file_path=bin_data_path
|
|
77
|
+
processed_data = hi_l1a(packet_file_path=bin_data_path)
|
|
80
78
|
|
|
81
79
|
assert processed_data[0].attrs["Logical_source"] == "imap_hi_l1a_90sensor-hist"
|
|
82
80
|
# TODO: compare with validation data once we have it. Issue: #1185
|
|
@@ -30,8 +30,8 @@ def test_parse_direct_events():
|
|
|
30
30
|
bytes_obj = bytes([int(bin_str[i : i + 8], 2) for i in range(0, len(bin_str), 8)])
|
|
31
31
|
# Parse the fake events and check values
|
|
32
32
|
de_dict = parse_direct_events(bytes_obj)
|
|
33
|
-
for key in exp_dict.
|
|
34
|
-
np.testing.assert_array_equal(de_dict[key],
|
|
33
|
+
for key, expected_val in exp_dict.items():
|
|
34
|
+
np.testing.assert_array_equal(de_dict[key], expected_val)
|
|
35
35
|
|
|
36
36
|
|
|
37
37
|
def test_create_dataset():
|