imap-processing 0.11.0__py3-none-any.whl → 0.12.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 (288) hide show
  1. imap_processing/__init__.py +10 -11
  2. imap_processing/_version.py +2 -2
  3. imap_processing/ccsds/excel_to_xtce.py +65 -16
  4. imap_processing/cdf/config/imap_codice_global_cdf_attrs.yaml +6 -28
  5. imap_processing/cdf/config/imap_codice_l1a_variable_attrs.yaml +365 -42
  6. imap_processing/cdf/config/imap_glows_global_cdf_attrs.yaml +0 -5
  7. imap_processing/cdf/config/imap_hi_global_cdf_attrs.yaml +10 -11
  8. imap_processing/cdf/config/imap_hi_variable_attrs.yaml +17 -19
  9. imap_processing/cdf/config/imap_hit_global_cdf_attrs.yaml +26 -13
  10. imap_processing/cdf/config/imap_hit_l1a_variable_attrs.yaml +106 -116
  11. imap_processing/cdf/config/imap_hit_l1b_variable_attrs.yaml +120 -145
  12. imap_processing/cdf/config/imap_hit_l2_variable_attrs.yaml +14 -0
  13. imap_processing/cdf/config/imap_idex_global_cdf_attrs.yaml +6 -9
  14. imap_processing/cdf/config/imap_idex_l1a_variable_attrs.yaml +1 -1
  15. imap_processing/cdf/config/imap_lo_global_cdf_attrs.yaml +0 -12
  16. imap_processing/cdf/config/imap_lo_l1a_variable_attrs.yaml +1 -1
  17. imap_processing/cdf/config/imap_mag_global_cdf_attrs.yaml +9 -21
  18. imap_processing/cdf/config/imap_mag_l1a_variable_attrs.yaml +361 -0
  19. imap_processing/cdf/config/imap_mag_l1b_variable_attrs.yaml +160 -0
  20. imap_processing/cdf/config/imap_mag_l1c_variable_attrs.yaml +160 -0
  21. imap_processing/cdf/config/imap_spacecraft_global_cdf_attrs.yaml +18 -0
  22. imap_processing/cdf/config/imap_spacecraft_variable_attrs.yaml +40 -0
  23. imap_processing/cdf/config/imap_swapi_global_cdf_attrs.yaml +1 -5
  24. imap_processing/cdf/config/imap_swe_global_cdf_attrs.yaml +12 -4
  25. imap_processing/cdf/config/imap_swe_l1a_variable_attrs.yaml +16 -2
  26. imap_processing/cdf/config/imap_swe_l1b_variable_attrs.yaml +48 -52
  27. imap_processing/cdf/config/imap_swe_l2_variable_attrs.yaml +71 -47
  28. imap_processing/cdf/config/imap_ultra_global_cdf_attrs.yaml +2 -14
  29. imap_processing/cdf/config/imap_ultra_l1b_variable_attrs.yaml +51 -2
  30. imap_processing/cdf/config/imap_ultra_l1c_variable_attrs.yaml +29 -14
  31. imap_processing/cdf/utils.py +13 -7
  32. imap_processing/cli.py +23 -8
  33. imap_processing/codice/codice_l1a.py +207 -85
  34. imap_processing/codice/constants.py +1322 -568
  35. imap_processing/codice/decompress.py +2 -6
  36. imap_processing/ena_maps/ena_maps.py +480 -116
  37. imap_processing/ena_maps/utils/coordinates.py +19 -0
  38. imap_processing/ena_maps/utils/map_utils.py +14 -17
  39. imap_processing/ena_maps/utils/spatial_utils.py +45 -47
  40. imap_processing/hi/l1a/hi_l1a.py +24 -18
  41. imap_processing/hi/l1a/histogram.py +0 -1
  42. imap_processing/hi/l1a/science_direct_event.py +6 -8
  43. imap_processing/hi/l1b/hi_l1b.py +31 -39
  44. imap_processing/hi/l1c/hi_l1c.py +405 -17
  45. imap_processing/hi/utils.py +58 -12
  46. imap_processing/hit/ancillary/imap_hit_l1b-to-l2-standard-dt0-factors_20250219_v002.csv +205 -0
  47. imap_processing/hit/ancillary/imap_hit_l1b-to-l2-standard-dt1-factors_20250219_v002.csv +205 -0
  48. imap_processing/hit/ancillary/imap_hit_l1b-to-l2-standard-dt2-factors_20250219_v002.csv +205 -0
  49. imap_processing/hit/ancillary/imap_hit_l1b-to-l2-standard-dt3-factors_20250219_v002.csv +205 -0
  50. imap_processing/hit/ancillary/imap_hit_l1b-to-l2-summed-dt0-factors_20250219_v002.csv +68 -0
  51. imap_processing/hit/hit_utils.py +173 -1
  52. imap_processing/hit/l0/constants.py +20 -11
  53. imap_processing/hit/l0/decom_hit.py +18 -4
  54. imap_processing/hit/l1a/hit_l1a.py +45 -54
  55. imap_processing/hit/l1b/constants.py +317 -0
  56. imap_processing/hit/l1b/hit_l1b.py +367 -18
  57. imap_processing/hit/l2/constants.py +281 -0
  58. imap_processing/hit/l2/hit_l2.py +614 -0
  59. imap_processing/hit/packet_definitions/hit_packet_definitions.xml +1323 -71
  60. imap_processing/ialirt/l0/mag_l0_ialirt_data.py +155 -0
  61. imap_processing/ialirt/l0/parse_mag.py +246 -0
  62. imap_processing/ialirt/l0/process_swe.py +252 -0
  63. imap_processing/ialirt/packet_definitions/ialirt.xml +7 -3
  64. imap_processing/ialirt/packet_definitions/ialirt_mag.xml +115 -0
  65. imap_processing/ialirt/utils/grouping.py +114 -0
  66. imap_processing/ialirt/utils/time.py +29 -0
  67. imap_processing/idex/atomic_masses.csv +22 -0
  68. imap_processing/idex/decode.py +2 -2
  69. imap_processing/idex/idex_constants.py +25 -0
  70. imap_processing/idex/idex_l1a.py +6 -7
  71. imap_processing/idex/idex_l1b.py +4 -31
  72. imap_processing/idex/idex_l2a.py +789 -0
  73. imap_processing/idex/idex_variable_unpacking_and_eu_conversion.csv +39 -33
  74. imap_processing/lo/l0/lo_science.py +6 -0
  75. imap_processing/lo/l1a/lo_l1a.py +0 -1
  76. imap_processing/lo/l1b/lo_l1b.py +177 -25
  77. imap_processing/mag/constants.py +8 -0
  78. imap_processing/mag/imap_mag_sdc-configuration_v001.yaml +6 -0
  79. imap_processing/mag/l0/decom_mag.py +10 -3
  80. imap_processing/mag/l1a/mag_l1a.py +22 -11
  81. imap_processing/mag/l1a/mag_l1a_data.py +28 -3
  82. imap_processing/mag/l1b/mag_l1b.py +190 -48
  83. imap_processing/mag/l1c/interpolation_methods.py +211 -0
  84. imap_processing/mag/l1c/mag_l1c.py +447 -9
  85. imap_processing/quality_flags.py +1 -0
  86. imap_processing/spacecraft/packet_definitions/scid_x252.xml +538 -0
  87. imap_processing/spacecraft/quaternions.py +123 -0
  88. imap_processing/spice/geometry.py +16 -19
  89. imap_processing/spice/repoint.py +120 -0
  90. imap_processing/swapi/l1/swapi_l1.py +4 -0
  91. imap_processing/swapi/l2/swapi_l2.py +0 -1
  92. imap_processing/swe/l1a/swe_l1a.py +47 -8
  93. imap_processing/swe/l1a/swe_science.py +5 -2
  94. imap_processing/swe/l1b/swe_l1b_science.py +103 -56
  95. imap_processing/swe/l2/swe_l2.py +60 -65
  96. imap_processing/swe/packet_definitions/swe_packet_definition.xml +1121 -1
  97. imap_processing/swe/utils/swe_constants.py +63 -0
  98. imap_processing/swe/utils/swe_utils.py +85 -28
  99. imap_processing/tests/ccsds/test_data/expected_output.xml +40 -1
  100. imap_processing/tests/ccsds/test_excel_to_xtce.py +23 -20
  101. imap_processing/tests/cdf/test_data/imap_instrument2_global_cdf_attrs.yaml +0 -2
  102. imap_processing/tests/codice/conftest.py +1 -1
  103. imap_processing/tests/codice/data/validation/imap_codice_l1a_hi-counters-aggregated_20241110193700_v0.0.0.cdf +0 -0
  104. imap_processing/tests/codice/data/validation/imap_codice_l1a_hi-counters-singles_20241110193700_v0.0.0.cdf +0 -0
  105. imap_processing/tests/codice/data/validation/imap_codice_l1a_hi-ialirt_20241110193700_v0.0.0.cdf +0 -0
  106. imap_processing/tests/codice/data/validation/imap_codice_l1a_hi-omni_20241110193700_v0.0.0.cdf +0 -0
  107. imap_processing/tests/codice/data/validation/imap_codice_l1a_hi-pha_20241110193700_v0.0.0.cdf +0 -0
  108. imap_processing/tests/codice/data/validation/imap_codice_l1a_hi-priorities_20241110193700_v0.0.0.cdf +0 -0
  109. imap_processing/tests/codice/data/validation/imap_codice_l1a_hi-sectored_20241110193700_v0.0.0.cdf +0 -0
  110. imap_processing/tests/codice/data/validation/imap_codice_l1a_lo-counters-aggregated_20241110193700_v0.0.0.cdf +0 -0
  111. imap_processing/tests/codice/data/validation/imap_codice_l1a_lo-counters-singles_20241110193700_v0.0.0.cdf +0 -0
  112. imap_processing/tests/codice/data/validation/imap_codice_l1a_lo-ialirt_20241110193700_v0.0.0.cdf +0 -0
  113. imap_processing/tests/codice/data/validation/imap_codice_l1a_lo-nsw-angular_20241110193700_v0.0.0.cdf +0 -0
  114. imap_processing/tests/codice/data/validation/imap_codice_l1a_lo-nsw-priority_20241110193700_v0.0.0.cdf +0 -0
  115. imap_processing/tests/codice/data/validation/imap_codice_l1a_lo-nsw-species_20241110193700_v0.0.0.cdf +0 -0
  116. imap_processing/tests/codice/data/validation/imap_codice_l1a_lo-pha_20241110193700_v0.0.0.cdf +0 -0
  117. imap_processing/tests/codice/data/validation/imap_codice_l1a_lo-sw-angular_20241110193700_v0.0.0.cdf +0 -0
  118. imap_processing/tests/codice/data/validation/imap_codice_l1a_lo-sw-priority_20241110193700_v0.0.0.cdf +0 -0
  119. imap_processing/tests/codice/data/validation/imap_codice_l1a_lo-sw-species_20241110193700_v0.0.0.cdf +0 -0
  120. imap_processing/tests/codice/test_codice_l1a.py +110 -46
  121. imap_processing/tests/codice/test_decompress.py +4 -4
  122. imap_processing/tests/conftest.py +166 -10
  123. imap_processing/tests/ena_maps/conftest.py +51 -0
  124. imap_processing/tests/ena_maps/test_ena_maps.py +638 -109
  125. imap_processing/tests/ena_maps/test_map_utils.py +66 -43
  126. imap_processing/tests/ena_maps/test_spatial_utils.py +16 -20
  127. imap_processing/tests/hi/data/l0/H45_diag_fee_20250208.bin +0 -0
  128. imap_processing/tests/hi/data/l0/H45_diag_fee_20250208_verify.csv +205 -0
  129. imap_processing/tests/hi/test_hi_l1b.py +12 -15
  130. imap_processing/tests/hi/test_hi_l1c.py +234 -6
  131. imap_processing/tests/hi/test_l1a.py +30 -0
  132. imap_processing/tests/hi/test_science_direct_event.py +1 -1
  133. imap_processing/tests/hi/test_utils.py +24 -2
  134. imap_processing/tests/hit/helpers/l1_validation.py +39 -39
  135. imap_processing/tests/hit/test_data/hskp_sample.ccsds +0 -0
  136. imap_processing/tests/hit/test_data/imap_hit_l0_raw_20100105_v001.pkts +0 -0
  137. imap_processing/tests/hit/test_decom_hit.py +4 -0
  138. imap_processing/tests/hit/test_hit_l1a.py +24 -28
  139. imap_processing/tests/hit/test_hit_l1b.py +304 -40
  140. imap_processing/tests/hit/test_hit_l2.py +454 -0
  141. imap_processing/tests/hit/test_hit_utils.py +112 -2
  142. imap_processing/tests/hit/validation_data/hskp_sample_eu_3_6_2025.csv +89 -0
  143. imap_processing/tests/hit/validation_data/hskp_sample_raw.csv +89 -88
  144. imap_processing/tests/ialirt/test_data/l0/461971383-404.bin +0 -0
  145. imap_processing/tests/ialirt/test_data/l0/461971384-405.bin +0 -0
  146. imap_processing/tests/ialirt/test_data/l0/461971385-406.bin +0 -0
  147. imap_processing/tests/ialirt/test_data/l0/461971386-407.bin +0 -0
  148. imap_processing/tests/ialirt/test_data/l0/461971387-408.bin +0 -0
  149. imap_processing/tests/ialirt/test_data/l0/461971388-409.bin +0 -0
  150. imap_processing/tests/ialirt/test_data/l0/461971389-410.bin +0 -0
  151. imap_processing/tests/ialirt/test_data/l0/461971390-411.bin +0 -0
  152. imap_processing/tests/ialirt/test_data/l0/461971391-412.bin +0 -0
  153. imap_processing/tests/ialirt/test_data/l0/sample_decoded_i-alirt_data.csv +383 -0
  154. imap_processing/tests/ialirt/unit/test_grouping.py +81 -0
  155. imap_processing/tests/ialirt/unit/test_parse_mag.py +168 -0
  156. imap_processing/tests/ialirt/unit/test_process_swe.py +208 -3
  157. imap_processing/tests/ialirt/unit/test_time.py +16 -0
  158. imap_processing/tests/idex/conftest.py +62 -6
  159. imap_processing/tests/idex/test_data/imap_idex_l0_raw_20231218_v001.pkts +0 -0
  160. imap_processing/tests/idex/test_data/impact_14_tof_high_data.txt +4508 -4508
  161. imap_processing/tests/idex/test_idex_l1a.py +48 -4
  162. imap_processing/tests/idex/test_idex_l1b.py +3 -3
  163. imap_processing/tests/idex/test_idex_l2a.py +383 -0
  164. imap_processing/tests/lo/test_cdfs/imap_lo_l1a_de_20241022_v002.cdf +0 -0
  165. imap_processing/tests/lo/test_cdfs/imap_lo_l1a_spin_20241022_v002.cdf +0 -0
  166. imap_processing/tests/lo/test_lo_l1b.py +148 -4
  167. imap_processing/tests/lo/test_lo_science.py +1 -0
  168. imap_processing/tests/mag/conftest.py +69 -0
  169. imap_processing/tests/mag/test_mag_decom.py +1 -1
  170. imap_processing/tests/mag/test_mag_l1a.py +38 -0
  171. imap_processing/tests/mag/test_mag_l1b.py +34 -53
  172. imap_processing/tests/mag/test_mag_l1c.py +251 -20
  173. imap_processing/tests/mag/test_mag_validation.py +109 -25
  174. imap_processing/tests/mag/validation/L1b/T009/MAGScience-normal-(2,2)-8s-20250204-16h39.csv +17 -0
  175. imap_processing/tests/mag/validation/L1b/T009/mag-l1a-l1b-t009-magi-out.csv +16 -16
  176. imap_processing/tests/mag/validation/L1b/T009/mag-l1a-l1b-t009-mago-out.csv +16 -16
  177. imap_processing/tests/mag/validation/L1b/T010/MAGScience-normal-(2,2)-8s-20250206-12h05.csv +17 -0
  178. imap_processing/tests/mag/validation/L1b/T011/MAGScience-normal-(2,2)-8s-20250204-16h08.csv +17 -0
  179. imap_processing/tests/mag/validation/L1b/T011/mag-l1a-l1b-t011-magi-out.csv +16 -16
  180. imap_processing/tests/mag/validation/L1b/T011/mag-l1a-l1b-t011-mago-out.csv +16 -16
  181. imap_processing/tests/mag/validation/L1b/T012/MAGScience-normal-(2,2)-8s-20250204-16h08.csv +17 -0
  182. imap_processing/tests/mag/validation/L1b/T012/data.bin +0 -0
  183. imap_processing/tests/mag/validation/L1b/T012/field_like_all_ranges.txt +19200 -0
  184. imap_processing/tests/mag/validation/L1b/T012/mag-l1a-l1b-t012-cal.cdf +0 -0
  185. imap_processing/tests/mag/validation/L1b/T012/mag-l1a-l1b-t012-in.csv +17 -0
  186. imap_processing/tests/mag/validation/L1b/T012/mag-l1a-l1b-t012-magi-out.csv +17 -0
  187. imap_processing/tests/mag/validation/L1b/T012/mag-l1a-l1b-t012-mago-out.csv +17 -0
  188. imap_processing/tests/mag/validation/imap_calibration_mag_20240229_v01.cdf +0 -0
  189. imap_processing/tests/spacecraft/__init__.py +0 -0
  190. imap_processing/tests/spacecraft/data/SSR_2024_190_20_08_12_0483851794_2_DA_apid0594_1packet.pkts +0 -0
  191. imap_processing/tests/spacecraft/test_quaternions.py +71 -0
  192. imap_processing/tests/spice/test_data/fake_repoint_data.csv +5 -0
  193. imap_processing/tests/spice/test_geometry.py +6 -9
  194. imap_processing/tests/spice/test_repoint.py +111 -0
  195. imap_processing/tests/swapi/test_swapi_l1.py +7 -3
  196. imap_processing/tests/swe/l0_data/2024051010_SWE_HK_packet.bin +0 -0
  197. imap_processing/tests/swe/l0_data/2024051011_SWE_CEM_RAW_packet.bin +0 -0
  198. imap_processing/tests/swe/l0_validation_data/idle_export_eu.SWE_APP_HK_20240510_092742.csv +49 -0
  199. imap_processing/tests/swe/l0_validation_data/idle_export_eu.SWE_CEM_RAW_20240510_092742.csv +593 -0
  200. imap_processing/tests/swe/test_swe_l1a.py +18 -0
  201. imap_processing/tests/swe/test_swe_l1a_cem_raw.py +52 -0
  202. imap_processing/tests/swe/test_swe_l1a_hk.py +68 -0
  203. imap_processing/tests/swe/test_swe_l1b_science.py +23 -4
  204. imap_processing/tests/swe/test_swe_l2.py +112 -30
  205. imap_processing/tests/test_cli.py +2 -2
  206. imap_processing/tests/test_utils.py +138 -16
  207. imap_processing/tests/ultra/data/l0/FM45_UltraFM45_Functional_2024-01-22T0105_20240122T010548.CCSDS +0 -0
  208. imap_processing/tests/ultra/data/l0/ultra45_raw_sc_ultraimgrates_20220530_00.csv +164 -0
  209. imap_processing/tests/ultra/{test_data → data}/l0/ultra45_raw_sc_ultrarawimg_withFSWcalcs_FM45_40P_Phi28p5_BeamCal_LinearScan_phi2850_theta-000_20240207T102740.csv +3243 -3243
  210. imap_processing/tests/ultra/data/mock_data.py +341 -0
  211. imap_processing/tests/ultra/unit/conftest.py +69 -26
  212. imap_processing/tests/ultra/unit/test_badtimes.py +2 -0
  213. imap_processing/tests/ultra/unit/test_cullingmask.py +4 -0
  214. imap_processing/tests/ultra/unit/test_de.py +12 -4
  215. imap_processing/tests/ultra/unit/test_decom_apid_881.py +44 -0
  216. imap_processing/tests/ultra/unit/test_spacecraft_pset.py +78 -0
  217. imap_processing/tests/ultra/unit/test_ultra_l1a.py +28 -12
  218. imap_processing/tests/ultra/unit/test_ultra_l1b.py +34 -6
  219. imap_processing/tests/ultra/unit/test_ultra_l1b_culling.py +22 -26
  220. imap_processing/tests/ultra/unit/test_ultra_l1b_extended.py +86 -51
  221. imap_processing/tests/ultra/unit/test_ultra_l1c_pset_bins.py +94 -52
  222. imap_processing/ultra/l0/decom_tools.py +6 -5
  223. imap_processing/ultra/l1a/ultra_l1a.py +28 -56
  224. imap_processing/ultra/l1b/de.py +72 -28
  225. imap_processing/ultra/l1b/extendedspin.py +12 -14
  226. imap_processing/ultra/l1b/ultra_l1b.py +34 -9
  227. imap_processing/ultra/l1b/ultra_l1b_culling.py +65 -29
  228. imap_processing/ultra/l1b/ultra_l1b_extended.py +64 -19
  229. imap_processing/ultra/l1c/spacecraft_pset.py +86 -0
  230. imap_processing/ultra/l1c/ultra_l1c.py +7 -4
  231. imap_processing/ultra/l1c/ultra_l1c_pset_bins.py +112 -61
  232. imap_processing/ultra/lookup_tables/ultra_90_dps_exposure_compressed.cdf +0 -0
  233. imap_processing/ultra/utils/ultra_l1_utils.py +20 -2
  234. imap_processing/utils.py +68 -28
  235. {imap_processing-0.11.0.dist-info → imap_processing-0.12.0.dist-info}/METADATA +8 -5
  236. {imap_processing-0.11.0.dist-info → imap_processing-0.12.0.dist-info}/RECORD +250 -199
  237. imap_processing/cdf/config/imap_mag_l1_variable_attrs.yaml +0 -237
  238. imap_processing/hi/l1a/housekeeping.py +0 -27
  239. imap_processing/tests/codice/data/imap_codice_l1a_hi-counters-aggregated_20240429_v001.cdf +0 -0
  240. imap_processing/tests/codice/data/imap_codice_l1a_hi-counters-singles_20240429_v001.cdf +0 -0
  241. imap_processing/tests/codice/data/imap_codice_l1a_hi-omni_20240429_v001.cdf +0 -0
  242. imap_processing/tests/codice/data/imap_codice_l1a_hi-sectored_20240429_v001.cdf +0 -0
  243. imap_processing/tests/codice/data/imap_codice_l1a_hskp_20100101_v001.cdf +0 -0
  244. imap_processing/tests/codice/data/imap_codice_l1a_lo-counters-aggregated_20240429_v001.cdf +0 -0
  245. imap_processing/tests/codice/data/imap_codice_l1a_lo-counters-singles_20240429_v001.cdf +0 -0
  246. imap_processing/tests/codice/data/imap_codice_l1a_lo-nsw-angular_20240429_v001.cdf +0 -0
  247. imap_processing/tests/codice/data/imap_codice_l1a_lo-nsw-priority_20240429_v001.cdf +0 -0
  248. imap_processing/tests/codice/data/imap_codice_l1a_lo-nsw-species_20240429_v001.cdf +0 -0
  249. imap_processing/tests/codice/data/imap_codice_l1a_lo-sw-angular_20240429_v001.cdf +0 -0
  250. imap_processing/tests/codice/data/imap_codice_l1a_lo-sw-priority_20240429_v001.cdf +0 -0
  251. imap_processing/tests/codice/data/imap_codice_l1a_lo-sw-species_20240429_v001.cdf +0 -0
  252. imap_processing/tests/codice/data/imap_codice_l1b_hi-counters-aggregated_20240429_v001.cdf +0 -0
  253. imap_processing/tests/codice/data/imap_codice_l1b_hi-counters-singles_20240429_v001.cdf +0 -0
  254. imap_processing/tests/codice/data/imap_codice_l1b_hi-omni_20240429_v001.cdf +0 -0
  255. imap_processing/tests/codice/data/imap_codice_l1b_hi-sectored_20240429_v001.cdf +0 -0
  256. imap_processing/tests/codice/data/imap_codice_l1b_hskp_20100101_v001.cdf +0 -0
  257. imap_processing/tests/codice/data/imap_codice_l1b_lo-counters-aggregated_20240429_v001.cdf +0 -0
  258. imap_processing/tests/codice/data/imap_codice_l1b_lo-counters-singles_20240429_v001.cdf +0 -0
  259. imap_processing/tests/codice/data/imap_codice_l1b_lo-nsw-angular_20240429_v001.cdf +0 -0
  260. imap_processing/tests/codice/data/imap_codice_l1b_lo-nsw-priority_20240429_v001.cdf +0 -0
  261. imap_processing/tests/codice/data/imap_codice_l1b_lo-nsw-species_20240429_v001.cdf +0 -0
  262. imap_processing/tests/codice/data/imap_codice_l1b_lo-sw-angular_20240429_v001.cdf +0 -0
  263. imap_processing/tests/codice/data/imap_codice_l1b_lo-sw-priority_20240429_v001.cdf +0 -0
  264. imap_processing/tests/codice/data/imap_codice_l1b_lo-sw-species_20240429_v001.cdf +0 -0
  265. imap_processing/tests/hi/data/l1/imap_hi_l1b_45sensor-de_20250415_v999.cdf +0 -0
  266. imap_processing/tests/hit/PREFLIGHT_raw_record_2023_256_15_59_04_apid1251.pkts +0 -0
  267. imap_processing/tests/hit/PREFLIGHT_raw_record_2023_256_15_59_04_apid1252.pkts +0 -0
  268. imap_processing/tests/hit/validation_data/hskp_sample_eu.csv +0 -89
  269. imap_processing/tests/hit/validation_data/sci_sample_raw1.csv +0 -29
  270. imap_processing/tests/idex/test_data/imap_idex_l0_raw_20231214_v001.pkts +0 -0
  271. imap_processing/tests/lo/test_cdfs/imap_lo_l1a_de_20100101_v001.cdf +0 -0
  272. imap_processing/tests/lo/test_cdfs/imap_lo_l1a_spin_20100101_v001.cdf +0 -0
  273. imap_processing/tests/ultra/test_data/mock_data.py +0 -161
  274. imap_processing/ultra/l1c/pset.py +0 -40
  275. /imap_processing/tests/ultra/{test_data → data}/l0/FM45_40P_Phi28p5_BeamCal_LinearScan_phi28.50_theta-0.00_20240207T102740.CCSDS +0 -0
  276. /imap_processing/tests/ultra/{test_data → data}/l0/FM45_7P_Phi0.0_BeamCal_LinearScan_phi0.04_theta-0.01_20230821T121304.CCSDS +0 -0
  277. /imap_processing/tests/ultra/{test_data → data}/l0/FM45_TV_Cycle6_Hot_Ops_Front212_20240124T063837.CCSDS +0 -0
  278. /imap_processing/tests/ultra/{test_data → data}/l0/Ultra45_EM_SwRI_Cal_Run7_ThetaScan_20220530T225054.CCSDS +0 -0
  279. /imap_processing/tests/ultra/{test_data → data}/l0/ultra45_raw_sc_auxdata_Ultra45_EM_SwRI_Cal_Run7_ThetaScan_20220530T225054.csv +0 -0
  280. /imap_processing/tests/ultra/{test_data → data}/l0/ultra45_raw_sc_enaphxtofhangimg_FM45_TV_Cycle6_Hot_Ops_Front212_20240124T063837.csv +0 -0
  281. /imap_processing/tests/ultra/{test_data → data}/l0/ultra45_raw_sc_ultraimgrates_Ultra45_EM_SwRI_Cal_Run7_ThetaScan_20220530T225054.csv +0 -0
  282. /imap_processing/tests/ultra/{test_data → data}/l0/ultra45_raw_sc_ultrarawimgevent_FM45_7P_Phi00_BeamCal_LinearScan_phi004_theta-001_20230821T121304.csv +0 -0
  283. /imap_processing/tests/ultra/{test_data → data}/l1/dps_exposure_helio_45_E1.cdf +0 -0
  284. /imap_processing/tests/ultra/{test_data → data}/l1/dps_exposure_helio_45_E12.cdf +0 -0
  285. /imap_processing/tests/ultra/{test_data → data}/l1/dps_exposure_helio_45_E24.cdf +0 -0
  286. {imap_processing-0.11.0.dist-info → imap_processing-0.12.0.dist-info}/LICENSE +0 -0
  287. {imap_processing-0.11.0.dist-info → imap_processing-0.12.0.dist-info}/WHEEL +0 -0
  288. {imap_processing-0.11.0.dist-info → imap_processing-0.12.0.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,78 @@
1
+ """Tests Spacecraft PSET for ULTRA L1c."""
2
+
3
+ import numpy as np
4
+ import pandas as pd
5
+ import pytest
6
+ import spiceypy
7
+ import xarray as xr
8
+
9
+ from imap_processing import imap_module_directory
10
+ from imap_processing.spice.geometry import SpiceFrame
11
+ from imap_processing.spice.kernels import ensure_spice
12
+ from imap_processing.ultra.l1b.ultra_l1b_annotated import (
13
+ get_annotated_particle_velocity,
14
+ )
15
+ from imap_processing.ultra.l1b.ultra_l1b_extended import (
16
+ get_de_energy_kev,
17
+ get_de_velocity,
18
+ )
19
+ from imap_processing.ultra.l1c.spacecraft_pset import calculate_spacecraft_pset
20
+
21
+ TEST_PATH = imap_module_directory / "tests" / "ultra" / "data" / "l1"
22
+
23
+
24
+ @pytest.mark.external_test_data()
25
+ @pytest.mark.external_kernel()
26
+ @ensure_spice
27
+ @pytest.mark.use_test_metakernel("imap_ena_sim_metakernel.template")
28
+ def test_pset():
29
+ """Tests calculate_pset function."""
30
+ # This is just setting up the data so that it is in the format of l1b_de_dataset.
31
+ test_path = TEST_PATH / "ultra-90_raw_event_data_shortened.csv"
32
+ df = pd.read_csv(test_path)
33
+ instrument_velocity = get_de_velocity(
34
+ (df["Xf"], df["Yf"]), (df["Xb"], df["Yb"]), df["d"], df["TOF"].values
35
+ )
36
+
37
+ et = spiceypy.str2et(df["Epoch"].values)
38
+ epoch = df["MET"].values
39
+
40
+ frame_velocities = get_annotated_particle_velocity(
41
+ et,
42
+ instrument_velocity,
43
+ SpiceFrame.IMAP_ULTRA_90,
44
+ SpiceFrame.IMAP_DPS,
45
+ SpiceFrame.IMAP_SPACECRAFT,
46
+ )
47
+
48
+ particle_velocity_dps_spacecraft = frame_velocities[1]
49
+
50
+ # Assume everything is Hydrogen
51
+ species = np.full(len(particle_velocity_dps_spacecraft), "H", dtype="<U1")
52
+ energy_dps_spacecraft = get_de_energy_kev(particle_velocity_dps_spacecraft, species)
53
+
54
+ test_l1b_de_dataset = xr.Dataset(
55
+ {
56
+ "species": (["epoch"], species),
57
+ "velocity_dps_sc": (
58
+ ["epoch", "component"],
59
+ particle_velocity_dps_spacecraft,
60
+ ),
61
+ "energy_spacecraft": (["epoch"], energy_dps_spacecraft),
62
+ },
63
+ coords={
64
+ "epoch": ("epoch", epoch),
65
+ "component": ("component", ["vx", "vy", "vz"]),
66
+ },
67
+ )
68
+
69
+ spacecraft_pset = calculate_spacecraft_pset(
70
+ test_l1b_de_dataset,
71
+ test_l1b_de_dataset, # placeholder for extendedspin_dataset
72
+ test_l1b_de_dataset, # placeholder for cullingmask_dataset
73
+ "imap_ultra_l1c_45sensor-spacecraftpset",
74
+ "001",
75
+ )
76
+ assert "healpix" in spacecraft_pset.coords
77
+ assert "epoch" in spacecraft_pset.coords
78
+ assert "energy_bin_geometric_mean" in spacecraft_pset.coords
@@ -1,3 +1,4 @@
1
+ import numpy as np
1
2
  import pytest
2
3
 
3
4
  from imap_processing import decom
@@ -9,7 +10,11 @@ from imap_processing.ultra.l0.ultra_utils import (
9
10
  ULTRA_RATES,
10
11
  ULTRA_TOF,
11
12
  )
12
- from imap_processing.ultra.l1a.ultra_l1a import create_dataset, ultra_l1a
13
+ from imap_processing.ultra.l1a.ultra_l1a import (
14
+ create_dataset,
15
+ get_event_id,
16
+ ultra_l1a,
17
+ )
13
18
  from imap_processing.utils import group_by_apid
14
19
 
15
20
 
@@ -253,10 +258,7 @@ def test_cdf_rates(ccsds_path_theta_0, decom_test_data):
253
258
  test_data = ultra_l1a(
254
259
  ccsds_path_theta_0, data_version="001", apid=ULTRA_RATES.apid[0]
255
260
  )
256
- # TODO: Dropping duplicates to ignore ISTP for now. Need to update test data
257
- # or wait for an update to cdflib
258
- test_data[0] = test_data[0].sortby("epoch").groupby("epoch").first()
259
- test_data_path = write_cdf(test_data[0])
261
+ test_data_path = write_cdf(test_data[0], istp=False)
260
262
 
261
263
  assert test_data_path.exists()
262
264
  assert test_data_path.name == "imap_ultra_l1a_45sensor-rates_20240207_v001.cdf"
@@ -319,20 +321,34 @@ def test_cdf_events(ccsds_path_theta_0, decom_ultra_aux, decom_test_data):
319
321
  test_data = ultra_l1a(
320
322
  ccsds_path_theta_0, data_version="001", apid=ULTRA_EVENTS.apid[0]
321
323
  )
322
- # TODO: Dropping duplicates to ignore ISTP for now. Need to update test data
323
- # or wait for an update to cdflib
324
- test_data[0] = test_data[0].sortby("epoch").groupby("epoch").first()
325
- test_data_path = write_cdf(test_data[0])
324
+ test_data_path = write_cdf(test_data[0], istp=False)
326
325
 
327
326
  assert test_data_path.exists()
328
327
  assert test_data_path.name == "imap_ultra_l1a_45sensor-de_20240207_v001.cdf"
329
328
 
330
- dataset_events = create_dataset(
331
- {ULTRA_EVENTS.apid[0]: decom_ultra_events, ULTRA_AUX.apid[0]: decom_ultra_aux}
332
- )
329
+ dataset_events = create_dataset({ULTRA_EVENTS.apid[0]: decom_ultra_events})
333
330
  input_xarray_events = load_cdf(test_data_path)
334
331
 
335
332
  # write_cdf() injects some attributes that are not in the xarray
336
333
  assert set(dataset_events.attrs.keys()).issubset(
337
334
  set(input_xarray_events.attrs.keys())
338
335
  )
336
+
337
+
338
+ def test_get_event_id():
339
+ """Test get_event_id"""
340
+ decom_ultra_dict = {
341
+ ULTRA_EVENTS.apid[0]: {"SHCOARSE": [445015662, 445015663, 445015664, 445015664]}
342
+ }
343
+ decom_events = get_event_id(decom_ultra_dict)
344
+ counters_for_met = []
345
+ for i in range(len(decom_events["EVENTID"])):
346
+ event_id = decom_events["EVENTID"][i]
347
+ met_extracted = event_id >> np.int64(31)
348
+
349
+ assert met_extracted == np.int64(
350
+ decom_ultra_dict[ULTRA_EVENTS.apid[0]]["SHCOARSE"][i]
351
+ )
352
+ counters_for_met.append(event_id & np.int64(0x7FFFFFFF))
353
+
354
+ assert counters_for_met == [0, 0, 0, 1]
@@ -2,6 +2,7 @@ import numpy as np
2
2
  import pytest
3
3
  import xarray as xr
4
4
 
5
+ from imap_processing.cdf.utils import write_cdf
5
6
  from imap_processing.ultra.l1b.ultra_l1b import ultra_l1b
6
7
  from imap_processing.ultra.utils.ultra_l1_utils import create_dataset
7
8
 
@@ -49,10 +50,12 @@ def mock_data_l1b_extendedspin_dict():
49
50
  [0, 1],
50
51
  dtype="int32",
51
52
  )
