-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot_tls_program.py
52 lines (47 loc) · 2 KB
/
plot_tls_program.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
'''
@Author: WANG Maonan
@Date: 2024-06-25 23:59:49
@Description: 绘制 Traffic Phase Duration 曲线
LastEditTime: 2024-06-29 17:23:45
'''
import argparse
from tshub.utils.init_log import set_logger
from tshub.utils.get_abs_path import get_abs_path
from tshub.sumo_tools.analysis_output.tls_program_visualization import TLSProgram_PDVis
current_file_path = get_abs_path(__file__)
set_logger(current_file_path('./'), file_log_level="INFO")
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Process delta_time.')
parser.add_argument('--action_type', type=str, default='Choose_Next_Choose', help='The name of action type.')
parser.add_argument('--delta_time', type=int, default=None, help='The delta time value.')
args = parser.parse_args() # Parse the arguments
delta_time = args.delta_time # Use the delta_time argument
action_type = args.action_type
# Start Analysis tls_programs
if delta_time == None:
tls_program_file = current_file_path(f'./{action_type}/exp_output/add/tls_programs.out_1.xml')
else:
tls_program_file = current_file_path(f'./{action_type}/exp_output/{delta_time}/add/tls_programs.out_1.xml')
tls_analysis = TLSProgram_PDVis(tls_program_file)
# 将所有的 Traffic Phase 绘制在一起
directions_state = [
'grrrrrgGGGrgrrrgGGr',
'GrrrrrGrrrGGrrrGrrG',
'GGGGrrGrrrrGGGrGrrr',
'GrrrGGGrrrrGrrGGrrr'
]
tls_analysis.plot_allphase_ratio(
directions_state, traffic_light_duration=120,
image_path=current_file_path(f"./all_phase_duration_{action_type}_{delta_time}.pdf")
)
# 绘制指定的 Traffic Phase Duration (使用折线图)
directions_state = [
'grrrrrgGGGrgrrrgGGr',
'GGGGrrGrrrrGGGrGrrr',
]
tls_analysis.plot_phase_ratio_line(
phase_strs=directions_state,
phase_label=['NS-SN', 'WE-EW'],
fig_text=f'{action_type}',
image_path=current_file_path(f"./phase_duration_line_{action_type}_{delta_time}.pdf")
)