imap-processing 0.16.2__py3-none-any.whl → 0.18.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 (110) hide show
  1. imap_processing/_version.py +2 -2
  2. imap_processing/ccsds/excel_to_xtce.py +12 -0
  3. imap_processing/cdf/config/imap_codice_global_cdf_attrs.yaml +6 -6
  4. imap_processing/cdf/config/imap_codice_l1a_variable_attrs.yaml +35 -0
  5. imap_processing/cdf/config/imap_codice_l1b_variable_attrs.yaml +35 -0
  6. imap_processing/cdf/config/imap_codice_l2_variable_attrs.yaml +24 -0
  7. imap_processing/cdf/config/imap_hi_variable_attrs.yaml +8 -8
  8. imap_processing/cdf/config/imap_hit_global_cdf_attrs.yaml +1 -1
  9. imap_processing/cdf/config/imap_hit_l1a_variable_attrs.yaml +163 -100
  10. imap_processing/cdf/config/imap_hit_l2_variable_attrs.yaml +398 -415
  11. imap_processing/cdf/config/imap_ialirt_l1_variable_attrs.yaml +97 -54
  12. imap_processing/cdf/config/imap_idex_global_cdf_attrs.yaml +9 -9
  13. imap_processing/cdf/config/imap_idex_l2b_variable_attrs.yaml +233 -57
  14. imap_processing/cdf/config/imap_idex_l2c_variable_attrs.yaml +16 -90
  15. imap_processing/cdf/config/imap_lo_global_cdf_attrs.yaml +30 -0
  16. imap_processing/cdf/config/imap_mag_global_cdf_attrs.yaml +15 -1
  17. imap_processing/cdf/config/imap_swapi_variable_attrs.yaml +19 -0
  18. imap_processing/cdf/config/imap_swe_l1b_variable_attrs.yaml +20 -0
  19. imap_processing/cdf/config/imap_swe_l2_variable_attrs.yaml +39 -0
  20. imap_processing/cdf/config/imap_ultra_global_cdf_attrs.yaml +168 -0
  21. imap_processing/cdf/config/imap_ultra_l1a_variable_attrs.yaml +103 -2
  22. imap_processing/cdf/config/imap_ultra_l1b_variable_attrs.yaml +91 -11
  23. imap_processing/cdf/utils.py +7 -1
  24. imap_processing/cli.py +42 -13
  25. imap_processing/codice/codice_l1a.py +125 -78
  26. imap_processing/codice/codice_l1b.py +1 -1
  27. imap_processing/codice/codice_l2.py +0 -9
  28. imap_processing/codice/constants.py +481 -498
  29. imap_processing/hi/hi_l1a.py +4 -4
  30. imap_processing/hi/hi_l1b.py +2 -2
  31. imap_processing/hi/packet_definitions/TLM_HI_COMBINED_SCI.xml +218 -38
  32. imap_processing/hit/hit_utils.py +2 -2
  33. imap_processing/hit/l0/decom_hit.py +4 -3
  34. imap_processing/hit/l1a/hit_l1a.py +64 -24
  35. imap_processing/hit/l1b/constants.py +5 -0
  36. imap_processing/hit/l1b/hit_l1b.py +18 -16
  37. imap_processing/hit/l2/constants.py +1 -1
  38. imap_processing/hit/l2/hit_l2.py +4 -4
  39. imap_processing/ialirt/constants.py +21 -0
  40. imap_processing/ialirt/generate_coverage.py +188 -0
  41. imap_processing/ialirt/l0/parse_mag.py +62 -5
  42. imap_processing/ialirt/l0/process_swapi.py +1 -1
  43. imap_processing/ialirt/l0/process_swe.py +23 -7
  44. imap_processing/ialirt/utils/constants.py +22 -16
  45. imap_processing/ialirt/utils/create_xarray.py +42 -19
  46. imap_processing/idex/idex_constants.py +8 -5
  47. imap_processing/idex/idex_l2b.py +554 -58
  48. imap_processing/idex/idex_l2c.py +30 -196
  49. imap_processing/lo/l0/lo_apid.py +1 -0
  50. imap_processing/lo/l0/lo_star_sensor.py +48 -0
  51. imap_processing/lo/l1a/lo_l1a.py +74 -30
  52. imap_processing/lo/packet_definitions/lo_xtce.xml +5359 -106
  53. imap_processing/mag/constants.py +1 -0
  54. imap_processing/mag/l0/decom_mag.py +9 -6
  55. imap_processing/mag/l0/mag_l0_data.py +46 -0
  56. imap_processing/mag/l1d/__init__.py +0 -0
  57. imap_processing/mag/l1d/mag_l1d.py +133 -0
  58. imap_processing/mag/l1d/mag_l1d_data.py +588 -0
  59. imap_processing/mag/l2/__init__.py +0 -0
  60. imap_processing/mag/l2/mag_l2.py +25 -20
  61. imap_processing/mag/l2/mag_l2_data.py +191 -130
  62. imap_processing/quality_flags.py +20 -2
  63. imap_processing/spice/geometry.py +25 -3
  64. imap_processing/spice/pointing_frame.py +1 -1
  65. imap_processing/spice/spin.py +4 -0
  66. imap_processing/spice/time.py +51 -0
  67. imap_processing/swapi/l1/swapi_l1.py +12 -2
  68. imap_processing/swapi/l2/swapi_l2.py +59 -14
  69. imap_processing/swapi/swapi_utils.py +1 -1
  70. imap_processing/swe/l1b/swe_l1b.py +11 -4
  71. imap_processing/swe/l2/swe_l2.py +111 -17
  72. imap_processing/ultra/constants.py +49 -1
  73. imap_processing/ultra/l0/decom_tools.py +28 -14
  74. imap_processing/ultra/l0/decom_ultra.py +225 -15
  75. imap_processing/ultra/l0/ultra_utils.py +281 -8
  76. imap_processing/ultra/l1a/ultra_l1a.py +77 -8
  77. imap_processing/ultra/l1b/cullingmask.py +3 -3
  78. imap_processing/ultra/l1b/de.py +53 -15
  79. imap_processing/ultra/l1b/extendedspin.py +26 -2
  80. imap_processing/ultra/l1b/lookup_utils.py +171 -50
  81. imap_processing/ultra/l1b/quality_flag_filters.py +14 -0
  82. imap_processing/ultra/l1b/ultra_l1b_culling.py +198 -5
  83. imap_processing/ultra/l1b/ultra_l1b_extended.py +304 -66
  84. imap_processing/ultra/l1c/helio_pset.py +54 -7
  85. imap_processing/ultra/l1c/spacecraft_pset.py +9 -1
  86. imap_processing/ultra/l1c/ultra_l1c.py +2 -0
  87. imap_processing/ultra/l1c/ultra_l1c_pset_bins.py +106 -109
  88. imap_processing/ultra/packet_definitions/ULTRA_SCI_COMBINED.xml +3 -3
  89. imap_processing/ultra/utils/ultra_l1_utils.py +13 -1
  90. imap_processing/utils.py +20 -42
  91. {imap_processing-0.16.2.dist-info → imap_processing-0.18.0.dist-info}/METADATA +2 -2
  92. {imap_processing-0.16.2.dist-info → imap_processing-0.18.0.dist-info}/RECORD +95 -103
  93. imap_processing/lo/l0/data_classes/star_sensor.py +0 -98
  94. imap_processing/lo/l0/utils/lo_base.py +0 -57
  95. imap_processing/ultra/lookup_tables/Angular_Profiles_FM45_LeftSlit.csv +0 -526
  96. imap_processing/ultra/lookup_tables/Angular_Profiles_FM45_RightSlit.csv +0 -526
  97. imap_processing/ultra/lookup_tables/Angular_Profiles_FM90_LeftSlit.csv +0 -526
  98. imap_processing/ultra/lookup_tables/Angular_Profiles_FM90_RightSlit.csv +0 -524
  99. imap_processing/ultra/lookup_tables/EgyNorm.mem.csv +0 -32769
  100. imap_processing/ultra/lookup_tables/FM45_Startup1_ULTRA_IMGPARAMS_20240719.csv +0 -2
  101. imap_processing/ultra/lookup_tables/FM90_Startup1_ULTRA_IMGPARAMS_20240719.csv +0 -2
  102. imap_processing/ultra/lookup_tables/dps_grid45_compressed.cdf +0 -0
  103. imap_processing/ultra/lookup_tables/ultra45_back-pos-luts.csv +0 -4097
  104. imap_processing/ultra/lookup_tables/ultra45_tdc_norm.csv +0 -2050
  105. imap_processing/ultra/lookup_tables/ultra90_back-pos-luts.csv +0 -4097
  106. imap_processing/ultra/lookup_tables/ultra90_tdc_norm.csv +0 -2050
  107. imap_processing/ultra/lookup_tables/yadjust.csv +0 -257
  108. {imap_processing-0.16.2.dist-info → imap_processing-0.18.0.dist-info}/LICENSE +0 -0
  109. {imap_processing-0.16.2.dist-info → imap_processing-0.18.0.dist-info}/WHEEL +0 -0
  110. {imap_processing-0.16.2.dist-info → imap_processing-0.18.0.dist-info}/entry_points.txt +0 -0
