Improving frequency time normalization/hilbert transfer runtimes
<p>So this is a bit of a nitty gritty question...</p>

<p>I have a time-series signal that has a non-uniform response spectrum that I need to whiten. I do this whitening using a frequency time normalization method, where I incrementally filter my signal between two frequency endpoints, using a constant narrow frequency band (~1/4 the lowest frequency end-member). I then find the envelope that characterizes each one of these narrow bands, and normalize that frequency component. I then rebuild my signal using these normalized signals... all done in python (sorry, has to be a python solution)...</p>

<p>Here is the raw data:
<a href="http://i.stack.imgur.com/MQut2.png" rel="nofollow"><img src="http://i.stack.imgur.com/MQut2.png" alt="enter image description here"></a></p>

<p>and here is its spectrum:
<a href="http://i.stack.imgur.com/SKvfC.png" rel="nofollow"><img src="http://i.stack.imgur.com/SKvfC.png" alt="enter image description here"></a></p>

<p>and here is the spectrum of the whitened data:
<a href="http://i.stack.imgur.com/hy3c9.png" rel="nofollow"><img src="http://i.stack.imgur.com/hy3c9.png" alt="enter image description here"></a></p>

<p>The problem is, that I have to do this for maybe ~500,000 signals like this, and it takes a while (~a minute each)... With almost the entirety of the time being spend doing the actual (multiple) Hilbert transforms </p>

<p>I have it running on a small cluster already. I don't want to parallelize the loop the Hilbert is in.</p>

<p>I'm looking for alternative envelope routines/functions (non Hilbert), or alternative ways to calculate the entire narrowband response function without doing a loop.</p>

<p>The other option is to make the frequency bands adaptive to the center frequency over which its filtering, so they get progressively larger as we march through the routines; which would just decrease the number of times I have to go through the loop.</p>

<p>Any and all suggestions welcome!!!</p>

<p>example code/dataset:
<a href="https://github.com/ashtonflinders/FTN_Example" rel="nofollow">https://github.com/ashtonflinders/FTN_Example</a></p>

<p>Here is a faster method to calculate the enveloop by local max:</p>

<pre><code>def calc_envelope(x, ind):
    x_abs = np.abs(x)
    loc = np.where(np.diff(np.sign(np.diff(x_abs))) &lt; 0)[0] + 1
    peak = x_abs[loc]
    envelope = np.interp(ind, loc, peak)
    return envelope
</code></pre>

<p>Here is an example output:</p>

<p><a href="http://i.stack.imgur.com/tRfDN.png" rel="nofollow"><img src="http://i.stack.imgur.com/tRfDN.png" alt="enter image description here"></a></p>

<p>It's about 6x faster than hilbert. To speedup even more, you can write a cython function that find next local max point and does normalization up to the local max point iteratively.</p>

python numpy math scipy