-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprocess_stat_file.py
22 lines (14 loc) · 1010 Bytes
/
process_stat_file.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from lxml import etree
root = etree.parse('stat.xml')
vehicles_inserted = int(root.find(".//vehicles").attrib['inserted'])
vehicles_waiting = int(root.find(".//vehicles").attrib['waiting'])
depart_delay = float(root.find(".//vehicleTripStatistics").attrib['departDelay'])
depart_delay_waiting = float(root.find(".//vehicleTripStatistics").attrib['departDelayWaiting'])
vehicle_count = float(root.find(".//vehicleTripStatistics").attrib['count'])
vehicle_duration = float(root.find(".//vehicleTripStatistics").attrib['duration'])
bike_count = float(root.find(".//bikeTripStatistics").attrib['count'])
bike_duration = float(root.find(".//bikeTripStatistics").attrib['duration'])
# avg_duration = (vehicle_duration * vehicle_count + bike_duration * bike_count) / (vehicle_count + bike_count)
avg_duration = vehicle_duration
totalTravelTimeAndDelay = vehicles_inserted * (avg_duration + depart_delay) + vehicles_waiting * depart_delay_waiting
print(totalTravelTimeAndDelay/(vehicle_count+vehicles_waiting))