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 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 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 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 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._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 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
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 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