Python读取和处理mf4
# 处理mf4数据
# 20220530 FQF
# 引入库文件
from asammdf import MDF # 用于处理MDF文件
import os # 用于获取文件路径
import numpy as np # 用于数学处理
import matplotlib.pyplot as plt # 用于绘图
# 读取mf4
path = 'C:/fqf'
os.chdir(path) # 更改python的工作空间
files = os.listdir(path)
for f in files:
if '_decoded' in f and f.endswith('.mf4') and f.startswith('df'): # 查找文件名字含有fish且以.png后缀的文件
# print('Find the mf4: ' + f)
# print(f.title())
mf4_name = f.split()
mdf = MDF(f)
# print(mdf.info())
# 读取数据
Prompt_info = mdf.get("InterSysInfoDisp")
Prompt_value = ICA_Prompt_info.samples
Prompt_timestamps = Prompt_info .timestamps
# 搜索工况
i = 1
while i < len(Prompt_timestamps )-1:
if Prompt_value [i] != 9 & Prompt_value [i+1] == 9: # 搜索工况
print( "============================")
print(f)
print(Prompt_timestamps [i])
i = i + 1
# 绘图
# plt.plot(Prompt_timestamps ,Prompt_value )#r表示颜色,v表示下三角线类型
# plt.xlabel('xlabel',fontsize = 25)
# plt.ylabel('ylabel',fontsize = 16)
# plt.grid()
# plt.show()