Beispiel #1
0
    def process_doppler(self, xr):
        z = np.transpose(
            xr[:, 0, :])  # consider fast and slow samples plan for antenna 0
        rx_hann = z * self.hann_matrix_range  # Hann windowing of dechirped samples
        NumberOfTargets = self.target_range_idx.size
        try:
            velocity_list = np.zeros(
                NumberOfTargets)  # initialize returned array of velocities
            #--- Perform a projection on the detcted range by DFT
            for k in range(NumberOfTargets):
                twiddle_factors = np.exp(
                    -2j * np.pi * self.target_range_idx[k] / self.N *
                    np.arange(self.N))  # DFT Twiddle factors
                projection_vector = np.dot(twiddle_factors, rx_hann)
                if self.is_root_music:
                    velocity = rp.root_music(
                        projection_vector, 1, 16, 1
                    )  #perform RootMusic on projected vector to estimate velocities components
                else:
                    velocity = rp.esprit(
                        projection_vector, 1, 16, 1
                    )  #perform Esprit on projected vector to estimate velocities components
                # return the first (most reliable component) of the velocities vector
                if len(velocity) > 0:
                    velocity_list[k] = velocity[0]
                else:
                    velocity_list[k] = 0
            self.targets_velocity = self.doppler_bin_size * velocity_list
            return True

        except ValueError as e:
            print("Doppler Process Failure: " + str(e))
            return False
Beispiel #2
0
    def process_radar_data_cube_doppler(xr, N, NN, hann_matrix, range_idx, cte_Dop, is_root_music):
        z = np.transpose(xr[:, 0, 0:1024]) # consider fast and slow samples plan for antenna 0
        rx_hann = z * hann_matrix # Hann windowing of dechirped samples
        NumberOfTargets = range_idx.size
        try:
            fx3 = np.zeros(NumberOfTargets)# initialize returned array of velocities
            #--- Perform a projection on the detcted range by DFT
            for k in range(NumberOfTargets):
                f_x1 = np.exp(-2j * np.pi * range_idx[k] / NN * np.arange(1024))# DFT Twiddle factors
                ProjVect = np.dot(f_x1,rx_hann)
                if is_root_music:
                    fx4 = rp.root_music(ProjVect, 1, 16, 1) #perform RootMusic on projected vector to estimate velocities components
                else:
                    fx4 = rp.esprit(ProjVect, 1, 16, 1) #perform Esprit on projected vector to estimate velocities components
                # return the first (most reliable component) of the velocities vector
                if len(fx4) > 0:
                    fx3[k] = fx4[0]
                else:
                    fx3[k] = 0

            My_cte = cte_Dop * NN # constant to convert returned values to m/s
            return My_cte * fx3
        except ValueError as e:
            #print("Doppler Process Failure: " + str(e))
            return []
Beispiel #3
0
    def process_radar_data_cube_aoa2(xr, N, NN, hann_matrix, velocities,
                                     n_rx_elements, is_root_music):
        z = np.transpose(xr[0, :, :])
        rx_hann_aoa = z * hann_matrix

        NumberOfRanges = velocities.size
        fx3 = np.zeros(NumberOfRanges)
        try:
            # --- Perform a projection on the detected velocities by DFT
            for k in range(NumberOfRanges):
                f_x1 = np.exp(-2j * np.pi * velocities[k] / NN *
                              np.arange(N))  # DFT Twiddle factors
                ProjVect = np.dot(f_x1, rx_hann_aoa)
                fx4 = []
                if is_root_music:
                    fx4 = rp.root_music(
                        ProjVect, 1, n_rx_elements - 4, 1
                    )  #perform RootMusic on projected vector to estimate AoA components
                else:
                    fx4 = rp.esprit(
                        ProjVect, 1, n_rx_elements - 4, 1
                    )  #perform Esprit on projected vector to estimate velocities components
                fx3[k] = fx4[
                    0]  #return the first (most reliable component) of the AoA vector

            return np.arcsin(
                -2 * fx3) / np.pi * 180  # angle returned in degrees
        except ValueError as e:
            print("AOA Process Failure: " + str(e))
            return []
