imap-processing 0.15.0__py3-none-any.whl → 0.16.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 (35) hide show
  1. imap_processing/_version.py +2 -2
  2. imap_processing/cdf/config/imap_ialirt_l1_variable_attrs.yaml +113 -130
  3. imap_processing/cli.py +1 -4
  4. imap_processing/codice/codice_l1a.py +87 -62
  5. imap_processing/codice/codice_l2.py +0 -8
  6. imap_processing/codice/constants.py +16 -5
  7. imap_processing/hi/hi_l1a.py +447 -0
  8. imap_processing/hi/{l1b/hi_l1b.py → hi_l1b.py} +1 -1
  9. imap_processing/hi/{l1c/hi_l1c.py → hi_l1c.py} +21 -21
  10. imap_processing/hi/{l2/hi_l2.py → hi_l2.py} +13 -13
  11. imap_processing/hi/utils.py +6 -6
  12. imap_processing/hit/l1b/hit_l1b.py +30 -11
  13. imap_processing/ialirt/constants.py +38 -0
  14. imap_processing/ialirt/l0/parse_mag.py +1 -1
  15. imap_processing/ialirt/l0/process_codice.py +91 -0
  16. imap_processing/ialirt/l0/process_hit.py +12 -21
  17. imap_processing/ialirt/l0/process_swapi.py +172 -23
  18. imap_processing/ialirt/l0/process_swe.py +3 -10
  19. imap_processing/ialirt/utils/constants.py +16 -2
  20. imap_processing/ialirt/utils/create_xarray.py +59 -11
  21. imap_processing/ultra/utils/ultra_l1_utils.py +4 -2
  22. {imap_processing-0.15.0.dist-info → imap_processing-0.16.0.dist-info}/METADATA +1 -1
  23. {imap_processing-0.15.0.dist-info → imap_processing-0.16.0.dist-info}/RECORD +26 -32
  24. imap_processing/hi/l1a/__init__.py +0 -0
  25. imap_processing/hi/l1a/hi_l1a.py +0 -98
  26. imap_processing/hi/l1a/histogram.py +0 -152
  27. imap_processing/hi/l1a/science_direct_event.py +0 -214
  28. imap_processing/hi/l1b/__init__.py +0 -0
  29. imap_processing/hi/l1c/__init__.py +0 -0
  30. imap_processing/hi/l2/__init__.py +0 -0
  31. imap_processing/ialirt/l0/process_codicehi.py +0 -156
  32. imap_processing/ialirt/l0/process_codicelo.py +0 -41
  33. {imap_processing-0.15.0.dist-info → imap_processing-0.16.0.dist-info}/LICENSE +0 -0
  34. {imap_processing-0.15.0.dist-info → imap_processing-0.16.0.dist-info}/WHEEL +0 -0
  35. {imap_processing-0.15.0.dist-info → imap_processing-0.16.0.dist-info}/entry_points.txt +0 -0
@@ -57,14 +57,16 @@ def create_dataset( # noqa: PLR0912
57
57
  data_dict["epoch"],
58
58
  name="epoch",
59
59
  dims=["epoch"],
60
- attrs=cdf_manager.get_variable_attributes("epoch"),
60
+ attrs=cdf_manager.get_variable_attributes("epoch", check_schema=False),
61
61
  )
62
62
  if "sensor-de" in name:
63
63
  component = xr.DataArray(
64
64
  ["vx", "vy", "vz"],
65
65
  name="component",
66
66
  dims=["component"],
67
- attrs=cdf_manager.get_variable_attributes("component"),
67
+ attrs=cdf_manager.get_variable_attributes(
68
+ "component", check_schema=False
69
+ ),
68
70
  )
69
71
  coords = {"epoch": epoch_time, "component": component}
70
72
  else:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: imap-processing
3
- Version: 0.15.0
3
+ Version: 0.16.0
4
4
  Summary: IMAP Science Operations Center Processing
5
5
  License: MIT
6
6
  Keywords: IMAP,SDC,SOC,Science Operations
@@ -1,5 +1,5 @@
1
1
  imap_processing/__init__.py,sha256=b9xHlf8_0OtN_OyhPlrC6ayahYR0QTt_e713NjxZObw,1305
2
- imap_processing/_version.py,sha256=irZ9t9UpzoARk751rz8rjjmcOizvIGEr5-xJe0qW6KE,127
2
+ imap_processing/_version.py,sha256=eLPvHzTLNE19Gzow2bKK6dlgu7T2y85RkAQPjNmibUA,127
3
3
  imap_processing/ancillary/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  imap_processing/ancillary/ancillary_dataset_combiner.py,sha256=Pxg1wQLjPKzEkgE3a4Tart5TfeuH9rqyCKTd5GbgiL0,9602
5
5
  imap_processing/ccsds/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -26,7 +26,7 @@ imap_processing/cdf/config/imap_hit_l1a_variable_attrs.yaml,sha256=5X8V6Hzg7UGP6
26
26
  imap_processing/cdf/config/imap_hit_l1b_variable_attrs.yaml,sha256=gxeC7-SUKkWiy1OE6MgfKxeV-0bdXuauodOIfFtQ3JQ,11287
