0

我正在与 asammdf 一起绘制信号,现在我遇到了一个问题,如何使用信号名称重命名通道组?

这是我的代码:

mdf = MDF()
sigs = []
for equipment in table_list:
    print("Table name:", equipment[0])
    df = pd.read_sql_query('select * from ' + equipment[0], con)
    df = df.replace(np.nan, 0)
    if equipment[0] == 'state':
        df_time = (df['id']-df.iloc[0]['id'])
    else:
        df_time = (df['ts']-df.iloc[0]['ts']) * 1e-6
        df.pop('ts')
    sigs = []
    for signal in df.columns.to_list():
        df[signal]
        test_signal = Signal(samples=df[signal],  timestamps=df_time,
                    name=signal,
                    unit='')
        sigs.append(test_signal)
    mdf.append(sigs)
mdf.save('..\\Output\\test_complete.mf4', overwrite=True)

在此处输入图像描述

4

1 回答 1

0

您应该更改频道组评论

mdf = MDF()
sigs = []
for equipment in table_list:
    print("Table name:", equipment[0])
    df = pd.read_sql_query('select * from ' + equipment[0], con)
    df = df.replace(np.nan, 0)
    if equipment[0] == 'state':
        df_time = (df['id']-df.iloc[0]['id'])
    else:
        df_time = (df['ts']-df.iloc[0]['ts']) * 1e-6
        df.pop('ts')
    sigs = []
    for signal in df.columns.to_list():
        df[signal]
        test_signal = Signal(samples=df[signal],  timestamps=df_time,
                    name=signal,
                    unit='')
        sigs.append(test_signal)
    mdf.append(sigs)
    channel_group = mdf.groups[-1].channel_group
    channel_group.comment = "fancy name"
mdf.save('..\\Output\\test_complete.mf4', overwrite=True)
于 2021-05-22T18:24:32.837 回答