Coder Social home page Coder Social logo

superhgq1 / gccestimating Goto Github PK

View Code? Open in Web Editor NEW

This project forked from siggigue/gccestimating

0.0 0.0 0.0 21 KB

Generalized Cross Correlation Estimator implementation based on numpy.

License: Mozilla Public License 2.0

Python 100.00%

gccestimating's Introduction

Generalized Cross Correlation (GCC) Estimates

Build Status

Coverage Status

Documentation Status

This project provides estimators for the generalized cross correlation according to Knapp and Carter 1976 [KC76].

Implemented Estimators (compare [KC76])

The generalized Estimator can be described by

where denotes the cross power spectrum of and . In this project, all estimates are computed in the spectral domain using the Wiener-Kinchin relations (e.g. ).

Following estimators are implemented:

  • Cross Correlation

  • Roth; same as the estimator describing the Wiener-Hopf filter

  • Smoothed Coherence Transform (SCOT):

  • PHAse Transform (PHAT):

  • Eckart

  • Hanan Thomson (HT), Maximum Likelihood estimator with

Insalling

This repo uses a pyproject.toml file generated with the dependency and package managing tool poetry.

This package can be installed with an up to date pip pip install .

or using poetry poetry install

otherwise use your own favorite way to install/use the code in your environment.

Example

import numpy as np
import matplotlib.pylab as plt
from gccestimating import GCC, corrlags

 # generate some noise signals
nsamp = 1024

noise1 =  0.5*np.random.randn(nsamp)
sig1 = np.zeros(nsamp) + noise1

noise2 =  0.5*np.random.randn(nsamp)
sig2 = np.zeros_like(sig1) + noise2

noise_both = np.random.randn(256)

sig1[:256] = noise_both
sig2[500:756] = noise_both

# create a lags array
lags = corrlags(2*nsamp-1, samplerate=1)

# Create the a GCC instance    
gcc = GCC(sig1, sig2)

def mkplot(est, p):
    plt.subplot(p)
    plt.plot(lags, est.sig, label=est.name)
    plt.legend()

# calculate the standard cc estimate
cc_est = gcc.cc()

# plot it using the mkplot function
mkplot(cc_est, 611)

# plot the other estimates
mkplot(gcc.scot(), 612)
mkplot(gcc.phat(), 613)
mkplot(gcc.roth(), 614)
mkplot(gcc.ht(), 615)
mkplot(gcc.eckart(noise_both, noise1, noise2), 616)

# compare cc to the timedomain based 
# implementation from Numpy
# you will see: very close (errors < 1e-13)
plt.figure()
plt.plot(np.correlate(sig1, sig2, 'full'))
plt.plot(gcc.cc())
plt.show()

References

[KC76]: Knapp and Carter, "The Generalized Correlation Method for Estimation of Time Delay", IEEE Trans. Acoust., Speech, Signal Processing, August, 1976

gccestimating's People

Contributors

siggigue avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.