27
27
  imap_processing/cdf/config/imap_hit_l2_variable_attrs.yaml,sha256=f8ZLlF9EIes8BcFrpKTO8Mb_VVnP2d9HoLtQVOgz23Q,61402
28
28
  imap_processing/cdf/config/imap_ialirt_global_cdf_attrs.yaml,sha256=AGQ9J0zEdWRZ_AR6_AYYHkRb57mYIe2jVflhYv8SEsQ,961
29
- imap_processing/cdf/config/imap_ialirt_l1_variable_attrs.yaml,sha256=Hl3VE_JRPPDWu9_KDE_zUu0CVGTSYOvIR31gFoyD0D0,9891
29
+ imap_processing/cdf/config/imap_ialirt_l1_variable_attrs.yaml,sha256=IWJwYEeIIWiL1EN8EufKc4O8BThHNDwL2CcfQWRcSPA,8362
30
30
  imap_processing/cdf/config/imap_idex_global_cdf_attrs.yaml,sha256=b0dbQ_IJtgTHmwdD754ZHr2-kwo8KIoG3FUZdK5vMEA,2920
31
31
  imap_processing/cdf/config/imap_idex_l1a_variable_attrs.yaml,sha256=KaRu-HPqAdAJ2vrX7m54pKUJsJtPaCfofi2OBs906cs,22493
32
32
  imap_processing/cdf/config/imap_idex_l1b_variable_attrs.yaml,sha256=Cx-s8hGmUtM_7pon1EbJTP3Im4uFfNeN6gZlGW5DudE,11153
@@ -57,13 +57,13 @@ imap_processing/cdf/config/imap_ultra_l1c_variable_attrs.yaml,sha256=D4uKUqZ8G5h
57
57
  imap_processing/cdf/config/imap_variable_schema.yaml,sha256=oKfSQKJ7vYh7SC9dwFeE5PzVQNXYCpcp3AZSclKUVeg,728
58
58
  imap_processing/cdf/imap_cdf_manager.py,sha256=K2W_5SzRTxJij2D-ZoKA4UdUxcVC1H90soEloJehsUk,2086
59
59
  imap_processing/cdf/utils.py,sha256=Go43WgJbp-BOH_5cLNAru76cCb6jW0ZzwwBCEmeV19E,7789
60
- imap_processing/cli.py,sha256=CzuVj86GDcBYBMsTt3_dXowiNN8eu9JK9H-vQtSP8Ls,53026
60
+ imap_processing/cli.py,sha256=6kvGorFaUWQeWt43INKbFCH6J7JUwZHSCMQdDTQs8-k,52921
61
61
  imap_processing/codice/__init__.py,sha256=Ga6Ioj68HnQ4moi7SxJdOyYmGHcRvKOh4uZUEPJZHl4,20
62
62
  imap_processing/codice/codice_l0.py,sha256=_StmC58uRLBuUKSpVaqv6Bo49CeexkcOqnt_askKtHk,1701
63
- imap_processing/codice/codice_l1a.py,sha256=fCCwAdqGU3RWflHTYl8QYq3J9UvpPaR8IWSQ4V-7L9w,56366
63
+ imap_processing/codice/codice_l1a.py,sha256=3sOzARFDNpL2JhNH2PugPMuMFkOUNMcI0I3T6jt8QhQ,57489
64
64
  imap_processing/codice/codice_l1b.py,sha256=_x--ZXHxxSknEC546hHQGqhRTanYtJTfKDsB8d9Pz_Q,5408
65
- imap_processing/codice/codice_l2.py,sha256=2UsNIWpsd6DRHlaFYF4AykaaCqPcoRln9dLhzyYMQcw,2947
66
- imap_processing/codice/constants.py,sha256=QOo0YVbZuTlWopRgbx4SPLhiSqXXeohMBa6bLACZrE0,45328
65
+ imap_processing/codice/codice_l2.py,sha256=6bWXaEZxE-LuLv9vlvTIDlCxRWhkYMva0Re7X7-MS_4,2603
66
+ imap_processing/codice/constants.py,sha256=nND2C9KVVkQ1_ZmmL3T9edqIF_gdqQ8h4NyEDVr7_HY,45621
67
67
  imap_processing/codice/data/esa_sweep_values.csv,sha256=RuRTBG_TftVKGDEslxDo5SVwLIWq2uh3WrlVsXABpfg,5336
68
68
  imap_processing/codice/data/lo_stepping_values.csv,sha256=Z-hdv2nxTzl-RXBWTa7Y_NRXR1HyW1mJrYMmX6vDnHo,5318
69
69
  imap_processing/codice/decompress.py,sha256=-EA7vlGIKx6d7gltfDLr8XmU-D6Q9_7FZRtzIUgW54M,5232
@@ -96,19 +96,13 @@ imap_processing/glows/packet_definitions/P_GLX_TMSCHIST.xml,sha256=Q7X5gF9jM4TA5
96
96
  imap_processing/glows/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
97
97
  imap_processing/glows/utils/constants.py,sha256=REjvd0NgnST_rsfFQNGDo0F3_KKDZz20Dyt-19T2txM,2837
98
98
  imap_processing/hi/__init__.py,sha256=Ga6Ioj68HnQ4moi7SxJdOyYmGHcRvKOh4uZUEPJZHl4,20
