Parsing¶
This submodule contains a collection of helper to parse filenames and some fields in bb_binary repositories to Python datastructures.
There are also some helper to convert some data representations like timeformats or ids.
-
int_id_to_binary
(int_id, nb_bits=12)[source]¶ Helper to convert an id represented as integer to a bit array.
Warning
This function uses big-endian notation whereas
DetectionDP
uses little-endian notation for decodedId.Parameters: int_id (int) – the integer id to convert to a bit array Keyword Arguments: nb_bits (Optional int) – number of bits in the bit array Returns: the bit array in big-endian notation Return type: np.array
-
binary_id_to_int
(decoded_id, threshold=0.5, endian='big')[source]¶ Helper to convert an id represented as bit array to an integer.
Warning
DetectionDP
uses little-endian notation for decodedId.Note
This is a generic solution to the problem. If have to decode a lot of ids take a look on numpy.packbits() and implement a vectorized version.
Parameters: decoded_id (
list
of int or float) – id as bit arrayKeyword Arguments: - threshold (Optional float) – decoded_id values >= threshold are interpreted as 1
- endian (Optional str) – use either ‘big’ or ‘little’, default is ‘big’
Returns: the decoded id represented as integer
Return type: