imap_processing.hi.l1a.science_direct_event.parse_direct_event#

imap_processing.hi.l1a.science_direct_event.parse_direct_event(event_data: str) dict#

Parse event data.

IMAP-Hi direct event data information is stored in 48-bits as follow:

Read first two bits (start_bitmask_data) to find
out which type of event it is. start_bitmask_data value mapping:

1 - A
2 - B
3 - C
0 - META
If it’s a metaevent:

Read 48-bits into 2, 4, 10, 32 bits. Each of these breaks
down as:

start_bitmask_data - 2 bits (tA=1, tB=2, tC1=3, META=0)
ESA step - 4 bits
integer millisecond of MET(subseconds) - 10 bits
integer MET(seconds) - 32 bits

If it’s not a metaevent:
Read 48-bits into 2, 10, 10, 10, 16 bits. Each of these breaks
down as:

start_bitmask_data - 2 bits (tA=1, tB=2, tC1=3, META=0)
tof_1 - 10 bit counter
tof_2 - 10 bit counter
tof_3 - 10 bit counter
de_tag - 16 bits

There are at most total of 665 of 48-bits in each data packet. This data packet is of variable length. If there is one event, then DE_TOF will contain 48-bits. If there are 665 events, then DE_TOF will contain 665 x 48-bits. If there is no event, then DE_TOF will contain 0-bits.

Per ESA, there should be two data packets. First one will begin with metaevent followed by direct events data. Second one will begin with direct event data only. If there is no event record for certain ESA step, then as mentioned above, first packet will contain metaevent in DE_TOF information and second packet will contain 0-bits in DE_TOF. In general, every two packets will look like this.

first packet = [
(start_bitmask_data, ESA step, int millisecond of MET, int MET),
(start_bitmask_data, tof_1, tof_2, tof_3, de_tag),
…..
]
second packet = [
(start_bitmask_data, tof_1, tof_2, tof_3, de_tag),
…..
]

In direct event data, if no hit is registered, the tof_x field in the DE to a value of negative one. However, since the field is described as a “10-bit unsigned counter,” it cannot actually store negative numbers. Instead, the value negative is represented by the maximum value that can be stored in a 10-bit unsigned integer, which is 0x3FF (in hexadecimal) or 1023 in decimal. This value is used as a special marker to indicate that no hit was registered. Ideally, the system should not be able to register a hit with a value of 1023 for all tof_1, tof_2, tof_3, because this is in case of an error. But, IMAP-Hi like to process it still to investigate the data. Example of what it will look like if no hit was registered.

(start_bitmask_data, 1023, 1023, 1023, de_tag)
start_bitmask_data will be 1 or 2 or 3.
Parameters:

event_data (str) – 48-bits Event data.

Returns:

Parsed event data.

Return type:

dict