def get_data(self): if self.radarFileEdit.text() != "" and self.gpsFileEdit.text() != "": radarData = toolsradarcas.loadFile(self.radarFileEdit.text()) gpsData = toolsradarcas.loadFile(self.gpsFileEdit.text()) if type(radarData) == list and type(gpsData) == list: delta = abs(len(radarData) - len(gpsData)) if delta > len(radarData) * 0.1: resMsg = QMessageBoxSample.showDialog( self, "The gap of shape between radar and gps is:" + str(delta) + " Are you sure to merge them?", appconfig.WARNING) if resMsg != 0: return -1 if len(gpsData) > len(radarData): gpsData = gpsData[:len(radarData)] if len(gpsData) < len(radarData): radarData = radarData[:len(gpsData)] gprObj = GPRTrace(len(radarData[0])) gprData = gprObj.pack_GPR_data(gpsData, radarData) if type(gprData) == int: QMessageBoxSample.showDialog( self, "Exception while merging data to GPR...Error Code: " + str(gprData), appconfig.ERROR) return -1 else: gprFile = toolsradarcas.save_data(gprData, filepath=self.directory, format='GPR', times=1) if type(gprFile) == int: QMessageBoxSample.showDialog( self, "Save GPR file failed.. error code: " + str(gprFile), appconfig.ERROR) else: QMessageBoxSample.showDialog( self, "GPR DATA LENGTH : " + str(len(gprData)) + ", saved at " + str(gprFile), appconfig.INFO) return 0 else: QMessageBoxSample.showDialog( self, "Load file exception, the data is not a list..", appconfig.ERROR) return -1 else: QMessageBoxSample.showDialog( self, "You didn't specify the data to merge!", appconfig.ERROR) return -1
def test_radar_point_leak(self): global buffer sampleData = loadFile("./test_data/samplePoints.pkl") sampleData.append([0] * 1024) # 3 error sampleData.append([29268, 29268, 4095, 7863, 5620]) # 4 error sampleData.append([0] * 507) # 5 pass sampleData.append([0] * 512) # 6 error sampleData.append(title + [0] * 509) # 7pass temp = [0] * 512 + title + [0] * 509 sampleData.append(temp) # 8 pass assert len(sampleData) == 9, "sample radar data error!" title_index = search_radar_title(sampleData[0]) process(title_index, sampleData[0]) assert len(buffer) == 512 assert buffer[0:3] == title title_index = search_radar_title(sampleData[1]) assert title_index == -1 process(title_index, sampleData[1]) assert len(buffer) == 0 title_index = search_radar_title(sampleData[2]) assert title_index == 0 process(title_index, sampleData[2]) assert len(buffer) == 512 assert buffer[0:3] == title title_index = search_radar_title(sampleData[3]) assert title_index == -1 process(title_index, sampleData[3]) assert len(buffer) == 512 # Well.. I don't want to write all..Let it be.. """ Here an other way to test:
def test_load_radar_file(): a = toolsradarcas.loadFile("radarMocks512.pkl") print(len(a)) print(type(a)) print(type(a[0])) print(len(a[0])) print(a)
def get_data(self): if self.featsFileBtn.text() != "" and self.gpsFileEdit.text() != "": featsData = toolsradarcas.loadFile(self.featsFileEdit.text()) gpsData = toolsradarcas.loadFile(self.gpsFileEdit.text()) if type(featsData) == list and type(gpsData) == list \ and len(gpsData[0]) == 3 and type(featsData[0]) == np.ndarray: if len(featsData) > len(gpsData): QMessageBoxSample.showDialog( self, "The feat length is greater than gps length, that's impossible!", appconfig.ERROR) return -1 resMsg = QMessageBoxSample.showDialog( self, "Feats length: " + str(len(featsData)) + " GPS length: " + str(len(gpsData)) + ", would you like to continue? ", appconfig.INFO) if resMsg != 0: return -1 else: if self.allerRetourButton.isChecked(): return { "featsData": featsData, "gpsData": gpsData, "moveMode": ALLER_RETOUR } else: return { "featsData": featsData, "gpsData": gpsData, "moveMode": ALLER_ALLER } else: QMessageBoxSample.showDialog( self, "Load file exception, the data is illegal!", appconfig.ERROR) return -1 else: QMessageBoxSample.showDialog( self, "You didn't specify the data to load!", appconfig.ERROR) return -1
def test_compare_feats(): feats = toolsradarcas.loadFile("2021-01-07-18-33-37-feats1.pkl") print(type(feats)) print(len(feats))
def test_load_gps_file(filename=''): if filename == '': filename = '2020-12-31-12-47-45-gps.pkl' gpsData = toolsradarcas.loadFile(filename) return gpsData