Permalink
Browse files

Added routine to compute rms values of selected curves and plot them.

  • Loading branch information...
ldemattos committed Feb 9, 2017
1 parent 93f2125 commit 2b7d14e977f7d05a6c9f148652b33e6304cc8a2e
Showing with 44 additions and 0 deletions.
  1. +44 −0 src/GUI_Analyses.py
@@ -22,3 +22,47 @@
#
#

import numpy as np
import pylab

# Calculate RMS value
def calcRMS(comtradeObj,analog_curves):

import tkMessageBox
from scipy import integrate

# Check if the selected data are ok
if len(analog_curves) == 0:
tkMessageBox.showerror("RMS - Error","Select at least one analog curve!")

else:
# previous variables
dt = 1./comtradeObj.getSamplingRate()
sizeWin = int(np.ceil(1. / comtradeObj.lf / dt))
tcyc = sizeWin * dt
datalen = comtradeObj.getNumberOfSamples()
t = comtradeObj.getTime()

# Allocate rms values vector
xrms = np.zeros(datalen)

# Generate figure frame
pylab.figure()

for i in analog_curves:
i = int(i)

# Getting oscillographics values
x = comtradeObj.getAnalogChannelData(i+1)[:,0]**2.0

# Compute RMS value for an one cycle window
for k in xrange(0,datalen):
xrms[k] = np.sqrt( integrate.trapz( x[k:(sizeWin+k)],t[k:(sizeWin+k)] ) / tcyc )

# plot result
label="%s (%s) - RMS"%(comtradeObj.Ach_id[i],comtradeObj.getAnalogUnit(i+1))
pylab.plot(t,xrms,label=label)

# Show all plots
pylab.legend()
pylab.show()

0 comments on commit 2b7d14e

Please sign in to comment.