So I am trying to use the shift theorem to to find the Fourier transform of two square waves that are separated by 30 pixels, but when I compare the Fourier transform of the two waves to the Fourier transform of one wave added to second wave using the shift theorem they don't match, and I have no idea why
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
plt.rcParams['image.cmap'] = 'magma'
import h5py
import scipy.fftpack
%matplotlib notebook
def magsq(arr):
return np.abs(arr*np.conj(arr))
fig1,ax1=plt.subplots()
l=512
test=np.zeros(l)
a=int(len(test)/2)
b=10
test[a-b:a+b]=1
test
ax1.plot(test)
test2=np.zeros(l)
test2[a-b:a+b]=1
test2[a+b+30:a+b+30+2*b]=1
ax1.plot(test2,'--')
FT=np.fft.fft(test)
x=np.linspace(0,l,l)
w = np.fft.fftfreq(30)
s=30
shift=FT*np.e**(1j*2*np.pi*x*s/l)
shifted=FT+shift
FT=np.fft.fftshift(FT)
shifted=np.fft.fftshift(shifted)
shiftedi=magsq(shifted)
FT2=np.fft.fft(test2)
FT2=np.fft.fftshift(FT2)
FT2I=magsq(FT2)
fig2,ax2=plt.subplots()
#ax2.plot(FTI)
ax2.plot(shiftedi)
ax2.plot(FT2I,'--')