Beispiel #4
0
    def process_aoa(self, xr):
        NumberOfRanges = self.target_range_idx.size
        aoa_list = []  #np.zeros(NumberOfRanges)
        aoa_estimates = []
        fxR = []
        fxV = []
        fxRCS = []
        fxPL = []
        #z = np.transpose(xr[0, :, 0:1024])  # consider dechirped samples for Sweep 0
        z = np.transpose(xr[0, :, :])
        rx_hann_aoa = z * self.hann_matrix_aoa  # Hann windowing of dechirped samples 1375x8
        print("hanning rx size = {0}".format(rx_hann_aoa.shape))
        kTargets = 0
        np_fft = pyfftw.interfaces.numpy_fft.fft(rx_hann_aoa, self.N_FFT, 0)

        try:
            # --- Perform a projection on the detected range by DFT
            for k in range(NumberOfRanges):
                # f_x1 = np.exp(-2j * np.pi * range_idx[k] / NN * np.arange(1024))# DFT Twiddle factors
                projection_vector = np_fft[int(
                    self.target_range_idx[k]), :]  #np.dot(f_x1, rx_hann_aoa)
                length_aic = rp.NumberOfTargetsAIC(projection_vector,
                                                   self.n_rx_elements - 4)
                #if is_root_music:
                aoa_estimates = rp.root_music(
                    projection_vector, length_aic, self.n_rx_elements - 4, 1
                )  #perform RootMusic on projected vector to estimate AoA components
                #else:
                #    fx4 = rp.esprit(projection_vector, L_AIC_new, self.n_rx_elements - 4, 1)#perform Esprit on projected vector to estimate velocities components
                #if len(fx4) > 0:
                #    fx3 = np.hstack((fx3,aoa_estimates[0]))
                #else:
                #    pass

                angles = np.arcsin(
                    -2. * aoa_estimates[0:length_aic]) / np.pi * 180.
                aoa_angles_truncated = np.extract(
                    np.abs(angles) <= 20, angles)  # 10 is azimuth FOV
                length_aic_truncated = len(aoa_angles_truncated)

                aoa_list = np.hstack(
                    (aoa_list, aoa_estimates[0:length_aic_truncated])
                )  # return the first (most reliable component) of the AoA vector
                for _ in range(length_aic_truncated):
                    fxR = np.hstack((fxR, self.targets_range[k]))
                    fxV = np.hstack((fxV, self.targets_velocity[k]))
                    fxRCS = np.hstack((fxRCS, self.targets_rcs[k]))
                    fxPL = np.hstack((fxPL, self.targets_rx_power[k]))
                kTargets = kTargets + length_aic_truncated
            aoa_degrees = np.arcsin(-2. * aoa_list) / np.pi * 180.0

            self.targets_range = fxR
            self.targets_velocity = fxV
            self.targets_aoa = aoa_degrees
            self.targets_rcs = fxRCS
            return True  # angle returned in degrees
        except ValueError as e:
            print("AOA Process Failure: " + str(e))
            return False
Beispiel #5
0
    def process_doppler(self, xr):
        xr_transposed = np.transpose(
            xr[:, 0, :])  # consider fast and slow samples plan for antenna 0
        rx_hanning = xr_transposed * self.hann_matrix_range  # Hann windowing of dechirped samples
        n_targets = self.target_range_idx.size
        try:
            velocity_list = np.zeros(n_targets)
            # --- Perform a projection on the detected range by DFT
            for k in range(n_targets):
                dft_twiddle_factors = np.exp(
                    -2j * np.pi * self.target_range_idx[k] /
                    self.samples_per_sweep * np.arange(self.samples_per_sweep))
                projection_vector = np.dot(dft_twiddle_factors, rx_hanning)
                n_freqs = 1
                velocity = rp.root_music(projection_vector, n_freqs, 16, 1)
                # return the first (most reliable component) of the velocities vector
                if len(velocity) > 0:
                    velocity_list[k] = velocity[0]
                else:
                    velocity_list[k] = 0
            self.targets_velocity = self.doppler_bin_size * velocity_list
            #print("targets_velocity = {0}".format(self.targets_velocity))
            return True

        except ValueError as e:
            logging.getLogger("sensor").error("Doppler Process Failure: " +
                                              str(e))
            return False