53
+ spin_start_time = np.array([0, 1, 2], dtype="uint64")
52
54
  quality = np.zeros((2, 3), dtype="uint16")
53
55
  data_dict = {
54
56
  "spin_number": spin,
55
57
  "energy_bin_geometric_mean": energy,
58
+ "spin_start_time": spin_start_time,
56
59
  "quality_ena_rates": quality,
57
60
  }
58
61
  return data_dict
@@ -90,22 +93,47 @@ def test_create_de_dataset(mock_data_l1b_de_dict):
90
93
  np.testing.assert_array_equal(dataset["x_front"], np.zeros(3))
91
94
 
92
95
 
93
- def test_ultra_l1b(l1b_datasets):
96
+ def test_ultra_l1b(l1b_de_dataset):
94
97
  """Tests that L1b data is created."""
95
98
 
96
- assert len(l1b_datasets) == 4
99
+ assert len(l1b_de_dataset) == 1
100
+
101
+ assert (
102
+ l1b_de_dataset[0].attrs["Logical_source_description"]
103
+ == "IMAP-Ultra Instrument Level-1B Direct Event Data."
104
+ )
105
+
106
+
107
+ def test_cdf_de(l1b_de_dataset):
108
+ """Tests that CDF file is created and contains same attributes as xarray."""
109
+ test_data_path = write_cdf(l1b_de_dataset[0], istp=False)
110
+ assert test_data_path.exists()
111
+ assert test_data_path.name == "imap_ultra_l1b_45sensor-de_20240207_v001.cdf"
112
+
113
+
114
+ def test_ultra_l1b_extendedspin(l1b_extendedspin_dataset):
115
+ """Tests that L1b data is created."""
116
+
117
+ assert len(l1b_extendedspin_dataset) == 3
97
118
 
