def main(): network = load_network(network_xml) model_output, model_time = load_beats_output(network, output_prefix) selected_links = ['38'] dataset = '/Users/leahanderson/Code/datasets_external/lankershim' sys.path.append(dataset) import network_properties as netprops #for lankershim... corresponding = { '61': [4, 'NB', [2, 3]], '42': [3, 'SB', [2, 1]], '15': [3, 'SB', [31]], '5': None, '4': [4, 'NB', [11]], '10': [1, 'NB', [1, 2]], '38': [2, 'NB', [2, 3]], '31': [2, 'NB', [11]] } traj_list = direct_to_trajectories(dataset) for l in selected_links: link_info = corresponding[l] initial_time = netprops.time_range[0] final_time = netprops.time_range[1] data_counts, data_time = output_count_sensor( traj_list, link_info[0], link_info[1], [initial_time, final_time], 5, link_info[2]) data_time = [(d - initial_time) / 1000.0 for d in data_time] plt.subplot(2, 1, 1) plt.plot(model_time, model_output['density_car'][l]) plt.title('Vehicles in Link ' + l) plt.ylabel('vehicles') plt.subplot(2, 1, 2) plt.plot(model_time[0:-1], model_output['outflow_car'][l], 'b', data_time, data_counts, 'k') plt.title('Link ' + l + ' Outflow') plt.ylabel('vehicles (per 5 seconds)') plt.xlabel('timestamp') plt.show() plt.plot(model_time[0:-1], accumu(model_output['outflow_car'][l]), 'b', data_time, accumu(data_counts), 'k') plt.show()
def main(): network = load_network(network_xml) model_output, model_time = load_beats_output(network, output_prefix) selected_links = ['38'] dataset = '/Users/leahanderson/Code/datasets_external/lankershim' sys.path.append(dataset) import network_properties as netprops #for lankershim... corresponding = {'61':[4, 'NB', [2,3]], '42':[3, 'SB', [2,1]], '15':[3, 'SB', [31]], '5': None, '4':[4, 'NB', [11]], '10':[1, 'NB', [1,2]], '38': [2,'NB',[2,3]], '31':[2, 'NB', [11]] } traj_list = direct_to_trajectories(dataset) for l in selected_links: link_info = corresponding[l] initial_time = netprops.time_range[0] final_time = netprops.time_range[1] data_counts, data_time = output_count_sensor(traj_list, link_info[0], link_info[1], [initial_time, final_time], 5, link_info[2]) data_time = [(d-initial_time)/1000.0 for d in data_time] plt.subplot(2,1,1) plt.plot(model_time, model_output['density_car'][l]) plt.title('Vehicles in Link '+l) plt.ylabel('vehicles') plt.subplot(2,1,2) plt.plot(model_time[0:-1], model_output['outflow_car'][l], 'b', data_time, data_counts, 'k') plt.title('Link '+l+ ' Outflow') plt.ylabel('vehicles (per 5 seconds)') plt.xlabel('timestamp') plt.show() plt.plot(model_time[0:-1], accumu(model_output['outflow_car'][l]), 'b', data_time,accumu(data_counts), 'k') plt.show()
def main(): parser = OptionParser() parser.add_option('-s', '--scenario', action='store', type='string', dest='scenario_xml', default='./scenarions/test_network_lankershim.xml', help='path to scenario file') parser.add_option( '-o', '--outdir', action='store', type='string', dest='outdir', help='directory to output files (defaults to same as input directory)') parser.add_option('-d', '--data', action='store', type='string', dest='data_prefix', default=None, help='path to beats output data, if exists') (options, args) = parser.parse_args() if not options.scenario_xml: # print('isthisworking') abort("missing --scenario file, try --help") scenario_network = load_network(options.scenario_xml) print scenario_network.name if options.data_prefix is None: k = convert_network_to_kml(scenario_network) else: data = load_beats_output(scenario_network, options.data_prefix) k = convert_data_to_kml(scenario_network, data) write_kmz( k, scenario_network.file_location + '/' + scenario_network.name.strip('.xml'))
def main(): parser = OptionParser() parser.add_option('-s', '--scenario', action='store', type='string', dest='scenario_xml', default='./scenarions/test_network_lankershim.xml', help='path to scenario file' ) parser.add_option('-o', '--outdir', action='store', type='string', dest='outdir', help='directory to output files (defaults to same as input directory)' ) parser.add_option('-d', '--data', action='store', type='string', dest='data_prefix', default=None, help='path to beats output data, if exists' ) (options, args) = parser.parse_args() if not options.scenario_xml: # print('isthisworking') abort("missing --scenario file, try --help") scenario_network = load_network(options.scenario_xml) print scenario_network.name if options.data_prefix is None: k = convert_network_to_kml(scenario_network) else: data = load_beats_output(scenario_network, options.data_prefix) k = convert_data_to_kml(scenario_network, data) write_kmz(k, scenario_network.file_location + '/' + scenario_network.name.strip('.xml'))
for e in reader: # e = row[0].split(',') # print e i = int(e[0]) l=e[1] mo=e[2] ts=[float(t) for t in e[3::]] if not l in events_dict.keys(): events_dict[l] = {mo: ts} else: events_dict[l][mo] = ts #load model output model_output = {} for mt in model_name: mout, model_time = load_beats_output(network, output_prefix[mt]) model_output[mt]=mout #set up plotting stuff data_plot_time = range(initial_time, final_time) model_plot_time = range(initial_time, final_time, time_aggregation) #create mapping from model links to data links network_dict = {} for v in netprops.data_to_scenario.values(): network_dict.update(v)
i = int(e[0]) l = e[1] m = e[2] ts = [float(t) for t in e[3::]] if not i in events_dict.keys(): events_dict[i] = {l: {m: ts}} elif not l in events_dict[i].keys(): events_dict[i][l] = {m: ts} else: events_dict[i][l][m] = ts data_dict = netprops.data_to_scenario network = load_network(network_xml) model_output = {} for mt in model_name: mout, model_time = load_beats_output(network, output_prefix[mt]) model_output[mt] = mout plot_time = [(t - initial_time) / 1000.0 for t in time_bounds[1::]] # markers = itertools.cycle([ '+', '*', ',', 'o', '.', '1', 'p', ]) for i in intersections: for link, move_dict in events_dict[i].iteritems(): if link in data_dict[i].keys( ): # and not is_integer(link) in netprops.origin_ids: plt.figure() p = 1 for m in ['T', 'R', 'L']: if m in move_dict.keys(): datah, _ = histogram(move_dict[m], bins=time_bounds) else: datah = [0] * len(plot_time)