@@ -170,8 +170,8 @@ def finish_de_dataset(packets_data: xr.Dataset) -> xr.Dataset:
170
170
  "last_spin_num": "last_spin_num",
171
171
  "spin_invalids": "spin_invalids",
172
172
  "esa_step_num": "esa_step",
173
- "meta_seconds": "meta_seconds",
174
- "meta_subseconds": "meta_subseconds",
173
+ "esa_step_seconds": "esa_step_seconds",
174
+ "esa_step_milliseconds": "esa_step_milliseconds",
175
175
  }.items():
176
176
  de_data_dict[to_key] = packets_data[from_key].data
177
177
 
@@ -228,8 +228,8 @@ def create_de_dataset(de_data_dict: dict[str, npt.ArrayLike]) -> xr.Dataset:
228
228
 
229
229
  # Compute the meta-event MET in seconds
230
230
  meta_event_met = (
231
- np.array(de_data_dict["meta_seconds"]).astype(np.float64)
232
- + np.array(de_data_dict["meta_subseconds"]) * MILLISECOND_TO_S
231
+ np.array(de_data_dict["esa_step_seconds"]).astype(np.float64)
232
+ + np.array(de_data_dict["esa_step_milliseconds"]) * MILLISECOND_TO_S
233
233
  )
234
234
  # Compute the MET of each event in seconds
235
235
  # event MET = meta_event_met + de_clock
@@ -169,8 +169,8 @@ def annotate_direct_events(l1a_dataset: xr.Dataset) -> xr.Dataset:
169
169
  "pkt_len",
170
170
  "last_spin_num",
171
171
  "spin_invalids",
172
- "meta_seconds",
173
- "meta_subseconds",
172
+ "esa_step_seconds",
173
+ "esa_step_milliseconds",
174
174
  "tof_1",
175
175
  "tof_2",
176
176
  "tof_3",
@@ -1,6 +1,6 @@
1
1
  <?xml version='1.0' encoding='utf-8'?>
2
2
  <xtce:SpaceSystem xmlns:xtce="http://www.omg.org/space/xtce" name="H45">
3
- <xtce:Header date="2024-11-26 00:00:00" version="1" author="IMAP SDC" source_file="TLM_H45_H90_20241126.xlsx" />
3
+ <xtce:Header date="29/04/2025" version="1.2" author="IMAP SDC" source_file="TLM_H45_H90_20250429.xlsx" />
4
4
  <xtce:TelemetryMetaData>
5
5
  <xtce:ParameterTypeSet>
6
6
  <xtce:IntegerParameterType name="VERSION" signed="false">
@@ -24,6 +24,56 @@
24
24
  <xtce:IntegerParameterType name="PKT_LEN" signed="false">
25
25
  <xtce:IntegerDataEncoding sizeInBits="16" encoding="unsigned" />
26
26
  </xtce:IntegerParameterType>
27
+ <xtce:IntegerParameterType name="H45_MEMDMP.SHCOARSE" signed="false">
28
+ <xtce:IntegerDataEncoding sizeInBits="32" encoding="unsigned" />
29
+ </xtce:IntegerParameterType>
30
+ <xtce:IntegerParameterType name="H45_MEMDMP.PACKET_VERSION" signed="false">
31
+ <xtce:IntegerDataEncoding sizeInBits="16" encoding="unsigned" />
32
+ </xtce:IntegerParameterType>
33
+ <xtce:IntegerParameterType name="H45_MEMDMP.SPARE" signed="false">
34
+ <xtce:IntegerDataEncoding sizeInBits="16" encoding="unsigned" />
35
+ </xtce:IntegerParameterType>
36
+ <xtce:EnumeratedParameterType name="H45_MEMDMP.MEMORY_ID" signed="false">
37
+ <xtce:IntegerDataEncoding sizeInBits="32" encoding="unsigned" />
38
+ <xtce:EnumerationList>
39
+ <xtce:Enumeration value="16777217" label="MIMEM_RAW" />
40
+ <xtce:Enumeration value="33554434" label="MIPROM" />
41
+ <xtce:Enumeration value="67108868" label="MIMRAM" />
42
+ <xtce:Enumeration value="134217736" label="MISDRAM_CPU" />
43
+ <xtce:Enumeration value="285212688" label="MISDRAM_SCI" />
44
+ <xtce:Enumeration value="591733573" label="MICDH_FPGA" />
45
+ <xtce:Enumeration value="301989920" label="MIHVPSBD1" />
46
+ <xtce:Enumeration value="335544384" label="MIHVPSBD2" />
47
+ <xtce:Enumeration value="402653312" label="MIFEEFPGA" />
48
+ <xtce:Enumeration value="570425856" label="MISCRATCH" />
49
+ <xtce:Enumeration value="587203328" label="MICPU" />
50
+ <xtce:Enumeration value="2050814831" label="MIENG_LUT_PRI" />
51
+ <xtce:Enumeration value="2116893225" label="MIENG_LUT_RED" />
52
+ <xtce:Enumeration value="1160045761" label="MIENG_LUT_RAM" />
53
+ <xtce:Enumeration value="763219379" label="MISCI_LUT_PRI" />
54
+ <xtce:Enumeration value="1973595935" label="MISCI_LUT_RED" />
55
+ <xtce:Enumeration value="1517368615" label="MISCI_LUT_RAM" />
56
+ </xtce:EnumerationList>
57
+ </xtce:EnumeratedParameterType>
58
+ <xtce:IntegerParameterType name="H45_MEMDMP.START_ADDRESS" signed="false">
59
+ <xtce:IntegerDataEncoding sizeInBits="32" encoding="unsigned" />
60
+ </xtce:IntegerParameterType>
61
+ <xtce:IntegerParameterType name="H45_MEMDMP.NUM_BYTES" signed="false">
62
+ <xtce:IntegerDataEncoding sizeInBits="32" encoding="unsigned" />
63
+ </xtce:IntegerParameterType>
64
+ <xtce:BinaryParameterType name="H45_MEMDMP.DUMP_DATA">
65
+ <xtce:BinaryDataEncoding bitOrder="mostSignificantBitFirst">
66
+ <xtce:SizeInBits>
67
+ <xtce:DynamicValue>
68
+ <xtce:ParameterInstanceRef parameterRef="PKT_LEN" />
69
+ <xtce:LinearAdjustment slope="8" intercept="-168" />
70
+ </xtce:DynamicValue>
71
+ </xtce:SizeInBits>
72
+ </xtce:BinaryDataEncoding>
73
+ </xtce:BinaryParameterType>
74
+ <xtce:IntegerParameterType name="H45_MEMDMP.CKSUM" signed="false">
75
+ <xtce:IntegerDataEncoding sizeInBits="16" encoding="unsigned" />
76
+ </xtce:IntegerParameterType>
27
77
  <xtce:IntegerParameterType name="H45_APP_NHK.SHCOARSE" signed="false">