98
119
  # Define the suffixes and prefix
99
120
  prefix = "imap_ultra_l1b_45sensor"
100
- suffixes = ["de", "extendedspin", "cullingmask", "badtimes"]
121
+ suffixes = ["extendedspin", "cullingmask", "badtimes"]
101
122
 
102
123
  for i in range(len(suffixes)):
103
124
  expected_logical_source = f"{prefix}-{suffixes[i]}"
104
- assert l1b_datasets[i].attrs["Logical_source"] == expected_logical_source
125
+ assert (
126
+ l1b_extendedspin_dataset[i].attrs["Logical_source"]
127
+ == expected_logical_source
128
+ )
129
+
105
130
 
131
+ def test_cdf_extendedspin(l1b_extendedspin_dataset):
132
+ """Tests that CDF file is created and contains same attributes as xarray."""
133
+ test_data_path = write_cdf(l1b_extendedspin_dataset[0], istp=False)
134
+ assert test_data_path.exists()
106
135
  assert (
107
- l1b_datasets[0].attrs["Logical_source_description"]
108
- == "IMAP-Ultra Instrument Level-1B Direct Event Data."
136
+ test_data_path.name == "imap_ultra_l1b_45sensor-extendedspin_20000101_v001.cdf"
109
137
  )
110
138
 