Beispiel #6
0
    def compute_range_and_indx(xr, N, NN, hann_matrix,cte_range):
        #if scipyio:
        #    scipyio.savemat('radar_cube__04_07_2018_001.mat', {'xr': xr})
        z = np.transpose(xr[:, 0, 0:1024])
        wx = hann_matrix[:, 0]
        wx = wx.reshape(1024, 1)
        [range_idx, toto] = np.array(rp.range_by_fft(z, wx, NN))
        range = cte_range * (range_idx+1)  # range converted in meters
        rcs_estimate = 10*np.log10(toto * (range ** 2)*(4*np.pi)**3 / NN**2)-34 # 25 is a Tuning constant chosen roughly
        rx_power = 10*np.log10(toto)

        return [range_idx, range, rcs_estimate, rx_power]
Beispiel #7
0
    def range_idx(self, xr):
        # if scipyio:
        #    scipyio.savemat('radar_cube__04_07_2018_001.mat', {'xr': xr})
        rx_signal_element_0 = np.transpose(xr[:, 0, :])

        hanning = self.hann_matrix_range[:, 0]
        hanning = hanning.reshape(self.samples_per_sweep, 1)
        rx_signal_shaped = rx_signal_element_0 * hanning  # 1375x64 2D-array Hann windowed dechirped samples (fast/slow plan)

        rx_signal = rx_signal_shaped[:, 0]
        self.rx_signal_real = rx_signal.imag  #used for display only

        self.rx_range_fft = pyfftw.interfaces.numpy_fft.fft(
            rx_signal_shaped, self.N_FFT,
            0)  # 1024 points FFT performed on the 64 1D-arrays

        target_range_idx, self.targets_rx_power = np.array(
            rp.range_by_fft(self.rx_range_fft))
        self.target_range_idx = target_range_idx.astype(int)
        #self.target_range_idx = ranges[0]
        #self.targets_rx_power = ranges[1]
        self.targets_range = 1.15 * self.bin_range * (
            target_range_idx + 1)  # range converted in meters
        self.targets_rcs = 10 * np.log10(
            self.targets_rx_power * (self.targets_range**2) *
            (4 * np.pi)**3 / self.N_FFT**2) - 43  # dBsm
        #self.target_rcs = 10 ** ((self.targets_rx_power + 30)/10) #dBsm
        self.targets_rx_power_db = 10 * np.log10(self.targets_rx_power) - 30.0
        # print("# radar targets {0}".format(len(self.targets_range)))
        # print("# targets range {0}".format(self.targets_range))
        # print("# targets power {0}".format(self.targets_rx_power_db))
        # print("# targets rcs {0}".format(self.targets_rcs))
        if len(target_range_idx) > 0:
            return True
        else:
            return False