28
78
  <xtce:IntegerDataEncoding sizeInBits="32" encoding="unsigned" />
29
79
  </xtce:IntegerParameterType>
@@ -970,16 +1020,16 @@
970
1020
  <xtce:IntegerParameterType name="H45_SCI_DE.SPARE" signed="false">
971
1021
  <xtce:IntegerDataEncoding sizeInBits="20" encoding="unsigned" />
972
1022
  </xtce:IntegerParameterType>
973
- <xtce:IntegerParameterType name="H45_SCI_DE.META_BITMASK" signed="false">
1023
+ <xtce:IntegerParameterType name="H45_SCI_DE.SPARE1" signed="false">
974
1024
  <xtce:IntegerDataEncoding sizeInBits="2" encoding="unsigned" />
975
1025
  </xtce:IntegerParameterType>
976
1026
  <xtce:IntegerParameterType name="H45_SCI_DE.ESA_STEP_NUM" signed="false">
977
1027
  <xtce:IntegerDataEncoding sizeInBits="4" encoding="unsigned" />
978
1028
  </xtce:IntegerParameterType>
979
- <xtce:IntegerParameterType name="H45_SCI_DE.META_SUBSECONDS" signed="false">
1029
+ <xtce:IntegerParameterType name="H45_SCI_DE.ESA_STEP_MILLISECONDS" signed="false">
980
1030
  <xtce:IntegerDataEncoding sizeInBits="10" encoding="unsigned" />
981
1031
  </xtce:IntegerParameterType>
982
- <xtce:IntegerParameterType name="H45_SCI_DE.META_SECONDS" signed="false">
1032
+ <xtce:IntegerParameterType name="H45_SCI_DE.ESA_STEP_SECONDS" signed="false">
983
1033
  <xtce:IntegerDataEncoding sizeInBits="32" encoding="unsigned" />
984
1034
  </xtce:IntegerParameterType>
985
1035
  <xtce:BinaryParameterType name="H45_SCI_DE.DE_TOF">
@@ -1271,6 +1321,56 @@
1271
1321
  <xtce:IntegerParameterType name="H45_DIAG_FEE.CKSUM" signed="false">
1272
1322
  <xtce:IntegerDataEncoding sizeInBits="16" encoding="unsigned" />
1273
1323
  </xtce:IntegerParameterType>
1324
+ <xtce:IntegerParameterType name="H90_MEMDMP.SHCOARSE" signed="false">
1325
+ <xtce:IntegerDataEncoding sizeInBits="32" encoding="unsigned" />
1326
+ </xtce:IntegerParameterType>
1327
+ <xtce:IntegerParameterType name="H90_MEMDMP.PACKET_VERSION" signed="false">
1328
+ <xtce:IntegerDataEncoding sizeInBits="16" encoding="unsigned" />
1329
+ </xtce:IntegerParameterType>
1330
+ <xtce:IntegerParameterType name="H90_MEMDMP.SPARE" signed="false">
1331
+ <xtce:IntegerDataEncoding sizeInBits="16" encoding="unsigned" />
1332
+ </xtce:IntegerParameterType>
1333
+ <xtce:EnumeratedParameterType name="H90_MEMDMP.MEMORY_ID" signed="false">
1334
+ <xtce:IntegerDataEncoding sizeInBits="32" encoding="unsigned" />
1335
+ <xtce:EnumerationList>
1336
+ <xtce:Enumeration value="16777217" label="MIMEM_RAW" />
1337
+ <xtce:Enumeration value="33554434" label="MIPROM" />
1338
+ <xtce:Enumeration value="67108868" label="MIMRAM" />
1339
+ <xtce:Enumeration value="134217736" label="MISDRAM_CPU" />
1340
+ <xtce:Enumeration value="285212688" label="MISDRAM_SCI" />
1341
+ <xtce:Enumeration value="591733573" label="MICDH_FPGA" />
1342
+ <xtce:Enumeration value="301989920" label="MIHVPSBD1" />
1343
+ <xtce:Enumeration value="335544384" label="MIHVPSBD2" />
1344
+ <xtce:Enumeration value="402653312" label="MIFEEFPGA" />
1345
+ <xtce:Enumeration value="570425856" label="MISCRATCH" />
1346
+ <xtce:Enumeration value="587203328" label="MICPU" />
1347
+ <xtce:Enumeration value="2050814831" label="MIENG_LUT_PRI" />
1348
+ <xtce:Enumeration value="2116893225" label="MIENG_LUT_RED" />
1349
+ <xtce:Enumeration value="1160045761" label="MIENG_LUT_RAM" />
1350
+ <xtce:Enumeration value="763219379" label="MISCI_LUT_PRI" />
1351
+ <xtce:Enumeration value="1973595935" label="MISCI_LUT_RED" />
1352
+ <xtce:Enumeration value="1517368615" label="MISCI_LUT_RAM" />
1353
+ </xtce:EnumerationList>
1354
+ </xtce:EnumeratedParameterType>
1355
+ <xtce:IntegerParameterType name="H90_MEMDMP.START_ADDRESS" signed="false">
1356
+ <xtce:IntegerDataEncoding sizeInBits="32" encoding="unsigned" />
1357
+ </xtce:IntegerParameterType>
1358
+ <xtce:IntegerParameterType name="H90_MEMDMP.NUM_BYTES" signed="false">
1359
+ <xtce:IntegerDataEncoding sizeInBits="32" encoding="unsigned" />
1360
+ </xtce:IntegerParameterType>
1361
+ <xtce:BinaryParameterType name="H90_MEMDMP.DUMP_DATA">
1362
+ <xtce:BinaryDataEncoding bitOrder="mostSignificantBitFirst">
1363
+ <xtce:SizeInBits>
1364
+ <xtce:DynamicValue>
1365
+ <xtce:ParameterInstanceRef parameterRef="PKT_LEN" />
1366
+ <xtce:LinearAdjustment slope="8" intercept="-168" />
1367
+ </xtce:DynamicValue>
1368
+ </xtce:SizeInBits>
1369
+ </xtce:BinaryDataEncoding>
1370
+ </xtce:BinaryParameterType>
1371
+ <xtce:IntegerParameterType name="H90_MEMDMP.CKSUM" signed="false">
1372
+ <xtce:IntegerDataEncoding sizeInBits="16" encoding="unsigned" />
1373
+ </xtce:IntegerParameterType>
1274
1374
  <xtce:IntegerParameterType name="H90_APP_NHK.SHCOARSE" signed="false">