111
139
 
@@ -6,11 +6,12 @@ import pytest
6
6
  from imap_processing.quality_flags import ImapAttitudeUltraFlags, ImapRatesUltraFlags
7
7
  from imap_processing.ultra.constants import UltraConstants
8
8
  from imap_processing.ultra.l1b.ultra_l1b_culling import (
9
+ compare_aux_univ_spin_table,
9
10
  flag_attitude,
10
11
  flag_spin,
11
12
  get_energy_histogram,
12
13
  get_n_sigma,
13
- get_spin,
14
+ get_spin_data,
14
15
  )
15
16
 
16
17
 
@@ -37,28 +38,13 @@ def test_data(use_fake_spin_data_for_time):
37
38
  )
38
39
  expected_counts[energy_idx, spin_idx] = count
39
40
 
40
- return time, spin_number, energy, expected_counts
41
-
42
-
43
- def test_get_spin(use_fake_spin_data_for_time):
44
- """Tests get_spin function."""
45
-
46
- nspins = 5
47
- spin_period = 15
48
- start = 0
49
- stop = start + (nspins + 1) * spin_period
50
- use_fake_spin_data_for_time(start, stop)
51
- spin_number = get_spin(np.linspace(start, stop, num=20))
52
-
53
- assert len(spin_number) == len(np.linspace(start, stop, num=20))
54
- expected_num_spins = np.ceil((stop - start) / 15) + 1
55
- assert np.array_equal(len(np.unique(spin_number)), expected_num_spins)
41
+ return spin_number, energy, expected_counts
56
42
 
