Phase invariant detection of low frequency spikes I am a physics graduate student studying a new physical device via simulations. Thanks to SE DSP, reading Lyon's Understanding DSP as suggested (not all the way through it yet though), and a bunch of work, I have been learning, and enjoying, DSP. I’m at a point where I am completely stumped by something, and need some help.

For this project, signal processing appears very simple, as seen in this diagram:

However, what happens inside the "Physics Device" somewhat complicated. Simply put, when the external signal $f(t)$ and the physics device interact, there is some destructive interference. To me, this means there will be a narrow low frequency spike at the time where there is interference. When there is no destructive interference, there is a lot of stuff going on. The outputs relating to the physical device are very ugly compared to a communication system; there are many harmonics and other things happening. 

When the physical device I'm simulating is running, and an external microwave signal $f(t)=A\cos(\omega_1 t +\phi_1)+B\cos(\omega_2 t + \phi_1)$ is introduced, destructive interference creates some low frequency oscillations at particular locations:

Input #1: $f(t)=A\cos(\omega_1 t +\phi_1)+B\cos(\omega_2 t + \phi_1)$

Output #1:



Th upper graph shows raw data, and the lower shows this after I apply a Low pass filter. If I use a low-pass FIR filter near DC, it gives me nice peaks to identify where the low frequency oscillations occur.

In these, the first peak near $60\textrm{ ns}$ is related to the first term, and the second smaller peak near $100\textrm{ ns}$ is related to the second term. Also, $B=0.2A$, so the second peak should be shorter than the first peak.

If instead of phase shift $\phi_1$ in the first term, the signal has a phase shift of $\phi_2$, or as: $f(t)=A\cos(\omega t + \phi_2) +B\cos(\omega_2 t + \phi_1)$, we get similar looking raw data: 

Input #2: $f(t)=A\cos(\omega_1 t +\phi_2)+B\cos(\omega_2 t + \phi_1)$

Output #2:



But after the low pass filter, the peaks are not-so-beautiful.  

Is there an algorithm that will allow me to determine when an external signal is introduced into the physical system regardless of the initial phase shift of the external signal? My eyes can identify from the raw data where the peaks should be, but a low pass filter doesn’t do the job consistently.

I have tried using signal energy, as $\int_t^{t+T} \lvert x(t’)\rvert^2 dt’$, but this fails in two regards. 


It does not see the second peak
And it requires some threshold, which doesn’t work well as $A$ and $B$ can differ by several orders of magnitude.


Is there a good algorithm to get nice thin peaks from both signals? Even more, is it something that can be built with existing technology?

I can post data for the above graphs. How can I post it? They are small lists, with ~ 100,000 elements.
I would use a band-pass filter centred at the frequency of the peaks (10ns period?). That should give you more of a peak in the second signal.
Use a quadrature filter pair (band-pass filter and its Hilbert transform) to gain phase invariance. The output is called the analytic signal. Its amplitude is a local phase-invariant energy measure.


In MATLAB this would be

f_a = hilbert(conv(f,g,'same'));
amplitude = abs(f_a);
phase = angle(f_a);


where f is the signal and g is the band-pass filter.