1275
1375
  <xtce:IntegerDataEncoding sizeInBits="32" encoding="unsigned" />
1276
1376
  </xtce:IntegerParameterType>
@@ -1386,7 +1486,7 @@
1386
1486
  <xtce:IntegerDataEncoding sizeInBits="12" encoding="unsigned">
1387
1487
  <xtce:DefaultCalibrator>
1388
1488
  <xtce:PolynomialCalibrator>
1389
- <xtce:Term coefficient="2.243589743589744" exponent="1" />
1489
+ <xtce:Term coefficient="2.243589744" exponent="1" />
1390
1490
  </xtce:PolynomialCalibrator>
1391
1491
  </xtce:DefaultCalibrator>
1392
1492
  </xtce:IntegerDataEncoding>
@@ -2216,16 +2316,16 @@
2216
2316
  <xtce:IntegerParameterType name="H90_SCI_DE.SPARE" signed="false">
2217
2317
  <xtce:IntegerDataEncoding sizeInBits="20" encoding="unsigned" />
2218
2318
  </xtce:IntegerParameterType>
2219
- <xtce:IntegerParameterType name="H90_SCI_DE.META_BITMASK" signed="false">
2319
+ <xtce:IntegerParameterType name="H90_SCI_DE.SPARE1" signed="false">
2220
2320
  <xtce:IntegerDataEncoding sizeInBits="2" encoding="unsigned" />
2221
2321
  </xtce:IntegerParameterType>
2222
2322
  <xtce:IntegerParameterType name="H90_SCI_DE.ESA_STEP_NUM" signed="false">
2223
2323
  <xtce:IntegerDataEncoding sizeInBits="4" encoding="unsigned" />
2224
2324
  </xtce:IntegerParameterType>
2225
- <xtce:IntegerParameterType name="H90_SCI_DE.META_SUBSECONDS" signed="false">
2325
+ <xtce:IntegerParameterType name="H90_SCI_DE.ESA_STEP_MILLISECONDS" signed="false">
2226
2326
  <xtce:IntegerDataEncoding sizeInBits="10" encoding="unsigned" />
2227
2327
  </xtce:IntegerParameterType>
2228
- <xtce:IntegerParameterType name="H90_SCI_DE.META_SECONDS" signed="false">
2328
+ <xtce:IntegerParameterType name="H90_SCI_DE.ESA_STEP_SECONDS" signed="false">
2229
2329
  <xtce:IntegerDataEncoding sizeInBits="32" encoding="unsigned" />
2230
2330
  </xtce:IntegerParameterType>
2231
2331
  <xtce:BinaryParameterType name="H90_SCI_DE.DE_TOF">
@@ -2540,6 +2640,28 @@
2540
2640
  <xtce:Parameter name="PKT_LEN" parameterTypeRef="PKT_LEN">
2541
2641
  <xtce:LongDescription>CCSDS Packet Length (number of bytes after Packet length minus 1)</xtce:LongDescription>
2542
2642
  </xtce:Parameter>
2643
+ <xtce:Parameter name="H45_MEMDMP.SHCOARSE" parameterTypeRef="H45_MEMDMP.SHCOARSE" shortDescription="MISSION ELAPSED TIME">
2644
+ <xtce:LongDescription>MISSION ELAPSED TIME</xtce:LongDescription>
2645
+ </xtce:Parameter>
2646
+ <xtce:Parameter name="H45_MEMDMP.PACKET_VERSION" parameterTypeRef="H45_MEMDMP.PACKET_VERSION" shortDescription="PACKET VERSION">
2647
+ <xtce:LongDescription>PACKET VERSION - THIS WILL BE INCREMENTED EACH TIME THE FORMAT OF THE PACKET CHANGES.</xtce:LongDescription>
2648
+ </xtce:Parameter>
2649
+ <xtce:Parameter name="H45_MEMDMP.SPARE" parameterTypeRef="H45_MEMDMP.SPARE" shortDescription="SPARE FOR ALIGNMENT">
2650
+ <xtce:LongDescription>SPARE FOR ALIGNMENT</xtce:LongDescription>
2651
+ </xtce:Parameter>
2652
+ <xtce:Parameter name="H45_MEMDMP.MEMORY_ID" parameterTypeRef="H45_MEMDMP.MEMORY_ID" shortDescription="MEMORY ID">
2653
+ <xtce:LongDescription>MEMORY DEVICE/TYPE IDENTIFIER. INDICATES THE SOURCE FOR THE DATA INCLUDED IN THE DATA FIELD</xtce:LongDescription>
2654
+ </xtce:Parameter>
2655
+ <xtce:Parameter name="H45_MEMDMP.START_ADDRESS" parameterTypeRef="H45_MEMDMP.START_ADDRESS" shortDescription="START ADDRESS">
2656
+ <xtce:LongDescription>START ADDRESS WITHIN THE DEVICE</xtce:LongDescription>
2657
+ </xtce:Parameter>
2658
+ <xtce:Parameter name="H45_MEMDMP.NUM_BYTES" parameterTypeRef="H45_MEMDMP.NUM_BYTES" shortDescription="NUMBER OF BYTES IN THE DATA FIELD">
2659
+ <xtce:LongDescription>NUMBER OF BYTES INCLUDED IN THE DATA FIELD (NOT INCLUDING PAD BYTES AND THE PACKET CHECKSUM)</xtce:LongDescription>
2660
+ </xtce:Parameter>
2661
+ <xtce:Parameter name="H45_MEMDMP.DUMP_DATA" parameterTypeRef="H45_MEMDMP.DUMP_DATA" shortDescription="DUMP DATA">
2662
+ <xtce:LongDescription>DUMPED DATA. SINCE THIS IS A VARIABLE LENGTH FIELD IT WILL ALSO ENCOMPASS ANY PAD BYTES AND THE PACKET CHECKSUM.</xtce:LongDescription>
2663
+ </xtce:Parameter>
2664
+ <xtce:Parameter name="H45_MEMDMP.CKSUM" parameterTypeRef="H45_MEMDMP.CKSUM" shortDescription="CHECKSUM" />
2543
2665
  <xtce:Parameter name="H45_APP_NHK.SHCOARSE" parameterTypeRef="H45_APP_NHK.SHCOARSE" shortDescription="MISSION ELAPSED TIME">
2544
2666
  <xtce:LongDescription>MISSION ELAPSED TIME</xtce:LongDescription>
2545
2667
  </xtce:Parameter>
@@ -2894,23 +3016,24 @@
2894
3016
  MOS SIGNIFICANT BIT IS ALSO THE HIGHEST SPIN</xtce:LongDescription>
2895
3017
  </xtce:Parameter>
2896
3018
  <xtce:Parameter name="H45_SCI_DE.SPARE" parameterTypeRef="H45_SCI_DE.SPARE" shortDescription="SPARE" />