99
- imap_processing/hi/l1a/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
100
- imap_processing/hi/l1a/hi_l1a.py,sha256=Nj0V9XJZXchdMwsZEyztS2IY_Y0ENMHEPqWUum2VZOQ,3247
101
- imap_processing/hi/l1a/histogram.py,sha256=ptwPrVDSVjVWJKww3W1XGUNh0Hw9A56_aRZpSANCAwI,4791
102
- imap_processing/hi/l1a/science_direct_event.py,sha256=dd0-Nf1kTd35GMqVUbidLSLP6b8JVlTzBrJ4yyCNUWA,7150
103
- imap_processing/hi/l1b/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
104
- imap_processing/hi/l1b/hi_l1b.py,sha256=IvHoTqtAf4u8zemWQ41frARR_gwbQboskp-7hk7AltY,14777
105
- imap_processing/hi/l1c/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
106
- imap_processing/hi/l1c/hi_l1c.py,sha256=iHOmVZkKEhxwwne1T5tFMxJZjD2n5wI0-WueumTwA50,28459
107
- imap_processing/hi/l2/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
108
- imap_processing/hi/l2/hi_l2.py,sha256=9Cd1FqdKk3ya6_u9f7gal-9pIxrLgEQT9EBREJ_DhOA,9288
99
+ imap_processing/hi/hi_l1a.py,sha256=m-KGuWw6NzRNuJJp8RVQI1zy636GS7HkXjJNSedPlJ0,14731
100
+ imap_processing/hi/hi_l1b.py,sha256=PegKVakMz_M73eenywiNmna_LlHPLCqRzAKkoEA5uR8,14759
101
+ imap_processing/hi/hi_l1c.py,sha256=lT_XFSRME1ol7Bo2y38RCHghEEXeW21oQ2Rcj2fmjDo,28529
102
+ imap_processing/hi/hi_l2.py,sha256=veO2FdinuiRcONQ5JucnRj8lvs6wwLVrA_oveqsFzFE,9360
109
103
  imap_processing/hi/packet_definitions/TLM_HI_COMBINED_SCI.xml,sha256=Cwu_sE-b6lpXtuikQKuU5uQ_pMFTG9HoZeH9c-QDQgU,251743
110
104
  imap_processing/hi/packet_definitions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
111
- imap_processing/hi/utils.py,sha256=J_LpWqnhZnukhNk5EVyGaU6ZNZjcCosQ-RUSUTFjXFc,8098
105
+ imap_processing/hi/utils.py,sha256=mZZtOK4S2Mu0uBfPY72x74gtt70anu4sA62PKUjwERk,8097
112
106
  imap_processing/hit/__init__.py,sha256=Ga6Ioj68HnQ4moi7SxJdOyYmGHcRvKOh4uZUEPJZHl4,20
113
107
  imap_processing/hit/hit_utils.py,sha256=-O8xt90w6sMPQ2t4CYmqrwkBw3rF1h1dMn58Q3Ioz3g,13371
114
108
  imap_processing/hit/l0/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -117,20 +111,20 @@ imap_processing/hit/l0/decom_hit.py,sha256=ur0M3AVhuptWRvUVUvugxfAMf6yKI0Xee_7RN
117
111
  imap_processing/hit/l1a/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
118
112
  imap_processing/hit/l1a/hit_l1a.py,sha256=BWxm73t6CeNXBt23NArnkXufeRH_OkhVOReLXEpiD3M,11241
119
113
  imap_processing/hit/l1b/constants.py,sha256=ZL5h2GgC5j_s11YgMxtY4EHpmkfo6IXnniCv-iXdG84,9692
120
- imap_processing/hit/l1b/hit_l1b.py,sha256=7CwzKpWD8HgsdQN0T72Dj9tP-jOE5_4kMViJ5yzFpYg,17495
114
+ imap_processing/hit/l1b/hit_l1b.py,sha256=nXy8SUXJujFcWOrOBufmdrxq9xzdmB9dyZQOYz3-xiM,18489
121
115
  imap_processing/hit/l2/constants.py,sha256=jvs7Uic3Bl1wyRC01s1-F5LAsTzTwi089TpN19fvlFg,18813
122
116
  imap_processing/hit/l2/hit_l2.py,sha256=E_3hyn_XzmnUbAFqTSHeM_QQtCYqMnOzLm6Km_crmOk,27102
123
117
  imap_processing/hit/packet_definitions/hit_packet_definitions.xml,sha256=CyYmMnuObmk2y1nlrd7xOZnwZ_qZ3X__AhhKmRyNOvg,136147
124
118
  imap_processing/ialirt/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
119
+ imap_processing/ialirt/constants.py,sha256=mwVPgSVNuPpTO4zx3LeUW7L5a6aJG2ZrezObPvR9s1c,1241
125
120
  imap_processing/ialirt/l0/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
126
121
  imap_processing/ialirt/l0/ialirt_spice.py,sha256=WNuMlxA5UDGiBd8ap2k_dHxFmi2UCFgnQ4_wEZUhVU0,5649
127
122
  imap_processing/ialirt/l0/mag_l0_ialirt_data.py,sha256=vgIerXkk4ZoOxxVaNEgvM1ESWVkGusSZ-3k73-Cl_tI,5276
