コード例 #1
0
def main():
    # Check args
    if len(sys.argv) > 1:
        print(sys.argv[1])
        pos1 = sys.argv[1].find('-h')
        if (pos1 >= 0):
            printOutHelp()
            sys.exit()

    if len(sys.argv) != 3 and len(sys.argv) > 1:
        printOutHelp()
        sys.exit()

    if len(sys.argv) == 3:
        fnamex = sys.argv[1]
        dataFileX = open(fnamex, 'r')

    if len(sys.argv) == 3:
        fnamey = sys.argv[2]
        dataFileY = open(fnamey, 'r')

    parserY = caMonitorArrayParser()

    firstY = 1
    for line in dataFileY:
        if not parserY.lineValid(line):
            continue

        pvName, timeVal, data = parserY.getValues(line)
        if firstY:
            pvY = caPVArray(pvName)
            firstY = 0

        pvY.setValues(timeVal, data)

    parserX = caMonitorArrayParser()
    firstX = 1
    for line in dataFileX:
        if not parserX.lineValid(line):
            continue

        pvName, timeVal, data = parserX.getValues(line)
        if firstX:
            pvX = caPVArray(pvName)
            firstX = 0

        pvX.setValues(timeVal, data)

    timeSetX, dataSetX = pvX.getData()
    timeSetY, dataSetY = pvY.getData()

    plt.plot(dataSetX, dataSetY)
    #plt.legend("Amplitude []")
    plt.grid()
    #plt.title("FFT of 5Hz sin wave sampled at 100Hz (generated in ecmc PLC)")
    #plt.xlabel("Freq [Hz]")
    plt.show()
コード例 #2
0
def main():
    # Check args
    if len(sys.argv) > 1:
        print(sys.argv[1])
        pos1 = sys.argv[1].find('-h')
        if (pos1 >= 0):
            printOutHelp()
            sys.exit()

    if len(sys.argv) != 3 and len(sys.argv) > 1:
        printOutHelp()
        sys.exit()

    if len(sys.argv) == 3:
        fnamex = sys.argv[1]
        dataFileX = open(fnamex, 'r')

    if len(sys.argv) == 3:
        fnamey = sys.argv[2]
        dataFileY = open(fnamey, 'r')

    parserY = caMonitorArrayParser()
    pvs = []
    dataBufferY = np.array([])
    for line in dataFileY:
        if not parserY.lineValid(line):
            continue

        pvName, timeVal, data = parserY.getValues(line)
        dataBufferY = np.append(dataBufferY, data[:].astype(np.float))

    y = dataBufferY

    parserX = caMonitorArrayParser()

    dataBufferX = np.array([])
    for line in dataFileX:
        if not parserX.lineValid(line):
            continue

        pvName, timeVal, data = parserX.getValues(line)
        dataBufferX = np.append(dataBufferX, data[:].astype(np.float))

    x = dataBufferX
    y = dataBufferY

    plt.plot(x, y)
    #plt.legend("Amplitude []")
    plt.grid()
    #plt.title("FFT of 5Hz sin wave sampled at 100Hz (generated in ecmc PLC)")
    #plt.xlabel("Freq [Hz]")
    plt.show()
