imap-processing 0.6.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.
- imap_processing/__init__.py +34 -0
- imap_processing/_version.py +3 -0
- imap_processing/ccsds/__init__.py +0 -0
- imap_processing/ccsds/ccsds_data.py +55 -0
- imap_processing/ccsds/excel_to_xtce.py +477 -0
- imap_processing/cdf/__init__.py +0 -0
- imap_processing/cdf/cdf_attribute_manager.py +322 -0
- imap_processing/cdf/config/imap_codice_global_cdf_attrs.yaml +212 -0
- imap_processing/cdf/config/imap_codice_l1a_variable_attrs.yaml +1358 -0
- imap_processing/cdf/config/imap_codice_l1b_variable_attrs.yaml +391 -0
- imap_processing/cdf/config/imap_constant_attrs.yaml +33 -0
- imap_processing/cdf/config/imap_default_global_cdf_attrs.yaml +17 -0
- imap_processing/cdf/config/imap_glows_global_cdf_attrs.yaml +41 -0
- imap_processing/cdf/config/imap_glows_l1a_variable_attrs.yaml +499 -0
- imap_processing/cdf/config/imap_glows_l1b_variable_attrs.yaml +334 -0
- imap_processing/cdf/config/imap_hi_global_cdf_attrs.yaml +51 -0
- imap_processing/cdf/config/imap_hi_variable_attrs.yaml +435 -0
- imap_processing/cdf/config/imap_hit_global_cdf_attrs.yaml +27 -0
- imap_processing/cdf/config/imap_hit_l1a_variable_attrs.yaml +493 -0
- imap_processing/cdf/config/imap_hit_l1b_variable_attrs.yaml +564 -0
- imap_processing/cdf/config/imap_idex_global_cdf_attrs.yaml +24 -0
- imap_processing/cdf/config/imap_idex_l1a_variable_attrs.yaml +426 -0
- imap_processing/cdf/config/imap_lo_global_cdf_attrs.yaml +90 -0
- imap_processing/cdf/config/imap_lo_l1a_variable_attrs.yaml +487 -0
- imap_processing/cdf/config/imap_lo_l1b_variable_attrs.yaml +121 -0
- imap_processing/cdf/config/imap_lo_l1c_variable_attrs.yaml +179 -0
- imap_processing/cdf/config/imap_mag_global_cdf_attrs.yaml +97 -0
- imap_processing/cdf/config/imap_mag_l1_variable_attrs.yaml +201 -0
- imap_processing/cdf/config/imap_swapi_global_cdf_attrs.yaml +33 -0
- imap_processing/cdf/config/imap_swapi_variable_attrs.yaml +137 -0
- imap_processing/cdf/config/imap_swe_global_cdf_attrs.yaml +24 -0
- imap_processing/cdf/config/imap_swe_l1a_variable_attrs.yaml +234 -0
- imap_processing/cdf/config/imap_swe_l1b_variable_attrs.yaml +273 -0
- imap_processing/cdf/config/imap_ultra_global_cdf_attrs.yaml +100 -0
- imap_processing/cdf/config/imap_ultra_l1a_variable_attrs.yaml +52 -0
- imap_processing/cdf/config/imap_ultra_l1b_variable_attrs.yaml +297 -0
- imap_processing/cdf/config/imap_ultra_l1c_variable_attrs.yaml +121 -0
- imap_processing/cdf/config/shared/default_global_cdf_attrs_schema.yaml +246 -0
- imap_processing/cdf/config/shared/default_variable_cdf_attrs_schema.yaml +466 -0
- imap_processing/cdf/imap_cdf_manager.py +64 -0
- imap_processing/cdf/utils.py +147 -0
- imap_processing/cli.py +863 -0
- imap_processing/codice/__init__.py +1 -0
- imap_processing/codice/codice_l0.py +54 -0
- imap_processing/codice/codice_l1a.py +558 -0
- imap_processing/codice/codice_l1b.py +194 -0
- imap_processing/codice/constants.py +986 -0
- imap_processing/codice/data/esa_sweep_values.csv +257 -0
- imap_processing/codice/data/lo_stepping_values.csv +129 -0
- imap_processing/codice/decompress.py +142 -0
- imap_processing/codice/packet_definitions/P_COD_NHK.xml +618 -0
- imap_processing/codice/packet_definitions/codice_packet_definition.xml +5073 -0
- imap_processing/codice/utils.py +95 -0
- imap_processing/decom.py +40 -0
- imap_processing/glows/__init__.py +1 -0
- imap_processing/glows/ancillary/l1b_conversion_table_v001.json +42 -0
- imap_processing/glows/l0/__init__.py +0 -0
- imap_processing/glows/l0/decom_glows.py +91 -0
- imap_processing/glows/l0/glows_l0_data.py +194 -0
- imap_processing/glows/l1a/glows_l1a.py +424 -0
- imap_processing/glows/l1a/glows_l1a_data.py +555 -0
- imap_processing/glows/l1b/glows_l1b.py +270 -0
- imap_processing/glows/l1b/glows_l1b_data.py +583 -0
- imap_processing/glows/packet_definitions/GLX_COMBINED.xml +254 -0
- imap_processing/glows/packet_definitions/P_GLX_TMSCDE.xml +97 -0
- imap_processing/glows/packet_definitions/P_GLX_TMSCHIST.xml +215 -0
- imap_processing/glows/utils/__init__.py +0 -0
- imap_processing/glows/utils/constants.py +105 -0
- imap_processing/hi/__init__.py +1 -0
- imap_processing/hi/l0/__init__.py +0 -0
- imap_processing/hi/l0/decom_hi.py +24 -0
- imap_processing/hi/l1a/__init__.py +0 -0
- imap_processing/hi/l1a/hi_l1a.py +73 -0
- imap_processing/hi/l1a/histogram.py +142 -0
- imap_processing/hi/l1a/housekeeping.py +27 -0
- imap_processing/hi/l1a/science_direct_event.py +341 -0
- imap_processing/hi/l1b/__init__.py +0 -0
- imap_processing/hi/l1b/hi_eng_unit_convert_table.csv +154 -0
- imap_processing/hi/l1b/hi_l1b.py +127 -0
- imap_processing/hi/l1c/__init__.py +0 -0
- imap_processing/hi/l1c/hi_l1c.py +228 -0
- imap_processing/hi/packet_definitions/__init__.py +0 -0
- imap_processing/hi/packet_definitions/hi_packet_definition.xml +482 -0
- imap_processing/hi/utils.py +27 -0
- imap_processing/hit/__init__.py +1 -0
- imap_processing/hit/l0/__init__.py +0 -0
- imap_processing/hit/l0/data_classes/housekeeping.py +240 -0
- imap_processing/hit/l0/data_classes/science_packet.py +259 -0
- imap_processing/hit/l0/decom_hit.py +467 -0
- imap_processing/hit/l0/utils/hit_base.py +57 -0
- imap_processing/hit/l1a/__init__.py +0 -0
- imap_processing/hit/l1a/hit_l1a.py +254 -0
- imap_processing/hit/l1b/hit_l1b.py +179 -0
- imap_processing/hit/packet_definitions/hit_packet_definitions.xml +1276 -0
- imap_processing/ialirt/__init__.py +0 -0
- imap_processing/ialirt/l0/__init__.py +0 -0
- imap_processing/ialirt/l0/process_hit.py +220 -0
- imap_processing/ialirt/packet_definitions/__init__.py +0 -0
- imap_processing/ialirt/packet_definitions/ialirt.xml +778 -0
- imap_processing/ialirt/packet_definitions/ialirt_hit.xml +186 -0
- imap_processing/idex/__init__.py +2 -0
- imap_processing/idex/idex_constants.py +27 -0
- imap_processing/idex/idex_l0.py +31 -0
- imap_processing/idex/idex_l1a.py +631 -0
- imap_processing/idex/packet_definitions/idex_packet_definition.xml +3162 -0
- imap_processing/lo/__init__.py +1 -0
- imap_processing/lo/l0/__init__.py +0 -0
- imap_processing/lo/l0/data_classes/science_direct_events.py +215 -0
- imap_processing/lo/l0/data_classes/star_sensor.py +98 -0
- imap_processing/lo/l0/decompression_tables/12_to_16_bit.csv +4097 -0
- imap_processing/lo/l0/decompression_tables/8_to_12_bit.csv +257 -0
- imap_processing/lo/l0/decompression_tables/8_to_16_bit.csv +257 -0
- imap_processing/lo/l0/decompression_tables/decompression_tables.py +75 -0
- imap_processing/lo/l0/lo_apid.py +15 -0
- imap_processing/lo/l0/lo_science.py +150 -0
- imap_processing/lo/l0/utils/binary_string.py +59 -0
- imap_processing/lo/l0/utils/bit_decompression.py +62 -0
- imap_processing/lo/l0/utils/lo_base.py +57 -0
- imap_processing/lo/l1a/__init__.py +0 -0
- imap_processing/lo/l1a/lo_l1a.py +157 -0
- imap_processing/lo/l1b/lo_l1b.py +160 -0
- imap_processing/lo/l1c/lo_l1c.py +180 -0
- imap_processing/lo/packet_definitions/lo_xtce.xml +3541 -0
- imap_processing/mag/__init__.py +2 -0
- imap_processing/mag/constants.py +108 -0
- imap_processing/mag/l0/decom_mag.py +170 -0
- imap_processing/mag/l0/mag_l0_data.py +118 -0
- imap_processing/mag/l1a/mag_l1a.py +317 -0
- imap_processing/mag/l1a/mag_l1a_data.py +1007 -0
- imap_processing/mag/l1b/__init__.py +0 -0
- imap_processing/mag/l1b/imap_calibration_mag_20240229_v01.cdf +0 -0
- imap_processing/mag/l1b/mag_l1b.py +125 -0
- imap_processing/mag/l1c/mag_l1c.py +57 -0
- imap_processing/mag/packet_definitions/MAG_SCI_COMBINED.xml +235 -0
- imap_processing/quality_flags.py +91 -0
- imap_processing/spice/__init__.py +1 -0
- imap_processing/spice/geometry.py +322 -0
- imap_processing/spice/kernels.py +459 -0
- imap_processing/spice/time.py +72 -0
- imap_processing/swapi/__init__.py +1 -0
- imap_processing/swapi/l1/__init__.py +0 -0
- imap_processing/swapi/l1/swapi_l1.py +685 -0
- imap_processing/swapi/l2/__init__.py +0 -0
- imap_processing/swapi/l2/swapi_l2.py +107 -0
- imap_processing/swapi/packet_definitions/__init__.py +0 -0
- imap_processing/swapi/packet_definitions/swapi_packet_definition.xml +708 -0
- imap_processing/swapi/swapi_utils.py +25 -0
- imap_processing/swe/__init__.py +1 -0
- imap_processing/swe/l1a/__init__.py +0 -0
- imap_processing/swe/l1a/swe_l1a.py +48 -0
- imap_processing/swe/l1a/swe_science.py +223 -0
- imap_processing/swe/l1b/engineering_unit_convert_table.csv +65 -0
- imap_processing/swe/l1b/swe_esa_lookup_table.csv +1441 -0
- imap_processing/swe/l1b/swe_l1b.py +49 -0
- imap_processing/swe/l1b/swe_l1b_science.py +557 -0
- imap_processing/swe/packet_definitions/__init__.py +0 -0
- imap_processing/swe/packet_definitions/swe_packet_definition.xml +303 -0
- imap_processing/swe/utils/__init__.py +0 -0
- imap_processing/swe/utils/swe_utils.py +9 -0
- imap_processing/tests/__init__.py +0 -0
- imap_processing/tests/ccsds/test_data/expected_output.xml +171 -0
- imap_processing/tests/ccsds/test_excel_to_xtce.py +285 -0
- imap_processing/tests/cdf/__init__.py +0 -0
- imap_processing/tests/cdf/imap_default_global_cdf_attrs.yaml +8 -0
- imap_processing/tests/cdf/shared/default_global_cdf_attrs_schema.yaml +246 -0
- imap_processing/tests/cdf/shared/default_variable_cdf_attrs_schema.yaml +466 -0
- imap_processing/tests/cdf/test_cdf_attribute_manager.py +353 -0
- imap_processing/tests/cdf/test_data/imap_default_global_test_cdf_attrs.yaml +7 -0
- imap_processing/tests/cdf/test_data/imap_instrument1_global_cdf_attrs.yaml +14 -0
- imap_processing/tests/cdf/test_data/imap_instrument1_level1_variable_attrs.yaml +23 -0
- imap_processing/tests/cdf/test_data/imap_instrument2_global_cdf_attrs.yaml +23 -0
- imap_processing/tests/cdf/test_data/imap_instrument2_level2_variable_attrs.yaml +30 -0
- imap_processing/tests/cdf/test_data/imap_test_global.yaml +26 -0
- imap_processing/tests/cdf/test_data/imap_test_variable.yaml +41 -0
- imap_processing/tests/cdf/test_imap_cdf_manager.py +62 -0
- imap_processing/tests/cdf/test_utils.py +109 -0
- imap_processing/tests/codice/__init__.py +0 -0
- imap_processing/tests/codice/conftest.py +56 -0
- imap_processing/tests/codice/data/eu_unit_lookup_table.csv +101 -0
- imap_processing/tests/codice/data/idle_export_eu.COD_NHK_20230822_122700 2.csv +100 -0
- imap_processing/tests/codice/data/idle_export_raw.COD_NHK_20230822_122700.csv +100 -0
- imap_processing/tests/codice/data/imap_codice_l0_hi-counters-aggregated_20240429_v001.pkts +0 -0
- imap_processing/tests/codice/data/imap_codice_l0_hi-counters-singles_20240429_v001.pkts +0 -0
- imap_processing/tests/codice/data/imap_codice_l0_hi-omni_20240429_v001.pkts +0 -0
- imap_processing/tests/codice/data/imap_codice_l0_hi-pha_20240429_v001.pkts +0 -0
- imap_processing/tests/codice/data/imap_codice_l0_hi-sectored_20240429_v001.pkts +0 -0
- imap_processing/tests/codice/data/imap_codice_l0_hskp_20100101_v001.pkts +0 -0
- imap_processing/tests/codice/data/imap_codice_l0_lo-counters-aggregated_20240429_v001.pkts +0 -0
- imap_processing/tests/codice/data/imap_codice_l0_lo-counters-singles_20240429_v001.pkts +0 -0
- imap_processing/tests/codice/data/imap_codice_l0_lo-nsw-angular_20240429_v001.pkts +0 -0
- imap_processing/tests/codice/data/imap_codice_l0_lo-nsw-priority_20240429_v001.pkts +0 -0
- imap_processing/tests/codice/data/imap_codice_l0_lo-nsw-species_20240429_v001.pkts +0 -0
- imap_processing/tests/codice/data/imap_codice_l0_lo-pha_20240429_v001.pkts +0 -0
- imap_processing/tests/codice/data/imap_codice_l0_lo-sw-angular_20240429_v001.pkts +0 -0
- imap_processing/tests/codice/data/imap_codice_l0_lo-sw-priority_20240429_v001.pkts +0 -0
- imap_processing/tests/codice/data/imap_codice_l0_lo-sw-species_20240429_v001.pkts +0 -0
- imap_processing/tests/codice/data/imap_codice_l1a_hi-counters-aggregated_20240429_v001.cdf +0 -0
- imap_processing/tests/codice/data/imap_codice_l1a_hi-counters-singles_20240429_v001.cdf +0 -0
- imap_processing/tests/codice/data/imap_codice_l1a_hi-omni_20240429_v001.cdf +0 -0
- imap_processing/tests/codice/data/imap_codice_l1a_hi-sectored_20240429_v001.cdf +0 -0
- imap_processing/tests/codice/data/imap_codice_l1a_hskp_20100101_v001.cdf +0 -0
- imap_processing/tests/codice/data/imap_codice_l1a_lo-counters-aggregated_20240429_v001.cdf +0 -0
- imap_processing/tests/codice/data/imap_codice_l1a_lo-counters-singles_20240429_v001.cdf +0 -0
- imap_processing/tests/codice/data/imap_codice_l1a_lo-nsw-angular_20240429_v001.cdf +0 -0
- imap_processing/tests/codice/data/imap_codice_l1a_lo-nsw-priority_20240429_v001.cdf +0 -0
- imap_processing/tests/codice/data/imap_codice_l1a_lo-nsw-species_20240429_v001.cdf +0 -0
- imap_processing/tests/codice/data/imap_codice_l1a_lo-sw-angular_20240429_v001.cdf +0 -0
- imap_processing/tests/codice/data/imap_codice_l1a_lo-sw-priority_20240429_v001.cdf +0 -0
- imap_processing/tests/codice/data/imap_codice_l1a_lo-sw-species_20240429_v001.cdf +0 -0
- imap_processing/tests/codice/data/imap_codice_l1b_hi-counters-aggregated_20240429_v001.cdf +0 -0
- imap_processing/tests/codice/data/imap_codice_l1b_hi-counters-singles_20240429_v001.cdf +0 -0
- imap_processing/tests/codice/data/imap_codice_l1b_hi-omni_20240429_v001.cdf +0 -0
- imap_processing/tests/codice/data/imap_codice_l1b_hi-sectored_20240429_v001.cdf +0 -0
- imap_processing/tests/codice/data/imap_codice_l1b_hskp_20100101_v001.cdf +0 -0
- imap_processing/tests/codice/data/imap_codice_l1b_lo-counters-aggregated_20240429_v001.cdf +0 -0
- imap_processing/tests/codice/data/imap_codice_l1b_lo-counters-singles_20240429_v001.cdf +0 -0
- imap_processing/tests/codice/data/imap_codice_l1b_lo-nsw-angular_20240429_v001.cdf +0 -0
- imap_processing/tests/codice/data/imap_codice_l1b_lo-nsw-priority_20240429_v001.cdf +0 -0
- imap_processing/tests/codice/data/imap_codice_l1b_lo-nsw-species_20240429_v001.cdf +0 -0
- imap_processing/tests/codice/data/imap_codice_l1b_lo-sw-angular_20240429_v001.cdf +0 -0
- imap_processing/tests/codice/data/imap_codice_l1b_lo-sw-priority_20240429_v001.cdf +0 -0
- imap_processing/tests/codice/data/imap_codice_l1b_lo-sw-species_20240429_v001.cdf +0 -0
- imap_processing/tests/codice/test_codice_l0.py +144 -0
- imap_processing/tests/codice/test_codice_l1a.py +187 -0
- imap_processing/tests/codice/test_codice_l1b.py +60 -0
- imap_processing/tests/codice/test_decompress.py +50 -0
- imap_processing/tests/conftest.py +372 -0
- imap_processing/tests/glows/direct_events_validation_data_l1a.csv +5704 -0
- imap_processing/tests/glows/glows_test_packet_20110921_v01.pkts +0 -0
- imap_processing/tests/glows/test_glows_decom.py +133 -0
- imap_processing/tests/glows/test_glows_l1a_cdf.py +85 -0
- imap_processing/tests/glows/test_glows_l1a_data.py +510 -0
- imap_processing/tests/glows/test_glows_l1b.py +348 -0
- imap_processing/tests/glows/test_glows_l1b_data.py +70 -0
- imap_processing/tests/hi/__init__.py +0 -0
- imap_processing/tests/hi/conftest.py +133 -0
- imap_processing/tests/hi/test_data/l0/20231030_H45_APP_NHK.bin +0 -0
- imap_processing/tests/hi/test_data/l0/20231030_H45_APP_NHK.csv +201 -0
- imap_processing/tests/hi/test_data/l0/20231030_H45_SCI_CNT.bin +0 -0
- imap_processing/tests/hi/test_data/l0/20231030_H45_SCI_DE.bin +0 -0
- imap_processing/tests/hi/test_data/l0/README.txt +54 -0
- imap_processing/tests/hi/test_decom.py +55 -0
- imap_processing/tests/hi/test_hi_l1b.py +31 -0
- imap_processing/tests/hi/test_hi_l1c.py +69 -0
- imap_processing/tests/hi/test_l1a.py +96 -0
- imap_processing/tests/hi/test_l1a_sci_de.py +72 -0
- imap_processing/tests/hi/test_utils.py +15 -0
- imap_processing/tests/hit/PREFLIGHT_raw_record_2023_256_15_59_04_apid1251.pkts +0 -0
- imap_processing/tests/hit/PREFLIGHT_raw_record_2023_256_15_59_04_apid1252.pkts +0 -0
- imap_processing/tests/hit/__init__.py +0 -0
- imap_processing/tests/hit/test_data/imap_hit_l0_hk_20100105_v001.pkts +0 -0
- imap_processing/tests/hit/test_data/sci_sample.ccsds +0 -0
- imap_processing/tests/hit/test_hit_decom.py +230 -0
- imap_processing/tests/hit/test_hit_l1a.py +224 -0
- imap_processing/tests/hit/test_hit_l1b.py +52 -0
- imap_processing/tests/hit/validation_data/hskp_sample_raw.csv +88 -0
- imap_processing/tests/ialirt/__init__.py +0 -0
- imap_processing/tests/ialirt/test_data/l0/IALiRT Raw Packet Telemetry.txt +33 -0
- imap_processing/tests/ialirt/test_data/l0/hit_ialirt_sample.ccsds +0 -0
- imap_processing/tests/ialirt/test_data/l0/hit_ialirt_sample.csv +1001 -0
- imap_processing/tests/ialirt/unit/__init__.py +0 -0
- imap_processing/tests/ialirt/unit/test_decom_ialirt.py +94 -0
- imap_processing/tests/ialirt/unit/test_process_hit.py +226 -0
- imap_processing/tests/idex/__init__.py +0 -0
- imap_processing/tests/idex/conftest.py +22 -0
- imap_processing/tests/idex/imap_idex_l0_raw_20230725_v001.pkts +0 -0
- imap_processing/tests/idex/impact_14_tof_high_data.txt +8189 -0
- imap_processing/tests/idex/test_idex_l0.py +45 -0
- imap_processing/tests/idex/test_idex_l1a.py +91 -0
- imap_processing/tests/lo/__init__.py +0 -0
- imap_processing/tests/lo/test_binary_string.py +21 -0
- imap_processing/tests/lo/test_bit_decompression.py +39 -0
- imap_processing/tests/lo/test_cdfs/imap_lo_l0_raw_20240627_v001.pkts +0 -0
- imap_processing/tests/lo/test_cdfs/imap_lo_l1a_de_20100101_v001.cdf +0 -0
- imap_processing/tests/lo/test_cdfs/imap_lo_l1a_spin_20100101_v001.cdf +0 -0
- imap_processing/tests/lo/test_cdfs/imap_lo_l1b_de_20100101_v001.cdf +0 -0
- imap_processing/tests/lo/test_lo_l1a.py +66 -0
- imap_processing/tests/lo/test_lo_l1b.py +74 -0
- imap_processing/tests/lo/test_lo_l1c.py +66 -0
- imap_processing/tests/lo/test_science_counts.py +41 -0
- imap_processing/tests/lo/test_science_direct_events.py +209 -0
- imap_processing/tests/lo/test_star_sensor.py +35 -0
- imap_processing/tests/mag/imap_mag_l1a_burst-magi_20231025_v001.cdf +0 -0
- imap_processing/tests/mag/mag_l0_test_data.pkts +0 -0
- imap_processing/tests/mag/mag_l0_test_output.csv +37 -0
- imap_processing/tests/mag/mag_l1_test_data.pkts +0 -0
- imap_processing/tests/mag/mag_l1a_test_output.csv +97 -0
- imap_processing/tests/mag/test_mag_decom.py +117 -0
- imap_processing/tests/mag/test_mag_l1a.py +856 -0
- imap_processing/tests/mag/test_mag_l1b.py +77 -0
- imap_processing/tests/mag/test_mag_l1c.py +40 -0
- imap_processing/tests/spice/__init__.py +0 -0
- imap_processing/tests/spice/test_data/imap_ena_sim_metakernel.template +4 -0
- imap_processing/tests/spice/test_data/imap_science_0001.tf +171 -0
- imap_processing/tests/spice/test_data/imap_sclk_0000.tsc +156 -0
- imap_processing/tests/spice/test_data/imap_sim_ck_2hr_2secsampling_with_nutation.bc +0 -0
- imap_processing/tests/spice/test_data/imap_simple_metakernel.template +3 -0
- imap_processing/tests/spice/test_data/imap_spk_demo.bsp +0 -0
- imap_processing/tests/spice/test_data/imap_wkcp.tf +1806 -0
- imap_processing/tests/spice/test_data/naif0012.tls +150 -0
- imap_processing/tests/spice/test_data/sim_1yr_imap_attitude.bc +0 -0
- imap_processing/tests/spice/test_data/sim_1yr_imap_pointing_frame.bc +0 -0
- imap_processing/tests/spice/test_geometry.py +214 -0
- imap_processing/tests/spice/test_kernels.py +272 -0
- imap_processing/tests/spice/test_time.py +35 -0
- imap_processing/tests/swapi/__init__.py +0 -0
- imap_processing/tests/swapi/conftest.py +16 -0
- imap_processing/tests/swapi/l0_data/__init__.py +0 -0
- imap_processing/tests/swapi/l0_data/imap_swapi_l0_raw_20231012_v001.pkts +0 -0
- imap_processing/tests/swapi/l0_validation_data/__init__.py +0 -0
- imap_processing/tests/swapi/l0_validation_data/idle_export_eu.SWP_AUT_20231012_125245.csv +124 -0
- imap_processing/tests/swapi/l0_validation_data/idle_export_eu.SWP_HK_20231012_125245.csv +98 -0
- imap_processing/tests/swapi/l0_validation_data/idle_export_eu.SWP_MG_20231012_125245.csv +9 -0
- imap_processing/tests/swapi/l0_validation_data/idle_export_eu.SWP_SCI_20231012_125245.csv +72 -0
- imap_processing/tests/swapi/l0_validation_data/idle_export_raw.SWP_AUT_20231012_125245.csv +124 -0
- imap_processing/tests/swapi/l0_validation_data/idle_export_raw.SWP_HK_20231012_125245.csv +98 -0
- imap_processing/tests/swapi/l0_validation_data/idle_export_raw.SWP_MG_20231012_125245.csv +9 -0
- imap_processing/tests/swapi/l0_validation_data/idle_export_raw.SWP_SCI_20231012_125245.csv +72 -0
- imap_processing/tests/swapi/test_swapi_decom.py +135 -0
- imap_processing/tests/swapi/test_swapi_l1.py +354 -0
- imap_processing/tests/swapi/test_swapi_l2.py +21 -0
- imap_processing/tests/swe/__init__.py +0 -0
- imap_processing/tests/swe/conftest.py +35 -0
- imap_processing/tests/swe/decompressed/20230927173238_4th_quarter_decompressed.csv +181 -0
- imap_processing/tests/swe/decompressed/20230927173253_1st_quarter_decompressed.csv +181 -0
- imap_processing/tests/swe/decompressed/20230927173308_2nd_quarter_decompressed.csv +181 -0
- imap_processing/tests/swe/decompressed/20230927173323_3rd_quarter_decompressed.csv +181 -0
- imap_processing/tests/swe/l0_data/2024051010_SWE_SCIENCE_packet.bin +0 -0
- imap_processing/tests/swe/l0_validation_data/idle_export_eu.SWE_SCIENCE_20240510_092742.csv +544 -0
- imap_processing/tests/swe/l0_validation_data/idle_export_raw.SWE_SCIENCE_20240510_092742.csv +363 -0
- imap_processing/tests/swe/test_swe_l1a.py +12 -0
- imap_processing/tests/swe/test_swe_l1a_science.py +129 -0
- imap_processing/tests/swe/test_swe_l1b.py +61 -0
- imap_processing/tests/swe/test_swe_l1b_science.py +65 -0
- imap_processing/tests/test_cli.py +229 -0
- imap_processing/tests/test_decom.py +66 -0
- imap_processing/tests/test_quality_flags.py +71 -0
- imap_processing/tests/test_utils.py +107 -0
- imap_processing/tests/ultra/__init__.py +0 -0
- imap_processing/tests/ultra/test_data/l0/FM45_40P_Phi28p5_BeamCal_LinearScan_phi28.50_theta-0.00_20240207T102740.CCSDS +0 -0
- imap_processing/tests/ultra/test_data/l0/FM45_7P_Phi0.0_BeamCal_LinearScan_phi0.04_theta-0.01_20230821T121304.CCSDS +0 -0
- imap_processing/tests/ultra/test_data/l0/FM45_TV_Cycle6_Hot_Ops_Front212_20240124T063837.CCSDS +0 -0
- imap_processing/tests/ultra/test_data/l0/Ultra45_EM_SwRI_Cal_Run7_ThetaScan_20220530T225054.CCSDS +0 -0
- imap_processing/tests/ultra/test_data/l0/ultra45_raw_sc_auxdata_Ultra45_EM_SwRI_Cal_Run7_ThetaScan_20220530T225054.csv +24 -0
- imap_processing/tests/ultra/test_data/l0/ultra45_raw_sc_enaphxtofhangimg_FM45_TV_Cycle6_Hot_Ops_Front212_20240124T063837.csv +105 -0
- imap_processing/tests/ultra/test_data/l0/ultra45_raw_sc_ultraimgrates_Ultra45_EM_SwRI_Cal_Run7_ThetaScan_20220530T225054.csv +24 -0
- imap_processing/tests/ultra/test_data/l0/ultra45_raw_sc_ultrarawimg_withFSWcalcs_FM45_40P_Phi28p5_BeamCal_LinearScan_phi2850_theta-000_20240207T102740.csv +3314 -0
- imap_processing/tests/ultra/test_data/l0/ultra45_raw_sc_ultrarawimgevent_FM45_7P_Phi00_BeamCal_LinearScan_phi004_theta-001_20230821T121304.csv +702 -0
- imap_processing/tests/ultra/unit/__init__.py +0 -0
- imap_processing/tests/ultra/unit/conftest.py +210 -0
- imap_processing/tests/ultra/unit/test_decom_apid_880.py +98 -0
- imap_processing/tests/ultra/unit/test_decom_apid_881.py +50 -0
- imap_processing/tests/ultra/unit/test_decom_apid_883.py +44 -0
- imap_processing/tests/ultra/unit/test_decom_apid_896.py +104 -0
- imap_processing/tests/ultra/unit/test_lookup_utils.py +68 -0
- imap_processing/tests/ultra/unit/test_ultra_l1a.py +338 -0
- imap_processing/tests/ultra/unit/test_ultra_l1b.py +122 -0
- imap_processing/tests/ultra/unit/test_ultra_l1b_annotated.py +57 -0
- imap_processing/tests/ultra/unit/test_ultra_l1b_extended.py +342 -0
- imap_processing/tests/ultra/unit/test_ultra_l1c.py +104 -0
- imap_processing/tests/ultra/unit/test_ultra_l1c_pset_bins.py +35 -0
- imap_processing/ultra/__init__.py +1 -0
- imap_processing/ultra/constants.py +60 -0
- imap_processing/ultra/l0/__init__.py +0 -0
- imap_processing/ultra/l0/decom_tools.py +281 -0
- imap_processing/ultra/l0/decom_ultra.py +278 -0
- imap_processing/ultra/l0/ultra_utils.py +326 -0
- imap_processing/ultra/l1a/__init__.py +0 -0
- imap_processing/ultra/l1a/ultra_l1a.py +319 -0
- imap_processing/ultra/l1b/badtimes.py +26 -0
- imap_processing/ultra/l1b/cullingmask.py +26 -0
- imap_processing/ultra/l1b/de.py +59 -0
- imap_processing/ultra/l1b/extendedspin.py +45 -0
- imap_processing/ultra/l1b/lookup_utils.py +165 -0
- imap_processing/ultra/l1b/ultra_l1b.py +65 -0
- imap_processing/ultra/l1b/ultra_l1b_annotated.py +54 -0
- imap_processing/ultra/l1b/ultra_l1b_extended.py +764 -0
- imap_processing/ultra/l1c/histogram.py +36 -0
- imap_processing/ultra/l1c/pset.py +36 -0
- imap_processing/ultra/l1c/ultra_l1c.py +52 -0
- imap_processing/ultra/l1c/ultra_l1c_pset_bins.py +54 -0
- imap_processing/ultra/lookup_tables/EgyNorm.mem.csv +32769 -0
- imap_processing/ultra/lookup_tables/FM45_Startup1_ULTRA_IMGPARAMS_20240719.csv +2 -0
- imap_processing/ultra/lookup_tables/ultra45_back-pos-luts.csv +4097 -0
- imap_processing/ultra/lookup_tables/ultra45_tdc_norm.csv +2050 -0
- imap_processing/ultra/lookup_tables/ultra90_back-pos-luts.csv +4097 -0
- imap_processing/ultra/lookup_tables/ultra90_tdc_norm.csv +2050 -0
- imap_processing/ultra/lookup_tables/yadjust.csv +257 -0
- imap_processing/ultra/packet_definitions/ULTRA_SCI_COMBINED.xml +547 -0
- imap_processing/ultra/packet_definitions/__init__.py +0 -0
- imap_processing/ultra/utils/__init__.py +0 -0
- imap_processing/ultra/utils/ultra_l1_utils.py +50 -0
- imap_processing/utils.py +413 -0
- imap_processing-0.6.0.dist-info/LICENSE +21 -0
- imap_processing-0.6.0.dist-info/METADATA +107 -0
- imap_processing-0.6.0.dist-info/RECORD +398 -0
- imap_processing-0.6.0.dist-info/WHEEL +4 -0
- imap_processing-0.6.0.dist-info/entry_points.txt +4 -0
|
@@ -0,0 +1,424 @@
|
|
|
1
|
+
"""Methods for GLOWS Level 1A processing and CDF writing."""
|
|
2
|
+
|
|
3
|
+
from collections import defaultdict
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
import numpy as np
|
|
7
|
+
import xarray as xr
|
|
8
|
+
|
|
9
|
+
from imap_processing.cdf.imap_cdf_manager import ImapCdfAttributes
|
|
10
|
+
from imap_processing.cdf.utils import J2000_EPOCH
|
|
11
|
+
from imap_processing.glows.l0.decom_glows import decom_packets
|
|
12
|
+
from imap_processing.glows.l0.glows_l0_data import DirectEventL0
|
|
13
|
+
from imap_processing.glows.l1a.glows_l1a_data import DirectEventL1A, HistogramL1A
|
|
14
|
+
from imap_processing.spice.time import met_to_j2000ns
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def create_glows_attr_obj(data_version: str) -> ImapCdfAttributes:
|
|
18
|
+
"""
|
|
19
|
+
Load in 1la CDF attributes for GLOWS instrument.
|
|
20
|
+
|
|
21
|
+
Parameters
|
|
22
|
+
----------
|
|
23
|
+
data_version : str
|
|
24
|
+
Data version for CDF filename, in the format "vXXX".
|
|
25
|
+
|
|
26
|
+
Returns
|
|
27
|
+
-------
|
|
28
|
+
glows_attrs : ImapCdfAttributes
|
|
29
|
+
Imap object with l1a attribute files loaded in.
|
|
30
|
+
"""
|
|
31
|
+
# Create ImapCdfAttributes object for cdf attributes management
|
|
32
|
+
glows_attrs = ImapCdfAttributes()
|
|
33
|
+
# Load in files
|
|
34
|
+
glows_attrs.add_instrument_global_attrs("glows")
|
|
35
|
+
glows_attrs.add_instrument_variable_attrs("glows", "l1a")
|
|
36
|
+
glows_attrs.add_global_attribute("Data_version", data_version)
|
|
37
|
+
return glows_attrs
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def glows_l1a(packet_filepath: Path, data_version: str) -> list[xr.Dataset]:
|
|
41
|
+
"""
|
|
42
|
+
Will process packets into GLOWS L1A CDF files.
|
|
43
|
+
|
|
44
|
+
Outputs Datasets for histogram and direct event GLOWS L1A. This list can be passed
|
|
45
|
+
into write_cdf to output CDF files.
|
|
46
|
+
|
|
47
|
+
Parameters
|
|
48
|
+
----------
|
|
49
|
+
packet_filepath : pathlib.Path
|
|
50
|
+
Path to packet file for processing.
|
|
51
|
+
data_version : str
|
|
52
|
+
Data version for CDF filename, in the format "vXXX".
|
|
53
|
+
|
|
54
|
+
Returns
|
|
55
|
+
-------
|
|
56
|
+
generated_files : list[xr.Dataset]
|
|
57
|
+
List of the L1A datasets.
|
|
58
|
+
"""
|
|
59
|
+
# Create ImapCdfAttributes object for cdf attributes management
|
|
60
|
+
glows_attrs = create_glows_attr_obj(data_version)
|
|
61
|
+
|
|
62
|
+
# TODO: Data version inside file as well?
|
|
63
|
+
|
|
64
|
+
# Decompose packet file into histogram, and direct event data.
|
|
65
|
+
hist_l0, de_l0 = decom_packets(packet_filepath)
|
|
66
|
+
|
|
67
|
+
# Create dictionaries to group data by day
|
|
68
|
+
de_by_day = process_de_l0(de_l0)
|
|
69
|
+
hists_by_day = defaultdict(list)
|
|
70
|
+
|
|
71
|
+
# TODO: Make this its own function?
|
|
72
|
+
for hist in hist_l0:
|
|
73
|
+
hist_l1a = HistogramL1A(hist)
|
|
74
|
+
# Split by IMAP start time
|
|
75
|
+
# TODO: Should this be MET?
|
|
76
|
+
hist_day = (J2000_EPOCH + met_to_j2000ns(hist.SEC)).astype("datetime64[D]")
|
|
77
|
+
hists_by_day[hist_day].append(hist_l1a)
|
|
78
|
+
|
|
79
|
+
# Generate CDF files for each day
|
|
80
|
+
output_datasets = []
|
|
81
|
+
for hist_l1a_list in hists_by_day.values():
|
|
82
|
+
dataset = generate_histogram_dataset(hist_l1a_list, glows_attrs)
|
|
83
|
+
output_datasets.append(dataset)
|
|
84
|
+
|
|
85
|
+
for de_l1a_list in de_by_day.values():
|
|
86
|
+
dataset = generate_de_dataset(de_l1a_list, glows_attrs)
|
|
87
|
+
output_datasets.append(dataset)
|
|
88
|
+
|
|
89
|
+
return output_datasets
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def process_de_l0(
|
|
93
|
+
de_l0: list[DirectEventL0],
|
|
94
|
+
) -> dict[np.datetime64, list[DirectEventL1A]]:
|
|
95
|
+
"""
|
|
96
|
+
Will process Direct Event packets into GLOWS L1A CDF files.
|
|
97
|
+
|
|
98
|
+
This involves combining packets with direct event sequences that span multiple
|
|
99
|
+
packets.
|
|
100
|
+
|
|
101
|
+
Parameters
|
|
102
|
+
----------
|
|
103
|
+
de_l0 : list[DirectEventL0]
|
|
104
|
+
List of DirectEventL0 objects.
|
|
105
|
+
|
|
106
|
+
Returns
|
|
107
|
+
-------
|
|
108
|
+
de_by_day : dict[np.datetime64, list[DirectEventL1A]]
|
|
109
|
+
Dictionary with keys of days and values of lists of DirectEventL1A objects.
|
|
110
|
+
Each day has one CDF file associated with it.
|
|
111
|
+
"""
|
|
112
|
+
de_by_day = dict()
|
|
113
|
+
|
|
114
|
+
for de in de_l0:
|
|
115
|
+
de_day = (J2000_EPOCH + met_to_j2000ns(de.MET)).astype("datetime64[D]")
|
|
116
|
+
if de_day not in de_by_day:
|
|
117
|
+
de_by_day[de_day] = [DirectEventL1A(de)]
|
|
118
|
+
# Putting not first data int o last direct event list.
|
|
119
|
+
elif de.SEQ != 0:
|
|
120
|
+
# If the direct event is part of a sequence and is not the first,
|
|
121
|
+
# append it to the last direct event in the list
|
|
122
|
+
de_by_day[de_day][-1].append(de)
|
|
123
|
+
else:
|
|
124
|
+
de_by_day[de_day].append(DirectEventL1A(de))
|
|
125
|
+
|
|
126
|
+
return de_by_day
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
def generate_de_dataset(
|
|
130
|
+
de_l1a_list: list[DirectEventL1A],
|
|
131
|
+
glows_cdf_attributes: ImapCdfAttributes,
|
|
132
|
+
) -> xr.Dataset:
|
|
133
|
+
"""
|
|
134
|
+
Generate a dataset for GLOWS L1A direct event data CDF files.
|
|
135
|
+
|
|
136
|
+
Parameters
|
|
137
|
+
----------
|
|
138
|
+
de_l1a_list : list[DirectEventL1A]
|
|
139
|
+
List of DirectEventL1A objects for a given day.
|
|
140
|
+
glows_cdf_attributes : ImapCdfAttributes
|
|
141
|
+
Object containing l1a CDF attributes for instrument glows.
|
|
142
|
+
|
|
143
|
+
Returns
|
|
144
|
+
-------
|
|
145
|
+
output : xarray.Dataset
|
|
146
|
+
Dataset containing the GLOWS L1A direct event CDF output.
|
|
147
|
+
"""
|
|
148
|
+
# TODO: Block header per second, or global attribute?
|
|
149
|
+
|
|
150
|
+
# Store timestamps for each DirectEventL1a object.
|
|
151
|
+
time_data = np.zeros(len(de_l1a_list), dtype="datetime64[ns]")
|
|
152
|
+
# TODO: Should each timestamp point to a list of direct events, each with a
|
|
153
|
+
# timestamp? Or should the list be split out to make the timestamps?
|
|
154
|
+
|
|
155
|
+
# Each DirectEventL1A class covers 1 second of direct events data
|
|
156
|
+
direct_events = np.zeros((len(de_l1a_list), len(de_l1a_list[0].direct_events), 4))
|
|
157
|
+
|
|
158
|
+
support_data: dict = {
|
|
159
|
+
# "flight_software_version": [], # breaks
|
|
160
|
+
"seq_count_in_pkts_file": [], # works
|
|
161
|
+
"number_of_de_packets": [], # works
|
|
162
|
+
# "missing_packet_sequences": [] # breaks
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
data_every_second: dict = {
|
|
166
|
+
"imap_sclk_last_pps": [],
|
|
167
|
+
"glows_sclk_last_pps": [],
|
|
168
|
+
"glows_ssclk_last_pps": [],
|
|
169
|
+
"imap_sclk_next_pps": [],
|
|
170
|
+
"catbed_heater_active": [],
|
|
171
|
+
"spin_period_valid": [],
|
|
172
|
+
"spin_phase_at_next_pps_valid": [],
|
|
173
|
+
"spin_period_source": [],
|
|
174
|
+
"spin_period": [],
|
|
175
|
+
"spin_phase_at_next_pps": [],
|
|
176
|
+
"number_of_completed_spins": [],
|
|
177
|
+
"filter_temperature": [],
|
|
178
|
+
"hv_voltage": [],
|
|
179
|
+
"glows_time_on_pps_valid": [],
|
|
180
|
+
"time_status_valid": [],
|
|
181
|
+
"housekeeping_valid": [],
|
|
182
|
+
"is_pps_autogenerated": [],
|
|
183
|
+
"hv_test_in_progress": [],
|
|
184
|
+
"pulse_test_in_progress": [],
|
|
185
|
+
"memory_error_detected": [],
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
for index, de in enumerate(de_l1a_list):
|
|
189
|
+
# Set the timestamp to the first timestamp of the direct event list
|
|
190
|
+
epoch_time = met_to_j2000ns(de.l0.MET).astype("datetime64[ns]")
|
|
191
|
+
|
|
192
|
+
# determine if the length of the direct_events numpy array is long enough,
|
|
193
|
+
# and extend the direct_events length dimension if necessary.
|
|
194
|
+
de_len = len(de.direct_events)
|
|
195
|
+
if de_len > direct_events.shape[1]:
|
|
196
|
+
# If the new DE list is longer than the existing shape, first reshape
|
|
197
|
+
# direct_events and pad the existing vectors with zeros.
|
|
198
|
+
direct_events = np.pad(
|
|
199
|
+
direct_events,
|
|
200
|
+
(
|
|
201
|
+
(
|
|
202
|
+
0,
|
|
203
|
+
0,
|
|
204
|
+
),
|
|
205
|
+
(0, de_len - direct_events.shape[1]),
|
|
206
|
+
(0, 0),
|
|
207
|
+
),
|
|
208
|
+
"constant",
|
|
209
|
+
constant_values=(0,),
|
|
210
|
+
)
|
|
211
|
+
|
|
212
|
+
new_de = np.array([event.to_list() for event in de.direct_events])
|
|
213
|
+
|
|
214
|
+
direct_events[index, : len(de.direct_events), :] = new_de
|
|
215
|
+
time_data[index] = epoch_time
|
|
216
|
+
|
|
217
|
+
# Adding data that will go into CDF file
|
|
218
|
+
# support_data["flight_software_version"].append(
|
|
219
|
+
# str(de.l0.ccsds_header.VERSION))
|
|
220
|
+
support_data["seq_count_in_pkts_file"].append(
|
|
221
|
+
int(de.l0.ccsds_header.SRC_SEQ_CTR)
|
|
222
|
+
)
|
|
223
|
+
support_data["number_of_de_packets"].append(int(de.l0.LEN))
|
|
224
|
+
# support_data["missing_packet_sequences"].append(str(de.missing_seq))
|
|
225
|
+
|
|
226
|
+
for key in data_every_second.keys():
|
|
227
|
+
data_every_second[key].append(de.status_data.__getattribute__(key))
|
|
228
|
+
|
|
229
|
+
# Convert arrays and dictionaries into xarray 'DataArray' objects
|
|
230
|
+
epoch_time = xr.DataArray(
|
|
231
|
+
time_data,
|
|
232
|
+
name="epoch",
|
|
233
|
+
dims=["epoch"],
|
|
234
|
+
attrs=glows_cdf_attributes.get_variable_attributes("epoch"),
|
|
235
|
+
)
|
|
236
|
+
|
|
237
|
+
direct_event = xr.DataArray(
|
|
238
|
+
# Corresponds to DirectEvent (seconds, subseconds, impulse_length, multi_event)
|
|
239
|
+
np.arange(4),
|
|
240
|
+
name="direct_event",
|
|
241
|
+
dims=["direct_event"],
|
|
242
|
+
attrs=glows_cdf_attributes.get_variable_attributes(
|
|
243
|
+
"direct_event_components_attrs"
|
|
244
|
+
),
|
|
245
|
+
)
|
|
246
|
+
|
|
247
|
+
# TODO come up with a better name
|
|
248
|
+
within_the_second = xr.DataArray(
|
|
249
|
+
np.arange(direct_events.shape[1]),
|
|
250
|
+
name="within_the_second",
|
|
251
|
+
dims=["within_the_second"],
|
|
252
|
+
attrs=glows_cdf_attributes.get_variable_attributes("within_the_second"),
|
|
253
|
+
)
|
|
254
|
+
|
|
255
|
+
de = xr.DataArray(
|
|
256
|
+
direct_events,
|
|
257
|
+
name="direct_events",
|
|
258
|
+
dims=["epoch", "within_the_second", "direct_event"],
|
|
259
|
+
coords={
|
|
260
|
+
"epoch": epoch_time,
|
|
261
|
+
"within_the_second": within_the_second,
|
|
262
|
+
"direct_event": direct_event,
|
|
263
|
+
},
|
|
264
|
+
attrs=glows_cdf_attributes.get_variable_attributes("direct_events"),
|
|
265
|
+
)
|
|
266
|
+
|
|
267
|
+
# TODO: This is the weird global attribute.
|
|
268
|
+
# Create an xarray dataset object, and add DataArray objects into it
|
|
269
|
+
output = xr.Dataset(
|
|
270
|
+
coords={"epoch": time_data},
|
|
271
|
+
attrs=glows_cdf_attributes.get_global_attributes("imap_glows_l1a_de"),
|
|
272
|
+
)
|
|
273
|
+
|
|
274
|
+
output["direct_events"] = de
|
|
275
|
+
|
|
276
|
+
# TODO: Do we want missing_sequences as support data or as global attrs?
|
|
277
|
+
# Currently: support data, with a string
|
|
278
|
+
|
|
279
|
+
for key, value in support_data.items():
|
|
280
|
+
output[key] = xr.DataArray(
|
|
281
|
+
value,
|
|
282
|
+
name=key,
|
|
283
|
+
dims=["epoch"],
|
|
284
|
+
coords={"epoch": epoch_time},
|
|
285
|
+
attrs=glows_cdf_attributes.get_variable_attributes(key),
|
|
286
|
+
)
|
|
287
|
+
|
|
288
|
+
for key, value in data_every_second.items():
|
|
289
|
+
output[key] = xr.DataArray(
|
|
290
|
+
value,
|
|
291
|
+
name=key,
|
|
292
|
+
dims=["epoch"],
|
|
293
|
+
coords={"epoch": epoch_time},
|
|
294
|
+
attrs=glows_cdf_attributes.get_variable_attributes(key),
|
|
295
|
+
)
|
|
296
|
+
|
|
297
|
+
return output
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
def generate_histogram_dataset(
|
|
301
|
+
hist_l1a_list: list[HistogramL1A], glows_cdf_attributes: ImapCdfAttributes
|
|
302
|
+
) -> xr.Dataset:
|
|
303
|
+
"""
|
|
304
|
+
Generate a dataset for GLOWS L1A histogram data CDF files.
|
|
305
|
+
|
|
306
|
+
Parameters
|
|
307
|
+
----------
|
|
308
|
+
hist_l1a_list : list[HistogramL1A]
|
|
309
|
+
List of HistogramL1A objects for a given day.
|
|
310
|
+
glows_cdf_attributes : ImapCdfAttributes
|
|
311
|
+
Object containing l1a CDF attributes for instrument glows.
|
|
312
|
+
|
|
313
|
+
Returns
|
|
314
|
+
-------
|
|
315
|
+
output : xarray.Dataset
|
|
316
|
+
Dataset containing the GLOWS L1A histogram CDF output.
|
|
317
|
+
"""
|
|
318
|
+
# Store timestamps for each HistogramL1A object.
|
|
319
|
+
time_data = np.zeros(len(hist_l1a_list), dtype="datetime64[ns]")
|
|
320
|
+
# TODO Add daily average of histogram counts
|
|
321
|
+
# TODO compute average temperature etc
|
|
322
|
+
# Data in lists, for each of the 25 time varying datapoints in HistogramL1A
|
|
323
|
+
|
|
324
|
+
hist_data = np.zeros((len(hist_l1a_list), 3600))
|
|
325
|
+
|
|
326
|
+
# TODO: add missing attributes
|
|
327
|
+
support_data: dict = {
|
|
328
|
+
"flight_software_version": [],
|
|
329
|
+
# "pkts_file_name": [],
|
|
330
|
+
"seq_count_in_pkts_file": [],
|
|
331
|
+
"last_spin_id": [],
|
|
332
|
+
"flags_set_onboard": [],
|
|
333
|
+
"is_generated_on_ground": [],
|
|
334
|
+
"number_of_spins_per_block": [],
|
|
335
|
+
"number_of_bins_per_histogram": [],
|
|
336
|
+
"number_of_events": [],
|
|
337
|
+
"filter_temperature_average": [],
|
|
338
|
+
"filter_temperature_variance": [],
|
|
339
|
+
"hv_voltage_average": [],
|
|
340
|
+
"hv_voltage_variance": [],
|
|
341
|
+
"spin_period_average": [],
|
|
342
|
+
"spin_period_variance": [],
|
|
343
|
+
"pulse_length_average": [],
|
|
344
|
+
"pulse_length_variance": [],
|
|
345
|
+
}
|
|
346
|
+
time_metadata: dict = {
|
|
347
|
+
"imap_start_time": [],
|
|
348
|
+
"imap_time_offset": [],
|
|
349
|
+
"glows_start_time": [],
|
|
350
|
+
"glows_time_offset": [],
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
for index, hist in enumerate(hist_l1a_list):
|
|
354
|
+
# TODO: Should this be MET?
|
|
355
|
+
epoch_time = met_to_j2000ns(hist.imap_start_time.to_seconds())
|
|
356
|
+
hist_data[index] = hist.histograms
|
|
357
|
+
|
|
358
|
+
support_data["flags_set_onboard"].append(hist.flags["flags_set_onboard"])
|
|
359
|
+
support_data["is_generated_on_ground"].append(
|
|
360
|
+
int(hist.flags["is_generated_on_ground"])
|
|
361
|
+
)
|
|
362
|
+
|
|
363
|
+
# Add support_data keys to the support_data dictionary
|
|
364
|
+
for key in support_data.keys():
|
|
365
|
+
if key not in ["flags_set_onboard", "is_generated_on_ground"]:
|
|
366
|
+
support_data[key].append(hist.__getattribute__(key))
|
|
367
|
+
# For the time varying data, convert to seconds and then append
|
|
368
|
+
for key in time_metadata.keys():
|
|
369
|
+
time_metadata[key].append(hist.__getattribute__(key).to_seconds())
|
|
370
|
+
time_data[index] = epoch_time
|
|
371
|
+
|
|
372
|
+
epoch_time = xr.DataArray(
|
|
373
|
+
time_data,
|
|
374
|
+
name="epoch",
|
|
375
|
+
dims=["epoch"],
|
|
376
|
+
attrs=glows_cdf_attributes.get_variable_attributes("epoch"),
|
|
377
|
+
)
|
|
378
|
+
bin_count = 3600 # TODO: Is it always 3600 bins?
|
|
379
|
+
|
|
380
|
+
bins = xr.DataArray(
|
|
381
|
+
np.arange(bin_count),
|
|
382
|
+
name="bins",
|
|
383
|
+
dims=["bins"],
|
|
384
|
+
attrs=glows_cdf_attributes.get_variable_attributes("bins_attrs"),
|
|
385
|
+
)
|
|
386
|
+
|
|
387
|
+
hist = xr.DataArray(
|
|
388
|
+
hist_data,
|
|
389
|
+
name="histograms",
|
|
390
|
+
dims=["epoch", "bins"],
|
|
391
|
+
coords={"epoch": epoch_time, "bins": bins},
|
|
392
|
+
attrs=glows_cdf_attributes.get_variable_attributes(
|
|
393
|
+
"histogram"
|
|
394
|
+
), # Used to be histogram_attrs
|
|
395
|
+
)
|
|
396
|
+
|
|
397
|
+
attrs = glows_cdf_attributes.get_global_attributes("imap_glows_l1a_hist")
|
|
398
|
+
|
|
399
|
+
output = xr.Dataset(
|
|
400
|
+
coords={"epoch": epoch_time, "bins": bins},
|
|
401
|
+
attrs=attrs,
|
|
402
|
+
)
|
|
403
|
+
|
|
404
|
+
output["histograms"] = hist
|
|
405
|
+
|
|
406
|
+
for key, value in support_data.items():
|
|
407
|
+
output[key] = xr.DataArray(
|
|
408
|
+
value,
|
|
409
|
+
name=key,
|
|
410
|
+
dims=["epoch"],
|
|
411
|
+
coords={"epoch": epoch_time},
|
|
412
|
+
attrs=glows_cdf_attributes.get_variable_attributes(key),
|
|
413
|
+
)
|
|
414
|
+
|
|
415
|
+
for key, value in time_metadata.items():
|
|
416
|
+
output[key] = xr.DataArray(
|
|
417
|
+
value,
|
|
418
|
+
name=key,
|
|
419
|
+
dims=["epoch"],
|
|
420
|
+
coords={"epoch": epoch_time},
|
|
421
|
+
attrs=glows_cdf_attributes.get_variable_attributes(key),
|
|
422
|
+
)
|
|
423
|
+
|
|
424
|
+
return output
|