128
- imap_processing/ialirt/l0/parse_mag.py,sha256=x51q2w_GPToSfKSnYzsscJkvsC2B8VSdL0jUuSo3FmQ,12780
129
- imap_processing/ialirt/l0/process_codicehi.py,sha256=cYkm_mKa502g4IeetTH-fVwxjFEZ2tRYFJ9WjrTEp40,4778
130
- imap_processing/ialirt/l0/process_codicelo.py,sha256=pF-1vBmIv2JhKzblSHgJMTXK23psJqCdFgWpL-ppl_Y,1037
131
- imap_processing/ialirt/l0/process_hit.py,sha256=Hws13pxQWRh7hYV2kl4bvg9R0sAtUo3DfnGAuaN5xSk,5680
132
- imap_processing/ialirt/l0/process_swapi.py,sha256=CLS-NVTddI1dGXEXdjSor2RNGnmdxMTe1_-WlU1PmyI,2113
133
- imap_processing/ialirt/l0/process_swe.py,sha256=5GGQ_f6uQlaEZB4vxIxvWCUUdN28coZHStxgqleyQWg,18150
123
+ imap_processing/ialirt/l0/parse_mag.py,sha256=v5Efczml4s-TFdREhjg3A6PzEFTYAx4dbJyeACmkbPc,12787
124
+ imap_processing/ialirt/l0/process_codice.py,sha256=_LvZJ-dt7Qbw41glYS4BdIJZhhChBIk8DvueyNphW4g,3062
125
+ imap_processing/ialirt/l0/process_hit.py,sha256=HJ_h8nd5Xs0NC-mWNS7Ce3D86H1408lT6ZCdXlNQv48,5408
126
+ imap_processing/ialirt/l0/process_swapi.py,sha256=EBr-wQB4IDrdYON80g8f9neNkUXTAAUMv3wlB1MXfr4,7490
127
+ imap_processing/ialirt/l0/process_swe.py,sha256=QXp6rmlxw8K5M0bapKwAArCd_99qHFS8sxOnhHLVkhU,17953
134
128
  imap_processing/ialirt/packet_definitions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
135
129
  imap_processing/ialirt/packet_definitions/ialirt.xml,sha256=-hlT16Mr2Q6uCUfJ3jdpw0mPdeGCcZiWiorbkiEanwA,40784
136
130
  imap_processing/ialirt/packet_definitions/ialirt_codicehi.xml,sha256=PwzGTJj4dROXJBqbT32UZ6swaPbjvXdXXn7E_Lxch2A,11367
@@ -140,8 +134,8 @@ imap_processing/ialirt/packet_definitions/ialirt_mag.xml,sha256=Kt3t3S1gk7kqv006
140
134
  imap_processing/ialirt/packet_definitions/ialirt_swapi.xml,sha256=tGC4V-IV7WO6U3HtC2rDWA-500oOubcXgidMNyeGOE4,8400
141
135
  imap_processing/ialirt/packet_definitions/ialirt_swe.xml,sha256=FJNhfWjBjK1Ze3BCW86hvNJIiWoIK5dujt2Dw76pjF0,13442
142
136
  imap_processing/ialirt/process_ephemeris.py,sha256=RN6rzEY4KBc0V-ZKrsKffu8MEo7k0q3zJATBqaat9OY,8073
143
- imap_processing/ialirt/utils/constants.py,sha256=tdsY51p0qTOtTVrEdqPbHgBbXJMYQ80dpnVIK6MddQw,1852
144
- imap_processing/ialirt/utils/create_xarray.py,sha256=e4yLK725-BAkBjVAZWQPW9TLUNB_ZiqoByH4fezzaXg,2938
137
+ imap_processing/ialirt/utils/constants.py,sha256=rF9KlnVig5Xk82lwo4OGbFPgf60lYNKHRP3FrlDQ4ls,2324
138
+ imap_processing/ialirt/utils/create_xarray.py,sha256=mNMiFk06YTl7dUxqguNtX_qytISWfp9VqVaVm6vF-NI,4743
145
139
  imap_processing/ialirt/utils/grouping.py,sha256=Hk5u_TC0r72fN6s2CUEsD6opGig31EiwnRepAH9oOEE,3795
146
140
  imap_processing/ialirt/utils/time.py,sha256=fXBDKxNp2IXYJ1laSPPAIw_GTKvjFIgPwh54fnNQMEI,636
147
141
  imap_processing/idex/__init__.py,sha256=jO9AUm6ORgQhIHszOzLb3Vb2RVyz_SDUV64peGcr20A,52
@@ -262,10 +256,10 @@ imap_processing/ultra/packet_definitions/README.md,sha256=Iam1bd6UVkRLayApXlHG_y
262
256
  imap_processing/ultra/packet_definitions/ULTRA_SCI_COMBINED.xml,sha256=q1Bmz5vJTdqjBcKPExBZ_LCismlQFHOFyTUI1dJsjiY,939289
263
257
  imap_processing/ultra/packet_definitions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
264
258
  imap_processing/ultra/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
265
- imap_processing/ultra/utils/ultra_l1_utils.py,sha256=QbDKjBo2m78AZMCorDdPpCL-ayQa7Fkm2PEbwmThCGU,5243
259
+ imap_processing/ultra/utils/ultra_l1_utils.py,sha256=W1wABph96AJVkFNGrmq_0Vf6i__fIFxIVTvjCPbysY0,5321
266
260
  imap_processing/utils.py,sha256=zdcBXBQKL2NnElJcEbd-2QPeEDz0H3Yy0hVjRy9xcCE,14062