57
43
 
58
44
  def test_get_energy_histogram(test_data):
59
45
  """Tests get_energy_histogram function."""
60
46
 
61
- _, spin_number, energy, expected_counts = test_data
47
+ spin_number, energy, expected_counts = test_data
62
48
 
63
49
  hist, _, counts, duration = get_energy_histogram(spin_number, energy)
64
50
 
@@ -67,19 +53,17 @@ def test_get_energy_histogram(test_data):
67
53
  assert duration == 15
68
54
 
69
55
 
70
- def test_flag_attitude(use_fake_spin_data_for_time):
56
+ def test_flag_attitude(use_fake_spin_data_for_time, faux_aux_dataset):
71
57
  """Tests flag_attitude function."""
72
58
 
73
- start = 4.45015658e08
74
- stop = 4.45015873e08
75
- use_fake_spin_data_for_time(start, stop)
59
+ use_fake_spin_data_for_time(0, 15 * 147)
76
60
  quality_flags, spin_rates, spin_period, spin_start_time = flag_attitude(
77
- np.linspace(start, stop, num=20)
61
+ faux_aux_dataset["SPINNUMBER"].values, faux_aux_dataset
78
62
  )
79
63
 
80
64
  flag = ImapAttitudeUltraFlags(quality_flags[0])
