SPaT data¶
Signal Adapters¶
AACVTE adapter¶
SPaT classes¶
Signal Collection¶
-
class
mtldp.mtlmap.signals.
SPaTCollection
¶ Class for a collection of SPaT information
- Main Attributes
.node_spats
: dict, key: node_id, value: mtldp.mtlmap.NodeSPaT
-
__init__
()¶ Initiate signal collection
-
add_node_spat
(node_spat)¶ Add the spat information of one node to the dictionary
- Parameters
node_spat – spat information of one node
- Returns
None
-
get_movement_spat
(node_id, movement_id)¶ Get a SPaT of a movement based on given node_id and movement_id
- Parameters
node_id – str
movement_id – str
- Returns
mtldp.mtlmap.MovementSPaT
-
load_spat_csv
(filename)¶ Load the spat information from a csv file
- Parameters
filename – str, spat csv file name
- Returns
None
-
output_spat_csv
(filename)¶ Output the spat information to a csv file
- Parameters
filename – str, spat csv file name
- Returns
None
Node SPaT¶
-
class
mtldp.mtlmap.signals.
NodeSPaT
¶ Class for the SPaT information of a node
- Main Attributes
.node_id
: id of the node.type
: type of the node.phases
: phases of the node.movement_spats
: a dictionary of spat information of each movement
-
__init__
()¶ Initiate node spat
-
get_movement_spat
(movement_id)¶ Get the movement spat. If not exists, return
None
- Parameters
movement_id –
- Returns
mtldp.mtlmap.MovementSPaT or None
Movement SPaT¶
-
class
mtldp.mtlmap.signals.
MovementSPaT
¶ Class for the SPaT information of a movement
- Main Attributes
.node_id
: id of the node which includes the movement.channel_id
: id of the channel in the signal controller.movement_id
: id of the movement.df
: a pandas dataframe that stores node id, movement id, start time, end time, duration, signal state
-
__init__
()¶ Initiate movement spat
-
analysis_tod_spat
(start_tod, end_tod, timezone, start_time=None, end_time=None, max_green=150, max_red=150, print_stats=True)¶ Analyze the SPaT data in the range of [start_tod, end_tod] in each day and in the range of [start_time, end_time] Note that 4 lists wil be returned: period time, green time, yellow time, red time
- Parameters
start_tod (str) – str, the start time period in a day
end_tod (str) – str, the end time period in a day
timezone – mtldp.utils.Timezone
start_time – timestamp, the end time that the users want to do analysis, default None
end_time – timestamp, the end time that the users want to do analysis, default None
max_green – any green light duration greater than max_green will be discarded, default 150s
max_red – any red light duration greater than max_red will be discarded, default 150s
print_stats – True if the user wants to print out the stats info of SPaT
- Returns
list
-
get_green_start
(timestamp)¶ Get the latest green start time given a certain time stamp
- Parameters
timestamp – int
- Returns
green_start, the latest green start time
-
get_signal_state
(timestamp)¶ Return the signal state given a certain timestamp
- Parameters
timestamp – int
- Returns
str, signal state (“Green”, “Yellow” or “Red”)
-
get_signal_states
(time_ls)¶ return the signal states given a list of timestamps. The timestamp list should be sorted.
- Parameters
time_ls – a list of timestamps
- Returns
signal_states, a list of signal states (“Green”, “Yellow” or “Red”)
-
initialize_movement
(node_id, movement_id, channel_id, df)¶ Initialize the movement
- Parameters
node_id – str
movement_id – str
channel_id – str
df – pandas.DataFrame
- Returns
None
-
truncate_movement_spat
(t_min, t_max)¶ Truncate the MovementSPaT to be within the range of [t_min, t_max]
- Parameters
t_min – timestamp
t_max – timestamp
- Returns