def run(xmlFile): (gcpsXYZ, cpsXYZ) = utils_execution.readGCPXMLFile(xmlFile) fig = plt.figure(figsize=(27, 15)) fig.subplots_adjust(left=0.01, bottom=0.01, right=0.99, top=0.99, wspace=0.005, hspace=0.005) ax = fig.add_subplot(1, 1, 1, projection='3d') (xs, ys, zs) = ([], [], []) for gcp in gcpsXYZ: (x, y, z) = gcpsXYZ[gcp] xs.append(x) ys.append(y) zs.append(z) ax.text(x, y, z, gcp, color='blue', fontsize=6) ax.scatter(xs, ys, zs, marker='o', c='blue') (xs, ys, zs) = ([], [], []) for cp in cpsXYZ: (x, y, z) = cpsXYZ[cp] xs.append(x) ys.append(y) zs.append(z) ax.text(x, y, z, cp, color='red', fontsize=6) ax.scatter(xs, ys, zs, marker='o', c='red') ax.set_xlabel('X', fontsize=8, labelpad=-5) ax.set_ylabel('Y', fontsize=8, labelpad=-5) ax.set_zlabel('Z', fontsize=8, labelpad=-5) ax.tick_params(labelsize=6, direction='out', pad=-1) ax.tick_params(axis='z', labelsize=0, pad=-3) blue_proxy = plt.Rectangle((0, 0), 1, 1, fc="b") red_proxy = plt.Rectangle((0, 0), 1, 1, fc="r") ax.legend([blue_proxy, red_proxy], ['GCPs', 'CPs'], loc='upper right', bbox_to_anchor=(0.9, 0.9), prop={'size': 6}) ax.view_init(elev=-90., azim=0.) plt.show()
def run(xmlFile): (gcpsXYZ, cpsXYZ) = utils_execution.readGCPXMLFile(xmlFile) fig = plt.figure(figsize=(27, 15)) fig.subplots_adjust( left=0.01, bottom=0.01, right=0.99, top=0.99, wspace=0.005, hspace=0.005) ax = fig.add_subplot(1, 1, 1, projection='3d') (xs, ys, zs) = ([], [], []) for gcp in gcpsXYZ: (x, y, z) = gcpsXYZ[gcp] xs.append(x) ys.append(y) zs.append(z) ax.text(x, y, z, gcp, color='blue', fontsize=6) ax.scatter(xs, ys, zs, marker='o', c='blue') (xs, ys, zs) = ([], [], []) for cp in cpsXYZ: (x, y, z) = cpsXYZ[cp] xs.append(x) ys.append(y) zs.append(z) ax.text(x, y, z, cp, color='red', fontsize=6) ax.scatter(xs, ys, zs, marker='o', c='red') ax.set_xlabel('X', fontsize=8, labelpad=-5) ax.set_ylabel('Y', fontsize=8, labelpad=-5) ax.set_zlabel('Z', fontsize=8, labelpad=-5) ax.tick_params(labelsize=6, direction='out', pad=-1) ax.tick_params(axis='z', labelsize=0, pad=-3) blue_proxy = plt.Rectangle((0, 0), 1, 1, fc="b") red_proxy = plt.Rectangle((0, 0), 1, 1, fc="r") ax.legend([blue_proxy, red_proxy], ['GCPs', 'CPs'], loc='upper right', bbox_to_anchor=(0.9, 0.9), prop={'size': 6}) ax.view_init(elev=-90., azim=0.) plt.show()
def run(xmlFile, foldersNames): (gcpsXYZ, cpsXYZ) = utils_execution.readGCPXMLFile(xmlFile) fig = plt.figure(figsize=(27, 15)) fig.subplots_adjust( left=0.01, bottom=0.01, right=0.99, top=0.99, wspace=0.005, hspace=0.005) gcpsUVW = {} cpsUVW = {} foldersNames = foldersNames.split(',') numFolders = len(foldersNames) for i in range(numFolders): if foldersNames[i].endswith('/'): foldersNames[i] = foldersNames[i][:-1] nY = int(math.ceil(math.sqrt(numFolders))) nX = int(math.ceil(numFolders / nY)) for i in range(numFolders): folderName = foldersNames[i] if folderName.endswith('/'): folderName = folderName[:-1] logFileName = folderName + '/Campari.log' if os.path.isfile(logFileName): lines = open(logFileName, 'r').read().split('\n') gcpsUVW[folderName] = {} cpsUVW[folderName] = {} eiLinesIndexes = [] for j in range(len(lines)): if lines[j].count('End Iter'): eiLinesIndexes.append(j) for j in range(eiLinesIndexes[-2], len(lines)): line = lines[j] if line.count('Dist'): gcp = line.split()[1] fields = line.split('[')[-1].split(']')[0].split(',') u = float(fields[0]) v = float(fields[1]) w = float(fields[2]) d = float(line.split('Dist')[-1].split()[0].split('=')[-1]) if gcp in cpsXYZ: cpsUVW[folderName][gcp] = (u, v, w, d) elif gcp in gcpsXYZ: gcpsUVW[folderName][gcp] = (u, v, w, d) else: raise Exception('GCP/CP: ' + gcp + ' not found') ax = fig.add_subplot(nX, nY, i + 1, projection='3d') (xs, ys, zs, us, vs, ws) = ([], [], [], [], [], []) for gcp in gcpsUVW[folderName]: (x, y, z) = gcpsXYZ[gcp] (u, u, w, _) = gcpsUVW[folderName][gcp] xs.append(x) ys.append(y) zs.append(z) us.append(u) vs.append(v) ws.append(w) # print(x, y, z, u, v, w) ax.text(x, y, z, gcp, color='blue', fontsize=6) ax.scatter(xs, ys, zs, marker='o', c='blue') ax.quiver( xs, ys, zs, us, vs, ws, length=1.0, pivot="tail", color='blue') (xs, ys, zs, us, vs, ws) = ([], [], [], [], [], []) for cp in cpsUVW[folderName]: (x, y, z) = cpsXYZ[cp] (u, u, w, _) = cpsUVW[folderName][cp] xs.append(x) ys.append(y) zs.append(z) us.append(u) vs.append(v) ws.append(w) # print(x, y, z, u, v, w) ax.text(x, y, z, cp, color='red', fontsize=6) ax.scatter(xs, ys, zs, marker='o', c='red') ax.quiver( xs, ys, zs, us, vs, ws, length=1.0, pivot="tail", color='red') ax.set_xlabel('X', fontsize=8, labelpad=-5) ax.set_ylabel('Y', fontsize=8, labelpad=-5) ax.set_zlabel('Z', fontsize=8, labelpad=-5) ax.set_title(folderName, fontsize=8) ax.tick_params(labelsize=6, direction='out', pad=-1) ax.tick_params(axis='z', labelsize=0, pad=-3) blue_proxy = plt.Rectangle((0, 0), 1, 1, fc="b") red_proxy = plt.Rectangle((0, 0), 1, 1, fc="r") ax.legend([blue_proxy, red_proxy], ['GCPs', 'CPs'], loc='upper right', bbox_to_anchor=(0.9, 0.9), prop={'size': 6}) ax.view_init(elev=-90., azim=0.) # ax.set_zlim(1,6) table = [] for gcp in sorted(gcpsXYZ): row = [gcp, ] for i in range(numFolders): folderName = foldersNames[i] if folderName in gcpsUVW and gcp in gcpsUVW[folderName]: row.append(gcpsUVW[folderName][gcp][-1]) else: row.append('-') table.append(row) print("########################") print("Campari Dist per GCP/CP") print("########################") header = ['GCP', ] + foldersNames print(tabulate(table, headers=header)) print() table = [] for cp in sorted(cpsXYZ): row = [cp, ] for i in range(numFolders): folderName = foldersNames[i] if folderName in cpsUVW and cp in cpsUVW[folderName]: row.append(cpsUVW[folderName][cp][-1]) else: row.append('-') table.append(row) header = ['CP', ] + foldersNames print(tabulate(table, headers=header)) print() plt.show()
def run(xmlFile, foldersNames): (gcpsXYZ, cpsXYZ) = utils_execution.readGCPXMLFile(xmlFile) tableGCPs = [] tableCPs = [] tableKOs = [] for folderName in foldersNames.split(','): if folderName.endswith('/'): folderName = folderName[:-1] logFileName = folderName + '/Campari.log' if os.path.isfile(logFileName): lines = open(logFileName, 'r').read().split('\n') (dsGCPs, _, _, _) = ([], [], [], []) (dsCPs, _, _, _) = ([], [], [], []) eiLinesIndexes = [] for j in range(len(lines)): if lines[j].count('End Iter'): eiLinesIndexes.append(j) gcpKOs = [] for j in range(eiLinesIndexes[-2], len(lines)): line = lines[j] if line.count('Dist'): gcp = line.split()[1] d = float(line.split('Dist')[-1].split()[0].split('=')[-1]) if gcp in gcpsXYZ: dsGCPs.append(d) elif gcp in cpsXYZ: dsCPs.append(d) else: print('GCP/CP: ' + gcp + ' not found') sys.exit(1) elif line.count('NOT OK'): gcpKOs.append(line.split(' ')[4]) if len(gcpKOs): tableKOs.append([folderName, ','.join(gcpKOs)]) else: tableKOs.append([folderName, '-']) pattern = "%0.4f" if len(dsGCPs): tableGCPs.append([folderName, pattern % numpy.min(dsGCPs), pattern % numpy.max(dsGCPs), pattern % numpy.mean(dsGCPs), pattern % numpy.std(dsGCPs), pattern % numpy.median(dsGCPs)]) else: tableGCPs.append([folderName, '-', '-', '-', '-', '-']) if len(dsCPs): tableCPs.append([folderName, pattern % numpy.min(dsCPs), pattern % numpy.max(dsCPs), pattern % numpy.mean(dsCPs), pattern % numpy.std(dsCPs), pattern % numpy.median(dsCPs)]) else: tableCPs.append([folderName, '-', '-', '-', '-', '-']) else: tableKOs.append([folderName, '-']) tableGCPs.append([folderName, '-', '-', '-', '-', '-']) tableCPs.append([folderName, '-', '-', '-', '-', '-']) print("########################") print("Campari Dists statistics") print("########################") print('KOs') print(tabulate(tableKOs, headers=['#Name', '', ])) print() header = ['#Name', 'Min', 'Max', 'Mean', 'Std', 'Median'] # header = ['#Name', 'MeanDist', 'StdDist', 'MeanXDist', 'StdXDist', # 'MeanYDist', 'StdYDist', 'MeanZDist', 'StdZDist'] print('GCPs') print(tabulate(tableGCPs, headers=header)) print() print('CPs') print(tabulate(tableCPs, headers=header)) print()
def run(xmlFile, foldersNames): (gcpsXYZ, cpsXYZ) = utils_execution.readGCPXMLFile(xmlFile) numGCPs = len(gcpsXYZ) numCPs = len(cpsXYZ) numPs = numGCPs + numCPs tableGCPs = [] tableCPs = [] tableKOs = [] for folderName in foldersNames.split(','): if folderName.endswith('/'): folderName = folderName[:-1] logFileName = folderName + '/GCPBascule.log' if os.path.isfile(logFileName): lines = open(logFileName, 'r').read().split('\n') (dsGCPs, usGCPs, vsGCPs, wsGCPs) = ([], [], [], []) (dsCPs, usCPs, vsCPs, wsCPs) = ([], [], [], []) pKOs = [] for line in lines: if line.count('Dist'): gcp = line.split()[1] fields = line.split('[')[-1].split(']')[0].split(',') # u = math.fabs(float(fields[0])) # v = math.fabs(float(fields[1])) # w = math.fabs(float(fields[2])) d = float(line.split('Dist')[-1].split()[0].split('=')[-1]) if gcp in gcpsXYZ: dsGCPs.append(d) # usGCPs.append(u) # vsGCPs.append(v) # wsGCPs.append(w) elif gcp in cpsXYZ: dsCPs.append(d) # usCPs.append(u) # vsCPs.append(v) # wsCPs.append(w) else: raise Exception('GCP/CP: ' + gcp + ' not found') elif line.count('NOT OK'): pKOs.append(line.split(' ')[4]) numGCPsFile = len(dsGCPs) numCPsFile = len(dsCPs) numPKOsFile = len(pKOs) numPsFile = numGCPsFile + numCPsFile + numPKOsFile if numPsFile != numPs: print("WARNING: number of GCPs/CPs (" + str(numPsFile) + ") processed in " + folderName + ' does not match the number in ' + xmlFile + "(" + str(numPs) + ")") if len(pKOs): tableKOs.append([folderName, ','.join(pKOs)]) else: tableKOs.append([folderName, '-']) pattern = "%0.4f" if len(dsGCPs): tableGCPs.append([ folderName, pattern % numpy.min(dsGCPs), pattern % numpy.max(dsGCPs), pattern % numpy.mean(dsGCPs), pattern % numpy.std(dsGCPs), pattern % numpy.median(dsGCPs) ]) #tableGCPs.append([folderName, pattern % numpy.mean(dsGCPs), pattern % numpy.std(dsGCPs), pattern % numpy.mean(usGCPs), pattern % numpy.std(usGCPs), pattern % numpy.mean(vsGCPs), pattern % numpy.std(vsGCPs), pattern % numpy.mean(wsGCPs), pattern % numpy.std(wsGCPs)]) else: tableGCPs.append([folderName, '-', '-', '-', '-', '-']) #tableGCPs.append([folderName, '-', '-', '-', '-', '-', '-', '-', '-']) if len(dsCPs): tableCPs.append([ folderName, pattern % numpy.min(dsCPs), pattern % numpy.max(dsCPs), pattern % numpy.mean(dsCPs), pattern % numpy.std(dsCPs), pattern % numpy.median(dsCPs) ]) #tableCPs.append([folderName, pattern % numpy.mean(dsCPs), pattern % numpy.std(dsCPs), pattern % numpy.mean(usCPs), pattern % numpy.std(usCPs), pattern % numpy.mean(vsCPs), pattern % numpy.std(vsCPs), pattern % numpy.mean(wsCPs), pattern % numpy.std(wsCPs)]) else: tableCPs.append([folderName, '-', '-', '-', '-', '-']) #tableCPs.append([folderName, '-', '-', '-', '-', '-', '-', '-', '-']) else: tableKOs.append([folderName, '-']) tableGCPs.append([folderName, '-', '-', '-', '-', '-']) #tableGCPs.append([folderName, '-', '-', '-', '-', '-', '-', '-', '-']) tableCPs.append([folderName, '-', '-', '-', '-', '-']) #tableCPs.append([folderName, '-', '-', '-', '-', '-', '-', '-', '-']) print("###########################") print("GCPBascule Dists statistics") print("###########################") print('KOs') print(tabulate(tableKOs, headers=[ '#Name', '', ])) print() header = ['#Name', 'Min', 'Max', 'Mean', 'Std', 'Median'] # header = ['#Name', 'MeanDist', 'StdDist', 'MeanXDist', 'StdXDist', # 'MeanYDist', 'StdYDist', 'MeanZDist', 'StdZDist'] print('GCPs') print(tabulate(tableGCPs, headers=header)) print() print('CPs') print(tabulate(tableCPs, headers=header)) print()
def run(xmlFile, foldersNames): (gcpsXYZ, cpsXYZ) = utils_execution.readGCPXMLFile(xmlFile) fig = plt.figure(figsize=(27, 15)) fig.subplots_adjust(left=0.01, bottom=0.01, right=0.99, top=0.99, wspace=0.005, hspace=0.005) gcpsUVW = {} cpsUVW = {} foldersNames = foldersNames.split(',') numFolders = len(foldersNames) for i in range(numFolders): if foldersNames[i].endswith('/'): foldersNames[i] = foldersNames[i][:-1] nY = int(math.ceil(math.sqrt(numFolders))) nX = int(math.ceil(numFolders / nY)) for i in range(numFolders): folderName = foldersNames[i] if folderName.endswith('/'): folderName = folderName[:-1] logFileName = folderName + '/Campari.log' if os.path.isfile(logFileName): lines = open(logFileName, 'r').read().split('\n') gcpsUVW[folderName] = {} cpsUVW[folderName] = {} eiLinesIndexes = [] for j in range(len(lines)): if lines[j].count('End Iter'): eiLinesIndexes.append(j) for j in range(eiLinesIndexes[-2], len(lines)): line = lines[j] if line.count('Dist'): gcp = line.split()[1] fields = line.split('[')[-1].split(']')[0].split(',') u = float(fields[0]) v = float(fields[1]) w = float(fields[2]) d = float(line.split('Dist')[-1].split()[0].split('=')[-1]) if gcp in cpsXYZ: cpsUVW[folderName][gcp] = (u, v, w, d) elif gcp in gcpsXYZ: gcpsUVW[folderName][gcp] = (u, v, w, d) else: raise Exception('GCP/CP: ' + gcp + ' not found') ax = fig.add_subplot(nX, nY, i + 1, projection='3d') (xs, ys, zs, us, vs, ws) = ([], [], [], [], [], []) for gcp in gcpsUVW[folderName]: (x, y, z) = gcpsXYZ[gcp] (u, u, w, _) = gcpsUVW[folderName][gcp] xs.append(x) ys.append(y) zs.append(z) us.append(u) vs.append(v) ws.append(w) # print(x, y, z, u, v, w) ax.text(x, y, z, gcp, color='blue', fontsize=6) ax.scatter(xs, ys, zs, marker='o', c='blue') ax.quiver(xs, ys, zs, us, vs, ws, length=1.0, pivot="tail", color='blue') (xs, ys, zs, us, vs, ws) = ([], [], [], [], [], []) for cp in cpsUVW[folderName]: (x, y, z) = cpsXYZ[cp] (u, u, w, _) = cpsUVW[folderName][cp] xs.append(x) ys.append(y) zs.append(z) us.append(u) vs.append(v) ws.append(w) # print(x, y, z, u, v, w) ax.text(x, y, z, cp, color='red', fontsize=6) ax.scatter(xs, ys, zs, marker='o', c='red') ax.quiver(xs, ys, zs, us, vs, ws, length=1.0, pivot="tail", color='red') ax.set_xlabel('X', fontsize=8, labelpad=-5) ax.set_ylabel('Y', fontsize=8, labelpad=-5) ax.set_zlabel('Z', fontsize=8, labelpad=-5) ax.set_title(folderName, fontsize=8) ax.tick_params(labelsize=6, direction='out', pad=-1) ax.tick_params(axis='z', labelsize=0, pad=-3) blue_proxy = plt.Rectangle((0, 0), 1, 1, fc="b") red_proxy = plt.Rectangle((0, 0), 1, 1, fc="r") ax.legend([blue_proxy, red_proxy], ['GCPs', 'CPs'], loc='upper right', bbox_to_anchor=(0.9, 0.9), prop={'size': 6}) ax.view_init(elev=-90., azim=0.) # ax.set_zlim(1,6) table = [] for gcp in sorted(gcpsXYZ): row = [ gcp, ] for i in range(numFolders): folderName = foldersNames[i] if folderName in gcpsUVW and gcp in gcpsUVW[folderName]: row.append(gcpsUVW[folderName][gcp][-1]) else: row.append('-') table.append(row) print("########################") print("Campari Dist per GCP/CP") print("########################") header = [ 'GCP', ] + foldersNames print(tabulate(table, headers=header)) print() table = [] for cp in sorted(cpsXYZ): row = [ cp, ] for i in range(numFolders): folderName = foldersNames[i] if folderName in cpsUVW and cp in cpsUVW[folderName]: row.append(cpsUVW[folderName][cp][-1]) else: row.append('-') table.append(row) header = [ 'CP', ] + foldersNames print(tabulate(table, headers=header)) print() plt.show()
def run(xmlFile, foldersNames): (gcpsXYZ, cpsXYZ) = utils_execution.readGCPXMLFile(xmlFile) numGCPs = len(gcpsXYZ) numCPs = len(cpsXYZ) numPs = numGCPs + numCPs tableGCPs = [] tableCPs = [] tableKOs = [] for folderName in foldersNames.split(','): if folderName.endswith('/'): folderName = folderName[:-1] logFileName = folderName + '/GCPBascule.log' if os.path.isfile(logFileName): lines = open(logFileName, 'r').read().split('\n') (dsGCPs, usGCPs, vsGCPs, wsGCPs) = ([], [], [], []) (dsCPs, usCPs, vsCPs, wsCPs) = ([], [], [], []) pKOs = [] for line in lines: if line.count('Dist'): gcp = line.split()[1] fields = line.split('[')[-1].split(']')[0].split(',') # u = math.fabs(float(fields[0])) # v = math.fabs(float(fields[1])) # w = math.fabs(float(fields[2])) d = float(line.split('Dist')[-1].split()[0].split('=')[-1]) if gcp in gcpsXYZ: dsGCPs.append(d) # usGCPs.append(u) # vsGCPs.append(v) # wsGCPs.append(w) elif gcp in cpsXYZ: dsCPs.append(d) # usCPs.append(u) # vsCPs.append(v) # wsCPs.append(w) else: raise Exception('GCP/CP: ' + gcp + ' not found') elif line.count('NOT OK'): pKOs.append(line.split(' ')[4]) numGCPsFile = len(dsGCPs) numCPsFile = len(dsCPs) numPKOsFile = len(pKOs) numPsFile = numGCPsFile + numCPsFile + numPKOsFile if numPsFile != numPs: print( "WARNING: number of GCPs/CPs (" + str(numPsFile) + ") processed in " + folderName + ' does not match the number in ' + xmlFile + "(" + str(numPs) + ")") if len(pKOs): tableKOs.append([folderName, ','.join(pKOs)]) else: tableKOs.append([folderName, '-']) pattern = "%0.4f" if len(dsGCPs): tableGCPs.append([folderName, pattern % numpy.min(dsGCPs), pattern % numpy.max(dsGCPs), pattern % numpy.mean(dsGCPs), pattern % numpy.std(dsGCPs), pattern % numpy.median(dsGCPs)]) #tableGCPs.append([folderName, pattern % numpy.mean(dsGCPs), pattern % numpy.std(dsGCPs), pattern % numpy.mean(usGCPs), pattern % numpy.std(usGCPs), pattern % numpy.mean(vsGCPs), pattern % numpy.std(vsGCPs), pattern % numpy.mean(wsGCPs), pattern % numpy.std(wsGCPs)]) else: tableGCPs.append([folderName, '-', '-', '-', '-', '-']) #tableGCPs.append([folderName, '-', '-', '-', '-', '-', '-', '-', '-']) if len(dsCPs): tableCPs.append([folderName, pattern % numpy.min(dsCPs), pattern % numpy.max(dsCPs), pattern % numpy.mean(dsCPs), pattern % numpy.std(dsCPs), pattern % numpy.median(dsCPs)]) #tableCPs.append([folderName, pattern % numpy.mean(dsCPs), pattern % numpy.std(dsCPs), pattern % numpy.mean(usCPs), pattern % numpy.std(usCPs), pattern % numpy.mean(vsCPs), pattern % numpy.std(vsCPs), pattern % numpy.mean(wsCPs), pattern % numpy.std(wsCPs)]) else: tableCPs.append([folderName, '-', '-', '-', '-', '-']) #tableCPs.append([folderName, '-', '-', '-', '-', '-', '-', '-', '-']) else: tableKOs.append([folderName, '-']) tableGCPs.append([folderName, '-', '-', '-', '-', '-']) #tableGCPs.append([folderName, '-', '-', '-', '-', '-', '-', '-', '-']) tableCPs.append([folderName, '-', '-', '-', '-', '-']) #tableCPs.append([folderName, '-', '-', '-', '-', '-', '-', '-', '-']) print("###########################") print("GCPBascule Dists statistics") print("###########################") print('KOs') print(tabulate(tableKOs, headers=['#Name', '', ])) print() header = ['#Name', 'Min', 'Max', 'Mean', 'Std', 'Median'] # header = ['#Name', 'MeanDist', 'StdDist', 'MeanXDist', 'StdXDist', # 'MeanYDist', 'StdYDist', 'MeanZDist', 'StdZDist'] print('GCPs') print(tabulate(tableGCPs, headers=header)) print() print('CPs') print(tabulate(tableCPs, headers=header)) print()