81
65
  assert flag.name == "NONE"
82
- assert np.all(quality_flags == ImapAttitudeUltraFlags.NONE.value)
66
+ assert quality_flags[-1] == ImapAttitudeUltraFlags.AUXMISMATCH.value
83
67
  assert np.all(spin_rates == 60 / spin_period)
84
68
  assert np.all(np.diff(spin_start_time) == 15)
85
69
 
@@ -102,8 +86,8 @@ def test_get_n_sigma():
102
86
  def test_flag_spin(test_data):
103
87
  """Tests flag_spin function."""
104
88
 
105
- time, _, energy, expected_counts = test_data
106
- quality_flags, spin, energy, _ = flag_spin(time, energy, 1)
89
+ spin_number, energy, expected_counts = test_data
90
+ quality_flags, spin, energy, _ = flag_spin(spin_number, energy, 1)
107
91
  threshold = get_n_sigma(expected_counts / 15, 15, 1)
108
92
 
109
93
  # At the first energy level were the rates > threshold and the counts > threshold?
@@ -112,3 +96,15 @@ def test_flag_spin(test_data):
112
96
  )
113
97
  high_rates_flag = quality_flags[expected_counts / 15 > threshold[:, np.newaxis]]
114
98
  assert np.all(high_rates_flag == ImapRatesUltraFlags.HIGHRATES.value)
99
+
100
+
101
+ def test_compare_aux_univ_spin_table(use_fake_spin_data_for_time, faux_aux_dataset):
102
+ """Tests compare_aux_univ_spin_table function."""
103
+ use_fake_spin_data_for_time(0, 15 * 147)
104
+ spins = faux_aux_dataset["SPINNUMBER"].values
105
+ spin_df = get_spin_data()
106
+
107
+ result = compare_aux_univ_spin_table(faux_aux_dataset, spins, spin_df)
108
+ expected = np.array([False] * 14 + [True])
109
+
110
+ assert np.all(result == expected)
@@ -4,6 +4,7 @@ import numpy as np
4
4
  import pandas as pd
5
5
  import pytest
6
6
 
