def plot_disk_flux_trajectories(trajectories, r, q, eps_r): st_pts, end_pts = pyscan.trajectories_to_flux(trajectories) st_pts = [pyscan.WPoint(1.0, float(p[0]), float(p[1]), 1.0) for p in st_pts] end_pts = [pyscan.WPoint(1.0, float(p[0]), float(p[1]), 1.0) for p in end_pts] scan = utils.range_to_func("disk") red, blue, mx_disk = pyscan.paired_plant_region(st_pts, end_pts, r, q, eps_r, scan) ax = plt.subplot() actor = plt.Circle((mx_disk.get_origin()[0], mx_disk.get_origin()[1]), mx_disk.get_radius(), fill=False) ax.add_artist(actor) ax.scatter([x[0] for x in red], [x[1] for x in red], c="r") ax.scatter([x[0] for x in blue], [x[1] for x in blue], c="b") ax.set_xlim(0, 1.0) ax.set_ylim(0, 1.0) plt.show()
def plot_plane_flux_trajectories(trajectories, r, q, eps_r): st_pts, end_pts = pyscan.trajectories_to_flux(trajectories) st_pts = [pyscan.WPoint(1.0, float(p[0]), float(p[1]), 1.0) for p in st_pts] end_pts = [pyscan.WPoint(1.0, float(p[0]), float(p[1]), 1.0) for p in end_pts] scan = utils.range_to_func("halfplane") red, blue, mx_plane = pyscan.paired_plant_region(st_pts, end_pts, r, q, eps_r, scan) ax = plt.subplot() ax.scatter([x[0] for x in red], [x[1] for x in red], c="r") ax.scatter([x[0] for x in blue], [x[1] for x in blue], c="b") xs = np.arange(0, 1, .01) ys = (-1 - mx_plane.get_coords()[0] * xs) * 1 / mx_plane.get_coords()[1] ax.plot(xs, ys, color="g") ax.set_xlim(0, 1.0) ax.set_ylim(0, 1.0) plt.show()
"m_disc_approx": mx, "m_disc": actual_mx } writer.writerow(row) f.flush() print(row) if max_time is not None and end_time - start_time > max_time: return if __name__ == "__main__": #trajectories = paths.read_geolife_files(10000) trajectories = paths.read_dong_csv( "/data/Dong_sets/Trajectory_Sets/samples/osm_eu_sample_100k_nw.tsv") st_pts, end_pts = pyscan.trajectories_to_flux(trajectories) st_pts = [ pyscan.WPoint(1.0, float(p[0]), float(p[1]), 1.0) for p in st_pts ] end_pts = [ pyscan.WPoint(1.0, float(p[0]), float(p[1]), 1.0) for p in end_pts ] r = .01 q = .8 eps_r = .01 for region_name in ["halfplane", "disk"]: scan_f = utils.range_to_func(region_name) print("Started planting") red, blue, region = pyscan.paired_plant_region(st_pts, end_pts, r, q,