Beispiel #8
0
    def process_radar_data_cube_aoa(xr, N,  NN, hann_matrix, range_idx, range, velocities, rcs_estimate, rx_power, n_rx_elements,nSweep, is_root_music):
        NumberOfRanges = range_idx.size
        fx33 = [] #np.zeros(NumberOfRanges)
        fx3 = []
        fxR = []
        fxV = []
        fxRCS = []
        fxPL = []
        z = np.transpose(xr[0, :, 0:1024])  # consider dechirped samples for Swwep 0
        rx_hann_aoa = z * hann_matrix  # Hann windowing of dechirped samples 1375x8
        kTargets = 0
        f_x1 = pyfftw.interfaces.numpy_fft.fft((rx_hann_aoa), NN, 0)
        #scipyio.savemat('z_04_07_2018_001.mat', {'z': z})
        #scipyio.savemat('hann_matrix_04_07_2018_001.mat', {'hann_matrix': hann_matrix})
        #scipyio.savemat('rx_hann_aoa_04_07_2018_001.mat', {'rx_hann': rx_hann_aoa})


        #scipyio.savemat('f_x1_04_07_2018_001.mat', {'f_x1': f_x1})
        #scipyio.savemat('range_idx_04_07_2018_001.mat', {'range_idx': range_idx})
        try:
            # --- Perform a projection on the detected range by DFT
            for k in range(NumberOfRanges):
                # f_x1 = np.exp(-2j * np.pi * range_idx[k] / NN * np.arange(1024))# DFT Twiddle factors
                ProjVect = f_x1[int(range_idx[k]),:] #np.dot(f_x1, rx_hann_aoa)
                L_AIC_new = rp.NumberOfTargetsAIC(ProjVect, n_rx_elements - 4)
                if is_root_music:
                    fx4 = rp.root_music(ProjVect, L_AIC_new, n_rx_elements - 4, 1)#perform RootMusic on projected vector to estimate AoA components
                else:
                    fx4 = rp.esprit(ProjVect, L_AIC_new, n_rx_elements - 4, 1)#perform Esprit on projected vector to estimate velocities components
                if len(fx4) > 0:
                    fx3 = np.hstack((fx3,fx4[0]))
                else:
                    pass

                angle1 = np.arcsin(-2. * fx4[0:L_AIC_new]) / np.pi * 180.
                angle = np.extract(np.abs(angle1) <= 20 , angle1) # 10 is azimuth FOV
                L_AIC_new = len(angle)

                fx33 = np.hstack((fx33, fx4[0:L_AIC_new]))  # return the first (most reliable component) of the AoA vector
                for klm in range(L_AIC_new):
                    fxR = np.hstack((fxR,range[k]))
                    fxV = np.hstack((fxV, velocities[k]))
                    fxRCS = np.hstack((fxRCS, rcs_estimate[k]))
                    fxPL = np.hstack((fxPL, rx_power[k]))
                kTargets = kTargets + L_AIC_new
            angle = np.arcsin(-2. * fx33) / np.pi * 180.

     #----To chose OMP Uncomment following code--------------------------------

        # NumberOfRanges = range_idx.size
        # fx3 = np.zeros(NumberOfRanges)
        #
        # try:
        #     z = np.transpose(xr[0, :, :])  # consider dechirped samples for Swwep 0
        #     rx_hann_aoa = z * hann_matrix  # Hann windowing of dechirped samples 1375x8
        #     f_x111 = pyfftw.interfaces.numpy_fft.fft(rx_hann_aoa, NN, 0)  # 1024x8
        #     if scipyio:
        #       scipyio.savemat('rx_hann__06_06_2018.mat', {'rx_hann_aoa': rx_hann_aoa})
        #       scipyio.savemat('f_x111__06_06_2018.mat', {'f_x111': f_x111})
        #       scipyio.savemat('Range_indx__06_06_2018.mat', {'range_idx': range_idx})
        #     for k in range(NumberOfRanges):  #
        #         # f_x1 = np.exp(-2j * np.pi * range_idx[k] / NN * np.arange(N))  # DFT Twiddle factors 1375
        #         for ks in range(1):
        #
        #             ProjVect1 = f_x111[int(range_idx[k]),:] # size = (8,)
        #             if ks == 0:
        #                 Xproj = np.transpose(ProjVect1)
        #             else:
        #                 Xproj = np.column_stack((Xproj, np.transpose(ProjVect1)))
        #             # Corr_Xproj = np.dot(Xproj, np.conj(np.transpose(Xproj)))
        #         if is_root_music:
        #             fx4 = rp.ML_AoA_Estimation(Xproj)
        #
        #         else:
        #             fx4 = rp.ML_AoA_Estimation(Xproj)
        #         fx3[k] = fx4  # return the first (most reliable component) of the AoA vector
        #         angle = fx3
            #logging.getLogger("sensor").debug("radar targets:{0}".format(len(fxR)))
            #if (len(fxR) > 20):
            #    fxR = fxR[0:20]
            #    fxV = fxV[0:20]
            #    angle = angle[0:20]
            #    fxRCS = fxRCS[0:20]
            #    fxPL = fxPL[0:20]

            return [fxR, fxV, angle, fxRCS, fxPL] # angle returned in degrees
        except ValueError as e:
            #print("AOA Process Failure: " + str(e))
            return []