7
+ from imap_processing.spice.spin import get_spin_data
7
8
  from imap_processing.ultra.constants import UltraConstants
8
9
  from imap_processing.ultra.l1b.ultra_l1b_extended import (
9
10
  CoinType,
@@ -13,23 +14,29 @@ from imap_processing.ultra.l1b.ultra_l1b_extended import (
13
14
  determine_species,
14
15
  get_coincidence_positions,
15
16
  get_ctof,
16
- get_de_az_el,
17
17
  get_de_energy_kev,
18
18
  get_de_velocity,
19
19
  get_energy_pulse_height,
20
20
  get_energy_ssd,
21
+ get_eventtimes,
21
22
  get_front_x_position,
22
23
  get_front_y_position,
23
24
  get_path_length,
24
25
  get_ph_tof_and_back_positions,
26
+ get_phi_theta,
25
27
  get_ssd_back_position_and_tof_offset,
26
28
  get_ssd_tof,
27
29
  )
28
30
 
29
31
 
30
32
  @pytest.fixture()
31
- def yf_fixture(de_dataset, events_fsw_comparison_theta_0):
33
+ def test_fixture(de_dataset, events_fsw_comparison_theta_0):
32
34
  """Fixture to compute and return yf and related data."""
35
+ # Remove start_type with fill values
36
+ de_dataset = de_dataset.where(
37
+ de_dataset["START_TYPE"] != np.iinfo(np.int64).min, drop=True
38
+ )
39
+
33
40
  df = pd.read_csv(events_fsw_comparison_theta_0)
34
41
  df_filt = df[df["StartType"] != -1]
35
42
 
@@ -37,16 +44,15 @@ def yf_fixture(de_dataset, events_fsw_comparison_theta_0):
37
44
  de_dataset["START_TYPE"].data, df_filt.Yb.values.astype("float")
38
45
  )
39
46
 
40
- return df_filt, d, yf
47
+ return df_filt, d, yf, de_dataset
41
48
 
42
49
 
43
50
  def test_get_front_x_position(
44
- de_dataset,
45
- yf_fixture,
51
+ test_fixture,
46
52
  ):
47
53
  """Tests get_front_x_position function."""
48
54
 
49
- df_filt, _, _ = yf_fixture
55
+ df_filt, _, _, de_dataset = test_fixture
50
56
 
