I'm looking for a good way to estimate the power of a signal (regularly sampled say at 10 kHz) vs. time at just one frequency (say 50 Hz).  I could calculate the spectrogram, and then take a slice of it at the target frequency.  This seems inefficient though, since I only care about the power at one frequency vs. time.  I realize that the power at exactly one frequency is zero (in the limit), I'd like to calculate the power of the signal within a small frequency interval around the target frequency.
My current "solution" is to use Matplotlib's mlab.specgram() function which returns a 2d array of power, and I just slice it.  I'm not satisified with this though because I don't totally trust the mab.specgram() function as it takes drastically different amounts of time to compute the spectrogram on different signals (even if they are the same length).
There's a ton of ways of doing this. One crude but effective way is to apply a bandpass filter (at 50Hz), thereby eliminating all other signals, and then calculate the RMS power of the last N samples.
Another is you can do a windowed FFT, but not actually FFT - just calculate the bin you want. The window can be whatever you want (e.g Kaiser with alpha 8). The DFT of a single bin is just the sum of products of the signal with e^(i*n*w) (where w is 50Hz at your sampling rate, and n the iterator).
There's probably simpler ways than that. It depends on what you're trying to be resilient to, how fast the signal moves, and whether you expect noise or other signals in the mix. If you're not trying to pick a signal out of a cacophony of others, you don't have to go to great lengths.
how to estimate the (power of a signal at a given frequency) vs. time in python