def azimuthCompression(Srx, h): """ Method to apply matched filter h on azimuth dimension """ # pad received and emitted signals on common time stemp # to obtain common fft n1 = len(h) n2 = Srx.shape[0] Nsa = n1 + n2 - 1 ## Nsa2 = int(np.power(2.0, np.ceil(np.log2( Nsa )))) Nsa2 = Nsa if Nsa % 2 == 0 else Nsa+1 SrxMF=np.zeros((Nsa2, Srx.shape[1]),dtype=complex) hMF = np.concatenate((np.zeros(np.floor((Nsa2-n1)*0.5)), h, np.zeros(np.ceil((Nsa2-n1)*0.5)))) HMF = GC.fft(hMF) for i in range(Srx.shape[1]): col = Srx[:,i] colMF = np.concatenate((np.zeros(np.floor((Nsa2-len(col))*0.5)), col, np.zeros(np.ceil((Nsa2-len(col))*0.5)))) ColMF = GC.fft(colMF) ColMF = ColMF * HMF SrxMF[:,i] = GC.ifft(ColMF) return SrxMF
def rangeCompression(Srx, h): """ Method to apply matched filter h on range dimension """ # pad received and emitted signals on common time stemp # to obtain common fft n1 = len(h) n2 = Srx.shape[1] Nsa = n1 + n2 - 1 ## Nsa2 = int(np.power(2.0, np.ceil(np.log2( Nsa )))) Nsa2 = Nsa if Nsa % 2 == 0 else Nsa+1 SrxMF=np.zeros((Srx.shape[0], Nsa2),dtype=complex) hMF = np.concatenate((np.zeros(np.floor((Nsa2-n1)*0.5)), h, np.zeros(np.ceil((Nsa2-n1)*0.5)))) HMF = GC.fft(hMF) for i in range(Srx.shape[0]): row = Srx[i,:] rowMF = np.concatenate((np.zeros(np.floor((Nsa2-len(row))*0.5)), row, np.zeros(np.ceil((Nsa2-len(row))*0.5)))) RowMF = GC.fft(rowMF) RowMF = RowMF * HMF SrxMF[i,:] = GC.ifft(RowMF) return SrxMF
def rangeCompression(Srx, HMF): """ Range compression with freq-domain filter H(f) """ assert Srx.shape[1] == len(HMF), logPrint("Range dimension of the Srx is not equal to length of HMF") SrxMF=np.zeros(Srx.shape,dtype=complex) for i in range(Srx.shape[0]): data = Srx[i,:] DataMF = GC.fft(data) * HMF SrxMF[i,:] = GC.ifft(DataMF) return SrxMF
def rangeCompression(Srx, HMF): """ Range compression with freq-domain filter H(f) """ assert Srx.shape[1] == len(HMF), logPrint( "Range dimension of the Srx is not equal to length of HMF") SrxMF = np.zeros(Srx.shape, dtype=complex) for i in range(Srx.shape[0]): data = Srx[i, :] DataMF = GC.fft(data) * HMF SrxMF[i, :] = GC.ifft(DataMF) return SrxMF
def generateRefPhase(fAzimuthArray, fRangeArray, f0, Rref, Vref, K, Tp, tZero=0, etaZero=0): """ Phi_ref(f_eta, f_tau) = 4*pi*Rref/c * sqrt( (f0+f_tau)^2 - c^2 * f_eta^2 / (4*Vref^2) ) - tZero corresponds to the 'zero' range time of the signal range time sampling. tZero = (tmax+tmin)/2 - etaZero corresponds to the 'zero' azimuth time of the signal azimuth time sampling. etaZero = (etaMax+etaMin)/2 """ a = 4.0 * np.pi * Rref / GC.C fRangeMax = np.abs(K) * Tp ## fRangeMax = fRangeArray[-1] phase = np.zeros((len(fAzimuthArray), len(fRangeArray)), dtype=np.complex) for i, f in enumerate(fAzimuthArray): b = np.sqrt((f0 + fRangeArray)**2 - (0.5 * GC.C * f / Vref)**2) c = np.pi * fRangeArray**2 / K d = 2.0 * np.pi * tZero * fRangeArray d2 = 2.0 * np.pi * etaZero * f phase[i, :] = GC.rect( fRangeArray / fRangeMax) * np.exp(1j * a * b[:] + 1j * c[:] - 1j * d[:] - 1j * d2) return phase
def idealWa(x,x_c,deltaX): """ Antenna Beam pattern ideal : Wa(x) = rect( (x - x_c)/deltaX ) where deltaX - azimuth flight distance covered by satellite during elimination and reception deltaX = deltaT * V_{sat}, V_{sat} - satellite velocity """ return GC.rect( (x-x_c) / deltaX )
def received2DSignal(t, x, dist, tau_p, f_c, K_r, Wa, sigma=1) : """ SAR received signal at range time t and azimuth position x S_{out}(t,x) = rect( (t-2*d(x)/c) / tau_p) * Wa(x) * sigma * exp( -4*pi*1j* f_c * d(x)/c + 1j*pi*K_r*(t-2*d(x)/c)^2 ) """ tt = t - 2.0*dist(x) / GC.C phase = -4.0*f_c*dist(x) / GC.C + K_r*(tt**2) return GC.rect( tt/tau_p ) * Wa(x) * sigma * np.exp(1j*np.pi*phase)
def received2DSignal(t, x, dist, tau_p, f_c, K_r, Wa, sigma=1): """ SAR received signal at range time t and azimuth position x S_{out}(t,x) = rect( (t-2*d(x)/c) / tau_p) * Wa(x) * sigma * exp( -4*pi*1j* f_c * d(x)/c + 1j*pi*K_r*(t-2*d(x)/c)^2 ) """ tt = t - 2.0 * dist(x) / GC.C phase = -4.0 * f_c * dist(x) / GC.C + K_r * (tt**2) return GC.rect(tt / tau_p) * Wa(x) * sigma * np.exp(1j * np.pi * phase)
def compression(Srx, h, dim0): """ Matched filter alogorith with filter 'h' is applied on the image 'Srx' on the dimension 'dim' dim is 'range' or 'azimuth' """ dim = 1 if dim0 is 'range' else 0 if dim0 is 'azimuth' else -1 assert dim >= 0, logPrint("Parameter dim should be 'range' or 'azimuth'") # inverse of dim idim = np.abs(dim-1) # pad received and emitted signals on common time stemp # to obtain common fft n1 = len(h) n2 = Srx.shape[dim] Nsa = n1 + n2 - 1 ## Nsa2 = int(np.power(2.0, np.ceil(np.log2( Nsa )))) Nsa2 = Nsa if Nsa % 2 == 0 else Nsa+1 ## shape = (Srx.shape[0], Nsa2) if dim == 1 else (Nsa2, Srx.shape[1]) ## SrxMF=np.zeros(shape,dtype=complex) SrxMF=np.zeros(Srx.shape,dtype=complex) hMF = np.concatenate((np.zeros(np.floor((Nsa2-n1)*0.5)), h, np.zeros(np.ceil((Nsa2-n1)*0.5)))) HMF = GC.fft(hMF) m1 = np.floor((Nsa2-n2)*0.5) m2 = np.ceil((Nsa2-n2)*0.5) for i in range(Srx.shape[idim]): data = Srx[i,:] if dim == 1 else Srx[:,i] dataMF = np.concatenate((np.zeros(m1), data, np.zeros(m2))) DataMF = GC.fft(dataMF) DataMF = DataMF * HMF if dim == 1: SrxMF[i,:] = GC.ifft(DataMF)[n1/2:n1/2+n2] else: SrxMF[:,i] = GC.ifft(DataMF)[n1/2:n1/2+n2] return SrxMF
def compression(Srx, h, dim0): """ Matched filter alogorith with filter 'h' is applied on the image 'Srx' on the dimension 'dim' dim is 'range' or 'azimuth' """ dim = 1 if dim0 is 'range' else 0 if dim0 is 'azimuth' else -1 assert dim >= 0, logPrint("Parameter dim should be 'range' or 'azimuth'") # inverse of dim idim = np.abs(dim - 1) # pad received and emitted signals on common time stemp # to obtain common fft n1 = len(h) n2 = Srx.shape[dim] Nsa = n1 + n2 - 1 ## Nsa2 = int(np.power(2.0, np.ceil(np.log2( Nsa )))) Nsa2 = Nsa if Nsa % 2 == 0 else Nsa + 1 ## shape = (Srx.shape[0], Nsa2) if dim == 1 else (Nsa2, Srx.shape[1]) ## SrxMF=np.zeros(shape,dtype=complex) SrxMF = np.zeros(Srx.shape, dtype=complex) hMF = np.concatenate((np.zeros(np.floor( (Nsa2 - n1) * 0.5)), h, np.zeros(np.ceil((Nsa2 - n1) * 0.5)))) HMF = GC.fft(hMF) m1 = np.floor((Nsa2 - n2) * 0.5) m2 = np.ceil((Nsa2 - n2) * 0.5) for i in range(Srx.shape[idim]): data = Srx[i, :] if dim == 1 else Srx[:, i] dataMF = np.concatenate((np.zeros(m1), data, np.zeros(m2))) DataMF = GC.fft(dataMF) DataMF = DataMF * HMF if dim == 1: SrxMF[i, :] = GC.ifft(DataMF)[n1 / 2:n1 / 2 + n2] else: SrxMF[:, i] = GC.ifft(DataMF)[n1 / 2:n1 / 2 + n2] return SrxMF
def sarResp(t,y,d_a,E_y): """ The demodulated received data for a single point at slant-range and azimuth position of r_a and y_a, respectively is given as s_a(t,y) = E_t(t - 2*d_a(y)/c) * E_y(y - Y0) * exp( -4*pi*1j * f_c * d_a(y) / c + 1j * pi * K_r * (t - 2*d_a(y) / c)**2 ) E_t(t) = rect(t/T_p) T_p - chirp duration time E_y - antenna beam pattern """ tt = t - 2.0*d_a(y) / GC.C return GC.rect(tt / T_p) * E_y(y - Y0) * np.exp(-4.0*1j*np.pi * TSX.Freq * d_a(y) / GC.C + 1j*np.pi * TSX.K * (tt)**2 )
def sarResp(t, y, d_a, E_y): """ The demodulated received data for a single point at slant-range and azimuth position of r_a and y_a, respectively is given as s_a(t,y) = E_t(t - 2*d_a(y)/c) * E_y(y - Y0) * exp( -4*pi*1j * f_c * d_a(y) / c + 1j * pi * K_r * (t - 2*d_a(y) / c)**2 ) E_t(t) = rect(t/T_p) T_p - chirp duration time E_y - antenna beam pattern """ tt = t - 2.0 * d_a(y) / GC.C return GC.rect(tt / T_p) * E_y(y - Y0) * np.exp( -4.0 * 1j * np.pi * TSX.Freq * d_a(y) / GC.C + 1j * np.pi * TSX.K * (tt)**2)
def showEmittedSignal(tArray, Stx, signalName=""): ## Stx = emittedSignal(tArray,Sat.Tp, Sat.Freq, Sat.K) StxFFT = GC.fft(Stx) fArray = Sat.Freq + Sat.K * tArray plt.subplot(221) plt.title(signalName + " signal, Re") plt.plot(tArray, np.real(Stx)) plt.subplot(222) plt.title(signalName + " signal, Im") plt.plot(tArray, np.imag(Stx)) plt.subplot(223) plt.title(signalName + " signal FFT, module") plt.plot(fArray, np.absolute(StxFFT)) plt.subplot(224) plt.title(signalName + " signal FFT, phase") plt.plot(fArray, np.sign(np.absolute(StxFFT)) * np.angle(StxFFT)) plt.show()
def generateRefPhase(fAzimuthArray, fRangeArray, f0, Rref, Vref, K, Tp, tZero=0, etaZero=0): """ Phi_ref(f_eta, f_tau) = 4*pi*Rref/c * sqrt( (f0+f_tau)^2 - c^2 * f_eta^2 / (4*Vref^2) ) - tZero corresponds to the 'zero' range time of the signal range time sampling. tZero = (tmax+tmin)/2 - etaZero corresponds to the 'zero' azimuth time of the signal azimuth time sampling. etaZero = (etaMax+etaMin)/2 """ a = 4.0*np.pi*Rref/GC.C fRangeMax = np.abs(K)*Tp ## fRangeMax = fRangeArray[-1] phase = np.zeros((len(fAzimuthArray),len(fRangeArray)), dtype=np.complex) for i, f in enumerate(fAzimuthArray): b = np.sqrt( (f0 + fRangeArray)**2 - ( 0.5 * GC.C * f / Vref)**2 ) c = np.pi * fRangeArray**2 / K d = 2.0*np.pi* tZero * fRangeArray d2 = 2.0*np.pi* etaZero * f phase[i,:] = GC.rect(fRangeArray / fRangeMax) * np.exp(1j * a * b[:] + 1j*c[:] - 1j*d[:] - 1j*d2) return phase
def chirpSignal(t,tau_p,K_r): """ Emitted signal : S_{tx}(t) = rect(t/tau_p) * exp(1j*pi*K_r*t^2) """ return GC.rect(t / tau_p) * np.exp(1j*np.pi*K_r * t**2)
h=chirpSignal(tArray0, Sat.Tp, -Sat.K) Srx_RC = rangeCompression(Srx,h) ## Nsa = SrxMF.shape[1] ## tmin = tArrayR[0] - len(h)*0.5*dt ## tmax = tmin + dt*Nsa ## tArrayMF = np.arange(tmin,tmax,dt) ## tArrayMF = np.resize(tArrayMF,Nsa) showResponse(Srx_RC) # 4) Azimuth FFT SrxAF_RC = np.zeros(Srx_RC.shape, dtype=complex) for i in range(SrxAF_RC.shape[1]): # get range fixed column SrxAF_RC[:,i] = GC.fft(Srx_RC[:,i]) showResponse(SrxAF_RC) exit() # 5) Range cell migration Compensation (RCMC) # from range time to range distance : dist = lambda x : distSST(x, Sat.H, x_c, y_c) dR = deltaR(xArray, x_c, dist) dRI = np.round(dR).astype(np.int) Srx_RC_RCMC = rangeMigration(Srx_RC, dRI) # 6) Azimuth compression :
def chirp(t): """ SAR emitting pulse """ return GC.rect(t / T_p) * np.exp(1j * np.pi * (2.0 * TSX.Freq * t + TSX.K * t**2))
def compressRawData(self, showProgress=True): """ Apply RDA on raw data 1) Range compression 2) Range Cell Migration Correction 3) Azimuth compression Returns (compressed 2D array, azimuth positions, range time) """ rawData = self._rawData assert rawData is not None, logPrint( "Raw data should be computed ( using computeRawData() ) or provided as argument" ) assert self._dt is not None, logPrint( "Error : Simulator badly configured, dt is None") assert self._dx is not None, logPrint( "Error : Simulator badly configured, dx is None") assert self._xArray is not None, logPrint( "Error : Simulator badly configured, xArray is None") assert self._tArray is not None, logPrint( "Error : Simulator badly configured, tArray is None") Tp = self._platform.Tp Vsat = self._platform.Vsat K = self._platform.K PRF = self._platform.PRF H = self._platform.H Lambda = self._platform.Lambda # 1) Range compression : if showProgress: logPrint(" - Range compression ...") fRangeArray = GC.freq(rawData.shape[1], 1.0 / self._dt) HMF = GC.rect(fRangeArray / (np.abs(K) * Tp)) * np.exp( 1j * np.pi * fRangeArray**2 / K) # Multiply by a phase due to different range zero time ## tZero = self._tArray[len(self._tArray)/2] ## HMF = HMF * np.exp( -1j* 2.0 * np.pi * fRangeArray * tZero) procData = rangeCompression(rawData, HMF) HMF = None if self.verbose: showResponse(procData, None, 'Range compression') # 2) Azimuth FFT : if showProgress: logPrint(" -- Azimuth FFT ...") procDataAF = np.zeros(procData.shape, dtype=complex) for i in range(procDataAF.shape[1]): # get range fixed column procDataAF[:, i] = GC.fft(procData[:, i]) procData = procDataAF procDataAF = None fArray = GC.freq(procData.shape[0], self._platform.Vsat / self._dx) if self.verbose: ## showResponse(procData, [self._tArray[0], self._tArray[-1], fArray[0], fArray[-1]], 'Azimuth FFT') showResponse(procData, None, 'Azimuth FFT') # 3) Range migration : if showProgress: logPrint(" --- Range migration ...") Dfreq = np.sqrt(1.0 - (0.5 * Lambda * fArray / Vsat)**2) procData = rangeMigration2(procData, self._tArray, Dfreq) if self.verbose: ## showResponse(procData, [self._tArray[0], self._tArray[-1], fArray[0], fArray[-1]], 'RCMC') showResponse(procData, None, 'RCMC') # 4) Azimuth compression : if showProgress: logPrint(" ---- Azimuth compression ...") etaZero = self._xArray[len(self._xArray) / 2] / Vsat for i in range(procData.shape[1]): # Use H(f) = exp( 1j * 4 * pi * R0 * D(f) * f0 / c ) # HMF = np.exp(2 * np.pi * 1j * GC.C * self._tArray[i] / Lambda * Dfreq) # Multiply by a phase due to different azimuth zero time HMF = HMF * np.exp(-1j * 2.0 * np.pi * fArray * etaZero) procData[:, i] = procData[:, i] * HMF # 5) Azimuth IFFT if showProgress: logPrint(" ----- Azimuth IFFT ...") procDataAF = np.zeros(procData.shape, dtype=complex) for i in range(procDataAF.shape[1]): # get range fixed column procDataAF[:, i] = GC.ifft(procData[:, i]) procData = procDataAF procDataAF = None if self.verbose: showResponse( procData, [self._tArray[0], self._tArray[-1], fArray[0], fArray[-1]], 'Compressed image', False) return procData, self._xArray, self._tArray
def chirp(t): """ SAR emitting pulse """ return GC.rect(t / T_p) * np.exp(1j*np.pi*( 2.0* TSX.Freq * t + TSX.K * t**2 ) )
## plt.title("Chirp module") ## plt.plot(tArray,np.absolute(emitSig)) ## plt.subplot(122) ## plt.title("Chirp phase") ## plt.plot(tArray,np.angle(emitSig)) ## plt.show() # Radar-Target distance plot ## dArray = d_a_0(yArray) ## plt.plot(yArray,dArray,'-b') ## plt.show() # SAR raw data respSig = np.zeros((len(tArray), len(yArray)), dtype=complex) E_y = lambda y : GC.rect(y/Y_d) for index, t in enumerate(tArray): respSig[index,:] = sarResp(t, yArray[:],d_a_0,E_y) plt.subplot(121) plt.imshow(np.absolute(respSig)) plt.colorbar() plt.subplot(122) plt.imshow(np.angle(respSig)) plt.colorbar() plt.show()
import Sensors.GlobalVariablesCSK_HI as Sensor # Test xc = 0.0 yc = Sensor.H * np.tan(55.0 * np.pi / 180.0) # Absolute reference distance Rref = np.sqrt(Sensor.H**2 + yc**2) # Relative reference distance to Rmin ymin = Sensor.H * np.tan(54.995 * np.pi / 180.0) Rref2 = Rref - np.sqrt(Sensor.H**2 + ymin**2) Vref = Sensor.Vsat dt = 1.0/(1.4*np.abs(Sensor.K) * Sensor.Tp) dx = Vref/Sensor.PRF fRangeArray = GC.freq(2*1024, 1.0/dt) fAzimuthArray = GC.freq(2*1024, Vref/dx) phaseRef = generateRefPhase(fAzimuthArray, fRangeArray, Sensor.Freq, Rref2, Vref, Sensor.K, Sensor.Tp) Sref = GC.ifft2(phaseRef) showResponse(Sref) exit() ## filename = "C:\\VFomin_folder\\PISE_project\\SAR-GMTI\\Data\\CSK_RAW_0340_B001_2689_15971_3028_3027.npy" ## pt = [2689,15971] ## filename = "C:\\VFomin_folder\\PISE_project\\SAR-GMTI\\Data\\CSK_RAW_0340_B001_10255_8742_3195_3195.npy" ## pt = [10255,8742]
## win = [1842, 1500, 150, data.shape[0]-1500] ## win = [1742, 0, 250, data.shape[0]] ## index = 134 ## data = data[win[1]:win[1]+win[3], win[0]:win[0]+win[2]] ## yArray = yArray[win[0]:win[0]+win[2]] SARSim.showResponse(data, None, 'Compressed image - Ground range') # Decompress image at azimuth dataAF = azimuthFFT(data) fArray = GC.freq(dataAF.shape[0], Vsat/dx) dataAF = azimuthTransform(dataAF, 'decompress', fArray, yArray, Lambda, Vsat) # Compress at different velocities vset = np.arange(0.0, 10.0, .2) stack3D = np.zeros((data.shape[0], data.shape[1], len(vset)), dtype=np.float32) for i, v in enumerate(vset): print "Compress at velocity:", v dataAF2 = azimuthTransform(dataAF, 'compress', fArray, yArray, Lambda, Vsat, v) outData = azimuthIFFT(dataAF2) stack3D[:,:,i] = np.abs(outData[:,:]) # User interaction : data0 = stack3D[:,:,0] fig, ax = plt.subplots(1,2)
def compressRawData(self, showProgress=True): """ Apply RDA on raw data 1) Range compression 2) Range Cell Migration Correction 3) Azimuth compression Returns (compressed 2D array, azimuth positions, range time) """ rawData = self._rawData assert rawData is not None, logPrint( "Raw data should be computed ( using computeRawData() ) or provided as argument" ) assert self._dt is not None, logPrint( "Error : Simulator badly configured, dt is None") assert self._dx is not None, logPrint( "Error : Simulator badly configured, dx is None") assert self._xArray is not None, logPrint( "Error : Simulator badly configured, xArray is None") assert self._xSwath is not None, logPrint( "Error : Simulator badly configured, xSwath is None") assert self._tArray is not None, logPrint( "Error : Simulator badly configured, tArray is None") Tp = self._platform.Tp Vsat = self._platform.Vsat K = self._platform.K PRF = self._platform.PRF H = self._platform.H Lambda = self._platform.Lambda # 1) Range compression : if showProgress: logPrint(" - Range compression ...") ## # !!! VERY VERY SLOW !!! ## tArray0=np.arange(-Tp*0.5,Tp*0.5,self._dt) ## h = GC.chirpSignal(tArray0, Tp, -K) ## procData = compression(rawData, h, 'range') fRangeArray = GC.freq(rawData.shape[1], 1.0 / self._dt) HMF = GC.rect(fRangeArray / (np.abs(K) * Tp)) * np.exp( 1j * np.pi * fRangeArray**2 / K) procData = rangeCompression(rawData, HMF) HMF = None if self.verbose: showResponse(procData, None, 'Range compression') ## # TEMP ## yc = self._params[2][1] ## yArray = np.sqrt( (0.5 * GC.C * self._tArray)**2 - H**2 ) ## indices = [1050] ## for index in indices: ## f = plt.figure() ## f.suptitle("Range compression") ## plt.subplot(211) ## plt.plot(yArray-yc, np.abs(rawData[index,:])) ## plt.subplot(212) ## plt.plot(yArray-yc, np.abs(procData[index,:])) ## plt.show() ## # TEMP # 2) Azimuth FFT : if showProgress: logPrint(" -- Azimuth FFT ...") procDataAF = np.zeros(procData.shape, dtype=complex) for i in range(procDataAF.shape[1]): # get range fixed column procDataAF[:, i] = GC.fft(procData[:, i]) procData = procDataAF procDataAF = None ## fArray = np.fft.fftshift(np.fft.fftfreq( procData.shape[0], self._dx / self._platform.Vsat)) fArray = GC.freq(procData.shape[0], self._platform.Vsat / self._dx) if self.verbose: ## showResponse(procData, [self._tArray[0], self._tArray[-1], fArray[0], fArray[-1]], 'Azimuth FFT') showResponse(procData, None, 'Azimuth FFT') # 3) Range migration : if showProgress: logPrint(" --- Range migration ...") Dfreq = np.sqrt(1.0 - (0.5 * Lambda * fArray / Vsat)**2) procData = rangeMigration2(procData, self._tArray, Dfreq) if self.verbose: ## showResponse(procData, [self._tArray[0], self._tArray[-1], fArray[0], fArray[-1]], 'RCMC') showResponse(procData, None, 'RCMC') # 4) Azimuth compression : if showProgress: logPrint(" ---- Azimuth compression ...") ## xc = self._params[2][0] ## yc = self._params[2][1] ## Rc = np.sqrt(H**2 + yc**2) ## Ka = 2.0 / Lambda * 1.0 / Rc ## h = GC.rect((self._xArray-xc)/self._xSwath) * np.exp(1j * np.pi * Ka * (self._xArray - xc)**2) ## H = GC.fft(h) xc = self._xArray[len(self._xArray) / 2] for i in range(procData.shape[1]): # Small squint approximation ## Ka = 4.0 * Vsat**2 / Lambda / GC.C / self._tArray[i] ## hMF = GC.rect((self._xArray-xc)/self._xSwath) * np.exp(1j * np.pi * Ka/Vsat**2 * (self._xArray - xc)**2) ## HMF = GC.fft(hMF) # Use H(f) = exp( 1j * 4 * pi * R0 * D(f) * f0 / c ) HMF = np.exp(2 * np.pi * 1j * GC.C * self._tArray[i] / Lambda * Dfreq) procData[:, i] = procData[:, i] * HMF # 5) Azimuth IFFT if showProgress: logPrint(" ----- Azimuth IFFT ...") procDataAF = np.zeros(procData.shape, dtype=complex) for i in range(procDataAF.shape[1]): # get range fixed column procDataAF[:, i] = GC.ifft(procData[:, i]) procData = procDataAF procDataAF = None if self.verbose: showResponse( procData, [self._tArray[0], self._tArray[-1], fArray[0], fArray[-1]], 'Compressed image', False) return procData, self._xArray, self._tArray
import Sensors.GlobalVariablesCSK_HI as Sensor # Test xc = 0.0 yc = Sensor.H * np.tan(55.0 * np.pi / 180.0) # Absolute reference distance Rref = np.sqrt(Sensor.H**2 + yc**2) # Relative reference distance to Rmin ymin = Sensor.H * np.tan(54.995 * np.pi / 180.0) Rref2 = Rref - np.sqrt(Sensor.H**2 + ymin**2) Vref = Sensor.Vsat dt = 1.0 / (1.4 * np.abs(Sensor.K) * Sensor.Tp) dx = Vref / Sensor.PRF fRangeArray = GC.freq(2 * 1024, 1.0 / dt) fAzimuthArray = GC.freq(2 * 1024, Vref / dx) phaseRef = generateRefPhase(fAzimuthArray, fRangeArray, Sensor.Freq, Rref2, Vref, Sensor.K, Sensor.Tp) Sref = GC.ifft2(phaseRef) showResponse(Sref) exit() ## filename = "C:\\VFomin_folder\\PISE_project\\SAR-GMTI\\Data\\CSK_RAW_0340_B001_2689_15971_3028_3027.npy" ## pt = [2689,15971] ## filename = "C:\\VFomin_folder\\PISE_project\\SAR-GMTI\\Data\\CSK_RAW_0340_B001_10255_8742_3195_3195.npy" ## pt = [10255,8742]
def compressRawData(self, showProgress=True): """ Apply RDA on raw data 1) Range compression 2) Range Cell Migration Correction 3) Azimuth compression Returns (compressed 2D array, azimuth positions, range time) """ rawData = self._rawData assert rawData is not None, logPrint("Raw data should be computed ( using computeRawData() ) or provided as argument") assert self._dt is not None, logPrint("Error : Simulator badly configured, dt is None") assert self._dx is not None, logPrint("Error : Simulator badly configured, dx is None") assert self._xArray is not None, logPrint("Error : Simulator badly configured, xArray is None") assert self._tArray is not None, logPrint("Error : Simulator badly configured, tArray is None") Tp = self._platform.Tp Vsat = self._platform.Vsat K = self._platform.K PRF = self._platform.PRF H = self._platform.H Lambda = self._platform.Lambda # 1) Range compression : if showProgress: logPrint(" - Range compression ...") fRangeArray = GC.freq(rawData.shape[1], 1.0/self._dt) HMF = GC.rect(fRangeArray / (np.abs(K)*Tp)) * np.exp(1j*np.pi*fRangeArray**2 / K) # Multiply by a phase due to different range zero time ## tZero = self._tArray[len(self._tArray)/2] ## HMF = HMF * np.exp( -1j* 2.0 * np.pi * fRangeArray * tZero) procData = rangeCompression(rawData, HMF) HMF = None if self.verbose: showResponse(procData, None, 'Range compression') # 2) Azimuth FFT : if showProgress: logPrint(" -- Azimuth FFT ...") procDataAF = np.zeros(procData.shape, dtype=complex) for i in range(procDataAF.shape[1]): # get range fixed column procDataAF[:,i] = GC.fft(procData[:,i]) procData = procDataAF procDataAF = None fArray = GC.freq(procData.shape[0], self._platform.Vsat/self._dx) if self.verbose: ## showResponse(procData, [self._tArray[0], self._tArray[-1], fArray[0], fArray[-1]], 'Azimuth FFT') showResponse(procData, None, 'Azimuth FFT') # 3) Range migration : if showProgress: logPrint(" --- Range migration ...") Dfreq = np.sqrt(1.0 - (0.5 * Lambda * fArray / Vsat)**2) procData = rangeMigration2(procData, self._tArray, Dfreq) if self.verbose: ## showResponse(procData, [self._tArray[0], self._tArray[-1], fArray[0], fArray[-1]], 'RCMC') showResponse(procData, None, 'RCMC') # 4) Azimuth compression : if showProgress: logPrint(" ---- Azimuth compression ...") etaZero = self._xArray[len(self._xArray)/2] / Vsat for i in range(procData.shape[1]): # Use H(f) = exp( 1j * 4 * pi * R0 * D(f) * f0 / c ) # HMF = np.exp( 2*np.pi*1j * GC.C * self._tArray[i] / Lambda * Dfreq) # Multiply by a phase due to different azimuth zero time HMF = HMF * np.exp( -1j* 2.0 * np.pi * fArray * etaZero) procData[:,i] = procData[:,i] * HMF # 5) Azimuth IFFT if showProgress: logPrint(" ----- Azimuth IFFT ...") procDataAF = np.zeros(procData.shape, dtype=complex) for i in range(procDataAF.shape[1]): # get range fixed column procDataAF[:,i] = GC.ifft(procData[:,i]) procData = procDataAF procDataAF = None if self.verbose: showResponse(procData, [self._tArray[0], self._tArray[-1], fArray[0], fArray[-1]], 'Compressed image', False) return procData, self._xArray, self._tArray
def compressRawData2(self, showProgress=True): """ Omega-K compressing algorithm 1) FFT 2D 2) Reference Function Multiplication 3) Stolt interpolation 4) IFFT 2D Returns (compressed 2D array, azimuth positions, range time) """ rawData = self._rawData assert rawData is not None, logPrint("Raw data should be computed ( using computeRawData() ) or provided as argument") assert self._dt is not None, logPrint("Error : Simulator badly configured, dt is None") assert self._dx is not None, logPrint("Error : Simulator badly configured, dx is None") assert self._xArray is not None, logPrint("Error : Simulator badly configured, xArray is None") assert self._tArray is not None, logPrint("Error : Simulator badly configured, tArray is None") Tp = self._platform.Tp Vsat = self._platform.Vsat K = self._platform.K PRF = self._platform.PRF H = self._platform.H Lambda = self._platform.Lambda f0 = self._platform.Freq # 1) 2D freq domain if showProgress: logPrint(" - 2D FFT ...") fRangeArray = GC.freq(rawData.shape[1], 1.0/self._dt) fAzimuthArray = GC.freq(rawData.shape[0], Vsat/self._dx) procData = rawData procData = GC.fft2(procData) if self.verbose: showResponse(procData, None, '2D FFT') # 2) RFM if showProgress: logPrint(" -- RMF ...") # Reference distance tZero = self._tArray[len(self._tArray)/2] etaZero = self._xArray[len(self._xArray)/2] / Vsat Rref = 0.5 * GC.C * tZero Vref = Vsat phaseRef = generateRefPhase(fAzimuthArray, fRangeArray, f0, Rref, Vref, K, Tp, tZero, etaZero) procData = procData * phaseRef if self.verbose: ## showReImAbsPhaseResponse(phaseRef, None, 'Reference Phase') showResponse(procData, None, 'RFM') # 3) Stolt mapping if showProgress: logPrint(" --- Stolt mapping ...") # For azimuth line : for i, f in enumerate(fAzimuthArray): # # Here we need analytical inverse of Stolt mapping : # f' + f0 = sqrt( (f0 + f)^2 - (c * fEta / (2*Vsat))^2 ) # # f + f0 = + sqrt( (f0 + f')^2 + (c * fEta / (2*Vsat))^2 ) # nfRangeArray = -f0 + np.sqrt( (f0 + fRangeArray)**2 + ( 0.5 * GC.C * f / Vsat)**2 ) yRe = np.real(procData[i,:]) yIm = np.imag(procData[i,:]) yRe = np.interp(nfRangeArray, fRangeArray, yRe) yIm = np.interp(nfRangeArray, fRangeArray, yIm) procData[i,:] = yRe + 1j * yIm if self.verbose: showReImAbsPhaseResponse(procData, None, 'Stolt mapping') # 4) 2D IFFT if showProgress: logPrint(" ---- 2D IFFT ...") procData = GC.ifft2(procData) if self.verbose: showResponse(procData, None, '2D IFFT') return procData, self._xArray, self._tArray
tArray = np.arange(-T_p * 0.6, T_p * 0.8, T_p * 0.001) # Chirp signal ## emitSig=chirp(tArray) ## plt.subplot(121) ## plt.title("Chirp module") ## plt.plot(tArray,np.absolute(emitSig)) ## plt.subplot(122) ## plt.title("Chirp phase") ## plt.plot(tArray,np.angle(emitSig)) ## plt.show() # Radar-Target distance plot ## dArray = d_a_0(yArray) ## plt.plot(yArray,dArray,'-b') ## plt.show() # SAR raw data respSig = np.zeros((len(tArray), len(yArray)), dtype=complex) E_y = lambda y: GC.rect(y / Y_d) for index, t in enumerate(tArray): respSig[index, :] = sarResp(t, yArray[:], d_a_0, E_y) plt.subplot(121) plt.imshow(np.absolute(respSig)) plt.colorbar() plt.subplot(122) plt.imshow(np.angle(respSig)) plt.colorbar() plt.show()
def emittedSignal(t,tau_p, f_c, K_r): """ Emitted signal : S_{tx}(t) = rect(t/tau_p) * exp(2*pi*1j* f_c * t + 1j*pi*K_r*t^2) """ return GC.rect(t / tau_p) * np.exp(1j*np.pi*( 2.0* f_c * t + K_r * t**2 ) )
def compressRawData2(self, showProgress=True): """ Omega-K compressing algorithm 1) FFT 2D 2) Reference Function Multiplication 3) Stolt interpolation 4) IFFT 2D Returns (compressed 2D array, azimuth positions, range time) """ rawData = self._rawData assert rawData is not None, logPrint( "Raw data should be computed ( using computeRawData() ) or provided as argument" ) assert self._dt is not None, logPrint( "Error : Simulator badly configured, dt is None") assert self._dx is not None, logPrint( "Error : Simulator badly configured, dx is None") assert self._xArray is not None, logPrint( "Error : Simulator badly configured, xArray is None") assert self._tArray is not None, logPrint( "Error : Simulator badly configured, tArray is None") Tp = self._platform.Tp Vsat = self._platform.Vsat K = self._platform.K PRF = self._platform.PRF H = self._platform.H Lambda = self._platform.Lambda f0 = self._platform.Freq # 1) 2D freq domain if showProgress: logPrint(" - 2D FFT ...") fRangeArray = GC.freq(rawData.shape[1], 1.0 / self._dt) fAzimuthArray = GC.freq(rawData.shape[0], Vsat / self._dx) procData = rawData procData = GC.fft2(procData) if self.verbose: showResponse(procData, None, '2D FFT') # 2) RFM if showProgress: logPrint(" -- RMF ...") # Reference distance tZero = self._tArray[len(self._tArray) / 2] etaZero = self._xArray[len(self._xArray) / 2] / Vsat Rref = 0.5 * GC.C * tZero Vref = Vsat phaseRef = generateRefPhase(fAzimuthArray, fRangeArray, f0, Rref, Vref, K, Tp, tZero, etaZero) procData = procData * phaseRef if self.verbose: ## showReImAbsPhaseResponse(phaseRef, None, 'Reference Phase') showResponse(procData, None, 'RFM') # 3) Stolt mapping if showProgress: logPrint(" --- Stolt mapping ...") # For azimuth line : for i, f in enumerate(fAzimuthArray): # # Here we need analytical inverse of Stolt mapping : # f' + f0 = sqrt( (f0 + f)^2 - (c * fEta / (2*Vsat))^2 ) # # f + f0 = + sqrt( (f0 + f')^2 + (c * fEta / (2*Vsat))^2 ) # nfRangeArray = -f0 + np.sqrt((f0 + fRangeArray)**2 + (0.5 * GC.C * f / Vsat)**2) yRe = np.real(procData[i, :]) yIm = np.imag(procData[i, :]) yRe = np.interp(nfRangeArray, fRangeArray, yRe) yIm = np.interp(nfRangeArray, fRangeArray, yIm) procData[i, :] = yRe + 1j * yIm if self.verbose: showReImAbsPhaseResponse(procData, None, 'Stolt mapping') # 4) 2D IFFT if showProgress: logPrint(" ---- 2D IFFT ...") procData = GC.ifft2(procData) if self.verbose: showResponse(procData, None, '2D IFFT') return procData, self._xArray, self._tArray
def azimuthIFFT(dataAF): procData = np.zeros(dataAF.shape, dtype=complex) for i in range(procData.shape[1]): # get range fixed column procData[:,i] = GC.ifft(dataAF[:,i]) return procData
def compressRawData(self, showProgress=True): """ Apply RDA on raw data 1) Range compression 2) Range Cell Migration Correction 3) Azimuth compression Returns (compressed 2D array, azimuth positions, range time) """ rawData = self._rawData assert rawData is not None, logPrint("Raw data should be computed ( using computeRawData() ) or provided as argument") assert self._dt is not None, logPrint("Error : Simulator badly configured, dt is None") assert self._dx is not None, logPrint("Error : Simulator badly configured, dx is None") assert self._xArray is not None, logPrint("Error : Simulator badly configured, xArray is None") assert self._xSwath is not None, logPrint("Error : Simulator badly configured, xSwath is None") assert self._tArray is not None, logPrint("Error : Simulator badly configured, tArray is None") Tp = self._platform.Tp Vsat = self._platform.Vsat K = self._platform.K PRF = self._platform.PRF H = self._platform.H Lambda = self._platform.Lambda # 1) Range compression : if showProgress: logPrint(" - Range compression ...") ## # !!! VERY VERY SLOW !!! ## tArray0=np.arange(-Tp*0.5,Tp*0.5,self._dt) ## h = GC.chirpSignal(tArray0, Tp, -K) ## procData = compression(rawData, h, 'range') fRangeArray = GC.freq(rawData.shape[1], 1.0/self._dt) HMF = GC.rect(fRangeArray / (np.abs(K)*Tp)) * np.exp(1j*np.pi*fRangeArray**2 / K) procData = rangeCompression(rawData, HMF) HMF = None if self.verbose: showResponse(procData, None, 'Range compression') ## # TEMP ## yc = self._params[2][1] ## yArray = np.sqrt( (0.5 * GC.C * self._tArray)**2 - H**2 ) ## indices = [1050] ## for index in indices: ## f = plt.figure() ## f.suptitle("Range compression") ## plt.subplot(211) ## plt.plot(yArray-yc, np.abs(rawData[index,:])) ## plt.subplot(212) ## plt.plot(yArray-yc, np.abs(procData[index,:])) ## plt.show() ## # TEMP # 2) Azimuth FFT : if showProgress: logPrint(" -- Azimuth FFT ...") procDataAF = np.zeros(procData.shape, dtype=complex) for i in range(procDataAF.shape[1]): # get range fixed column procDataAF[:,i] = GC.fft(procData[:,i]) procData = procDataAF procDataAF = None ## fArray = np.fft.fftshift(np.fft.fftfreq( procData.shape[0], self._dx / self._platform.Vsat)) fArray = GC.freq(procData.shape[0], self._platform.Vsat/self._dx) if self.verbose: ## showResponse(procData, [self._tArray[0], self._tArray[-1], fArray[0], fArray[-1]], 'Azimuth FFT') showResponse(procData, None, 'Azimuth FFT') # 3) Range migration : if showProgress: logPrint(" --- Range migration ...") Dfreq = np.sqrt(1.0 - (0.5 * Lambda * fArray / Vsat)**2) procData = rangeMigration2(procData, self._tArray, Dfreq) if self.verbose: ## showResponse(procData, [self._tArray[0], self._tArray[-1], fArray[0], fArray[-1]], 'RCMC') showResponse(procData, None, 'RCMC') # 4) Azimuth compression : if showProgress: logPrint(" ---- Azimuth compression ...") ## xc = self._params[2][0] ## yc = self._params[2][1] ## Rc = np.sqrt(H**2 + yc**2) ## Ka = 2.0 / Lambda * 1.0 / Rc ## h = GC.rect((self._xArray-xc)/self._xSwath) * np.exp(1j * np.pi * Ka * (self._xArray - xc)**2) ## H = GC.fft(h) xc = self._xArray[len(self._xArray)/2] for i in range(procData.shape[1]): # Small squint approximation ## Ka = 4.0 * Vsat**2 / Lambda / GC.C / self._tArray[i] ## hMF = GC.rect((self._xArray-xc)/self._xSwath) * np.exp(1j * np.pi * Ka/Vsat**2 * (self._xArray - xc)**2) ## HMF = GC.fft(hMF) # Use H(f) = exp( 1j * 4 * pi * R0 * D(f) * f0 / c ) HMF = np.exp( 2*np.pi*1j * GC.C * self._tArray[i] / Lambda * Dfreq) procData[:,i] = procData[:,i] * HMF # 5) Azimuth IFFT if showProgress: logPrint(" ----- Azimuth IFFT ...") procDataAF = np.zeros(procData.shape, dtype=complex) for i in range(procDataAF.shape[1]): # get range fixed column procDataAF[:,i] = GC.ifft(procData[:,i]) procData = procDataAF procDataAF = None if self.verbose: showResponse(procData, [self._tArray[0], self._tArray[-1], fArray[0], fArray[-1]], 'Compressed image', False) return procData, self._xArray, self._tArray