コード例 #3
0
def main():
    # Check args
    if len(sys.argv) > 1:
        print sys.argv[1]
        pos1 = sys.argv[1].find('-h')
        if (pos1 >= 0):
            printOutHelp()
            sys.exit()

    if len(sys.argv) != 2 and len(sys.argv) > 1:
        printOutHelp()
        sys.exit()

    if len(sys.argv) == 2:
        fname = sys.argv[1]
        dataFile = open(fname, 'r')

    if len(sys.argv) == 1:
        fname = ""
        dataFile = sys.stdin

    parser = caMonitorArrayParser()
    pvs = []

    for line in dataFile:
        if not parser.lineValid(line):
            continue

        pvName, timeVal, data = parser.getValues(line)
        newPv = True
        pvToAddDataTo = caPVArray(pvName)
        # See if old or new pv
        for pv in pvs:
            if pv.getName() == pvName:
                pvToAddDataTo = pv
                newPv = False
                break

        pvToAddDataTo.setValues(timeVal, data)
        if newPv:
            pvs.append(pvToAddDataTo)
            print "Added PV: " + pvName

    print "Statistics: "
    legend = []
    for pv in pvs:
        timeSet, dataSet = pv.getData()
        #for d in dataSet:
        #  print d
        pvLength = pv.getLength()
        pvMax = np.max(dataSet)
        pvMin = np.min(dataSet)
        pvAvg = np.mean(dataSet)
        pvStd = np.std(dataSet)
        legStr = pv.getName() + "[" + str(pvLength) + "] " + str(
            pvMin) + ".." + str(pvMax) + ", mean: " + str(
                pvAvg) + ", std: " + str(pvStd)
        x = timeSet
        y = dataSet
        print legStr
コード例 #4
0
def main():
  timeLimit = ""
  # Check args
  if len(sys.argv)>1:
    print sys.argv[1] 
    pos1=sys.argv[1].find('-h')
    if(pos1>=0):
      printOutHelp()
      sys.exit()
  
  if (len(sys.argv)!=3 and len(sys.argv)!=2) and len(sys.argv)>1:  
      printOutHelp()
      sys.exit()
  
  if len(sys.argv)==3:      
    timeLimit = sys.argv[1]
    fname=sys.argv[2]
    dataFile=open(fname,'r')

  if len(sys.argv)==2:
    timeLimit = sys.argv[1]
    fname=""
    dataFile=sys.stdin;

  print "Using time limit: " + timeLimit

  parser=caMonitorArrayParser()
  parser.setLowTimeLimit(timeLimit)
  pvs=[]

  for line in dataFile:
    if not parser.lineValid(line):      
      continue

    pvName, timeVal, data=parser.getValues(line)
    newPv=True;
    pvToAddDataTo=caPVArray(pvName)
    # See if old or new pv
    for pv in pvs:
      if pv.getName() == pvName:        
        pvToAddDataTo=pv
        newPv=False;
        break;
    
    pvToAddDataTo.setValues(timeVal,data)
    if newPv:       
      pvs.append(pvToAddDataTo)
      print "Added PV: " + pvName
  
  
  legend=[]
  for pv in pvs:      
    pv.printValues()
コード例 #5
0
def main():
    numberToAdd = 0
    # Check args
    if len(sys.argv) > 1:
        print sys.argv[1]
        pos1 = sys.argv[1].find('-h')
        if (pos1 >= 0):
            printOutHelp()
            sys.exit()

    if (len(sys.argv) != 3 and len(sys.argv) != 2) and len(sys.argv) > 1:
        printOutHelp()
        sys.exit()

    if len(sys.argv) == 3:
        numberToAdd = float(sys.argv[1])
        fname = sys.argv[2]
        dataFile = open(fname, 'r')

    if len(sys.argv) == 2:
        numberToAdd = float(sys.argv[1])
        fname = ""
        dataFile = sys.stdin

    print "Number to add: " + str(numberToAdd)

    parser = caMonitorArrayParser()
    pvs = []

    for line in dataFile:
        if not parser.lineValid(line):
            continue

        pvName, timeVal, data = parser.getValues(line)
        newPv = True
        pvToAddDataTo = caPVArray(pvName)
        # See if old or new pv
        for pv in pvs:
            if pv.getName() == pvName:
                pvToAddDataTo = pv
                newPv = False
                break

        pvToAddDataTo.setValues(timeVal, data)
        if newPv:
            pvs.append(pvToAddDataTo)
            print "Added PV: " + pvName

    legend = []
    for pv in pvs:
        pv.calcAdd(numberToAdd)
        pv.printAddValues()
