Bakr Hesham
Bakr Hesham

Reputation: 13

How to find the RMS value of an arbitrary wave form in python

I would like to calculate the RMS value of any waveform using its amplitude and time vectors. for example:

Amplitude =1000*np.array([0,0,0,0.00000121,0.00000113,0.00000104,7.00E-07,1.06E-22,1.06E-22,1.06E-22,1.06E-22,-1.06E-22,-5.00E-07,-1.06E-22,0.00000187,5.50E-07,-2.12E-22,-2.12E-22,-2.12E-22,-4.76E-22])
time = np.array([0,0.02,0.04,0.06,0.08,0.1,0.12,0.14,0.16,0.18,0.2,0.2,0.45,0.45,0.47,0.49,0.51,0.53,0.55,1.5])

Upvotes: 1

Views: 1472

Answers (1)

user10289025
user10289025

Reputation:

To compute RMS, you need to compute the integral of square of the Amplitude w.r.t time. This can be done with numpy.trapz From the definition of RMS, you can compute RMS as

RMS = np.sqrt(np.trapz(Amplitude**2,time)/(time[-1]-time[0]))

Upvotes: 1

Related Questions