trafficgen.plot_traffic_situation

Functions to prepare and plot traffic situations.

Functions

add_ship_to_map(ship, vector_time, lat_lon0, ...)

Add the ship to the map.

add_ship_to_plot(ship, vector_time, ...[, color])

Add the ship to the plot.

calculate_ship_outline(position, cog, lat_lon0)

Calculate the outline of the ship pointing in the direction of ship course.

calculate_vector_arrow(position, direction, ...)

Calculate the arrow with length vector pointing in the direction of ship course.

find_max_value_for_plot(ship, max_value, ...)

Find the maximum deviation from the Reference point in north and east direction.

plot_specific_traffic_situation(...)

Plot a specific situation in map.

plot_traffic_situations(traffic_situations, ...)

Plot the traffic situations in one more figures.

trafficgen.plot_traffic_situation.add_ship_to_map(ship: Ship, vector_time: float, lat_lon0: GeoPosition, map_plot: Map | None, color: str = 'black') Map

Add the ship to the map.

Parameters:
  • ship (Ship) – Ship information

  • vector_time (float) – Vector time [sec]

  • lat_lon0 (GeoPosition) – Reference point, latitudinal [rad] and longitudinal [rad]

  • map_plot (Map | None) – Instance of Map. If not set, instance is set to None

  • color (str) – Color of the ship. If not set, color is ‘black’

Returns:

map_plot – Updated instance of Map.

Return type:

Map

trafficgen.plot_traffic_situation.add_ship_to_plot(ship: Ship, vector_time: float, lat_lon0: GeoPosition, axes: Axes | None, color: str = 'black') Axes

Add the ship to the plot.

Parameters:
  • ship (Ship) – Ship information

  • vector_time (float) – Vector time [sec]

  • axes (Axes | None) – Instance of figure axis. If not set, instance is set to None

  • color (str) – Color of the ship. If not set, color is ‘black’

trafficgen.plot_traffic_situation.calculate_ship_outline(position: GeoPosition, cog: float, lat_lon0: GeoPosition, ship_length: float = 100.0, ship_width: float = 15.0) list[tuple[float, float]]

Calculate the outline of the ship pointing in the direction of ship course.

Parameters:
  • position (GeoPosition) – {lat}, {lon} position of the ship [rad]

  • cog (float) – Course over ground of the ship [rad]

  • lat_lon0 (GeoPosition) – Reference point, latitudinal [rad] and longitudinal [rad]

  • ship_length (float) – Ship length. If not given, ship length is set to 100

  • ship_width (float) – Ship width. If not given, ship width is set to 15

Returns:

ship_outline_points – Polygon points to draw the ship [deg]

Return type:

list[tuple[float, float]]

trafficgen.plot_traffic_situation.calculate_vector_arrow(position: GeoPosition, direction: float, vector_length: float, lat_lon0: GeoPosition) list[tuple[float, float]]

Calculate the arrow with length vector pointing in the direction of ship course.

Parameters:
  • position (GeoPosition) – {lat}, {lon} position of the ship [rad]

  • direction (float) – Direction the arrow is pointing [rad]

  • vector_length (float) – Length of vector [m]

  • lat_lon0 (GeoPosition) – Reference point, latitudinal [rad] and longitudinal [rad]

Returns:

arrow_points – Polygon points to draw the arrow [deg]

Return type:

list[tuple[float, float]]

trafficgen.plot_traffic_situation.find_max_value_for_plot(ship: Ship, max_value: float, lat_lon0: GeoPosition) float

Find the maximum deviation from the Reference point in north and east direction.

Parameters:
  • ship (Ship) – Ship information

  • max_value (float) – Maximum deviation in north, east direction [m]

  • lat_lon0 (GeoPosition) – Reference point, latitudinal [rad] and longitudinal [rad]

Returns:

* max_value

Return type:

updated maximum deviation in north, east direction [m]

trafficgen.plot_traffic_situation.plot_specific_traffic_situation(traffic_situations: list[TrafficSituation], situation_number: int, encounter_settings: EncounterSettings) None

Plot a specific situation in map.

Parameters:
  • traffic_situations (list[TrafficSituation]) – List of traffic situations that are generated

  • situation_number (int) – The specific situation to be plotted

  • encounter_settings (EncounterSettings) – Encounter settings

trafficgen.plot_traffic_situation.plot_traffic_situations(traffic_situations: list[TrafficSituation], col: int, row: int, encounter_settings: EncounterSettings) None

Plot the traffic situations in one more figures.

Parameters:
  • traffic_situations (list[TrafficSituation]) – List of traffic situations to be plotted

  • col (int) – Number of columns in each figure

  • row (int) – Number of rows in each figure

  • encounter_settings (EncounterSettings) – Encounter settings