コード例 #6
0
ファイル: deLin.py プロジェクト: anderssandstrom/ecmccomgui
def main():
  # Check args
  if len(sys.argv)>1:
    print (sys.argv[1] )
    pos1=sys.argv[1].find('-h')
    if(pos1>=0):
      printOutHelp()
      sys.exit()
  
  if len(sys.argv)!=2  and len(sys.argv)>1:  
      printOutHelp()
      sys.exit()
  
  if len(sys.argv)==2:  
    fname=sys.argv[2]
    dataFile=open(fname,'r')

  if len(sys.argv)==1:
    fname=""
    dataFile=sys.stdin;

  parser=caMonitorArrayParser()
  pvs=[]

  for line in dataFile:
    if not parser.lineValid(line):      
      continue

    pvName, timeVal, data=parser.getValues(line)
    newPv=True;
    pvToAddDataTo=caPVArray(pvName)
    # See if old or new pv
    for pv in pvs:
      if pv.getName() == pvName:        
        pvToAddDataTo=pv
        newPv=False;
        break;
    
    pvToAddDataTo.setValues(timeVal,data)
    if newPv:       
      pvs.append(pvToAddDataTo)
      print ("Added PV: " + pvName)
  
  
  legend=[]
  for pv in pvs:   
    pv.substLin()
    pv.printDeLinValues()
コード例 #7
0
def main():
    # Check args
    if len(sys.argv) > 1:
        print(sys.argv[1])
        pos1 = sys.argv[1].find('-h')
        if (pos1 >= 0):
            printOutHelp()
            sys.exit()

    if len(sys.argv) != 2 and len(sys.argv) > 1:
        printOutHelp()
        sys.exit()

    if len(sys.argv) == 2:
        fname = sys.argv[1]
        dataFile = open(fname, 'r')

    if len(sys.argv) == 1:
        fname = ""
        dataFile = sys.stdin

    parser = caMonitorArrayParser()
    pvs = []
    dataBuffer = np.array([])
    for line in dataFile:
        if not parser.lineValid(line):
            continue

        pvName, timeVal, data = parser.getValues(line)
        dataBuffer = np.append(dataBuffer, data[:].astype(np.float))
    print(dataBuffer)

    y = dataBuffer
    plt.plot(y)
    plt.legend("Data")
    plt.grid()
    plt.title("Wavform data")
    plt.xlabel("time [samples in 20kHz]")
    plt.ylabel("Voltage [raw]")
    plt.show()
