标题: dat数据跳频及分析 python代码 [打印本页]

作者: Agle    时间: 2020-12-4 16:31
标题: dat数据跳频及分析 python代码
#!/usr/bin/env python2
# -*- coding: utf-8 -*-
import mdfreader
import time
import os
import matplotlib.pyplot as plt
import numpy as np

class SpeedCheck(object):
    def __init__(self,dir):
        self.yop = mdfreader.mdf(dir,noDataLoading=True)

    def Check(self,SampleTime = 0.1):
        VKPH = self.yop.getChannelData("vfzg_w")         
        print("VKPT=%d"%len(VKPH))
        plt.plot(VKPH)
        plt.plot(DFC_HDRmax)
        plt.ylabel('VKPH')
        plt.plot(DFC_HDRmin)
        #fig, ax = plt.subplots()
        t = np.arange(0, (len(VKPH) - 1), 1)

        temp = DFC_HDRmax[0]
        for xy in zip(t, DFC_HDRmax):
            print "DFC_HDRmax[%s] = %s" % xy
            #for i in range(len(xy)):
            if temp-round(xy[1]) != 0 and abs(temp-round(xy[1])) > 1:
                print "DFC_HDRmax = (%s,%s)" % xy
                for i in range(len(xy)):
                    k=xy[0]
                print "k = %d" %k
                temp = DFC_HDRmax[k]
                plt.annotate("DFC_HDRmax =(%s ,%s)" % (k+1,DFC_HDRmax[k+1]), xy=(k+1,DFC_HDRmax[k+1]),xytext=(0, 100),textcoords='offset points')
                plt.annotate("VKPH =(%d ,%d)" % (k,VKPH[k]), xy=(k, VKPH[k]), xytext=(0, 80), textcoords='offset points')
                plt.annotate("DFC_HDRmin =(%d ,%d)" % (k, DFC_HDRmin[k]), xy=(k, DFC_HDRmin[k]), xytext=(0, 50),
                             textcoords='offset points')
                break
        plt.show()



if __name__ == "__main__":
    dir = r"C:\Users\Administrator\Desktop\WarningUp.dat"
    filename = os.path.split(dir)[1]
    yop = mdfreader.mdf(dir)
    yop.resample(0.1)
    resampleFile = 'resample_{0}'.format(filename)
    yop.write(resampleFile)
    SpeedCheck(resampleFile).Check()
    print "数据后处理软件"







欢迎光临 (http://www.51hei.com/bbs/) Powered by Discuz! X3.1