Пример #1
0
    def openMsg(self):
        global file, dir, channels, mdf
        self.statusBar.showMessage("Select target file")
        dirfile, _ = QFileDialog.getOpenFileName(
            self, "打开", "D:/4_SW_Tool/SW_Project/Python/",
            "All Files(*);; Text Filesle(*.txt)")
        if dirfile.endswith('.mdf'):
            self.ShowDirBrowser.setText(dirfile)
            file = os.path.split(dirfile)[1]
            dir = os.path.split(dirfile)[0]

            os.chdir(dir)
            mdf = MDF(file)
            os.chdir(Origindir)
            channels = mdf.export('pandas').columns
        else:
            self.msg_file()
Пример #2
0
from asammdf import MDF
import sys
import matplotlib.pyplot as plt
mdf = MDF('Dauerzeitschrieb_20171218_053831.mf4', memory='full')

sig_list = []
while 1:
    choice_1 = input("Do you want to add a signal?(y/n)\n")
    if choice_1 == "n":
        if len(sig_list) > 0:
            filter = mdf.filter(sig_list)
            file_name = input("Enter the file name to be saved\n")
            filter.convert('4.10').save(file_name + '.mf4')
            mdf_new = MDF((file_name + '.mf4'), memory='full')
            data_frame = mdf_new.export('pandas', filename=file_name)
            data_frame.to_csv(file_name + '.csv')
            print("CSV and mf4 file created.\n")
            choice_2 = input("Do you want to plot the signal(s)?(y/n)\n")
            if choice_2 == "y":
                for i in range(len(sig_list)):
                    plt.figure(i)
                    plt.xlabel('Time [s]')
                    plt.ylabel('[{}]'.format(mdf.get(sig_list[i]).unit))
                    plt.plot(
                        mdf.get(sig_list[i]).timestamps,
                        mdf.get(sig_list[i]).samples, 'b')
                    plt.plot(
                        mdf.get(sig_list[i]).timestamps,
                        mdf.get(sig_list[i]).samples, 'b.')
                    plt.grid(True)
        break