51
57
  xf = get_front_x_position(
52
58
  de_dataset["START_TYPE"].data,
@@ -56,18 +62,18 @@ def test_get_front_x_position(
56
62
  assert xf == pytest.approx(df_filt["Xf"].astype("float"), 1e-5)
57
63
 
58
64
 
59
- def test_get_front_y_position(yf_fixture):
65
+ def test_get_front_y_position(test_fixture):
60
66
  """Tests get_front_y_position function."""
61
- df_filt, d, yf = yf_fixture
67
+ df_filt, d, yf, _ = test_fixture
62
68
 
63
69
  assert yf == pytest.approx(df_filt["Yf"].astype("float"), abs=1e-5)
64
70
  assert d == pytest.approx(df_filt["d"].astype("float"), abs=1e-5)
65
71
 
66
72
 
67
- def test_get_path_length(de_dataset, yf_fixture):
73
+ def test_get_path_length(test_fixture):
68
74
  """Tests get_path_length function."""
69
75
 
70
- df_filt, d, yf = yf_fixture
76
+ df_filt, d, yf, _ = test_fixture
71
77
 
72
78
  test_xf = df_filt["Xf"].astype("float").values
73
79
  test_yf = df_filt["Yf"].astype("float").values
@@ -79,12 +85,11 @@ def test_get_path_length(de_dataset, yf_fixture):
79
85
 
80
86
 
81
87
  def test_get_ph_tof_and_back_positions(
82
- de_dataset,
83
- yf_fixture,
88
+ test_fixture,
84
89
  ):
85
90
  """Tests get_ph_tof_and_back_positions function."""
86
91
 
87
- df_filt, _, _ = yf_fixture
92
+ df_filt, _, _, de_dataset = test_fixture
88
93
 
89
94
  ph_tof, _, ph_xb, ph_yb = get_ph_tof_and_back_positions(
90
95
  de_dataset, df_filt.Xf.astype("float").values, "ultra45"
@@ -104,10 +109,11 @@ def test_get_ph_tof_and_back_positions(
104
109
 
105
110
 
106
111
  def test_get_ssd_back_position_and_tof_offset(
107
- de_dataset,
112
+ test_fixture,
108
113
  events_fsw_comparison_theta_0,
109
114
  ):
110
115
  """Tests get_ssd_back_position function."""
116
+ _, _, _, de_dataset = test_fixture
111
117
  yb, tof_offset, ssd_number = get_ssd_back_position_and_tof_offset(de_dataset)
112
118
 
113
119
  df = pd.read_csv(events_fsw_comparison_theta_0)
@@ -143,9 +149,9 @@ def test_get_ssd_back_position_and_tof_offset(
143
149
  assert np.all(ssd_number_rt <= 7), "Values in ssd_number_rt out of range."
144
150
 
145
151
 
146
- def test_get_coincidence_positions(de_dataset, yf_fixture):
152
+ def test_get_coincidence_positions(test_fixture):
147
153
  """Tests get_coincidence_positions function."""
148
- df_filt, _, _ = yf_fixture
154
+ df_filt, _, _, de_dataset = test_fixture
149
155
  # Get particle tof (t2).
150
156
  _, t2, _, _ = get_ph_tof_and_back_positions(
151
157
  de_dataset, df_filt.Xf.astype("float").values, "ultra45"
@@ -167,9 +173,9 @@ def test_get_coincidence_positions(de_dataset, yf_fixture):
167
173
  )
168
174
 
169
175
 
170
- def test_calculate_etof_xc(de_dataset, yf_fixture):
176
+ def test_calculate_etof_xc(test_fixture):
171
177
  """Tests calculate_etof_xc function."""
172
- df_filt, _, _ = yf_fixture
178
+ df_filt, _, _, de_dataset = test_fixture
173
179
  # Get particle tof (t2).
174
180
  _, t2, _, _ = get_ph_tof_and_back_positions(
175
181
  de_dataset, df_filt.Xf.astype("float").values, "ultra45"
@@ -215,9 +221,9 @@ def test_calculate_etof_xc(de_dataset, yf_fixture):
215
221
  )
216
222
 
217
223
 
218
- def test_get_de_velocity(de_dataset, yf_fixture):
224
+ def test_get_de_velocity(test_fixture):
219
225
  """Tests get_de_velocity function."""
220
- df_filt, _, _ = yf_fixture
226
+ df_filt, _, _, _ = test_fixture
221
227
  df_ph = df_filt[np.isin(df_filt["StopType"], [StopType.PH.value])]
222
228
 
223
229
  test_xf, test_yf, test_xb, test_yb, test_d, test_tof = (
@@ -254,9 +260,9 @@ def test_get_de_velocity(de_dataset, yf_fixture):
254
260
  )
255
261
 
256
262
 
257
- def test_get_ssd_tof(de_dataset, yf_fixture):
263
+ def test_get_ssd_tof(test_fixture):
258
264
  """Tests get_ssd_tof function."""
259
- df_filt, _, _ = yf_fixture
265
+ df_filt, _, _, de_dataset = test_fixture
260
266
  df_ssd = df_filt[np.isin(df_filt["StopType"], [StopType.SSD.value])]
261
267
  test_xf = df_filt["Xf"].astype("float").values
262
268
 
@@ -267,9 +273,9 @@ def test_get_ssd_tof(de_dataset, yf_fixture):
267
273
  )
268
274
 
269
275
 
270
- def test_get_de_energy_kev(de_dataset, yf_fixture):
276
+ def test_get_de_energy_kev(test_fixture):
271
277
  """Tests get_de_energy_kev function."""
272
- df_filt, _, _ = yf_fixture
278
+ df_filt, _, _, _ = test_fixture
273
279
  df_ph = df_filt[np.isin(df_filt["StopType"], [StopType.PH.value])]
274
280
  df_ph = df_ph[df_ph["energy_revised"].astype("str") != "FILL"]
275
281
 
@@ -298,9 +304,9 @@ def test_get_de_energy_kev(de_dataset, yf_fixture):
298
304
  np.testing.assert_allclose(actual_energy, expected_energy, atol=1e-01, rtol=0)
299
305
 
300
306
 
301
- def test_get_energy_ssd(de_dataset, yf_fixture):
307
+ def test_get_energy_ssd(test_fixture):
302
308
  """Tests get_energy_ssd function."""
303
- df_filt, _, _ = yf_fixture
309
+ df_filt, _, _, de_dataset = test_fixture
304
310
  df_ssd = df_filt[np.isin(df_filt["StopType"], [StopType.SSD.value])]
305
311
  _, _, ssd_number = get_ssd_back_position_and_tof_offset(de_dataset)
306
312
  energy = get_energy_ssd(de_dataset, ssd_number)
@@ -309,9 +315,9 @@ def test_get_energy_ssd(de_dataset, yf_fixture):
309
315
  assert np.array_equal(test_energy, energy)
310
316
 
311
317
 
312
- def test_get_energy_pulse_height(de_dataset, yf_fixture):
318
+ def test_get_energy_pulse_height(test_fixture):
313
319
  """Tests get_energy_ssd function."""
314
- df_filt, _, _ = yf_fixture
320
+ df_filt, _, _, de_dataset = test_fixture
315
321
  df_ph = df_filt[np.isin(df_filt["StopType"], [StopType.PH.value])]
316
322
  ph_indices = np.nonzero(
317
323
  np.isin(de_dataset["STOP_TYPE"], [StopType.Top.value, StopType.Bottom.value])
@@ -328,9 +334,9 @@ def test_get_energy_pulse_height(de_dataset, yf_fixture):
328
334
  assert np.array_equal(test_energy, energy[ph_indices])
329
335
 
330
336
 
331
- def test_get_ctof(yf_fixture):
337
+ def test_get_ctof(test_fixture):
332
338
  """Tests get_ctof function."""
333
- df_filt, _, _ = yf_fixture
339
+ df_filt, _, _, _ = test_fixture
334
340
  df_filt = df_filt[df_filt["eTOF"].astype("str") != "FILL"]
335
341
  df_filt = df_filt[df_filt["cTOF"].astype("float") > 0]
336
342
 
@@ -363,9 +369,9 @@ def test_get_ctof(yf_fixture):
363
369
  )
364
370
 
365
371
 
366
- def test_determine_species(yf_fixture):
372
+ def test_determine_species(test_fixture):
367
373
  """Tests determine_species function."""
368
- df_filt, _, _ = yf_fixture
374
+ df_filt, _, _, _ = test_fixture
369
375
  df_ph = df_filt[np.isin(df_filt["StopType"], [StopType.PH.value])]
370
376
  df_ssd = df_filt[np.isin(df_filt["StopType"], [StopType.SSD.value])]
371
377
 
@@ -396,27 +402,56 @@ def test_determine_species(yf_fixture):
396
402
  np.testing.assert_array_equal(h_indices_ssd, ctof_indices_ssd)
397
403
 
398
404
 
399
- def test_get_de_az_el(de_dataset, yf_fixture):
400
- """Tests get_de_az_el function."""
401
- df_filt, _, _ = yf_fixture
402
- df_filt = df_filt[
403
- (df_filt["event_theta"].astype("str") != "FILL")
404
- & (df_filt["TOF"].astype("float") >= 0)
405
- ]
406
- df_ph = df_filt[np.isin(df_filt["StopType"], [StopType.PH.value])]
405
+ def test_get_phi_theta(test_fixture):
406
+ """Tests get_phi_theta function."""
407
+ df_filt, d, _, _ = test_fixture
407
408
 
408
- test_xf, test_yf, test_xb, test_yb, test_d, test_tof = (
409
- df_ph[col].astype("float").values
410
- for col in ["Xf", "Yf", "Xb", "Yb", "d", "TOF"]
409
+ test_xf = df_filt["Xf"].astype("float").values
410
+ test_yf = df_filt["Yf"].astype("float").values
411
+
412
+ test_xb = df_filt["Xb"].astype("float").values
413
+ test_yb = df_filt["Yb"].astype("float").values
414
+
415
+ phi, theta = get_phi_theta((test_xf, test_yf), (test_xb, test_yb), d)
416
+ expected_phi = df_filt["phi"].astype("float")
417
+ expected_theta = df_filt["theta"].astype("float")
418
+
419
+ np.testing.assert_allclose(phi, expected_phi, atol=1e-03, rtol=0)
420
+ np.testing.assert_allclose(theta, expected_theta, atol=1e-03, rtol=0)
421
+
422
+
423
+ def test_get_eventtimes(test_fixture, use_fake_spin_data_for_time):
424
+ """Tests get_eventtimes function."""
425
+ df_filt, _, _, de_dataset = test_fixture
426
+ # Create a spin table that cover spin 0-141
427
+ use_fake_spin_data_for_time(0, 141 * 15)
428
+
429
+ event_times, spin_starts, spin_period_sec = get_eventtimes(
430
+ de_dataset["SPIN"].values, de_dataset["PHASE_ANGLE"].values
411
431
  )
412
432
 
413
- v = get_de_velocity(
414
- (test_xf, test_yf),
415
- (test_xb, test_yb),
416
- test_d,
417
- test_tof,
433
+ spin_df = get_spin_data()
434
+ expected_min_df = spin_df[spin_df["spin_number"] == de_dataset["SPIN"].values.min()]
435
+ expected_max_df = spin_df[spin_df["spin_number"] == de_dataset["SPIN"].values.max()]
436
+ spin_period_sec_min = expected_min_df["spin_period_sec"].values[0]
437
+ spin_period_sec_max = expected_max_df["spin_period_sec"].values[0]
438
+
439
+ spin_start_min = (
440
+ expected_min_df["spin_start_sec"] + expected_min_df["spin_start_subsec"] / 1000
441
+ )
442
+ spin_start_max = (
443
+ expected_max_df["spin_start_sec"] + expected_max_df["spin_start_subsec"] / 1000
444
+ )
445
+
446
+ assert spin_start_min.values[0] == spin_starts.min()
447
+ assert spin_start_max.values[0] == spin_starts.max()
448
+
449
+ event_times_min = spin_start_min.values[0] + spin_period_sec_min * (
450
+ de_dataset["PHASE_ANGLE"][0] / 720
451
+ )
452
+ event_times_max = spin_start_max.values[0] + spin_period_sec_max * (
453
+ de_dataset["PHASE_ANGLE"][-1] / 720
418
454
  )
419
- az, _ = get_de_az_el(v)
420
- expected_phi = df_ph["event_phi"].astype("float")
421
455
 
422
- np.testing.assert_allclose(az, expected_phi % (2 * np.pi), atol=1e-03, rtol=0)
456
+ assert event_times_min == event_times.min()
457
+ assert event_times_max == event_times.max()