file_header
Documentation for methods in the file_header script that are for data translation.
- slap2_utils.utils.file_header.load_file_header_v2(obj, rawUint32)[source]
Performs sanity checks on the file header and parses it into usable Python structures.
- Parameters:
obj (object) – An object that contains file-level metadata (e.g., constants like MAGIC_NUMBER).
rawUint32 (
np.ndarray
) – The raw header data as a uint32 array from the SLAP2 file.
- Returns:
A tuple containing: -
header
(dict): Parsed header metadata. -num_cycles
(int): Total number of cycles computed from the file size.- Return type:
tuple
- slap2_utils.utils.file_header.translate_field_value_pairs(field_value_pairs)[source]
Maps integer field IDs to named header fields and assigns their values.
- Parameters:
field_value_pairs (
np.ndarray
) – A (N, 2) array where each row is a field ID and its associated value.- Returns:
A dictionary mapping field names to their parsed float values.
- Return type:
dict
- slap2_utils.utils.file_header.translate_channel_mask(header)[source]
A function that translates the channel mask from the header as the input. It then has various checks that validate the number of channels specified.
- Parameters:
header (dict) – Header of SLAP2 binary file read as Uint32
- Returns:
The updated header with an added ‘channels’ list, if validation passes.
- Return type:
dict
- slap2_utils.utils.file_header.translate_reference_timestamp(header)[source]
Combines the lower and upper parts of the reference timestamp if they exist.
- Parameters:
header (dict) – Header dictionary containing fields like ‘referenceTimestamp_lower’ and ‘referenceTimestamp_upper’.
- Returns:
The updated header dictionary with a combined ‘referenceTimestamp’ field.
- Return type:
dict