trafficgen.plot_traffic_situation module

Functions to prepare and plot traffic situations.

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

Add the ship to the map.

Params:
  • ship: Ship information

  • vector_time: Vector time [sec]

  • lat_lon0=Reference point, latitudinal [rad] and longitudinal [rad]

  • map_plot: Instance of Map. If not set, instance is set to None

  • color: Color of the ship. If not set, color is ‘black’

Returns:

* m

Return type:

Updated instance of Map.

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

Add the ship to the plot.

Params:
  • ship: Ship information

  • vector_time: Vector time [sec]

  • axes: Instance of figure axis. If not set, instance is set to None

  • color: Color of the ship. If not set, color is ‘black’

trafficgen.plot_traffic_situation.calculate_ship_outline(position: Position, course: float, lat_lon0: Position, ship_length: float = 100.0, ship_width: float = 15.0) List[Tuple[float, float]][source]

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

Params:
  • position: {latitude}, {longitude} position of the ship [rad]

  • course: course of the ship [rad]

  • lat_lon0: Reference point, latitudinal [rad] and longitudinal [rad]

  • ship_length: Ship length. If not given, ship length is set to 100

  • ship_width: Ship width. If not given, ship width is set to 15

Returns:

* ship_outline_points

Return type:

Polygon points to draw the ship [deg]

trafficgen.plot_traffic_situation.calculate_vector_arrow(position: Position, direction: float, vector_length: float, lat_lon0: Position) List[Tuple[float, float]][source]

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

Params:
  • position: {latitude}, {longitude} position of the ship [rad]

  • direction: direction the arrow is pointing [rad]

  • vector_length: length of vector [m]

  • lat_lon0: Reference point, latitudinal [rad] and longitudinal [rad]

Returns:

* arrow_points

Return type:

Polygon points to draw the arrow [deg]

trafficgen.plot_traffic_situation.find_max_value_for_plot(ship: Ship, max_value: float, lat_lon0: Position) float[source]

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

Params:
  • ship: Ship information

  • max_value: maximum deviation in north, east direction

  • lat_lon0: Reference point, latitudinal [rad] and longitudinal [rad]

Returns:

* max_value

Return type:

updated maximum deviation in north, east direction

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

Plot a specific situation in map.

Params:
  • traffic_situations: Generated traffic situations

  • situation_number: The specific situation to be plotted

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

Plot the traffic situations in one more figures.

Params:
  • traffic_situations: Traffic situations to be plotted

  • col: Number of columns in each figure

  • row: Number of rows in each figure