267
- imap_processing-0.15.0.dist-info/LICENSE,sha256=F2rxhvc6auEI0Dk9IGjglQSQQk60EvTe8M1dORMZPOg,1098
268
- imap_processing-0.15.0.dist-info/METADATA,sha256=o3cpLf1n619mCGzVt3RgsHIBuLiQo7z4eIjStubAg5U,9102
269
- imap_processing-0.15.0.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
270
- imap_processing-0.15.0.dist-info/entry_points.txt,sha256=5r8ijLImHSNJxr-SGDC8kJy81BtXjmeUOmNfWSfLuRs,104
271
- imap_processing-0.15.0.dist-info/RECORD,,
261
+ imap_processing-0.16.0.dist-info/LICENSE,sha256=F2rxhvc6auEI0Dk9IGjglQSQQk60EvTe8M1dORMZPOg,1098
262
+ imap_processing-0.16.0.dist-info/METADATA,sha256=ejLO2sQJAM297xzu16ALDVLTqqDA3CXQuqJg2kh8tiM,9102
263
+ imap_processing-0.16.0.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
264
+ imap_processing-0.16.0.dist-info/entry_points.txt,sha256=5r8ijLImHSNJxr-SGDC8kJy81BtXjmeUOmNfWSfLuRs,104
265
+ imap_processing-0.16.0.dist-info/RECORD,,
File without changes
@@ -1,98 +0,0 @@
1
- """IMAP-HI L1A processing module."""
2
-
3
- import logging
4
- from pathlib import Path
5
- from typing import Union
6
-
7
- import xarray as xr
8
-
9
- from imap_processing import imap_module_directory
10
- from imap_processing.cdf.imap_cdf_manager import ImapCdfAttributes
11
- from imap_processing.hi.l1a.histogram import create_dataset as hist_create_dataset
12
- from imap_processing.hi.l1a.science_direct_event import science_direct_event
13
- from imap_processing.hi.utils import HIAPID
14
- from imap_processing.utils import packet_file_to_datasets
15
-
16
- logger = logging.getLogger(__name__)
17
-
18
-
19
- def hi_l1a(packet_file_path: Union[str, Path]) -> list[xr.Dataset]:
20
- """
21
- Will process IMAP raw data to l1a.
22
-
23
- Parameters
24
- ----------
25
- packet_file_path : str
26
- Data packet file path.
27
-
28
- Returns
29
- -------
30
- processed_data : list[xarray.Dataset]
31
- List of processed xarray dataset.
32
- """
33
- datasets_by_apid = hi_packet_file_to_datasets(packet_file_path)
34
-
35
- # Process science to l1a.
36
- processed_data = []
37
- for apid in datasets_by_apid:
38
- try:
39
- apid_enum = HIAPID(apid)
40
- except ValueError as err:
41
- raise RuntimeError(f"Encountered unexpected APID [{apid}]") from err
42
-
43
- logger.info(f"Processing IMAP-Hi data for {apid_enum.name} packets")
44
-
45
- if apid_enum in [HIAPID.H45_SCI_CNT, HIAPID.H90_SCI_CNT]:
46
- data = hist_create_dataset(datasets_by_apid[apid])
47
- gattr_key = "imap_hi_l1a_hist_attrs"
48
- elif apid_enum in [HIAPID.H45_SCI_DE, HIAPID.H90_SCI_DE]:
49
- data = science_direct_event(datasets_by_apid[apid])
50
- gattr_key = "imap_hi_l1a_de_attrs"
51
- elif apid_enum in [HIAPID.H45_APP_NHK, HIAPID.H90_APP_NHK]:
52
- data = datasets_by_apid[apid]
53
- gattr_key = "imap_hi_l1a_hk_attrs"
54
- elif apid_enum in [HIAPID.H45_DIAG_FEE, HIAPID.H90_DIAG_FEE]:
55
- data = datasets_by_apid[apid]
56
- gattr_key = "imap_hi_l1a_diagfee_attrs"
57
-
58
- # Update dataset global attributes
59
- attr_mgr = ImapCdfAttributes()
60
- attr_mgr.add_instrument_global_attrs("hi")
61
- data.attrs.update(attr_mgr.get_global_attributes(gattr_key))
62
-
63
- # set the sensor string in Logical_source
64
- sensor_str = apid_enum.sensor
65
- data.attrs["Logical_source"] = data.attrs["Logical_source"].format(
66
- sensor=sensor_str
67
- )
68
- processed_data.append(data)
69
- return processed_data
70
-
71
-
72
- def hi_packet_file_to_datasets(
73
- packet_file_path: Union[str, Path], use_derived_value: bool = False
74
- ) -> dict[int, xr.Dataset]:
75
- """
76
- Extract hi datasets from packet file.
77
-
78
- Parameters
79
- ----------
80
- packet_file_path : str
81
- L0 packet file path.
82
- use_derived_value : bool
83
- Whether to use the derived value from the XTCE definition. Default is False.
84
-
85
- Returns
86
- -------
87
- datasets : dict[int, xarray.Dataset]
88
- Dictionary of xarray datasets keyed by APID.
89
- """
90
- packet_def_file = (
91
- imap_module_directory / "hi/packet_definitions/TLM_HI_COMBINED_SCI.xml"
92
- )
93
- datasets_by_apid = packet_file_to_datasets(
94
- packet_file=packet_file_path,
95
- xtce_packet_definition=packet_def_file,
96
- use_derived_value=use_derived_value,
97
- )
98
- return datasets_by_apid
@@ -1,152 +0,0 @@
1
- """Unpack IMAP-Hi histogram data."""
2
-
3
- import numpy as np
4
- import xarray as xr
5
- from numpy._typing import NDArray
6
-
7
- from imap_processing.cdf.imap_cdf_manager import ImapCdfAttributes
8
-
9
- # define the names of the 24 counter arrays
10
- # contained in the histogram packet
11
- QUALIFIED_COUNTERS = (
12
- "ab_qualified",
13
- "c1c2_qualified",
14
- "ac1_qualified",
15
- "bc1_qualified",
16
- "abc1_qualified",
17
- "ac1c2_qualified",
18
- "bc1c2_qualified",
19
- "abc1c2_qualified",
20
- )
21
- LONG_COUNTERS = (
22
- "a_first_only",
23
- "b_first_only",
24
- "c_first_only",
25
- "ab_long",
26
- "c1c2_long",
27
- "ac1_long",
28
- "bc1_long",
29
- "abc1_long",
30
- "ac1c2_long",
31
- "bc1c2_long",
32
- "abc1c2_long",
33
- )
34
- TOTAL_COUNTERS = ("a_total", "b_total", "c_total", "fee_de_recd", "fee_de_sent")
35
-
36
-
37
- def create_dataset(input_ds: xr.Dataset) -> xr.Dataset:
38
- """
39
- Create dataset for a number of Hi Histogram packets.
40
-
41
- Parameters
42
- ----------
43
- input_ds : xarray.Dataset
44
- Dataset of packets generated using the
45
- `imap_processing.utils.packet_file_to_datasets` function.
46
-
47
- Returns
48
- -------
49
- dataset : xarray.Dataset
50
- Dataset with all metadata field data in xr.DataArray.
51
- """
52
- attr_mgr = ImapCdfAttributes()
53
- attr_mgr.add_instrument_global_attrs(instrument="hi")
54
- attr_mgr.add_instrument_variable_attrs(instrument="hi", level=None)
55
-
56
- # Rename shcoarse variable (do this first since it copies the input_ds)
57
- dataset = input_ds.rename_vars({"shcoarse": "ccsds_met"})
58
-
59
- dataset.epoch.attrs.update(
60
- attr_mgr.get_variable_attributes("epoch"),
61
- )
62
- # Add the hist_angle coordinate
63
- # Histogram data is binned in 90, 4-degree bins
64
- attrs = attr_mgr.get_variable_attributes("hi_hist_angle")
65
- dataset.coords.update(
66
- {
67
- "angle": xr.DataArray(
68
- np.arange(2, 360, 4),
69
- name="angle",
70
- dims=["angle"],
71
- attrs=attrs,
72
- )
73
- }
74
- )
75
- # Update existing variable attributes
76
- for var_name in [
77
- "version",
78
- "type",
79
- "sec_hdr_flg",
80
- "pkt_apid",
81
- "seq_flgs",
82
- "src_seq_ctr",
83
- "pkt_len",
84
- "ccsds_met",
85
- "esa_step",
86
- "num_of_spins",
87
- "cksum",
88
- ]:
89
- attrs = attr_mgr.get_variable_attributes(f"hi_hist_{var_name}")
90
- dataset.data_vars[var_name].attrs.update(attrs)
91
-
92
- new_vars = dict()
93
- # Populate 90-element histogram counters
94
- default_counter_attrs = attr_mgr.get_variable_attributes("hi_hist_counters")
95
- for counter_name in (*QUALIFIED_COUNTERS, *LONG_COUNTERS, *TOTAL_COUNTERS):
96
- # Inject counter name into generic counter attributes
97
- counter_attrs = default_counter_attrs.copy()
98
- for key, val in counter_attrs.items():
99
- if isinstance(val, str) and "{counter_name}" in val:
100
- counter_attrs[key] = val.format(counter_name=counter_name)
101
- # Instantiate the counter DataArray
102
- new_vars[counter_name] = xr.DataArray(
103
- data=unpack_hist_counter(input_ds[counter_name].data.sum()),
104
- dims=["epoch", "angle"],
105
- attrs=counter_attrs,
106
- )
107
-
108
- # Generate label variable for angle coordinate
109
- new_vars["angle_label"] = xr.DataArray(
110
- dataset.coords["angle"].values.astype(str),
111
- name="angle_label",
112
- dims=["angle"],
113
- attrs=attr_mgr.get_variable_attributes(
114
- "hi_hist_angle_label", check_schema=False
115
- ),
116
- )
117
-
118
- dataset.update(new_vars)
119
-
120
- return dataset
121
-
122
-
123
- def unpack_hist_counter(counter_bytes: bytes) -> NDArray[np.uint16]:
124
- """
125
- Unpack Hi SCI_CNT counter data for a single counter.
126
-
127
- Parameters
128
- ----------
129
- counter_bytes : bytes
130
- Sum individual bytes for all epochs of a Hi SCI_CNT counter.
131
-
132
- Returns
133
- -------
134
- output_array : numpy.ndarray[numpy.uint16]
135
- The unpacked 12-bit unsigned integers for the input bytes. The
136
- output array has a shape of (n, 90) where n is the number of SCI_CNT
137
- packets in the input dataset.
138
- """
139
- # Interpret bytes for all epochs of current counter as uint8 array
140
- counter_uint8 = np.frombuffer(counter_bytes, dtype=np.uint8)
141
- # Split into triplets of upper-byte, split-byte and lower-byte arrays
142
- upper_uint8, split_unit8, lower_uint8 = np.reshape(
143
- counter_uint8, (3, -1), order="F"
144
- ).astype(np.uint16)
145
- # Compute even indexed uint12 values from upper-byte and first 4-bits of
146
- # split-byte
147
- even_uint12 = (upper_uint8 << 4) + (split_unit8 >> 4)
148
- # Compute odd indexed uint12 values from lower 4-bits of split-byte and
149
- # lower-byte
150
- odd_uint12 = ((split_unit8 & (2**4 - 1)) << 8) + lower_uint8
151
- output_array = np.column_stack((even_uint12, odd_uint12)).reshape(-1, 90)
152
- return output_array
@@ -1,214 +0,0 @@
1
- """IMAP-Hi direct event processing."""
2
-
3
- import logging
4
- from collections import defaultdict
5
-
6
- import numpy as np
7
- import numpy._typing as npt
8
- import xarray as xr
9
-
10
- from imap_processing.cdf.imap_cdf_manager import ImapCdfAttributes
11
- from imap_processing.spice.time import met_to_ttj2000ns
12
-
13
- # TODO: read DE_CLOCK_TICK_US from
14
- # instrument status summary later. This value
15
- # is rarely change but want to be able to change
16
- # it if needed. It stores information about how
17
- # fast the time was ticking. It is in microseconds.
18
- DE_CLOCK_TICK_US = 1999
19
- DE_CLOCK_TICK_S = DE_CLOCK_TICK_US / 1e6
20
- HALF_CLOCK_TICK_S = DE_CLOCK_TICK_S / 2
21
-
22
- MILLISECOND_TO_S = 1e-3
23
-
24
- logger = logging.getLogger(__name__)
25
-
26
-
27
- def parse_direct_events(de_data: bytes) -> dict[str, npt.ArrayLike]:
28
- """
29
- Parse event data from a binary blob.
30
-
31
- IMAP-Hi direct event data information is stored in
32
- 48-bits as follows:
33
-
34
- | Read 48-bits into 16, 2, 10, 10, 10, bits. Each of these breaks
35
- | down as:
36
- |
37
- | de_tag - 16 bits
38
- | start_bitmask_data - 2 bits (tA=1, tB=2, tC1=3)
39
- | tof_1 - 10 bit counter
40
- | tof_2 - 10 bit counter
41
- | tof_3 - 10 bit counter
42
-
43
- There are at most total of 664 of 48-bits in each data packet.
44
- This data packet is of variable length. If there is one event, then
45
- DE_TOF will contain 48-bits. If there are 664 events, then
46
- DE_TOF will contain 664 x 48-bits. If there is no event, then
47
- DE_TOF will contain 0-bits.
48
-
49
- There should be two data packets per ESA. Each packet contains meta-event
50
- data that is identical between the two packets for a common ESA.
51
- If there is no event record for certain ESA step, then both packets will
52
- contain 0-bits in DE_TOF.
53
-
54
- Parameters
55
- ----------
56
- de_data : bytes
57
- Binary blob from de_tag field of SCI_DE packet. Must be an integer
58
- multiple of 48-bits of data.
59
-
60
- Returns
61
- -------
62
- Dict[str, list]
63
- Parsed event data.
64
- """
65
- # The de_data is a binary blob with Nx6 bytes of data where N = number of
66
- # direct events encoded into the binary blob. Interpreting the data as
67
- # big-endian uint16 data and reshaping into a (3, -1) ndarray results
68
- # in an array with shape (3, N). Indexing the first axis of that array
69
- # (e.g. data_uint16[i]) gives the ith 2-bytes of data for each of the N
70
- # direct events.
71
- # Considering the 6-bytes of data for each DE as 3 2-byte words,
72
- # each word contains the following:
73
- # word_0: full 16-bits is the de_tag
74
- # word_1: 2-bits of Trigger ID, 10-bits tof_1, upper 4-bits of tof_2
75
- # word_2: lower 6-bits of tof_2, 10-bits of tof_3
76
- data_uint16 = np.reshape(
77
- np.frombuffer(de_data, dtype=">u2"), (3, -1), order="F"
78
- ).astype(np.uint16)
79
-
80
- de_dict = dict()
81
- de_dict["de_tag"] = data_uint16[0]
82
- de_dict["trigger_id"] = (data_uint16[1] >> 14).astype(np.uint8)
83
- de_dict["tof_1"] = (data_uint16[1] & int(b"00111111_11110000", 2)) >> 4
84
- de_dict["tof_2"] = ((data_uint16[1] & int(b"00000000_00001111", 2)) << 6) + (
85
- data_uint16[2] >> 10
86
- )
87
- de_dict["tof_3"] = data_uint16[2] & int(b"00000011_11111111", 2)
88
-
89
- return de_dict
90
-
91
-
92
- def create_dataset(de_data_dict: dict[str, npt.ArrayLike]) -> xr.Dataset:
93
- """
94
- Create xarray dataset.
95
-
96
- Parameters
97
- ----------
98
- de_data_dict : Dict[list]
99
- Dictionary of packet telemetry and direct event data lists.
100
-
101
- Returns
102
- -------
103
- dataset : xarray.Dataset
104
- Xarray dataset.
105
- """
106
- # Load the CDF attributes
107
- attr_mgr = ImapCdfAttributes()
108
- attr_mgr.add_instrument_global_attrs("hi")
109
- attr_mgr.add_instrument_variable_attrs(instrument="hi", level=None)
110
-
111
- # check_schema=False keeps DEPEND_0 = '' from being auto added
112
- epoch_attrs = attr_mgr.get_variable_attributes("epoch", check_schema=False)
113
- epoch_attrs["CATDESC"] = (
114
- "CCSDS creation time, number of nanoseconds since J2000 with leap "
115
- "seconds included"
116
- )
117
- epoch = xr.DataArray(
118
- met_to_ttj2000ns(de_data_dict["ccsds_met"]),
119
- name="epoch",
120
- dims=["epoch"],
121
- attrs=epoch_attrs,
122
- )
123
-
124
- event_met_attrs = attr_mgr.get_variable_attributes(
125
- "hi_de_event_met", check_schema=False
126
- )
127
- # For L1A DE, event_met is its own dimension, so we remove the DEPEND_0 attribute
128
- _ = event_met_attrs.pop("DEPEND_0")
129
-
130
- # Compute the meta-event MET in seconds
131
- meta_event_met = (
132
- np.array(de_data_dict["meta_seconds"]).astype(np.float64)
133
- + np.array(de_data_dict["meta_subseconds"]) * MILLISECOND_TO_S
134
- )
135
- # Compute the MET of each event in seconds
136
- # event MET = meta_event_met + de_clock
137
- # See Hi Algorithm Document section 2.2.5
138
- event_met_array = np.array(
139
- meta_event_met[de_data_dict["ccsds_index"]]
140
- + np.array(de_data_dict["de_tag"]) * DE_CLOCK_TICK_S,
141
- dtype=event_met_attrs.pop("dtype"),
142
- )
143
- event_met = xr.DataArray(
144
- event_met_array,
145
- name="event_met",
146
- dims=["event_met"],
147
- attrs=event_met_attrs,
148
- )
149
-
150
- dataset = xr.Dataset(
151
- coords={"epoch": epoch, "event_met": event_met},
152
- )
153
-
154
- for var_name, data in de_data_dict.items():
155
- attrs = attr_mgr.get_variable_attributes(
156
- f"hi_de_{var_name}", check_schema=False
157
- ).copy()
158
- dtype = attrs.pop("dtype")
159
- dataset[var_name] = xr.DataArray(
160
- np.array(data, dtype=np.dtype(dtype)),
161
- dims=attrs["DEPEND_0"],
162
- attrs=attrs,
163
- )
164
-
165
- return dataset
166
-
167
-
168
- def science_direct_event(packets_data: xr.Dataset) -> xr.Dataset:
169
- """
170
- Unpack IMAP-Hi direct event data.
171
-
172
- Processing step:
173
-
174
- | 1. Break binary stream data into unit of 48-bits
175
- | 2. Parse direct event data
176
- | 5. Save the data into xarray dataset.
177
-
178
- Parameters
179
- ----------
180
- packets_data : xarray.Dataset
181
- Packets extracted into a dataset.
182
-
183
- Returns
184
- -------
185
- dataset : xarray.Dataset
186
- Xarray dataset.
187
- """
188
- de_data_dict: dict[str, list] = defaultdict(list)
189
-
190
- # Add packet data to the dictionary, renaming some fields
191
- # This is done first so that these variables are first in the CDF
192
- for from_key, to_key in {
193
- "shcoarse": "ccsds_met",
194
- "src_seq_ctr": "src_seq_ctr",
195
- "pkt_len": "pkt_len",
196
- "last_spin_num": "last_spin_num",
197
- "spin_invalids": "spin_invalids",
198
- "esa_step_num": "esa_step",
199
- "meta_seconds": "meta_seconds",
200
- "meta_subseconds": "meta_subseconds",
201
- }.items():
202
- de_data_dict[to_key] = packets_data[from_key].data
203
-
204
- # For each packet, parse the DE data and add it to the Pointing
205
- # list of DE data usint `extend()`
206
- for i, data in enumerate(packets_data["de_tof"].data):
207
- parsed_de_data = parse_direct_events(data)
208
- for key, new_data in parsed_de_data.items():
209
- de_data_dict[key].extend(new_data)
210
- # Record the ccsds packet index for each DE
211
- de_data_dict["ccsds_index"].extend([i] * len(parsed_de_data["de_tag"]))
212
-
213
- # create dataset
214
- return create_dataset(de_data_dict)
File without changes
File without changes
File without changes