Please assume that we have the following test signal:
import numpy as np
fs = 10000
f1 = 60
duration = 10
samples = int(fs*duration)
t = np.arange(samples) / fs
signal = 15 * t * np.sin(2.0*np.pi*f1*t)
from which the RMS value will be calculated using convolution as follows:
def calculate_rms(signal, N):
sig2 = np.power(signal,2)
window = np.ones(N)/float(N)
return np.sqrt(np.convolve(sig2, window, 'valid'))
N = (1.0 / f1) * fs
RMS = calculate_rms(signal,N)
However, after convolution, RMS of course has less data points than t and signal and I am not sure how to postprocess t and signal in order to be able to plot them together with RMS as signal=f(t) and RMS=f(t) in the same plot witout distorting the temporal dimension.