def run(route, prd, **kwargs): """ :type route: pyticas.ttypes.Route :type prd: pyticas.ttypes.Period :return: """ rnode_list = route.get_stations() # load_data vmt data vmt_results = vmt.run(route, prd) vmt_data = [res.data for res in vmt_results] # load_data speed data us_results = speed.run(route, prd) us_results = moe_helper.add_virtual_rnodes(us_results, route) us_data = [res.data for res in us_results] # copy results to save VMT values vht_results = [res.clone() for res in us_results] # calculate VMT vht_data = _calculate_vht(vmt_data, us_data, prd.interval, **kwargs) for ridx, res in enumerate(vht_results): res.data = vht_data[ridx] return vht_results
def run(route, prd, **kwargs): """ :type route: pyticas.ttypes.Route :type prd: pyticas.ttypes.Period :return: """ # load_data vmt data vmt_results = vmt.run(route, prd) # load_data speed data us_results = speed.run(route, prd) us_results = moe_helper.add_virtual_rnodes(us_results, route) # copy whole_data to save VMT values dvh_results = [res.clone() for res in vmt_results] # calculate VHT dvh_data = _calculate_dvh(vmt_results, us_results, prd.interval, **kwargs) for ridx, res in enumerate(dvh_results): res.data = dvh_data[ridx] return dvh_results
if __name__ == '__main__': import os from pyticas.infra import Infra from pyticas import route from pyticas import period from pyticas.moe import writer data_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '../../../../../data')) Infra.initialize(data_path) infra = Infra.load_infra() r = route.load_route_by_name('Route I-494 WB') prd1 = period.create_period_from_string('2016-05-17 06:00:00', '2016-05-17 09:00:00', 300) prd2 = period.create_period_from_string('2016-05-18 06:00:00', '2016-05-18 09:00:00', 300) res1 = run(r, prd1) res2 = run(r, prd2) res = [res1, res2] writer.write_cm(os.path.join(infra.get_path('moe', create=True), 'cm.xlsx'), r, res) from pyticas.moe.mods import speed ures1 = speed.run(r, prd1) ures2 = speed.run(r, prd2) ures1 = moe_helper.add_virtual_rnodes(ures1, r) ures2 = moe_helper.add_virtual_rnodes(ures2, r) ures = [ures1, ures2] writer.write(os.path.join(infra.get_path('moe', create=True), 'u.xlsx'), r, ures)