# Representation of two uncoded pulses
pulse1 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
pulse2 = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
# Matched filter output (pulse correlated with itself)
correlator_output1 = np.correlate(pulse1,pulse1,mode='full');
correlator_output2 = np.correlate(pulse2,pulse2,mode='full');
# 13-baud Barker Code
c = 3e8;
i_baud = np.arange(-12,13,1) # x-index, peak centered at 0
baud_length_t = 10e-6 # baud length in seconds
baud_length_km = c * baud_length_t / 1e3; # baud length in km
i_baud_km = i_baud * baud_length_km; # x-index in km
# Plot output power vs range for each pulse
fig = pyplot.figure(figsize=(10,8))
ax = fig.add_subplot(111)
ax.plot(i_baud_km,correlator_output1);
ax.grid()
ax.set_xlabel('Range (km)');
ax.set_ylabel('Output Power (arbitrary units)');
ax.plot(i_baud_km,correlator_output2);
ax.set_title('Matched Filter Output');