コード例 #8
0
def main():
    # Check args
    if len(sys.argv) > 1:
        print sys.argv[1]
        pos1 = sys.argv[1].find('-h')
        if (pos1 >= 0):
            printOutHelp()
            sys.exit()

    if len(sys.argv) != 2 and len(sys.argv) > 1:
        printOutHelp()
        sys.exit()

    if len(sys.argv) == 2:
        fname = sys.argv[1]
        dataFile = open(fname, 'r')

    if len(sys.argv) == 1:
        fname = ""
        dataFile = sys.stdin

    parser = caMonitorArrayParser()
    pvs = []

    for line in dataFile:
        if not parser.lineValid(line):
            continue

        pvName, timeVal, data = parser.getValues(line)
        newPv = True
        pvToAddDataTo = caPVArray(pvName)
        # See if old or new pv
        for pv in pvs:
            if pv.getName() == pvName:
                pvToAddDataTo = pv
                newPv = False
                break

        pvToAddDataTo.setValues(timeVal, data)
        if newPv:
            pvs.append(pvToAddDataTo)
            print "Added PV" + pvName

    legend = []
    for pv in pvs:
        legend.append(pv.getName())
        print pv.getName() + ": " + str(pv.getLength())
        timeSet, dataSet = pv.getData()
        sampleTime = pv.getSampleTime()
        x = timeSet
        y = dataSet
        plt.plot(x, y, 'o-')

    #print "Sample Mean" + str(np.mean(sampleTime))
    plt.legend(legend)
    plt.grid()
    plt.title(fname)
    plt.xlabel("time")

    plt.figure()

    N = dataSet.size
    # sample spacing
    T = np.mean(sampleTime)
    x = np.linspace(0.0, N * T, N)
    #normalize data (remove slope)
    p = np.polyfit(x, dataSet, 1)

    y = dataSet - np.polyval(p, x)
    yf = scipy.fftpack.fft(y)
    xf = np.linspace(0.0, 1.0 / (2.0 * T), N / 2)
    yfft = 2.0 / N * np.abs(yf[:N // 2])  # integer division

    plt.plot(xf, yfft, '*-')
    plt.grid()
    plt.xlabel("Frequency [Hz]")
    plt.ylabel("Amplitude")

    plt.show()
コード例 #9
0
def main():
    # Check args
    if len(sys.argv) > 1:
        print(sys.argv[1])
        pos1 = sys.argv[1].find('-h')
        if (pos1 >= 0):
            printOutHelp()
            sys.exit()
        pos1 = sys.argv[1].find('-t')
        if (pos1 >= 0) and len(sys.argv) > 2:
            title = sys.argv[2]
            if len(sys.argv) > 3:
                fname = sys.argv[3]
                dataFile = open(fname, 'r')
            else:
                fname = ""
                dataFile = sys.stdin
        else:
            title = ""
            fname = sys.argv[2]
            dataFile = open(fname, 'r')
    else:
        title = ""
        fname = ""
        dataFile = sys.stdin

    parser = caMonitorArrayParser()
    pvs = []

    for line in dataFile:
        if not parser.lineValid(line):
            continue

        pvName, timeVal, data = parser.getValues(line)
        newPv = True
        pvToAddDataTo = caPVArray(pvName)
        # See if old or new pv
        for pv in pvs:
            if pv.getName() == pvName:
                pvToAddDataTo = pv
                newPv = False
                break

        pvToAddDataTo.setValues(timeVal, data)
        if newPv:
            pvs.append(pvToAddDataTo)
            print("Added PV: " + pvName)

    print("Statistics: ")
    legend = []
    count = 0
    for pv in pvs:

        count += 1
        timeSet, dataSet = pv.getData()
        #for d in dataSet:
        #  print(d)
        pvLength = pv.getLength()
        pvMax = np.max(dataSet)
        pvMin = np.min(dataSet)
        pvAvg = np.mean(dataSet)
        pvStd = np.std(dataSet)
        legStr = pv.getName() + "[" + str(pvLength) + "] " + str(
            pvMin) + ".." + str(pvMax) + ", mean: " + str(
                pvAvg) + ", std: " + str(pvStd) + ", range: " + str(pvMax -
                                                                    pvMin)
        #infoStr = "[" + str(pvLength) + "] " + str(pvMin) + ".." + str(pvMax) + ", mean: " + str(pvAvg) + ", std: " + str(pvStd) + ", range: " +str(pvMax-pvMin)
        infoStr = pv.getName(
        ) + "[{0}]:\n  range: {1:.7f}.. {2:.7f} ({3:.7f}), \n  mean: {4:.7f},\n  std: {5:.7f}".format(
            pvLength, pvMin, pvMax, pvMax - pvMin, pvAvg, pvStd)
        legend.append(pv.getName())

        x = timeSet

        print(legStr)
        plt.figure(figsize=(8, 8))
        n, bins, patches = plt.hist(dataSet, int(pvLength / 5), density=1)
        y = mlab.normpdf(bins, pvAvg, pvStd)
        l = plt.plot(bins, y, linewidth=1)

    if count == 1:
        plt.gcf().text(0.01, 0.91, infoStr)

    plt.legend(legend)
    plt.grid()
    plt.title(title)
    plt.show()