MDF CAN Buslogging file [filtering, merging, cutting, dataframe generating, exporting to excel, styling] with asammdf
This python code uses the MDF class from asammdf, pandas, Styleframe, and numpy for some math operations, in that way we use:
- concatenate method: To merge several MDF Files into 1 file.
- resample method: To resample the file into the wanted time sampling. (Uses interpolation)
- cut method: To cut the file from start time and end time variables. (Expects that the mdf file start time is less than wanted start time and end time is greater than wanted end time)
- to_dataframe: Used to further print a pandas dataframe that corresponds to the new file.
- insert: Insert list as column in dataframe.
- ExcelWriter instance: For excel generation and styling.
- This code was made for specific needs, to adjust to your needs needs to be substantially changed.
- The excel export uses Excel map files and interpolation to generate new data and introduce it into the dataframe, you will probably don't need that so just DELETE it if you clone the repo.
- The saving of the files is done with a writen absolute path and then saves with the filename with the activity of that day and the date extracted from the MDF File.
To change signals according to your needs: Change the: required_channels list:
required_channels = [ 'BMS_U_Batt', 'BMS_SOC', 'BMS_I_Batt', 'Cell_T_max', 'Controller_Temperature', 'Motor_Temperature', 'Aussentemperatur', 'GPS_Speed', 'Capacitor_Voltage', 'Motor_RPM', 'Current_RMS' ]
For more information about asammdf API, visit: https://asammdf.readthedocs.io/en/master/api.html
For more information about pandas API; visit: https://pandas.pydata.org/docs/reference/index.html
For more information about styleframe API, visit: https://styleframe.readthedocs.io/en/latest/api_documentation.html