nautical.units package

Submodules

nautical.units.conversion module

nautical.units.conversion.convert_temperature(value: float, init_units: TemperatureUnits, final_units: TemperatureUnits) float[source]

Convert the temperature value from the initial units to the final units

Parameters:
  • value – initial value for temperature

  • init_units – initial units for temperature

  • final_units – desired temperature units

Returns:

value converted from the initial units to the final units

nautical.units.conversion.convert_time(value: float, init_units: TimeUnits, final_units: TimeUnits) float[source]

Convert the time value from the initial units to the final units

Parameters:
  • value – initial value for time

  • init_units – initial units for time

  • final_units – desired time units

Returns:

value converted from the initial units to the final units

Raises:

KeyError

nautical.units.conversion.convert_distance(value: float, init_units: DistanceUnits, final_units: DistanceUnits) float[source]

Convert the distance value from the initial units to the final units

Parameters:
  • value – initial value for distance

  • init_units – initial units for distance

  • final_units – desired distance units

Returns:

value converted from the initial units to the final units

nautical.units.conversion.convert_speed(value: float, init_units: SpeedUnits, final_units: SpeedUnits) float[source]

Convert the speed value from the initial units to the final units

Parameters:
  • value – initial value for speed

  • init_units – initial units for speed

  • final_units – desired speed units

Returns:

value converted from the initial units to the final units

nautical.units.conversion.convert_pressure(value: float, init_units: PressureUnits, final_units: PressureUnits) float[source]

Convert the pressure value from the initial units to the final units

Parameters:
  • value – initial value for pressure

  • init_units – initial units for pressure

  • final_units – desired pressure units

Returns:

value converted from the initial units to the final units

nautical.units.conversion.convert(value: float, init_units: object, final_units: object) float[source]

Convert the value given the current units to the new units. If the units are not in the same set of units then the value cannot be converted, and None will be returned.

Parameters:
  • value – Value provided in the units (init_units)

  • init_units – initial units of the value (must match final units type)

  • final_units – final units of the value (must match initial units type)

Returns:

The value converted to the final units. If the units did not match None is returned

Raises:

TypeError – when the two types do not match, or when any of the parameters are None

nautical.units.units module

class nautical.units.units.TimeUnits(value)[source]

Bases: Enum

Various units of time to provide to the user in the event that they do not wish to use the base units from NOAA

SECONDS = 1
MINUTES = 2
HOURS = 3
DAYS = 4
class nautical.units.units.TemperatureUnits(value)[source]

Bases: Enum

Various units of temperature to provide to the user in the event that they do not wish to use the base units from NOAA

DEG_F = 1
DEG_C = 2
class nautical.units.units.SpeedUnits(value)[source]

Bases: Enum

Various units of speed to provide to the user in the event that they do not wish to use the base units from NOAA

KNOTS = 1
MPS = 2
MPH = 3
KPH = 4
FPS = 5
class nautical.units.units.DistanceUnits(value)[source]

Bases: Enum

Various units of distance to provide to the user in the event that they do not wish to use the base units from NOAA

CENTIMETERS = 1
FEET = 2
YARDS = 3
METERS = 4
KILOMETERS = 5
MILES = 6
NAUTICAL_MILES = 7
class nautical.units.units.PressureUnits(value)[source]

Bases: Enum

Various units of pressure to provide to the user in the event that they do not wish to use the base units from NOAA

PA = 1
TORR = 2
BARR = 3
ATM = 4
AT = 5
BA = 6
PSI = 7
HG = 8
class nautical.units.units.SalinityUnits(value)[source]

Bases: Enum

Units of salinity

PSU = 1

Module contents

nautical.units.convert(value: float, init_units: object, final_units: object) float[source]

Convert the value given the current units to the new units. If the units are not in the same set of units then the value cannot be converted, and None will be returned.

Parameters:
  • value – Value provided in the units (init_units)

  • init_units – initial units of the value (must match final units type)

  • final_units – final units of the value (must match initial units type)

Returns:

The value converted to the final units. If the units did not match None is returned

Raises:

TypeError – when the two types do not match, or when any of the parameters are None

nautical.units.convert_temperature(value: float, init_units: TemperatureUnits, final_units: TemperatureUnits) float[source]

Convert the temperature value from the initial units to the final units

Parameters:
  • value – initial value for temperature

  • init_units – initial units for temperature

  • final_units – desired temperature units

Returns:

value converted from the initial units to the final units

nautical.units.convert_time(value: float, init_units: TimeUnits, final_units: TimeUnits) float[source]

Convert the time value from the initial units to the final units

Parameters:
  • value – initial value for time

  • init_units – initial units for time

  • final_units – desired time units

Returns:

value converted from the initial units to the final units

Raises:

KeyError

nautical.units.convert_distance(value: float, init_units: DistanceUnits, final_units: DistanceUnits) float[source]

Convert the distance value from the initial units to the final units

Parameters:
  • value – initial value for distance

  • init_units – initial units for distance

  • final_units – desired distance units

Returns:

value converted from the initial units to the final units

nautical.units.convert_speed(value: float, init_units: SpeedUnits, final_units: SpeedUnits) float[source]

Convert the speed value from the initial units to the final units

Parameters:
  • value – initial value for speed

  • init_units – initial units for speed

  • final_units – desired speed units

Returns:

value converted from the initial units to the final units

class nautical.units.TimeUnits(value)[source]

Bases: Enum

Various units of time to provide to the user in the event that they do not wish to use the base units from NOAA

SECONDS = 1
MINUTES = 2
HOURS = 3
DAYS = 4
class nautical.units.TemperatureUnits(value)[source]

Bases: Enum

Various units of temperature to provide to the user in the event that they do not wish to use the base units from NOAA

DEG_F = 1
DEG_C = 2
class nautical.units.SpeedUnits(value)[source]

Bases: Enum

Various units of speed to provide to the user in the event that they do not wish to use the base units from NOAA

KNOTS = 1
MPS = 2
MPH = 3
KPH = 4
FPS = 5
class nautical.units.DistanceUnits(value)[source]

Bases: Enum

Various units of distance to provide to the user in the event that they do not wish to use the base units from NOAA

CENTIMETERS = 1
FEET = 2
YARDS = 3
METERS = 4
KILOMETERS = 5
MILES = 6
NAUTICAL_MILES = 7
class nautical.units.PressureUnits(value)[source]

Bases: Enum

Various units of pressure to provide to the user in the event that they do not wish to use the base units from NOAA

PA = 1
TORR = 2
BARR = 3
ATM = 4
AT = 5
BA = 6
PSI = 7
HG = 8
nautical.units.convert_pressure(value: float, init_units: PressureUnits, final_units: PressureUnits) float[source]

Convert the pressure value from the initial units to the final units

Parameters:
  • value – initial value for pressure

  • init_units – initial units for pressure

  • final_units – desired pressure units

Returns:

value converted from the initial units to the final units

class nautical.units.SalinityUnits(value)[source]

Bases: Enum

Units of salinity

PSU = 1