Skip to content

Instantly share code, notes, and snippets.

@anielsen001
Created June 19, 2019 09:22
Show Gist options
  • Save anielsen001/e8d0b997de22e839d36315a1f73d0e0b to your computer and use it in GitHub Desktop.
Save anielsen001/e8d0b997de22e839d36315a1f73d0e0b to your computer and use it in GitHub Desktop.
Python implementation of wideband ambiguity function
# this is a python version of the wideband ambiguity function. A matlab version that it was ported from is below.
# https://dsp.stackexchange.com/questions/51372/how-to-calculate-the-ambiguity-function
import numpy as np
from scipy.interpolate import interp1d
from matplotlib import pylab as plt
tb = -1
tend = 1
dilation = 0.8
signal = np.zeros( 400,dtype = np.complex64 )
signal[100:300] = np.exp( 1J * 2 * np.pi * ( 4 * np.arange(200) + 0.01 * np.arange(200)**2 )/200 )
conj_rev_signal = np.conj( signal[::-1] )
time = np.linspace( tb, tend, len(signal) )
delay_time = np.linspace( 2*tb, 2*tend, 2*len(signal)-1 )
tau = np.linspace( dilation, 1./dilation, 512 )
out = np.zeros( [len(tau), 2*len(signal) -1] , dtype = np.complex64)
f = interp1d( time, conj_rev_signal, kind='cubic', fill_value='extrapolate' )
for i, t in enumerate(tau):
out[i,:] = np.convolve( signal, f( time * t ) )
plt.figure(); plt.pcolor( delay_time, tau, np.abs(out) )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment