Skip to content

Commit 65890a7

Browse files
authored
Update parsing of DE binary blob to match updated order of DE fields (IMAP-Science-Operations-Center#1494)
Update test to match updated DE field order
1 parent 09d7608 commit 65890a7

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

imap_processing/hi/l1a/science_direct_event.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ def parse_direct_events(de_data: bytes) -> dict[str, npt.ArrayLike]:
3131
IMAP-Hi direct event data information is stored in
3232
48-bits as follows:
3333
34-
| Read 48-bits into 2, 16, 10, 10, 10, bits. Each of these breaks
34+
| Read 48-bits into 16, 2, 10, 10, 10, bits. Each of these breaks
3535
| down as:
3636
|
37-
| start_bitmask_data - 2 bits (tA=1, tB=2, tC1=3, META=0)
3837
| de_tag - 16 bits
38+
| start_bitmask_data - 2 bits (tA=1, tB=2, tC1=3)
3939
| tof_1 - 10 bit counter
4040
| tof_2 - 10 bit counter
4141
| tof_3 - 10 bit counter
@@ -70,16 +70,16 @@ def parse_direct_events(de_data: bytes) -> dict[str, npt.ArrayLike]:
7070
# direct events.
7171
# Considering the 6-bytes of data for each DE as 3 2-byte words,
7272
# each word contains the following:
73-
# word_0: 2-bits of Trigger ID, upper 14-bits of de_tag
74-
# word_1: lower 2-bits of de_tag, 10-bits tof_1, upper 4-bits of tof_2
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
7575
# word_2: lower 6-bits of tof_2, 10-bits of tof_3
7676
data_uint16 = np.reshape(
7777
np.frombuffer(de_data, dtype=">u2"), (3, -1), order="F"
7878
).astype(np.uint16)
7979

8080
de_dict = dict()
81-
de_dict["trigger_id"] = (data_uint16[0] >> 14).astype(np.uint8)
82-
de_dict["de_tag"] = (data_uint16[0] << 2) + (data_uint16[1] >> 14)
81+
de_dict["de_tag"] = data_uint16[0]
82+
de_dict["trigger_id"] = (data_uint16[1] >> 14).astype(np.uint8)
8383
de_dict["tof_1"] = (data_uint16[1] & int(b"00111111_11110000", 2)) >> 4
8484
de_dict["tof_2"] = ((data_uint16[1] & int(b"00000000_00001111", 2)) << 6) + (
8585
data_uint16[2] >> 10

imap_processing/tests/hi/test_science_direct_event.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ def test_parse_direct_events():
2121
# Encode the random events data into a bit-string
2222
bin_str = ""
2323
for i in range(n_events):
24-
bin_str += f"{exp_dict['trigger_id'][i]:02b}" # 2-bits for trigger_id
2524
bin_str += f"{exp_dict['de_tag'][i]:016b}" # 16-bits for de_tag
25+
bin_str += f"{exp_dict['trigger_id'][i]:02b}" # 2-bits for trigger_id
2626
bin_str += f"{exp_dict['tof_1'][i]:010b}" # 10-bits for tof_1
2727
bin_str += f"{exp_dict['tof_2'][i]:010b}" # 10-bits for tof_2
2828
bin_str += f"{exp_dict['tof_3'][i]:010b}" # 10-bits for tof_3

0 commit comments

Comments
 (0)