2897
- <xtce:Parameter name="H45_SCI_DE.META_BITMASK" parameterTypeRef="H45_SCI_DE.META_BITMASK" shortDescription="META_BITMASK IS ALWAYS 0" />
2898
- <xtce:Parameter name="H45_SCI_DE.ESA_STEP_NUM" parameterTypeRef="H45_SCI_DE.ESA_STEP_NUM" shortDescription="ESA STEP NUMBER" />
2899
- <xtce:Parameter name="H45_SCI_DE.META_SUBSECONDS" parameterTypeRef="H45_SCI_DE.META_SUBSECONDS" shortDescription="META EVENT FINE CLOCK TICKS" />
2900
- <xtce:Parameter name="H45_SCI_DE.META_SECONDS" parameterTypeRef="H45_SCI_DE.META_SECONDS" shortDescription="META EVENT COARSE CLOKC TICKS" />
2901
- <xtce:Parameter name="H45_SCI_DE.DE_TOF" parameterTypeRef="H45_SCI_DE.DE_TOF" shortDescription="VARIABLE LENGTH FIELD FOR DIRECT EVENT TOF DATA. MAX SIZE 665X48 BITS.">
3019
+ <xtce:Parameter name="H45_SCI_DE.SPARE1" parameterTypeRef="H45_SCI_DE.SPARE1" shortDescription="MORE SPARE" />
3020
+ <xtce:Parameter name="H45_SCI_DE.ESA_STEP_NUM" parameterTypeRef="H45_SCI_DE.ESA_STEP_NUM" shortDescription="ONE BASED ESA STEP NUMBER THE PACKET'S DATA CORESPONDS TO">
3021
+ <xtce:LongDescription>ESA STEP NUMBER WHEN THE DATA IS COLLECTED STARTING AT 1</xtce:LongDescription>
3022
+ </xtce:Parameter>
3023
+ <xtce:Parameter name="H45_SCI_DE.ESA_STEP_MILLISECONDS" parameterTypeRef="H45_SCI_DE.ESA_STEP_MILLISECONDS" shortDescription="MILLISECOND PART OF START TIME OF ESA STEP THE PACKET DATA IS FOR">
3024
+ <xtce:LongDescription>TIMESTAMP OF ESA STEP STARTING TIME, MILLISECONDS</xtce:LongDescription>
3025
+ </xtce:Parameter>
3026
+ <xtce:Parameter name="H45_SCI_DE.ESA_STEP_SECONDS" parameterTypeRef="H45_SCI_DE.ESA_STEP_SECONDS" shortDescription="SECOND PART OF START TIME OF ESA STEP THE PACKET DATA IS FOR">
3027
+ <xtce:LongDescription>TIMESTAMP OF ESA STEP STARTING TIME, SECONDS</xtce:LongDescription>
3028
+ </xtce:Parameter>
3029
+ <xtce:Parameter name="H45_SCI_DE.DE_TOF" parameterTypeRef="H45_SCI_DE.DE_TOF" shortDescription="VARIABLE LENGTH FIELD FOR DIRECT EVENT TOF DATA. MAX SIZE 664X48 BITS.">
2902
3030
  <xtce:LongDescription>DIRECT EVENT TOF DATA.
2903
- LENGTH IS VARIABLE. MAX IS 665 X 48 BITS
3031
+ LENGTH IS VARIABLE. MAX IS 664 X 48 BITS
2904
3032
  START_BITMASK_DATA - 2 BITS (TA=1, TB=2, TC1=3, META=0)
2905
- IF START_BITMASK != 0
2906
3033
  DE_TAG - 16 BITS
2907
3034
  TOF_1 - 10 BITS
2908
3035
  TOF_2 - 10 BITS
2909
- TOF_3 - 10 BITS
2910
- IF START_BIT_MASK == 0:
2911
- ESA_STEP_NUM - 4 BITS
2912
- MET_SUBSECONDS - 10 BITS
2913
- MET_SECONDS - 32 BITS</xtce:LongDescription>
3036
+ TOF_3 - 10 BITS</xtce:LongDescription>
2914
3037
  </xtce:Parameter>
2915
3038
  <xtce:Parameter name="H45_SCI_DE.CKSUM" parameterTypeRef="H45_SCI_DE.CKSUM" shortDescription="PACKET CHECKSUM" />
2916
3039
  <xtce:Parameter name="H45_DIAG_FEE.SHCOARSE" parameterTypeRef="H45_DIAG_FEE.SHCOARSE" shortDescription="MISSION ELAPSED TIME" />
@@ -3005,6 +3128,28 @@ MET_SECONDS - 32 BITS</xtce:LongDescription>
3005
3128
  <xtce:Parameter name="H45_DIAG_FEE.FEE_RECV_CMD_COUNT" parameterTypeRef="H45_DIAG_FEE.FEE_RECV_CMD_COUNT" shortDescription="SHOWS HOW MANY COMMANDS ARE RECEIVED FROM THE FEE FROM THE C&amp;DH FPGA" />
3006
3129
  <xtce:Parameter name="H45_DIAG_FEE.SPARE" parameterTypeRef="H45_DIAG_FEE.SPARE" shortDescription="SPARE FIELD" />
3007
3130
  <xtce:Parameter name="H45_DIAG_FEE.CKSUM" parameterTypeRef="H45_DIAG_FEE.CKSUM" shortDescription="PACKET CHECKSUM" />
3131
+ <xtce:Parameter name="H90_MEMDMP.SHCOARSE" parameterTypeRef="H90_MEMDMP.SHCOARSE" shortDescription="MISSION ELAPSED TIME">
3132
+ <xtce:LongDescription>MISSION ELAPSED TIME</xtce:LongDescription>
3133
+ </xtce:Parameter>
3134
+ <xtce:Parameter name="H90_MEMDMP.PACKET_VERSION" parameterTypeRef="H90_MEMDMP.PACKET_VERSION" shortDescription="PACKET VERSION">
3135
+ <xtce:LongDescription>PACKET VERSION - THIS WILL BE INCREMENTED EACH TIME THE FORMAT OF THE PACKET CHANGES.</xtce:LongDescription>
3136
+ </xtce:Parameter>
3137
+ <xtce:Parameter name="H90_MEMDMP.SPARE" parameterTypeRef="H90_MEMDMP.SPARE" shortDescription="SPARE FOR ALIGNMENT">
3138
+ <xtce:LongDescription>SPARE FOR ALIGNMENT</xtce:LongDescription>
3139
+ </xtce:Parameter>
3140
+ <xtce:Parameter name="H90_MEMDMP.MEMORY_ID" parameterTypeRef="H90_MEMDMP.MEMORY_ID" shortDescription="MEMORY ID">
3141
+ <xtce:LongDescription>MEMORY DEVICE/TYPE IDENTIFIER. INDICATES THE SOURCE FOR THE DATA INCLUDED IN THE DATA FIELD</xtce:LongDescription>
3142
+ </xtce:Parameter>
3143
+ <xtce:Parameter name="H90_MEMDMP.START_ADDRESS" parameterTypeRef="H90_MEMDMP.START_ADDRESS" shortDescription="START ADDRESS">
3144
+ <xtce:LongDescription>START ADDRESS WITHIN THE DEVICE</xtce:LongDescription>
3145
+ </xtce:Parameter>
3146
+ <xtce:Parameter name="H90_MEMDMP.NUM_BYTES" parameterTypeRef="H90_MEMDMP.NUM_BYTES" shortDescription="NUMBER OF BYTES IN THE DATA FIELD">
3147
+ <xtce:LongDescription>NUMBER OF BYTES INCLUDED IN THE DATA FIELD (NOT INCLUDING PAD BYTES AND THE PACKET CHECKSUM)</xtce:LongDescription>
3148
+ </xtce:Parameter>
3149
+ <xtce:Parameter name="H90_MEMDMP.DUMP_DATA" parameterTypeRef="H90_MEMDMP.DUMP_DATA" shortDescription="DUMP DATA">
3150
+ <xtce:LongDescription>DUMPED DATA. SINCE THIS IS A VARIABLE LENGTH FIELD IT WILL ALSO ENCOMPASS ANY PAD BYTES AND THE PACKET CHECKSUM.</xtce:LongDescription>
3151
+ </xtce:Parameter>
3152
+ <xtce:Parameter name="H90_MEMDMP.CKSUM" parameterTypeRef="H90_MEMDMP.CKSUM" shortDescription="CHECKSUM" />
3008
3153
  <xtce:Parameter name="H90_APP_NHK.SHCOARSE" parameterTypeRef="H90_APP_NHK.SHCOARSE" shortDescription="MISSION ELAPSED TIME">
