I found that my machine is struggling with convolution, so I offer the following solution:
Fast RMS moving window calculation
Suppose we have analog voltage samples a0 ... a99 (one hundred samples), and we need to go through RMS 10 samples.
Initially, the window will be scanned from elements a0 through a9 (ten samples) to get rms0.
# rms = [rms0, rms1, ... rms99-9] (total of 91 elements in list): (rms0)^2 = (1/10) (a0^2 + ... + a9^2)
Simplification: we have a = [a0,... a99] To create an RMS of 10 samples, we can take sqrt of addition 10 a^2 and multiply by 1/10.
In other words, if we have
p = (1/10) * a^2 = 1/10 * [a0^2, ... a99^2]
To get rms^2 just add a group of 10 people.
Let there be acummulator acu:
acu = p0 + ... p8
Then we can have
rms0^2 = p0 + ... p8 + p9 = acu + p9 rms1^2 = acu + p9 + p10 - p0 rms2^2 = acu + p9 + p10 + p11 - p0 - p1 ...
we can create:
V0 = [acu, 0, 0, ... 0] V1 = [ p9, p10, p11, .... p99] -- len=91 V2 = [ 0, -p0, -p1, ... -p89] -- len=91 V3 = V0 + V1 + V2
if we run itertools.accumulate(V3) we get an rms array
The code:
import numpy as np from itertools import accumulate a2 = np.power(in_ch, 2) / tm_w
I can calculate an array of 128 megapixels in less than 1 minute.