def draw_reachability_dis_base(dis_path, base_result_path, s=1, show=True, title='title', max_y=None): lines = Line(title=title, max_y=max_y) # 画所有的dis allCoords = [[], []] reader = IterableReader(dis_path) i = 0 id_2_index = {} for line in reader: allCoords[0].append(i) coords = line.split(Global.delimiterLevel1)[1].split(Global.delimiterSpace) allCoords[1].append(float(coords[1])) id_2_index[line.split(Global.delimiterLevel1)[0]] = i i = i + 1 lines.draw_line(allCoords, s=s) # 画base_result对于的dis clusterCoords = [[], []] reader = IterableReader(base_result_path) for line in reader: if line.startswith('Cluster'): lines.draw_line(clusterCoords, s=s, c=Line.color()) clusterCoords = [[], []] if line.startswith('-1'): orderId = id_2_index[line.split(Global.delimiterLevel1)[1]] clusterCoords[0].append(allCoords[0][orderId]) clusterCoords[1].append(allCoords[1][orderId]) if show: lines.show() return lines
def draw_reachability_dis_cluster(dis_path, result_path, s=1, show=True, title='title', max_y=None): lines = Line(title=title, max_y=max_y) # 画所有的dis allCoords = [[], []] reader = IterableReader(dis_path) i = 0 for line in reader: allCoords[0].append(i) coords = line.split(Global.delimiterLevel1)[1].split(Global.delimiterSpace) allCoords[1].append(float(coords[1])) i = i + 1 lines.draw_line(allCoords, s=s) # 画聚类出的dis clusterCoords = [[], []] reader = IterableReader(result_path) for line in reader: if line.startswith('qParams'): continue elif line.startswith('Cluster'): if len(clusterCoords) != 0: lines.draw_line(clusterCoords, s=s, c='red') clusterCoords = [[], []] elif line.startswith('cluster_num'): continue else: orderId = int(line.split(Global.delimiterLevel1)[0]) clusterCoords[0].append(allCoords[0][orderId]) clusterCoords[1].append(allCoords[1][orderId]) lines.draw_line(clusterCoords, s=s, c='red') if show: lines.show() return lines
def draw_result(all_coord_path, result_path, s=10, show=True, title='title', pathBgImg = None, xlim=None, ylim=None, fName = 'test.pdf', showXY = False): # scatter = Scatter.draw_orginal_coord(all_coord_path, s=s, show=False, title=title, pathBgImg=pathBgImg, xlim=xlim, ylim=ylim) # if xs is None: # self.xs = [] # for i in range(0, 11, 1): # self.xs.append(i * 0.1) # else: # self.xs = xs; # if ys is None: # self.ys = [] # for i in range(0, 11, 1): # self.ys.append(i * 0.1) # else: # self.ys = ys; xs = [] for i in range(0, 11, 1): xs.append(i * 0.1) ys = xs # xlim = [0, 1] # ylim = [0, 1] Scatter.index_marker = 0 scatter = Scatter(title=title[title.rindex('\\') + 1:], xs=xs, ys=ys, pathBgImg = pathBgImg, xlim=xlim, ylim=ylim, fName=fName, showXY=showXY) allCoords = [[], []] centerCoords = [[], []] reader = IterableReader(result_path) for line in reader: if line.startswith('qParams'): coords = line.split(Global.delimiterLevel1)[1].split(Global.delimiterSpace) # if float(coords[0]) >= scatter.xlim[0] and float(coords[0]) <= scatter.xlim[1] and float(coords[1]) >= scatter.ylim[0] and float(coords[1]) <= scatter.ylim[1]: # continue centerCoords[0].append(float(coords[0])) centerCoords[1].append(float(coords[1])) elif line.startswith('Cluster'): scatter.draw_scatter(allCoords, s=s, marker=Scatter.marker(), c=Scatter.color()) # scatter.draw_scatter(allCoords, s=s) allCoords[0].clear() allCoords[1].clear() elif line.startswith("cluster_num"): continue else: coords = line.split(Global.delimiterLevel1)[2].split(Global.delimiterSpace) # if float(coords[0]) >= scatter.xlim[0] and float(coords[0]) <= scatter.xlim[1] and float(coords[1]) >= scatter.ylim[0] and float(coords[1]) <= scatter.ylim[1]: # continue allCoords[0].append(float(coords[0])) allCoords[1].append(float(coords[1])) scatter.draw_scatter(allCoords, s=s, marker=Scatter.marker(), c=Scatter.color()) # scatter.draw_scatter(allCoords, s=s) scatter.draw_scatter(centerCoords, s=s, marker='*') if show: scatter.show() Scatter.index_colors = -1 return scatter
def draw_k_nearest_distance(file_paths, title='title', fName='test.pdf'): upRate = 1000000000 myline = Line(title, fName=fName, yscale='log', ylim=[1, upRate], xlabel='number of object', ylable='distance (m)') for file_path in file_paths: allCoords = [[], []] reader = IterableReader(file_path) i = 1 for line in reader: allCoords[0].append(i) coords = line.split(Global.delimiterLevel1) allCoords[1].append(float(coords[0]) * upRate + 1) i = i + 1 myline.drawLine( allCoords[0], allCoords[1], label="k = " + file_path[file_path.rindex("_") + 1:file_path.rindex(".")], linewidth=2, dashes=myline.dash()) myline.show() return myline
def draw_k_nearest_distance(file_paths, s=10, show=True, title='title'): upRate = 1000000000 scatter = Scatter(title=title, ylim=[1, upRate], yscale='log', markerscale=8) for file_path in file_paths: allCoords = [[], []] reader = IterableReader(file_path) i = 1 for line in reader: allCoords[0].append(i) coords = line.split(Global.delimiterLevel1) allCoords[1].append(float(coords[0]) * upRate + 1) i = i + 1 scatter.draw_scatter( allCoords, s=s, marker='o', label="k = " + file_path[file_path.rindex("_") + 1:file_path.rindex(".")]) if show: scatter.show() Scatter.index_colors = -1 return scatter
def draw_orginal_coord(path, s=1, marker='o', show=True, title='title', pathBgImg=None, xlim=None, ylim=None, scala=10000000000): scatter = Scatter(title=title, xlim=xlim, ylim=ylim, pathBgImg=pathBgImg) allCoords = [[], []] reader = IterableReader(path) i = 0 recAccCoords = set() for line in reader: coords = line.split(Global.delimiterLevel1)[1].split( Global.delimiterSpace) lon = float(coords[0]) lon = int(lon * scala) / float(scala) lat = float(coords[1]) lat = int(lat * scala) / float(scala) if lon * lat in recAccCoords: continue else: recAccCoords.add(lon * lat) allCoords[0].append(lon) allCoords[1].append(lat) i = i + 1 scatter.draw_scatter(allCoords, s=s, marker=marker, c='#AFEEEE') print("num coord: " + str(i)) if show: scatter.show() return scatter
def draw_reachability_dis(file_path, s=1, show=True, title='title', max_y=None): lines = Line(title=title, max_y=max_y) allCoords = [[], []] reader = IterableReader(file_path) i = 0 for line in reader: allCoords[0].append(i) coords = line.split(Global.delimiterLevel1)[1].split(Global.delimiterSpace) allCoords[1].append(float(coords[1])) i = i + 1 lines.draw_line(allCoords, s=s) if show: lines.show() Scatter.index_colors = -1 return lines
def draw_reachability_dis(file_path, s=10, show=True, title='title'): scatter = Scatter(title=title) allCoords = [[], []] reader = IterableReader(file_path) i = 1 for line in reader: allCoords[0].append(i) coords = line.split(Global.delimiterLevel1)[1].split(Global.delimiterSpace) allCoords[1].append(float(coords[1])) i = i + 1 scatter.draw_scatter(allCoords, s=s, marker='v') if show: scatter.show() Scatter.index_colors = -1 return scatter
def loadCsv(dir, rFanout=50, alpha=0.5, steepD=0.1, h=15, om=1, oe='1.0E-4', ns=50, t=1, k=5000, nw=2, mpts=5, eps='0.001', xi='0.001', maxPNeiByte=2147483631): fp = PathUtility.sample_res_path(dir, rFanout, alpha, steepD, h, om, oe, ns, t, k, nw, mpts,eps, xi, maxPNeiByte) filename = fp[fp.rindex('res') + 4:] alldata = [] reader = IterableReader(fp) index = 0 for line in reader: if index == 0: index += 1 continue strArr = line.split(',') data = Data(filename) data.numSample = 1 data.numRangeRtree = int(strArr[7]) data.numOpticFastRange = int(strArr[16]) data.numOpticLuceneRange = int(strArr[18]) data.timeTotal = int(strArr[24]) data.numCluster = int(strArr[25]) alldata.append(data) return alldata