Frequency of a noisy signal with fixed width pulses My electricity meter has a front panel LED which pulses in proportional to the current energy rate. The frequency changes but the pulse width is set at 250ms.  Due to environmental conditions there's plenty of noise. Currently I'm sampling this at 10kHz, the pulses may be a few seconds apart.

I would like to filter these pulses and ignore anything else that wasn't 250ms long (ie the noise) and find the frequency of the train. Are there any suitable methods to achieve this?

My first thought was to differentiate the signal but this would be easily confused by large noise spikes.
I also wondered about testing it's coherence with a simulated pulse train, but as the frequency changes this would be potentially infinitely intensive AFAIK.

If I was to build an electronic solution I'd use edge comparators to find the pulses.  I'm wanting to use NumPy/matplotlib and deal with the signal in the frequency domain, if possible (purely as an educational exercise).
Not an easy problem to solve...

You could always cross-correlate the signal with a replica square wave and then apply simple thresholding to find the pulse locations. Then just count the peaks in a given interval to determine frequency.

I think the square wave nature of the signal could make the signal quite difficult to deal with in the frequency domain because of all the harmonics that comprise it.