imap-processing 0.7.0__py3-none-any.whl → 0.8.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 -1
- imap_processing/_version.py +2 -2
- imap_processing/ccsds/excel_to_xtce.py +34 -2
- imap_processing/cdf/config/imap_codice_global_cdf_attrs.yaml +1 -1
- imap_processing/cdf/config/imap_codice_l1a_variable_attrs.yaml +145 -30
- imap_processing/cdf/config/imap_glows_l1b_variable_attrs.yaml +36 -36
- imap_processing/cdf/config/imap_hi_variable_attrs.yaml +36 -8
- imap_processing/cdf/config/imap_hit_l1b_variable_attrs.yaml +9 -0
- imap_processing/cdf/config/imap_idex_global_cdf_attrs.yaml +7 -7
- imap_processing/cdf/config/imap_idex_l1a_variable_attrs.yaml +32 -33
- imap_processing/cdf/config/imap_mag_l1_variable_attrs.yaml +24 -28
- imap_processing/cdf/config/imap_ultra_l1a_variable_attrs.yaml +1 -0
- imap_processing/cdf/config/imap_ultra_l1b_variable_attrs.yaml +133 -78
- imap_processing/cdf/config/imap_variable_schema.yaml +13 -0
- imap_processing/cdf/imap_cdf_manager.py +31 -27
- imap_processing/cli.py +12 -10
- imap_processing/codice/codice_l1a.py +151 -61
- imap_processing/codice/constants.py +1 -1
- imap_processing/codice/decompress.py +4 -9
- imap_processing/codice/utils.py +1 -0
- imap_processing/glows/l1b/glows_l1b.py +3 -3
- imap_processing/glows/l1b/glows_l1b_data.py +59 -37
- imap_processing/glows/l2/glows_l2_data.py +123 -0
- imap_processing/hi/l1a/histogram.py +1 -1
- imap_processing/hi/l1a/science_direct_event.py +1 -1
- imap_processing/hi/l1b/hi_l1b.py +85 -11
- imap_processing/hi/l1c/hi_l1c.py +23 -1
- imap_processing/hi/utils.py +1 -1
- imap_processing/hit/hit_utils.py +221 -0
- imap_processing/hit/l0/constants.py +118 -0
- imap_processing/hit/l0/decom_hit.py +186 -153
- imap_processing/hit/l1a/hit_l1a.py +20 -175
- imap_processing/hit/l1b/hit_l1b.py +33 -153
- imap_processing/idex/idex_l1a.py +10 -9
- imap_processing/lo/l0/decompression_tables/decompression_tables.py +1 -1
- imap_processing/lo/l0/lo_science.py +1 -1
- imap_processing/lo/packet_definitions/lo_xtce.xml +1 -3296
- imap_processing/mag/l0/decom_mag.py +4 -3
- imap_processing/mag/l1a/mag_l1a.py +11 -11
- imap_processing/mag/l1b/mag_l1b.py +89 -7
- imap_processing/spice/geometry.py +126 -4
- imap_processing/swapi/l1/swapi_l1.py +1 -1
- imap_processing/swapi/l2/swapi_l2.py +1 -1
- imap_processing/swe/l1b/swe_l1b_science.py +8 -8
- imap_processing/tests/ccsds/test_data/expected_output.xml +1 -0
- imap_processing/tests/ccsds/test_excel_to_xtce.py +4 -4
- imap_processing/tests/cdf/test_imap_cdf_manager.py +0 -10
- imap_processing/tests/codice/conftest.py +1 -17
- imap_processing/tests/codice/data/imap_codice_l0_raw_20241110_v001.pkts +0 -0
- imap_processing/tests/codice/test_codice_l0.py +8 -2
- imap_processing/tests/codice/test_codice_l1a.py +127 -107
- imap_processing/tests/codice/test_codice_l1b.py +1 -0
- imap_processing/tests/codice/test_decompress.py +7 -7
- imap_processing/tests/conftest.py +54 -15
- imap_processing/tests/glows/conftest.py +6 -0
- imap_processing/tests/glows/test_glows_l1b.py +9 -9
- imap_processing/tests/glows/test_glows_l1b_data.py +9 -9
- imap_processing/tests/glows/test_glows_l2_data.py +0 -0
- imap_processing/tests/hi/test_data/l1a/imap_hi_l1a_45sensor-de_20250415_v000.cdf +0 -0
- imap_processing/tests/hi/test_hi_l1b.py +71 -1
- imap_processing/tests/hi/test_hi_l1c.py +10 -2
- imap_processing/tests/hi/test_utils.py +4 -3
- imap_processing/tests/hit/{test_hit_decom.py → test_decom_hit.py} +84 -35
- imap_processing/tests/hit/test_hit_l1a.py +2 -197
- imap_processing/tests/hit/test_hit_l1b.py +156 -25
- imap_processing/tests/hit/test_hit_utils.py +218 -0
- imap_processing/tests/idex/conftest.py +1 -1
- imap_processing/tests/idex/imap_idex_l0_raw_20231214_v001.pkts +0 -0
- imap_processing/tests/idex/impact_14_tof_high_data.txt +4444 -4444
- imap_processing/tests/idex/test_idex_l0.py +3 -3
- imap_processing/tests/idex/test_idex_l1a.py +1 -1
- imap_processing/tests/lo/test_lo_science.py +2 -2
- imap_processing/tests/mag/imap_mag_l1a_norm-magi_20251017_v001.cdf +0 -0
- imap_processing/tests/mag/test_mag_l1b.py +59 -3
- imap_processing/tests/spice/test_data/imap_ena_sim_metakernel.template +3 -1
- imap_processing/tests/spice/test_geometry.py +84 -4
- imap_processing/tests/swe/conftest.py +33 -0
- imap_processing/tests/swe/l1_validation/swe_l0_unpacked-data_20240510_v001_VALIDATION_L1B_v3.dat +4332 -0
- imap_processing/tests/swe/test_swe_l1b.py +29 -8
- imap_processing/tests/test_utils.py +1 -1
- imap_processing/tests/ultra/test_data/l1/dps_exposure_helio_45_E12.cdf +0 -0
- imap_processing/tests/ultra/test_data/l1/dps_exposure_helio_45_E24.cdf +0 -0
- imap_processing/tests/ultra/unit/test_de.py +108 -0
- imap_processing/tests/ultra/unit/test_ultra_l1b.py +27 -3
- imap_processing/tests/ultra/unit/test_ultra_l1b_annotated.py +31 -10
- imap_processing/tests/ultra/unit/test_ultra_l1b_extended.py +21 -11
- imap_processing/tests/ultra/unit/test_ultra_l1c_pset_bins.py +9 -44
- imap_processing/ultra/constants.py +8 -3
- imap_processing/ultra/l1b/de.py +174 -30
- imap_processing/ultra/l1b/ultra_l1b_annotated.py +24 -10
- imap_processing/ultra/l1b/ultra_l1b_extended.py +21 -14
- imap_processing/ultra/l1c/ultra_l1c_pset_bins.py +70 -119
- {imap_processing-0.7.0.dist-info → imap_processing-0.8.0.dist-info}/METADATA +15 -14
- {imap_processing-0.7.0.dist-info → imap_processing-0.8.0.dist-info}/RECORD +98 -113
- imap_processing/cdf/cdf_attribute_manager.py +0 -322
- imap_processing/cdf/config/shared/default_global_cdf_attrs_schema.yaml +0 -246
- imap_processing/cdf/config/shared/default_variable_cdf_attrs_schema.yaml +0 -466
- imap_processing/hit/l0/data_classes/housekeeping.py +0 -240
- imap_processing/hit/l0/data_classes/science_packet.py +0 -259
- imap_processing/hit/l0/utils/hit_base.py +0 -57
- imap_processing/tests/cdf/shared/default_global_cdf_attrs_schema.yaml +0 -246
- imap_processing/tests/cdf/shared/default_variable_cdf_attrs_schema.yaml +0 -466
- imap_processing/tests/cdf/test_cdf_attribute_manager.py +0 -353
- 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/idex/imap_idex_l0_raw_20230725_v001.pkts +0 -0
- imap_processing/tests/mag/imap_mag_l1a_burst-magi_20231025_v001.cdf +0 -0
- /imap_processing/tests/hit/test_data/{imap_hit_l0_hk_20100105_v001.pkts → imap_hit_l0_raw_20100105_v001.pkts} +0 -0
- {imap_processing-0.7.0.dist-info → imap_processing-0.8.0.dist-info}/LICENSE +0 -0
- {imap_processing-0.7.0.dist-info → imap_processing-0.8.0.dist-info}/WHEEL +0 -0
- {imap_processing-0.7.0.dist-info → imap_processing-0.8.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
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|