Exemple #1
0
def main():
    network = load_network(network_xml)
    model_output = {}
    for mt, op in output_prefix.iteritems():
        mout, time = load_beats_output(network, op)
        model_output[mt] = mout
    selected_links = ['8', '38', '6', '60', '18', '15']

    for l in selected_links:
        plt.figure()
        plt.subplot(2, 1, 1)
        for mt in model_name:
            plt.plot(time, model_output[mt]['density_car'][l])
        plt.title('Vehicles in Link ' + l)
        plt.ylabel('vehicles')
        plt.legend(model_name)
        plt.subplot(2, 1, 2)
        for mt in model_name:
            plt.plot(time[0:-1], model_output[mt]['outflow_car'][l])
        plt.title('Link ' + l + ' Outflow')
        plt.ylabel('vehicles (per 5 seconds)')
        plt.xlabel('timestamp')
        plt.legend(model_name)
        # plt.plot(time[0:-1], accumu(model_output['outflow_car'][l]), 'b')
        # plt.show()
        # print (model_output['outflow_car'][l])
    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():
    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'))
model_name = ['CTM', 'VCM']
network_xml = '/Users/leahanderson/Code/Lanksershim_Network/Lshim_'+version+'_'+model_name[0]+'.xml'
output_prefix={}
for mt in model_name:
    output_prefix[mt]='/Users/leahanderson/Code/Lanksershim_Network/output/'+version+'_'+mt
dataset = '/Users/leahanderson/Code/datasets_external/lankershim'
time_aggregation = 5
sys.path.append(dataset)

import network_properties as netprops
intersections = netprops.intersection_ids
links = netprops.link_ids
initial_time = 0
final_time = (netprops.time_range[1] - netprops.time_range[0])/1000
time_bounds = range(netprops.time_range[0],netprops.time_range[1], time_aggregation*1000)
network = load_network(network_xml)

#load data density
link_densities={}
with open(dataset+'/densities_links.csv', 'rb') as csvfile:
    reader = csv.reader(csvfile, delimiter=',', quotechar='|')
    for row in reader:
        link = row[0]+row[1]
        movement = row[2]
        denlist = [int(d) for d in row[3::]]
        if link not in link_densities.keys():
            link_densities[link]={movement:denlist}
        else:
            link_densities[link][movement]=denlist

#load data outflow events
Exemple #7
0
    for e in reader:
        # e = row[0].split(',')
        # print e
        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():
__author__ = 'leahanderson'

from scenarioUtils.networktools import load_network
from outputtools import load_beats_output

network = load_network('test_network_lankershim.xml')
data, time = load_beats_output(network, '/Users/leahanderson/Code/Lanksershim_Network/output/v7_TEST')
print data.keys()



# print data['density_car']['11']
print data['outflow_car']['11']