1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
| def real_solution(b, l, h, b1, l1, h1): level_1_accuracy = 0 level_2_accuracy = 0 level_3_accuracy = 0 level_4_accuracy = 0 pass_group = 0 alldatafirst, alldatasecond, alldatathird = [], [], [] X, Y, Z = BLH2XYZ(b, l, h) X1, Y1, Z1 = BLH2XYZ(b1, l1, h1)
real_distance = math.sqrt((X - X1) ** 2 + (Y - Y1) ** 2 + (Z - Z1) ** 2) * 1000 real_distance_horizon = math.sqrt((X - X1) ** 2 + (Y - Y1) ** 2) * 1000
path = filedialog.askopenfilename() with open(path, 'r') as f: lines = f.readlines() line = [line for line in lines if line.strip() and "RECV ASCII" not in line] total = len(line) - 19 for index in range(len(line) - 19): success = 0 pass_status = False for j in range(20): numbers = line[index + j].strip().split(',') if numbers[6] == '4': success += 1 if success >= 19: pass_group += 1 pass_status = True if pass_status and index % 20 == 0: for k in range(20): numbers = line[index + k].strip().split(',') alldatafirst.append(NEtoangle(numbers[2])) alldatasecond.append(NEtoangle(numbers[4])) alldatathird.append(float(numbers[9]) + float(numbers[11])) xyz = [BLH2XYZ(b, l, h) for b, l, h in zip(alldatafirst, alldatasecond, alldatathird)] measure_distance = [math.sqrt((x - X) ** 2 + (y - Y) ** 2 + (z - Z) ** 2) * 1000 for x, y, z in xyz] measure_distance_horizon = [math.sqrt((x - X) ** 2 + (y - Y) ** 2) * 1000 for x, y, z in xyz]
delta_distance = [x - real_distance for x in measure_distance] delta_distance_horizon = [x - real_distance_horizon for x in measure_distance_horizon]
deltaH = [(z - Z1) * 1000 for x, y, z in xyz]
pass_rate = pass_group / total workbook = xlwt.Workbook(encoding='utf-8') sheet1 = workbook.add_sheet("真误差") sheet1.write(0, 1, "掩膜通过率") sheet1.write(0, 2, f"{pass_rate * 100}%") sheet1.write(1, 1, "基线长真误差(mm)") sheet1.write(1, 2, "基线长水平方向真误差(mm)") sheet1.write(1, 3, "高程真误差(mm)") for i in range(1, len(delta_distance) + 1): sheet1.write(i + 1, 1, delta_distance[i - 1]) sheet1.write(i + 1, 2, delta_distance_horizon[i - 1]) sheet1.write(i + 1, 3, deltaH[i - 1]) save_path = r"D:\9999868真误差报告.xls" workbook.save(save_path) print(f"解算成功!\n文件已经保存为:{save_path}")
|