Skip to content

Instantly share code, notes, and snippets.

@multivac61
Created December 18, 2015 11:05
Show Gist options
  • Save multivac61/dfdde2b142dfaa8b9224 to your computer and use it in GitHub Desktop.
Save multivac61/dfdde2b142dfaa8b9224 to your computer and use it in GitHub Desktop.
def freq_from_AC(sig, fs):
corr = np.correlate(sig, sig, mode='full')
corr = corr[corr.size/2:]
# Find the first low point
d = diff(corr)
# first point with pos.
start = find(d > 0)
# Find first peak after first low point
peak = argmax(corr[start:-2]) + start
crossings = interpolate(corr, peak)
return fs / px
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment