message_preprocessor module

message_preprocessor.dummy_padding(value_dict, key_dict, dummy=0.0, reverse=False, verbose=False)

Assume that several Lists in a Dict have different length, e.g. ‘ADAS_Seg_CycCnt_ST32’ and ‘ADAS_Seg_CmpxInsct_ST32’ are both Segment messages, while they have different length of list(6026 and 6178 respectively).

Let the biggest length of List as standard. This function aims to padding the missing part of the shorter lists.

For memory saving, Protobuf3 defines that one field is inplicit (won’t be displayed, saved or serialized) when its value is set to default 0.

Therefore a related change was made in data_processor.py that every single value of messages is incremented by 1 additionaly, except for msgType and prfType. That is to say, this feature of ProtoBuf3 can be exploited to fill in the missing part of messages without raising any value error.

Parameters
  • value_dict – A Dict that contains message of a specific type

  • key_dict – A Dict that contains keys of a message type

  • reverse – To define the way of padding dummy value. if reverse=True, dummy value(0.0 by default) will be filled from the back end of the List

  • verbose – To define if you want debug message to be displayed. if verbose=True, when come aross a field with deficient value, the name of the field will be displayed.

Returns

value_dict that has been populated with dummy data

Return type

dict



message_preprocessor.duplicate_filter(val_list, idx_list)

A function that filters duplicate elements. Note that val_list is in ascending order.

Parameters
  • val_list – A list of origin message data

  • ind_list – A list of indices that index duplicated value in val_list

Returns

val_list without duplicated value

Examples
>>> data = [1, 3, 3, 3, 7, 7, 7, 7]
>>> ind = [1, 2, 4, 5, 6]
>>> data = duplicate_filter(data, ind)
>>> data
[1, 3, 7]


message_preprocessor.get_index_of_duplicated_value(lst)

Return a list of index

Note: Assume that lst is already in ascending order

Parameters

lst – A list that has duplicated elements

Returns

The index of duplicated elements except for the last one.

Return type

list

Examples
>>> data = [1, 3, 3, 3, 7, 7, 7, 7]
>>> index = get_index_of_duplicated_value(data)
>>> index
[1, 2, 4, 5, 6]


message_preprocessor.profType_convert(msgType, prfType)

Return the value of profile Type

Note that profile Long start with the value 11, which is defined in the .proto file

Examples
>>> value = profType_convert('PROFILE_LONG', 'Longitude')
>>> value
11


message_preprocessor.sort_message(data, keys, value, verbose=False)

Return a List of values, which has the same dimension with input values, and all duplicated elements deleted

Parameters
  • data – A Dict of all value (data = mat4py.load(‘matfile’))

  • keys – A Dict of keys of specific type of message

  • value – A Dict of value corresponding to each key in keys

Returns

A List of values without duplicated elements

Return type

list