3009
3154
  <xtce:LongDescription>MISSION ELAPSED TIME</xtce:LongDescription>
3010
3155
  </xtce:Parameter>
@@ -3359,23 +3504,24 @@ MET_SECONDS - 32 BITS</xtce:LongDescription>
3359
3504
  MOS SIGNIFICANT BIT IS ALSO THE HIGHEST SPIN</xtce:LongDescription>
3360
3505
  </xtce:Parameter>
3361
3506
  <xtce:Parameter name="H90_SCI_DE.SPARE" parameterTypeRef="H90_SCI_DE.SPARE" shortDescription="SPARE" />
3362
- <xtce:Parameter name="H90_SCI_DE.META_BITMASK" parameterTypeRef="H90_SCI_DE.META_BITMASK" shortDescription="META_BITMASK IS ALWAYS 0" />
3363
- <xtce:Parameter name="H90_SCI_DE.ESA_STEP_NUM" parameterTypeRef="H90_SCI_DE.ESA_STEP_NUM" shortDescription="ESA STEP NUMBER" />
3364
- <xtce:Parameter name="H90_SCI_DE.META_SUBSECONDS" parameterTypeRef="H90_SCI_DE.META_SUBSECONDS" shortDescription="META EVENT FINE CLOCK TICKS" />
3365
- <xtce:Parameter name="H90_SCI_DE.META_SECONDS" parameterTypeRef="H90_SCI_DE.META_SECONDS" shortDescription="META EVENT COARSE CLOKC TICKS" />
3366
- <xtce:Parameter name="H90_SCI_DE.DE_TOF" parameterTypeRef="H90_SCI_DE.DE_TOF" shortDescription="VARIABLE LENGTH FIELD FOR DIRECT EVENT TOF DATA. MAX SIZE 665X48 BITS.">
3507
+ <xtce:Parameter name="H90_SCI_DE.SPARE1" parameterTypeRef="H90_SCI_DE.SPARE1" shortDescription="MORE SPARE" />
3508
+ <xtce:Parameter name="H90_SCI_DE.ESA_STEP_NUM" parameterTypeRef="H90_SCI_DE.ESA_STEP_NUM" shortDescription="ONE BASED ESA STEP NUMBER THE PACKET'S DATA CORESPONDS TO">
3509
+ <xtce:LongDescription>ESA STEP NUMBER WHEN THE DATA IS COLLECTED STARTING AT 1</xtce:LongDescription>
3510
+ </xtce:Parameter>
3511
+ <xtce:Parameter name="H90_SCI_DE.ESA_STEP_MILLISECONDS" parameterTypeRef="H90_SCI_DE.ESA_STEP_MILLISECONDS" shortDescription="MILLISECOND PART OF START TIME OF ESA STEP THE PACKET DATA IS FOR">
3512
+ <xtce:LongDescription>TIMESTAMP OF ESA STEP STARTING TIME, MILLISECONDS</xtce:LongDescription>
3513
+ </xtce:Parameter>
3514
+ <xtce:Parameter name="H90_SCI_DE.ESA_STEP_SECONDS" parameterTypeRef="H90_SCI_DE.ESA_STEP_SECONDS" shortDescription="SECOND PART OF START TIME OF ESA STEP THE PACKET DATA IS FOR">
3515
+ <xtce:LongDescription>TIMESTAMP OF ESA STEP STARTING TIME, SECONDS</xtce:LongDescription>
3516
+ </xtce:Parameter>
3517
+ <xtce:Parameter name="H90_SCI_DE.DE_TOF" parameterTypeRef="H90_SCI_DE.DE_TOF" shortDescription="VARIABLE LENGTH FIELD FOR DIRECT EVENT TOF DATA. MAX SIZE 664X48 BITS.">
3367
3518
  <xtce:LongDescription>DIRECT EVENT TOF DATA.
3368
- LENGTH IS VARIABLE. MAX IS 665 X 48 BITS
3519
+ LENGTH IS VARIABLE. MAX IS 664 X 48 BITS
3369
3520
  START_BITMASK_DATA - 2 BITS (TA=1, TB=2, TC1=3, META=0)
3370
- IF START_BITMASK != 0
3371
3521
  DE_TAG - 16 BITS
3372
3522
  TOF_1 - 10 BITS
3373
3523
  TOF_2 - 10 BITS
3374
- TOF_3 - 10 BITS
3375
- IF START_BIT_MASK == 0:
3376
- ESA_STEP_NUM - 4 BITS
3377
- MET_SUBSECONDS - 10 BITS
3378
- MET_SECONDS - 32 BITS</xtce:LongDescription>
3524
+ TOF_3 - 10 BITS</xtce:LongDescription>
3379
3525
  </xtce:Parameter>
3380
3526
  <xtce:Parameter name="H90_SCI_DE.CKSUM" parameterTypeRef="H90_SCI_DE.CKSUM" shortDescription="PACKET CHECKSUM" />
3381
3527
  <xtce:Parameter name="H90_DIAG_FEE.SHCOARSE" parameterTypeRef="H90_DIAG_FEE.SHCOARSE" shortDescription="MISSION ELAPSED TIME" />
@@ -3483,6 +3629,23 @@ MET_SECONDS - 32 BITS</xtce:LongDescription>
3483
3629
  <xtce:ParameterRefEntry parameterRef="PKT_LEN" />
3484
3630
  </xtce:EntryList>
3485
3631
  </xtce:SequenceContainer>
3632
+ <xtce:SequenceContainer name="H45_MEMDMP">
3633
+ <xtce:BaseContainer containerRef="CCSDSPacket">
3634
+ <xtce:RestrictionCriteria>
3635
+ <xtce:Comparison parameterRef="PKT_APID" value="740" useCalibratedValue="false" />
3636
+ </xtce:RestrictionCriteria>
3637
+ </xtce:BaseContainer>
3638
+ <xtce:EntryList>
3639
+ <xtce:ParameterRefEntry parameterRef="H45_MEMDMP.SHCOARSE" />
3640
+ <xtce:ParameterRefEntry parameterRef="H45_MEMDMP.PACKET_VERSION" />
3641
+ <xtce:ParameterRefEntry parameterRef="H45_MEMDMP.SPARE" />
3642
+ <xtce:ParameterRefEntry parameterRef="H45_MEMDMP.MEMORY_ID" />
3643
+ <xtce:ParameterRefEntry parameterRef="H45_MEMDMP.START_ADDRESS" />
3644
+ <xtce:ParameterRefEntry parameterRef="H45_MEMDMP.NUM_BYTES" />
3645
+ <xtce:ParameterRefEntry parameterRef="H45_MEMDMP.DUMP_DATA" />
3646
+ <xtce:ParameterRefEntry parameterRef="H45_MEMDMP.CKSUM" />
3647
+ </xtce:EntryList>
3648
+ </xtce:SequenceContainer>
3486
3649
  <xtce:SequenceContainer name="H45_APP_NHK">
3487
3650
  <xtce:BaseContainer containerRef="CCSDSPacket">
3488
3651
  <xtce:RestrictionCriteria>
@@ -3627,10 +3790,10 @@ MET_SECONDS - 32 BITS</xtce:LongDescription>
3627
3790
  <xtce:ParameterRefEntry parameterRef="H45_SCI_DE.LAST_SPIN_NUM" />
3628
3791
  <xtce:ParameterRefEntry parameterRef="H45_SCI_DE.SPIN_INVALIDS" />
3629
3792
  <xtce:ParameterRefEntry parameterRef="H45_SCI_DE.SPARE" />
3630
- <xtce:ParameterRefEntry parameterRef="H45_SCI_DE.META_BITMASK" />
3793
+ <xtce:ParameterRefEntry parameterRef="H45_SCI_DE.SPARE1" />
3631
3794
  <xtce:ParameterRefEntry parameterRef="H45_SCI_DE.ESA_STEP_NUM" />
3632
- <xtce:ParameterRefEntry parameterRef="H45_SCI_DE.META_SUBSECONDS" />
3633
- <xtce:ParameterRefEntry parameterRef="H45_SCI_DE.META_SECONDS" />
3795
+ <xtce:ParameterRefEntry parameterRef="H45_SCI_DE.ESA_STEP_MILLISECONDS" />
3796
+ <xtce:ParameterRefEntry parameterRef="H45_SCI_DE.ESA_STEP_SECONDS" />
3634
3797
  <xtce:ParameterRefEntry parameterRef="H45_SCI_DE.DE_TOF" />
3635
3798
  <xtce:ParameterRefEntry parameterRef="H45_SCI_DE.CKSUM" />
3636
3799
  </xtce:EntryList>
@@ -3736,6 +3899,23 @@ MET_SECONDS - 32 BITS</xtce:LongDescription>
3736
3899
  <xtce:ParameterRefEntry parameterRef="H45_DIAG_FEE.CKSUM" />
3737
3900
  </xtce:EntryList>
3738
3901
  </xtce:SequenceContainer>
3902
+ <xtce:SequenceContainer name="H90_MEMDMP">
3903
+ <xtce:BaseContainer containerRef="CCSDSPacket">
3904
+ <xtce:RestrictionCriteria>
3905
+ <xtce:Comparison parameterRef="PKT_APID" value="804" useCalibratedValue="false" />
3906
+ </xtce:RestrictionCriteria>
3907
+ </xtce:BaseContainer>
3908
+ <xtce:EntryList>
3909
+ <xtce:ParameterRefEntry parameterRef="H90_MEMDMP.SHCOARSE" />
3910
+ <xtce:ParameterRefEntry parameterRef="H90_MEMDMP.PACKET_VERSION" />
3911
+ <xtce:ParameterRefEntry parameterRef="H90_MEMDMP.SPARE" />
3912
+ <xtce:ParameterRefEntry parameterRef="H90_MEMDMP.MEMORY_ID" />
3913
+ <xtce:ParameterRefEntry parameterRef="H90_MEMDMP.START_ADDRESS" />
3914
+ <xtce:ParameterRefEntry parameterRef="H90_MEMDMP.NUM_BYTES" />
3915
+ <xtce:ParameterRefEntry parameterRef="H90_MEMDMP.DUMP_DATA" />
3916
+ <xtce:ParameterRefEntry parameterRef="H90_MEMDMP.CKSUM" />
3917
+ </xtce:EntryList>
3918
+ </xtce:SequenceContainer>
3739
3919
  <xtce:SequenceContainer name="H90_APP_NHK">
3740
3920
  <xtce:BaseContainer containerRef="CCSDSPacket">
3741
3921
  <xtce:RestrictionCriteria>
@@ -3880,10 +4060,10 @@ MET_SECONDS - 32 BITS</xtce:LongDescription>
3880
4060
  <xtce:ParameterRefEntry parameterRef="H90_SCI_DE.LAST_SPIN_NUM" />
3881
4061
  <xtce:ParameterRefEntry parameterRef="H90_SCI_DE.SPIN_INVALIDS" />
3882
4062
  <xtce:ParameterRefEntry parameterRef="H90_SCI_DE.SPARE" />
3883
- <xtce:ParameterRefEntry parameterRef="H90_SCI_DE.META_BITMASK" />
4063
+ <xtce:ParameterRefEntry parameterRef="H90_SCI_DE.SPARE1" />
3884
4064
  <xtce:ParameterRefEntry parameterRef="H90_SCI_DE.ESA_STEP_NUM" />
3885
- <xtce:ParameterRefEntry parameterRef="H90_SCI_DE.META_SUBSECONDS" />
3886
- <xtce:ParameterRefEntry parameterRef="H90_SCI_DE.META_SECONDS" />
4065
+ <xtce:ParameterRefEntry parameterRef="H90_SCI_DE.ESA_STEP_MILLISECONDS" />
4066
+ <xtce:ParameterRefEntry parameterRef="H90_SCI_DE.ESA_STEP_SECONDS" />
3887
4067
  <xtce:ParameterRefEntry parameterRef="H90_SCI_DE.DE_TOF" />
3888
4068
  <xtce:ParameterRefEntry parameterRef="H90_SCI_DE.CKSUM" />
3889
4069
  </xtce:EntryList>
