numpy - Match filtering in Python -
i'm trying simple match filtering operation on data set in python (so tried doing conjugation followed convolution). however, error message showing in convolution function saying object deep desired array
. below code i'm using:
import numpy np import cpickle import matplotlib.pyplot plt open('meteor2.pkl', 'rb') f: data = cpickle.load(f) vlt = data['vlt'] mfilt=np.conjugate(vlt) mfilt1=np.convolve(vlt,mfilt,mode='full') #mfilt=np.conjugate(vlt) #mfilt1=np.convolve(vlt,mfilt,'same') r = data['r'] t = data['t'] codes = data['codes'] freqs = data['freqs'] ch0_db = 10*np.log10(np.abs(mfilt1[:, 0, :])**2) plt.figure() plt.imshow(ch0_db.t, vmin=0, origin='lower', cmap=plt.cm.coolwarm,aspect='auto') plt.title('all pulses') plt.figure() plt.imshow(ch0_db[3::5, :].t, vmin=0, origin='lower', cmap=plt.cm.coolwarm,aspect='auto') plt.title('minimum sidelobe coded-pulses') plt.show()
np.convolve
one-dimensional convolution, in line:
mfilt1=np.convolve(vlt,mfilt,mode='full')
you'll error if either vlt
or mfilt
not 1-d. example,
in [12]: x = np.array([[1,2,3]]) # x 2-d in [13]: y = np.array([1,2,3]) in [14]: np.convolve(x, y, mode='full') --------------------------------------------------------------------------- valueerror traceback (most recent call last) <ipython-input-14-9bf37a14877a> in <module>() ----> 1 np.convolve(x, y, mode='full') /home/warren/anaconda/lib/python2.7/site-packages/numpy/core/numeric.pyc in convolve(a, v, mode) 822 raise valueerror('v cannot empty') 823 mode = _mode_from_name(mode) --> 824 return multiarray.correlate(a, v[::-1], mode) 825 826 def outer(a,b): valueerror: object deep desired array
it looks want 2-d (or higher) convolution. scipy
has few options:
Comments
Post a Comment