-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmatched_multiplepulses.py
72 lines (63 loc) · 1.9 KB
/
matched_multiplepulses.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
from scipy.fftpack import fft, ifft, fftshift
#from scipy import conj, linspace, exp
from scipy.constants import pi
from matplotlib import pyplot as plt
from numpy import linspace,exp,conj
def generate_signals(R,fc,BWf,t1,t2, num_samples):
t = linspace(t1, t2,num_samples) # Pulsewidth (s)
Td=t2-t1
c=3e8
t0=2*R/c
Kchirp = BWf/Td; #chirp pulse parameter
st = exp(1j*2*pi*(fc*t+Kchirp/2*(t**2))) # transmited signal
sr=exp(1j*2*pi*(fc*(t-t0)+Kchirp/2*(t-t0)**2)) # recieved signal
mean = 0
std = 1
GWN = numpy.random.normal(mean, std, size=num_samples)
sr=sr+GWN
return(st,sr,t)
def matched_filter(st,sr):
Hf = fft(conj(st))
Si = fft(sr)
so = fftshift(ifft(Si * Hf))
return(so)
st,sr,t=generate_signals(R=4e2 ,fc=8e8,BWf=10e6,t1=-2.5e-6,t2=2.5e-6, num_samples=400)
st2,sr2,t2=generate_signals(R=8e2 ,fc=8e8,BWf=10e6,t1=-2.5e-6,t2=2.5e-6, num_samples=400)
so=matched_filter(st,sr)
so2=matched_filter(st2,sr2)
buffer=numpy.zeros(400)
pulses=numpy.append(buffer,so)
pulses=numpy.append(pulses,buffer)
pulses=numpy.append(pulses,so2)
pulses=numpy.append(pulses,buffer)
plt.figure(1)
plt.plot(t,st.real)
plt.title('transmitted signal for range=4e2')
plt.xlabel('Time Delay (s)')
plt.ylabel('real part')
plt.show()
plt.figure(1)
plt.plot(t, sr.real)
plt.title('recieved signal for range=4e2')
plt.xlabel('Time Delay (s)')
plt.ylabel('real part')
plt.show()
plt.plot(t2, st2.real)
plt.title('transmitted signal for range=8e2')
plt.xlabel('Time Delay (s)')
plt.ylabel('real part')
plt.show()
plt.figure(1)
plt.plot(t2, sr2.real)
plt.title('recieved signal for range=8e2')
plt.xlabel('Time Delay (s)')
plt.ylabel('real part')
plt.show()
plt.figure(1)
totaltime=numpy.array(range(len(pulses)))*1.25e-8
plt.plot(totaltime,abs(pulses))
plt.title('matched filter output(allpulses)')
#plt.xlabel('Time Delay (s)')
plt.xlabel('Time(sec)')
plt.ylabel('Amplitude')
plt.show()