Units

convert_distance(distance, from_unit, to_unit)[source]

Convert distance between specified units.

Parameters:
  • distance (float) – Distance to convert.

  • from_unit (str) – Unit of the input distance. Must be one of “meters”, “kilometers”, “miles”, “nautical_miles”, “feet”.

  • to_unit (str) – Unit of the output distance. Must be one of “meters”, “kilometers”, “miles”, “nautical_miles”, “feet”.

Returns:

Distance converted to the target unit.

Return type:

float

convert_speed(speed, from_unit, to_unit)[source]

Convert speed between specified units.

Parameters:
  • speed (float) – Speed to convert.

  • from_unit (str) – Unit of the input speed. Must be one of “mps”, “kph”, “mph”, “knots”, “fps”.

  • to_unit (str) – Unit of the output speed. Must be one of “mps”, “kph”, “mph”, “knots”, “fps”.

Returns:

Speed converted to the target unit.

Return type:

float

altitude_to_flight_level(altitude, pressure=1013.25)[source]

Converts altitude to flight level (FL), considering atmospheric pressure.

Parameters:
  • altitude (float or pint.Quantity) – Altitude to convert. If a float, it is assumed to be in meters.

  • pressure (float or pint.Quantity) – Atmospheric pressure. If a float, it is assumed to be in hPa.

Returns:

Flight level (FL) as a string (e.g., “FL030”, “FL350”).

Return type:

str

Raises:
  • ValueError – If altitude is not a float or a pint length.

  • ValueError – If pressure is not a float or a pint pressure unit.