imap-processing 0.7.0__py3-none-any.whl → 0.9.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.

Files changed (172) hide show
  1. imap_processing/__init__.py +1 -1
  2. imap_processing/_version.py +2 -2
  3. imap_processing/ccsds/excel_to_xtce.py +36 -2
  4. imap_processing/cdf/config/imap_codice_global_cdf_attrs.yaml +1 -1
  5. imap_processing/cdf/config/imap_codice_l1a_variable_attrs.yaml +145 -30
  6. imap_processing/cdf/config/imap_glows_l1b_variable_attrs.yaml +36 -36
  7. imap_processing/cdf/config/imap_hi_variable_attrs.yaml +136 -9
  8. imap_processing/cdf/config/imap_hit_global_cdf_attrs.yaml +14 -0
  9. imap_processing/cdf/config/imap_hit_l1a_variable_attrs.yaml +63 -1
  10. imap_processing/cdf/config/imap_hit_l1b_variable_attrs.yaml +9 -0
  11. imap_processing/cdf/config/imap_idex_global_cdf_attrs.yaml +14 -7
  12. imap_processing/cdf/config/imap_idex_l1a_variable_attrs.yaml +577 -235
  13. imap_processing/cdf/config/imap_idex_l1b_variable_attrs.yaml +326 -0
  14. imap_processing/cdf/config/imap_lo_l1a_variable_attrs.yaml +33 -23
  15. imap_processing/cdf/config/imap_mag_l1_variable_attrs.yaml +24 -28
  16. imap_processing/cdf/config/imap_ultra_l1a_variable_attrs.yaml +1 -0
  17. imap_processing/cdf/config/imap_ultra_l1b_variable_attrs.yaml +137 -79
  18. imap_processing/cdf/config/imap_variable_schema.yaml +13 -0
  19. imap_processing/cdf/imap_cdf_manager.py +31 -27
  20. imap_processing/cdf/utils.py +3 -5
  21. imap_processing/cli.py +25 -14
  22. imap_processing/codice/codice_l1a.py +153 -63
  23. imap_processing/codice/constants.py +10 -10
  24. imap_processing/codice/decompress.py +10 -11
  25. imap_processing/codice/utils.py +1 -0
  26. imap_processing/glows/l1a/glows_l1a.py +1 -2
  27. imap_processing/glows/l1b/glows_l1b.py +3 -3
  28. imap_processing/glows/l1b/glows_l1b_data.py +59 -37
  29. imap_processing/glows/l2/glows_l2_data.py +123 -0
  30. imap_processing/hi/l1a/hi_l1a.py +4 -4
  31. imap_processing/hi/l1a/histogram.py +107 -109
  32. imap_processing/hi/l1a/science_direct_event.py +92 -225
  33. imap_processing/hi/l1b/hi_l1b.py +85 -11
  34. imap_processing/hi/l1c/hi_l1c.py +23 -1
  35. imap_processing/hi/packet_definitions/TLM_HI_COMBINED_SCI.xml +3994 -0
  36. imap_processing/hi/utils.py +1 -1
  37. imap_processing/hit/hit_utils.py +221 -0
  38. imap_processing/hit/l0/constants.py +118 -0
  39. imap_processing/hit/l0/decom_hit.py +100 -156
  40. imap_processing/hit/l1a/hit_l1a.py +170 -184
  41. imap_processing/hit/l1b/hit_l1b.py +33 -153
  42. imap_processing/ialirt/l0/process_codicelo.py +153 -0
  43. imap_processing/ialirt/l0/process_hit.py +5 -5
  44. imap_processing/ialirt/packet_definitions/ialirt_codicelo.xml +281 -0
  45. imap_processing/ialirt/process_ephemeris.py +212 -0
  46. imap_processing/idex/idex_l1a.py +65 -84
  47. imap_processing/idex/idex_l1b.py +192 -0
  48. imap_processing/idex/idex_variable_unpacking_and_eu_conversion.csv +33 -0
  49. imap_processing/idex/packet_definitions/idex_packet_definition.xml +97 -595
  50. imap_processing/lo/l0/decompression_tables/decompression_tables.py +17 -1
  51. imap_processing/lo/l0/lo_science.py +45 -13
  52. imap_processing/lo/l1a/lo_l1a.py +76 -8
  53. imap_processing/lo/packet_definitions/lo_xtce.xml +8344 -1849
  54. imap_processing/mag/l0/decom_mag.py +4 -3
  55. imap_processing/mag/l1a/mag_l1a.py +12 -13
  56. imap_processing/mag/l1a/mag_l1a_data.py +1 -2
  57. imap_processing/mag/l1b/mag_l1b.py +90 -7
  58. imap_processing/spice/geometry.py +156 -16
  59. imap_processing/spice/time.py +144 -2
  60. imap_processing/swapi/l1/swapi_l1.py +4 -4
  61. imap_processing/swapi/l2/swapi_l2.py +1 -1
  62. imap_processing/swapi/packet_definitions/swapi_packet_definition.xml +1535 -446
  63. imap_processing/swe/l1b/swe_l1b_science.py +8 -8
  64. imap_processing/swe/l2/swe_l2.py +134 -17
  65. imap_processing/tests/ccsds/test_data/expected_output.xml +2 -1
  66. imap_processing/tests/ccsds/test_excel_to_xtce.py +4 -4
  67. imap_processing/tests/cdf/test_imap_cdf_manager.py +0 -10
  68. imap_processing/tests/codice/conftest.py +1 -17
  69. imap_processing/tests/codice/data/imap_codice_l0_raw_20241110_v001.pkts +0 -0
  70. imap_processing/tests/codice/test_codice_l0.py +8 -2
  71. imap_processing/tests/codice/test_codice_l1a.py +127 -107
  72. imap_processing/tests/codice/test_codice_l1b.py +1 -0
  73. imap_processing/tests/codice/test_decompress.py +7 -7
  74. imap_processing/tests/conftest.py +100 -58
  75. imap_processing/tests/glows/conftest.py +6 -0
  76. imap_processing/tests/glows/test_glows_l1b.py +9 -9
  77. imap_processing/tests/glows/test_glows_l1b_data.py +9 -9
  78. imap_processing/tests/hi/test_data/l0/H90_NHK_20241104.bin +0 -0
  79. imap_processing/tests/hi/test_data/l0/H90_sci_cnt_20241104.bin +0 -0
  80. imap_processing/tests/hi/test_data/l0/H90_sci_de_20241104.bin +0 -0
  81. imap_processing/tests/hi/test_data/l1a/imap_hi_l1a_45sensor-de_20250415_v000.cdf +0 -0
  82. imap_processing/tests/hi/test_hi_l1b.py +73 -3
  83. imap_processing/tests/hi/test_hi_l1c.py +10 -2
  84. imap_processing/tests/hi/test_l1a.py +31 -58
  85. imap_processing/tests/hi/test_science_direct_event.py +58 -0
  86. imap_processing/tests/hi/test_utils.py +4 -3
  87. imap_processing/tests/hit/test_data/sci_sample1.ccsds +0 -0
  88. imap_processing/tests/hit/{test_hit_decom.py → test_decom_hit.py} +95 -36
  89. imap_processing/tests/hit/test_hit_l1a.py +299 -179
  90. imap_processing/tests/hit/test_hit_l1b.py +231 -24
  91. imap_processing/tests/hit/test_hit_utils.py +218 -0
  92. imap_processing/tests/hit/validation_data/hskp_sample_eu.csv +89 -0
  93. imap_processing/tests/hit/validation_data/sci_sample_raw1.csv +29 -0
  94. imap_processing/tests/ialirt/test_data/l0/apid01152.tlm +0 -0
  95. imap_processing/tests/ialirt/test_data/l0/imap_codice_l1a_lo-ialirt_20241110193700_v0.0.0.cdf +0 -0
  96. imap_processing/tests/ialirt/unit/test_process_codicelo.py +106 -0
  97. imap_processing/tests/ialirt/unit/test_process_ephemeris.py +109 -0
  98. imap_processing/tests/ialirt/unit/test_process_hit.py +9 -6
  99. imap_processing/tests/idex/conftest.py +2 -2
  100. imap_processing/tests/idex/imap_idex_l0_raw_20231214_v001.pkts +0 -0
  101. imap_processing/tests/idex/impact_14_tof_high_data.txt +4444 -4444
  102. imap_processing/tests/idex/test_idex_l0.py +4 -4
  103. imap_processing/tests/idex/test_idex_l1a.py +8 -2
  104. imap_processing/tests/idex/test_idex_l1b.py +126 -0
  105. imap_processing/tests/lo/test_lo_l1a.py +7 -16
  106. imap_processing/tests/lo/test_lo_science.py +69 -5
  107. imap_processing/tests/lo/test_pkts/imap_lo_l0_raw_20240803_v002.pkts +0 -0
  108. imap_processing/tests/lo/validation_data/Instrument_FM1_T104_R129_20240803_ILO_SCI_DE_dec_DN_with_fills.csv +1999 -0
  109. imap_processing/tests/mag/imap_mag_l1a_norm-magi_20251017_v001.cdf +0 -0
  110. imap_processing/tests/mag/test_mag_l1b.py +97 -7
  111. imap_processing/tests/spice/test_data/imap_ena_sim_metakernel.template +3 -1
  112. imap_processing/tests/spice/test_geometry.py +115 -9
  113. imap_processing/tests/spice/test_time.py +135 -6
  114. imap_processing/tests/swapi/test_swapi_decom.py +75 -69
  115. imap_processing/tests/swapi/test_swapi_l1.py +4 -4
  116. imap_processing/tests/swe/conftest.py +33 -0
  117. imap_processing/tests/swe/l1_validation/swe_l0_unpacked-data_20240510_v001_VALIDATION_L1B_v3.dat +4332 -0
  118. imap_processing/tests/swe/test_swe_l1b.py +29 -8
  119. imap_processing/tests/swe/test_swe_l2.py +64 -8
  120. imap_processing/tests/test_utils.py +2 -2
  121. imap_processing/tests/ultra/test_data/l0/ultra45_raw_sc_ultrarawimg_withFSWcalcs_FM45_40P_Phi28p5_BeamCal_LinearScan_phi2850_theta-000_20240207T102740.csv +3314 -3314
  122. imap_processing/tests/ultra/test_data/l1/dps_exposure_helio_45_E12.cdf +0 -0
  123. imap_processing/tests/ultra/test_data/l1/dps_exposure_helio_45_E24.cdf +0 -0
  124. imap_processing/tests/ultra/unit/test_de.py +113 -0
  125. imap_processing/tests/ultra/unit/test_spatial_utils.py +125 -0
  126. imap_processing/tests/ultra/unit/test_ultra_l1b.py +27 -3
  127. imap_processing/tests/ultra/unit/test_ultra_l1b_annotated.py +31 -10
  128. imap_processing/tests/ultra/unit/test_ultra_l1b_extended.py +55 -35
  129. imap_processing/tests/ultra/unit/test_ultra_l1c_pset_bins.py +10 -68
  130. imap_processing/ultra/constants.py +12 -3
  131. imap_processing/ultra/l1b/de.py +168 -30
  132. imap_processing/ultra/l1b/ultra_l1b_annotated.py +24 -10
  133. imap_processing/ultra/l1b/ultra_l1b_extended.py +46 -80
  134. imap_processing/ultra/l1c/ultra_l1c_pset_bins.py +60 -144
  135. imap_processing/ultra/utils/spatial_utils.py +221 -0
  136. {imap_processing-0.7.0.dist-info → imap_processing-0.9.0.dist-info}/METADATA +15 -14
  137. {imap_processing-0.7.0.dist-info → imap_processing-0.9.0.dist-info}/RECORD +142 -139
  138. imap_processing/cdf/cdf_attribute_manager.py +0 -322
  139. imap_processing/cdf/config/shared/default_global_cdf_attrs_schema.yaml +0 -246
  140. imap_processing/cdf/config/shared/default_variable_cdf_attrs_schema.yaml +0 -466
  141. imap_processing/hi/l0/decom_hi.py +0 -24
  142. imap_processing/hi/packet_definitions/hi_packet_definition.xml +0 -482
  143. imap_processing/hit/l0/data_classes/housekeeping.py +0 -240
  144. imap_processing/hit/l0/data_classes/science_packet.py +0 -259
  145. imap_processing/hit/l0/utils/hit_base.py +0 -57
  146. imap_processing/tests/cdf/shared/default_global_cdf_attrs_schema.yaml +0 -246
  147. imap_processing/tests/cdf/shared/default_variable_cdf_attrs_schema.yaml +0 -466
  148. imap_processing/tests/cdf/test_cdf_attribute_manager.py +0 -353
  149. imap_processing/tests/codice/data/imap_codice_l0_hi-counters-aggregated_20240429_v001.pkts +0 -0
  150. imap_processing/tests/codice/data/imap_codice_l0_hi-counters-singles_20240429_v001.pkts +0 -0
  151. imap_processing/tests/codice/data/imap_codice_l0_hi-omni_20240429_v001.pkts +0 -0
  152. imap_processing/tests/codice/data/imap_codice_l0_hi-pha_20240429_v001.pkts +0 -0
  153. imap_processing/tests/codice/data/imap_codice_l0_hi-sectored_20240429_v001.pkts +0 -0
  154. imap_processing/tests/codice/data/imap_codice_l0_hskp_20100101_v001.pkts +0 -0
  155. imap_processing/tests/codice/data/imap_codice_l0_lo-counters-aggregated_20240429_v001.pkts +0 -0
  156. imap_processing/tests/codice/data/imap_codice_l0_lo-counters-singles_20240429_v001.pkts +0 -0
  157. imap_processing/tests/codice/data/imap_codice_l0_lo-nsw-angular_20240429_v001.pkts +0 -0
  158. imap_processing/tests/codice/data/imap_codice_l0_lo-nsw-priority_20240429_v001.pkts +0 -0
  159. imap_processing/tests/codice/data/imap_codice_l0_lo-nsw-species_20240429_v001.pkts +0 -0
  160. imap_processing/tests/codice/data/imap_codice_l0_lo-pha_20240429_v001.pkts +0 -0
  161. imap_processing/tests/codice/data/imap_codice_l0_lo-sw-angular_20240429_v001.pkts +0 -0
  162. imap_processing/tests/codice/data/imap_codice_l0_lo-sw-priority_20240429_v001.pkts +0 -0
  163. imap_processing/tests/codice/data/imap_codice_l0_lo-sw-species_20240429_v001.pkts +0 -0
  164. imap_processing/tests/hi/test_decom.py +0 -55
  165. imap_processing/tests/hi/test_l1a_sci_de.py +0 -72
  166. imap_processing/tests/idex/imap_idex_l0_raw_20230725_v001.pkts +0 -0
  167. imap_processing/tests/mag/imap_mag_l1a_burst-magi_20231025_v001.cdf +0 -0
  168. /imap_processing/{hi/l0/__init__.py → tests/glows/test_glows_l2_data.py} +0 -0
  169. /imap_processing/tests/hit/test_data/{imap_hit_l0_hk_20100105_v001.pkts → imap_hit_l0_raw_20100105_v001.pkts} +0 -0
  170. {imap_processing-0.7.0.dist-info → imap_processing-0.9.0.dist-info}/LICENSE +0 -0
  171. {imap_processing-0.7.0.dist-info → imap_processing-0.9.0.dist-info}/WHEEL +0 -0
  172. {imap_processing-0.7.0.dist-info → imap_processing-0.9.0.dist-info}/entry_points.txt +0 -0