@@ -368,8 +368,8 @@ def add_energy_variables(
368
368
  """
369
369
  updated_ds = dataset.copy()
370
370
 
371
- energy_mean = np.mean(
372
- np.array([energy_min_values, energy_max_values]), axis=0
371
+ energy_mean = np.round(
372
+ np.mean(np.array([energy_min_values, energy_max_values]), axis=0), 3
373
373
  ).astype(np.float32)
374
374
 
375
375
  updated_ds[f"{particle}_energy_mean"] = xr.DataArray(
@@ -116,16 +116,17 @@ def parse_count_rates(sci_dataset: xr.Dataset) -> None:
116
116
  else:
117
117
  dims = ["epoch"]
118
118
 
119
+ dtype = np.uint8 if field == "hdr_dynamic_threshold_state" else np.int64
119
120
  sci_dataset[field] = xr.DataArray(
120
- np.array(parsed_data, dtype=np.int64), dims=dims, name=field
121
+ np.array(parsed_data, dtype=dtype), dims=dims, name=field
121
122
  )
122
123
  # Add dimensions to coordinates
123
124
  for dim in dims:
124
125
  if dim not in sci_dataset.coords:
125
126
  sci_dataset.coords[dim] = xr.DataArray(
126
- np.arange(sci_dataset.sizes[dim], dtype=np.int16)
127
+ np.arange(sci_dataset.sizes[dim], dtype=np.uint16)
127
128
  if dim == "gain"
128
- else np.arange(sci_dataset.sizes[dim], dtype=np.int32),
129
+ else np.arange(sci_dataset.sizes[dim], dtype=np.uint32),
129
130
  dims=[dim],
130
131
  name=dim,
131
132
  )
@@ -245,6 +245,69 @@ def calculate_uncertainties(dataset: xr.Dataset) -> xr.Dataset:
245
245
  return dataset
246
246
 
247
247
 
248
+ def add_cdf_attributes(
249
+ dataset: xr.Dataset, logical_source: str, attr_mgr: ImapCdfAttributes
250
+ ) -> xr.Dataset:
251
+ """
252
+ Add attributes to the dataset.
253
+
254
+ This function adds attributes to the dataset variables and dimensions.
255
+ It also adds dimension labels as coordinates to the dataset.The attributes
256
+ are defined in a YAML file and retrieved by the attribute manager.
257
+
258
+ Parameters
259
+ ----------
260
+ dataset : xarray.Dataset
261
+ The dataset to update.
262
+ logical_source : str
263
+ The logical source of the dataset.
264
+ attr_mgr : ImapCdfAttributes
265
+ The attribute manager to retrieve attributes.
266
+
267
+ Returns
268
+ -------
269
+ xarray.Dataset
270
+ The updated dataset with attributes and dimension labels.
271
+ """
272
+ dataset.attrs = attr_mgr.get_global_attributes(logical_source)
273
+
274
+ # Assign attributes and dimensions to each data array in the Dataset
275
+ for var in dataset.data_vars.keys():
276
+ try:
277
+ if "energy_delta" in var or var in {
278
+ "pkt_len",
279
+ "version",
280
+ "type",
281
+ "src_seq_ctr",
282
+ "seq_flgs",
283
+ "pkt_apid",
284
+ "sec_hdr_flg",
285
+ }:
286
+ # skip schema check to avoid DEPEND_0 being added unnecessarily
287
+ dataset[var].attrs = attr_mgr.get_variable_attributes(
288
+ var, check_schema=False
289
+ )
290
+ else:
291
+ dataset[var].attrs = attr_mgr.get_variable_attributes(var)
292
+ except KeyError:
293
+ logger.warning(f"Field {var} not found in attribute manager.")
294
+
295
+ # check_schema=False to avoid attr_mgr adding stuff dimensions don't need
296
+ for dim in dataset.dims:
297
+ dataset[dim].attrs = attr_mgr.get_variable_attributes(dim, check_schema=False)
298
+ if dim != "epoch":
299
+ label_array = xr.DataArray(
300
+ dataset[dim].values.astype(str),
301
+ name=f"{dim}_label",
302
+ dims=[dim],
303
+ attrs=attr_mgr.get_variable_attributes(
304
+ f"{dim}_label", check_schema=False
305
+ ),
306
+ )
307
+ dataset.coords[f"{dim}_label"] = label_array
308
+ return dataset
309
+
310
+
248
311
  def process_science(
249
312
  dataset: xr.Dataset, attr_mgr: ImapCdfAttributes
250
313
  ) -> list[xr.Dataset]:
@@ -294,30 +357,7 @@ def process_science(
294
357
 
295
358
  # Update attributes and dimensions
296
359
  for logical_source, ds in l1a_datasets.items():
297
- ds.attrs = attr_mgr.get_global_attributes(logical_source)
298
-
299
- # Assign attributes and dimensions to each data array in the Dataset
300
- for field in ds.data_vars.keys():
301
- try:
302
- ds[field].attrs = attr_mgr.get_variable_attributes(field)
303
- except KeyError:
304
- print(f"Field {field} not found in attribute manager.")
305
- logger.warning(f"Field {field} not found in attribute manager.")
306
-
307
- # check_schema=False to avoid attr_mgr adding stuff dimensions don't need
308
- for dim in ds.dims:
309
- ds[dim].attrs = attr_mgr.get_variable_attributes(dim, check_schema=False)
310
- # TODO: should labels be added as coordinates? Check with SPDF
311
- if dim != "epoch":
312
- label_array = xr.DataArray(
313
- ds[dim].values.astype(str),
314
- name=f"{dim}_label",
315
- dims=[dim],
316
- attrs=attr_mgr.get_variable_attributes(
317
- f"{dim}_label", check_schema=False
318
- ),
319
- )
320
- ds.coords[f"{dim}_label"] = label_array
360
+ l1a_datasets[logical_source] = add_cdf_attributes(ds, logical_source, attr_mgr)
321
361
 
322
362
  logger.info(f"HIT L1A dataset created for {logical_source}")
323
363
 
@@ -4,6 +4,11 @@
4
4
  # This is used to calculate the fractional livetime
5
5
  LIVESTIM_PULSES = 270
6
6
 
7
+ # A factor used to find the count rate for sectored data that
8
+ # accounts for the fact that a single spacecraft rotation is
9
+ # split into 15 inclination ranges.
10
+ SECTORS = 15
11
+
7
12
  # Fill values for missing data
8
13
  FILLVAL_FLOAT32 = -1.00e31
9
14
  FILLVAL_INT64 = -9223372036854775808
@@ -17,6 +17,7 @@ from imap_processing.hit.l1b.constants import (
17
17
  FILLVAL_FLOAT32,
18
18
  FILLVAL_INT64,
19
19
  LIVESTIM_PULSES,
20
+ SECTORS,
20
21
  SUMMED_PARTICLE_ENERGY_RANGE_MAPPING,
21
22
  )
22
23
 
@@ -106,16 +107,17 @@ def process_science_data(
106
107
  livetime = livetime.rename("livetime")
107
108
 
108
109
  # Process counts data to L1B datasets
109
- l1b_datasets: dict = {}
110
- l1b_datasets["imap_hit_l1b_standard-rates"] = process_standard_rates_data(
111
- l1a_counts_dataset, livetime
112
- )
113
- l1b_datasets["imap_hit_l1b_summed-rates"] = process_summed_rates_data(
114
- l1a_counts_dataset, livetime
115
- )
116
- l1b_datasets["imap_hit_l1b_sectored-rates"] = process_sectored_rates_data(
117
- l1a_counts_dataset, livetime
118
- )
110
+ l1b_datasets: dict = {
111
+ "imap_hit_l1b_standard-rates": process_standard_rates_data(
112
+ l1a_counts_dataset, livetime
113
+ ),
114
+ "imap_hit_l1b_summed-rates": process_summed_rates_data(
115
+ l1a_counts_dataset, livetime
116
+ ),
117
+ "imap_hit_l1b_sectored-rates": process_sectored_rates_data(
118
+ l1a_counts_dataset, livetime
119
+ ),
120
+ }
119
121
 
120
122
  # Update attributes and dimensions
121
123
  for logical_source, dataset in l1b_datasets.items():
@@ -444,7 +446,10 @@ def process_sectored_rates_data(
444
446
 
445
447
  Sectored counts data is transmitted 10 minutes after they are collected.
446
448
  To calculate rates, the sectored counts over 10 minutes need to be divided by
447
- the sum of livetime values from the previous 10 minutes.
449
+ the sum of livetime values from the previous 10 minutes multiplied by a factor
450
+ 15 to account for the different inclination sectors (a single spacecraft
451
+ rotation is split into 15 inclination ranges). See equation 11 in the algorithm
452
+ document.
448
453
 
449
454
  Parameters
450
455
  ----------
@@ -460,10 +465,7 @@ def process_sectored_rates_data(
460
465
  xr.Dataset
461
466
  The processed L1B sectored rates dataset.
462
467
  """
463
- # TODO
464
- # -filter by epoch values in day being processed.
465
- # middle epoch (or mod 5 value for 6th frame)
466
- # -consider refactoring calculate_rates function to handle sectored rates
468
+ # TODO - consider refactoring calculate_rates function to handle sectored rates
467
469
 
468
470
  # Define particles and coordinates
469
471
  particles = ["h", "he4", "cno", "nemgsi", "fe"]
@@ -520,7 +522,7 @@ def process_sectored_rates_data(
520
522
  rates = xr.DataArray(
521
523
  np.where(
522
524
  counts != FILLVAL_INT64,
523
- (counts / livetime_10min_reshaped).astype(np.float32),
525
+ (counts / (SECTORS * livetime_10min_reshaped)).astype(np.float32),
524
526
  FILLVAL_FLOAT32,
525
527
  ),
526
528
  dims=l1a_counts_dataset[var].dims,