@@ -1,353 +0,0 @@
1
- from pathlib import Path
2
-
3
- import pytest
4
-
5
- from imap_processing.cdf.cdf_attribute_manager import CdfAttributeManager
6
-
7
-
8
- def test_default_attr_schema():
9
- """
10
- Test function that covers:
11
- _load_default_global_attr_schema
12
- _load_default_variable_attr_schema
13
- """
14
-
15
- # Initialize CdfAttributeManager object which loads in default schema
16
- cdf_manager = CdfAttributeManager(Path(__file__).parent.parent / "cdf")
17
-
18
- # Default global tests
19
- assert cdf_manager.global_attribute_schema["DOI"]["required"] is False
20
- assert cdf_manager.global_attribute_schema["Data_level"]["required"] is True
21
-
22
- # Default variable tests
23
- assert (
24
- cdf_manager.variable_attribute_schema["attribute_key"]["ABSOLUTE_ERROR"][
25
- "required"
26
- ]
27
- is False
28
- )
29
- assert (
30
- cdf_manager.variable_attribute_schema["attribute_key"]["RESOLUTION"]["required"]
31
- is True
32
- )
33
-
34
-
35
- def test_load_global_attribute():
36
- """
37
- Test function that covers:
38
- load_global_attributes
39
- """
40
-
41
- # Initialize CdfAttributeManager object which loads in default info
42
- cdf_manager = CdfAttributeManager(Path(__file__).parent.parent / "cdf")
43
- cdf_manager.load_global_attributes("imap_default_global_cdf_attrs.yaml")
44
-
45
- # Testing information has been loaded in
46
- assert cdf_manager._global_attributes["Project"] == "STP>Solar-Terrestrial Physics"
47
- assert (
48
- cdf_manager._global_attributes["Source_name"]
49
- == "IMAP>Interstellar Mapping and Acceleration Probe"
50
- )
51
- assert (
52
- cdf_manager._global_attributes["Discipline"]
53
- == "Solar Physics>Heliospheric Physics"
54
- )
55
- assert (
56
- cdf_manager._global_attributes["Mission_group"]
57
- == "IMAP>Interstellar Mapping and Acceleration Probe"
58
- )
59
- assert cdf_manager._global_attributes["PI_name"] == "Dr. David J. McComas"
60
- assert (
61
- cdf_manager._global_attributes["PI_affiliation"]
62
- == "Princeton Plasma Physics Laboratory, 100 Stellarator Road, "
63
- "Princeton, NJ 08540"
64
- )
65
- assert (
66
- cdf_manager._global_attributes["File_naming_convention"]
67
- == "source_descriptor_datatype_yyyyMMdd_vNNN"
68
- )
69
- # The following test should fail because "DOI" is not an attribute in
70
- # imap_default_global_cdf_attrs.yaml
71
- with pytest.raises(KeyError):
72
- assert cdf_manager._global_attributes["DOI"] == "test"
73
-
74
- # Load in different data
75
- cdf_manager.source_dir = Path(__file__).parent.parent / "cdf" / "test_data"
76
- cdf_manager.load_global_attributes("imap_default_global_test_cdf_attrs.yaml")
77
-
78
- # Testing attributes carried over
79
- assert (
80
- cdf_manager._global_attributes["File_naming_convention"]
81
- == "source_descriptor_datatype_yyyyMMdd_vNNN"
82
- )
83
- assert (
84
- cdf_manager._global_attributes["Discipline"]
85
- == "Solar Physics>Heliospheric Physics"
86
- )
87
-
88
- # Testing attributes newly loaded
89
- assert cdf_manager._global_attributes["Project"] == "STP>Solar-Terrestrial Physics"
90
- assert (
91
- cdf_manager._global_attributes["Source_name"]
92
- == "IMAP>Interstellar Mapping and Acceleration Probe"
93
- )
94
- assert cdf_manager._global_attributes["Mission_group"] == "Dysfunctional Cats"
95
- assert cdf_manager._global_attributes["PI_name"] == "Ana Manica"
96
- assert cdf_manager._global_attributes["PI_affiliation"] == "LASP, CU"
97
- assert cdf_manager._global_attributes["Data_version"] == 2
98
- assert cdf_manager._global_attributes["DOI"] == "test"
99
-
100
- # Testing that everything loaded into the global attrs is present in
101
- # the global attrs schema
102
- for attr in cdf_manager._global_attributes.keys():
103
- assert attr in cdf_manager.global_attribute_schema.keys()
104
-
105
-
106
- def test_get_global_attributes():
107
- """
108
- Test function that covers:
109
- get_global_attributes
110
- """
111
-
112
- # Initialize CdfAttributeManager object which loads in default info
113
- cdf_manager = CdfAttributeManager(Path(__file__).parent.parent / "cdf")
114
-
115
- # Change filepath to load test global attributes
116
- cdf_manager.source_dir = Path(__file__).parent.parent / "cdf" / "test_data"
117
- cdf_manager.load_global_attributes("imap_default_global_test_cdf_attrs.yaml")
118
- cdf_manager.load_global_attributes("imap_test_global.yaml")
119
-
120
- # Loading in instrument specific attributes
121
- test_get_global_attrs = cdf_manager.get_global_attributes("imap_test_T1_test")
122
-
123
- # Testing information previously loaded into global attributes (first if statement)
124
- assert test_get_global_attrs["Project"] == "STP>Solar-Terrestrial Physics"
125
- assert (
126
- test_get_global_attrs["Source_name"]
127
- == "IMAP>Interstellar Mapping and Acceleration Probe"
128
- )
129
- assert test_get_global_attrs["Mission_group"] == "Dysfunctional Cats"
130
- # Testing instrument specific global attributes (first elif statement)
131
- assert test_get_global_attrs["Descriptor"] == "TEST>Testinstrument"
132
- assert test_get_global_attrs["Data_type"] == "T1_test-one>Test-1 test one"
133
- assert test_get_global_attrs["Logical_source"] == "imap_test_T1_test"
134
- assert (
135
- test_get_global_attrs["Logical_source_description"]
136
- == "IMAP Mission TEST one document Level-T1."
137
- )
138
- # Not given, and not required information
139
- assert test_get_global_attrs["Data_level"] is None
140
- with pytest.raises(KeyError):
141
- assert test_get_global_attrs["bad_name"] == "false info"
142
-
143
- # Testing second elif statement
144
- test_error_elif = cdf_manager.get_global_attributes("imap_test_T3_test")
145
- with pytest.raises(KeyError):
146
- assert test_error_elif["Data_type"] == "Does Not Exist"
147
-
148
- # Load in more data using get_global_attributes
149
- test_get_global_attrs_2 = cdf_manager.get_global_attributes("imap_test_T2_test")
150
- # Testing information previously loaded into global attributes (first if statement)
151
- assert test_get_global_attrs_2["Project"] == "STP>Solar-Terrestrial Physics"
152
- # Testing first elif statement
153
- assert test_get_global_attrs_2["Descriptor"] == "TEST>Testinstrument"
154
- # "Data_type" not required according to default schema
155
- assert test_get_global_attrs_2["Data_type"] == "T2_test-two>Test-2 test two"
156
-
157
- # Testing that required schema keys are in get_global_attributes
158
- for attr_name in cdf_manager.global_attribute_schema.keys():
159
- required_schema = cdf_manager.global_attribute_schema[attr_name]["required"]
160
- if required_schema is True:
161
- assert attr_name in test_get_global_attrs.keys()
162
-
163
-
164
- def test_instrument_id_format():
165
- # Initialize CdfAttributeManager object which loads in default info
166
- cdf_manager = CdfAttributeManager(Path(__file__).parent.parent / "cdf")
167
-
168
- # Change filepath to load test global attributes
169
- cdf_manager.source_dir = Path(__file__).parent.parent / "cdf" / "test_data"
170
- cdf_manager.load_global_attributes("imap_default_global_test_cdf_attrs.yaml")
171
- cdf_manager.load_global_attributes("imap_test_global.yaml")
172
-
173
- # Loading in instrument specific attributes
174
- test_get_global_attrs = cdf_manager.get_global_attributes("imap_test_T1_test")
175
-
176
- # Testing how instrument_id operates
177
- assert test_get_global_attrs["Project"] == cdf_manager._global_attributes["Project"]
178
- assert (
179
- test_get_global_attrs["Source_name"]
180
- == cdf_manager._global_attributes["Source_name"]
181
- )
182
- assert (
183
- test_get_global_attrs["Data_type"]
184
- == cdf_manager._global_attributes["imap_test_T1_test"]["Data_type"]
185
- )
186
- assert (
187
- cdf_manager._global_attributes["imap_test_T1_test"]["Logical_source"]
188
- == "imap_test_T1_test"
189
- )
190
- with pytest.raises(KeyError):
191
- assert cdf_manager._global_attributes["imap_test_T1_test"]["Project"]
192
-
193
-
194
- def test_add_global_attribute():
195
- # Initialize CdfAttributeManager object which loads in default info
196
- cdf_manager = CdfAttributeManager(Path(__file__).parent.parent / "cdf")
197
-
198
- # Change filepath to load test global attributes
199
- cdf_manager.source_dir = Path(__file__).parent.parent / "cdf" / "test_data"
200
- cdf_manager.load_global_attributes("imap_test_global.yaml")
201
-
202
- # Changing a dynamic global variable
203
- cdf_manager.add_global_attribute("Project", "Test Project")
204
- test_get_global_attrs = cdf_manager.get_global_attributes("imap_test_T1_test")
205
- assert cdf_manager._global_attributes["Project"] == "Test Project"
206
- assert test_get_global_attrs["Project"] == "Test Project"
207
-
208
- # Testing adding required global attribute
209
- cdf_manager._global_attributes.__delitem__("Source_name")
210
- # Reloading get_global_attributes to pick up deleted Source_name
211
- test_get_global_attrs = cdf_manager.get_global_attributes("imap_test_T1_test")
212
- with pytest.raises(KeyError):
213
- assert cdf_manager._global_attributes["Source_name"]
214
- assert test_get_global_attrs["Source_name"] is None
215
-
216
- # Adding deleted global attribute
217
- cdf_manager.add_global_attribute("Source_name", "anas_source")
218
- assert cdf_manager._global_attributes["Source_name"] == "anas_source"
219
- # Reloading get_global_attributes to pick up added Source_name
220
- test_get_global_attrs = cdf_manager.get_global_attributes("imap_test_T1_test")
221
- assert test_get_global_attrs["Source_name"] == "anas_source"
222
-
223
- # Testing instrument specific attribute
224
- cdf_manager._global_attributes["imap_test_T1_test"].__delitem__("Logical_source")
225
- # Reloading get_global_attributes to pick up deleted Source_name
226
- test_get_global_attrs = cdf_manager.get_global_attributes("imap_test_T1_test")
227
- with pytest.raises(KeyError):
228
- assert cdf_manager._global_attributes["imap_test_T1_test"]["Logical_source"]
229
- assert test_get_global_attrs["Logical_source"] is None
230
-
231
-
232
- def test_variable_attribute():
233
- """
234
- Test function that covers:
235
- load_variable_attributes
236
- get_variable_attributes
237
- """
238
-
239
- # Creating CdfAttributeManager object, loading in default data
240
- cdf_manager = CdfAttributeManager(Path(__file__).parent.parent / "cdf")
241
- cdf_manager.source_dir = Path(__file__).parent.parent / "cdf" / "test_data"
242
- cdf_manager.load_global_attributes("imap_default_global_test_cdf_attrs.yaml")
243
- # Loading in test data
244
- cdf_manager.load_variable_attributes("imap_test_variable.yaml")
245
-
246
- # All variables required to have:
247
- expected_attributes = [
248
- "CATDESC",
249
- "DEPEND_0",
250
- "DISPLAY_TYPE",
251
- "FIELDNAM",
252
- "FILLVAL",
253
- "FORMAT",
254
- "LABLAXIS",
255
- "UNITS",
256
- "VALIDMIN",
257
- "VALIDMAX",
258
- "VAR_TYPE",
259
- ]
260
-
261
- # Assuring all required attributes are loaded in
262
- for attr_name in cdf_manager.variable_attribute_schema["attribute_key"]:
263
- attribute = cdf_manager.variable_attribute_schema["attribute_key"][attr_name]
264
- if attribute["required"] is True:
265
- for exp_attr in expected_attributes:
266
- assert (
267
- exp_attr in cdf_manager.variable_attribute_schema["attribute_key"]
268
- )
269
-
270
- # Testing specific attributes
271
- assert (
272
- cdf_manager._variable_attributes["default_attrs"]["DEPEND_0"]
273
- == cdf_manager._variable_attributes["default_attrs"]["DEPEND_0"]
274
- )
275
- assert cdf_manager._variable_attributes["default_attrs"]["FILLVAL"] == -10
276
- assert cdf_manager._variable_attributes["test_field_1"]["DEPEND_0"] == "test_depend"
277
- assert (
278
- cdf_manager._variable_attributes["default_attrs"]["VAR_TYPE"] == "test_var_type"
279
- )
280
- with pytest.raises(KeyError):
281
- assert cdf_manager._variable_attributes["default_attrs"]["CATDESC"] == "test"
282
-
283
-
284
- def test_get_variable_attributes():
285
- # Creating CdfAttributeManager object, loading in default data
286
- cdf_manager = CdfAttributeManager(Path(__file__).parent.parent / "cdf")
287
-
288
- # Change filepath to load test global attributes
289
- cdf_manager.source_dir = Path(__file__).parent.parent / "cdf" / "test_data"
290
- cdf_manager.load_global_attributes("imap_default_global_test_cdf_attrs.yaml")
291
- cdf_manager.load_variable_attributes("imap_test_variable.yaml")
292
-
293
- # Loading in instrument specific attributes
294
- imap_test_variable = cdf_manager.get_variable_attributes("test_field_1")
295
-
296
- # Make sure all expected attributes are present
297
- for variable_attrs in cdf_manager.variable_attribute_schema["attribute_key"]:
298
- required_var_attributes = cdf_manager.variable_attribute_schema[
299
- "attribute_key"
300
- ][variable_attrs]["required"]
301
- if required_var_attributes is True:
302
- assert variable_attrs in imap_test_variable.keys()
303
-
304
- # Calling default attributes
305
- assert imap_test_variable["DEPEND_0"] == "test_depend"
306
- assert imap_test_variable["DISPLAY_TYPE"] == "test_display_type"
307
- assert imap_test_variable["FILLVAL"] == -10
308
-
309
- # Calling required attributes
310
- assert imap_test_variable["CATDESC"] == "test time"
311
- assert imap_test_variable["TIME_BASE"] == 10
312
- assert imap_test_variable["DEPEND_1"] == "test_depend_1"
313
- assert imap_test_variable["DEPEND_2"] == "test_depend_2"
314
-
315
- # Calling to non required attributes
316
- assert imap_test_variable["LEAP_SECONDS_INCLUDED"] == "test_not_required"
317
-
318
- # Calling attribute name that does not exist
319
- with pytest.raises(KeyError):
320
- assert imap_test_variable["DOES_NOT_EXIST"]
321
-
322
- # Testing for attribute not in schema
323
- with pytest.raises(KeyError):
324
- assert imap_test_variable["NOT_IN_SCHEMA"]
325
-
326
- # Load in different data, test again
327
- imap_test_variable_2 = cdf_manager.get_variable_attributes("test_field_2")
328
- # Calling default attributes
329
- assert imap_test_variable_2["DEPEND_0"] == "test_depend"
330
- assert imap_test_variable_2["DISPLAY_TYPE"] == "test_display_type"
331
- assert imap_test_variable_2["FILLVAL"] == -10
332
-
333
- # Calling required attributes
334
- assert imap_test_variable_2["CATDESC"] == "test time 2"
335
- assert imap_test_variable_2["TIME_BASE"] == 11
336
-
337
- # Loading in different data to test logger errors, empty strings,
338
- # and DEPEND_i with i >= 1 condition
339
- imap_test_variable_3 = cdf_manager.get_variable_attributes("test_field_3")
340
-
341
- assert imap_test_variable_3["DEPEND_1"] == "depend_1_test_3"
342
- with pytest.raises(KeyError):
343
- assert imap_test_variable_3["DEPEND_0"]
344
- assert imap_test_variable_3["CATDESC"] == ""
345
- assert imap_test_variable_3["REPRESENTATION_2"] == "representation_2"
346
- assert imap_test_variable_3["LABL_PTR_1"] == "labl_ptr_1"
347
-
348
- # check_schema = False
349
- imap_test_variable_1_false = cdf_manager.get_variable_attributes(
350
- "test_field_1", False
351
- )
352
- assert imap_test_variable_1_false["NOT_IN_SCHEMA"] == "not_in_schema"
353
- assert imap_test_variable_1_false["VALIDMIN"] == 0
@@ -1,55 +0,0 @@
1
- import pandas as pd
2
- import pytest
3
-
4
- from imap_processing.hi.l0.decom_hi import decom_packets
5
-
6
-
7
- @pytest.fixture(scope="session")
8
- def decom_nhk_data(hi_l0_test_data_path):
9
- """Read test housekeeping data from test folder"""
10
- packet_file = hi_l0_test_data_path / "20231030_H45_APP_NHK.bin"
11
- return list(decom_packets(packet_file))
12
-
13
-
14
- @pytest.fixture(scope="session")
15
- def nhk_validation_data(hi_l0_test_data_path):
16
- """Read in validation data from the CSV file"""
17
- raw_validation_data = pd.read_csv(
18
- hi_l0_test_data_path / "20231030_H45_APP_NHK.csv",
19
- index_col="CCSDS_MET",
20
- )
21
- return raw_validation_data
22
-
23
-
24
- @pytest.fixture(scope="session")
25
- def decom_sci_de_data(hi_l0_test_data_path):
26
- """Read science direct event data from test folder"""
27
- packet_file = hi_l0_test_data_path / "20231030_H45_SCI_DE.bin"
28
- return list(decom_packets(packet_file))
29
-
30
-
31
- @pytest.fixture(scope="session")
32
- def decom_sci_cnt_data(hi_l0_test_data_path):
33
- """Read science count data from test folder"""
34
- packet_file = hi_l0_test_data_path / "20231030_H45_SCI_CNT.bin"
35
- return list(decom_packets(packet_file))
36
-
37
-
38
- def test_app_nhk_decom(decom_nhk_data):
39
- """Test housekeeping data"""
40
- expected_number_of_packets = 100
41
- assert len(decom_nhk_data) == expected_number_of_packets
42
- # TODO: extend test more and check with validation data
43
- # Validation data seems off. TODO: check with IMAP-Hi team
44
-
45
-
46
- def test_sci_de_decom(decom_sci_de_data):
47
- """Test science direct event data"""
48
- expected_number_of_packets = 100
49
- assert len(decom_sci_de_data) == expected_number_of_packets
50
-
51
-
52
- def test_sci_cnt_decom(decom_sci_cnt_data):
53
- "Test science count data"
54
- expected_number_of_packets = 100
55
- assert len(decom_sci_cnt_data) == expected_number_of_packets
@@ -1,72 +0,0 @@
1
- import numpy as np
2
-
3
- from imap_processing.hi.l1a.science_direct_event import create_dataset
4
-
5
-
6
- def test_create_dataset():
7
- """Test create_dataset"""
8
- # dummy data to test create_dataset
9
- metaevent = {
10
- "start_bitmask_data": 0,
11
- "esa_step": 1,
12
- "subseconds": 512,
13
- "seconds": 433522962,
14
- }
15
- directevent_1 = {
16
- "start_bitmask_data": 1,
17
- "tof_1": 512,
18
- "tof_2": 512,
19
- "tof_3": 512,
20
- "de_tag": 1,
21
- }
22
- directevent_2 = {
23
- "start_bitmask_data": 2,
24
- "tof_1": 512,
25
- "tof_2": 512,
26
- "tof_3": 512,
27
- "de_tag": 2,
28
- }
29
- directevent_3 = {
30
- "start_bitmask_data": 3,
31
- "tof_1": 512,
32
- "tof_2": 512,
33
- "tof_3": 512,
34
- "de_tag": 3,
35
- }
36
- # Test for good data
37
- list_with_meta_first = [metaevent, directevent_1, directevent_2, directevent_3]
38
- packet_time = [123] * len(list_with_meta_first)
39
- dataset = create_dataset(list_with_meta_first, packet_time)
40
- assert dataset["epoch"].shape == (3,)
41
-
42
- # Test for missing metaevent
43
- list_with_no_meta = [directevent_1, directevent_2, directevent_3]
44
- packet_time = [123] * len(list_with_no_meta)
45
- dataset = create_dataset(list_with_no_meta, packet_time)
46
- assert dataset is None
47
-
48
- # test for first metaevent missing in the list
49
- list_with_meta_middle = [
50
- directevent_1,
51
- directevent_2,
52
- metaevent,
53
- directevent_1,
54
- directevent_2,
55
- directevent_3,
56
- ]
57
- packet_time = [123] * len(list_with_meta_middle)
58
- dataset = create_dataset(list_with_meta_middle, packet_time)
59
- assert dataset["epoch"].shape == (3,)
60
- np.testing.assert_array_equal(dataset["trigger_id"].data, [1, 2, 3])
61
-
62
- list_with_meta_last = [
63
- directevent_1,
64
- directevent_2,
65
- directevent_3,
66
- directevent_1,
67
- directevent_2,
68
- metaevent,
69
- ]
70
- packet_time = [123] * len(list_with_meta_last)
71
- dataset = create_dataset(list_with_meta_last, packet_time)
72
- assert dataset["epoch"].shape == (0,)