vunits.convert.convert_unit

vunits.convert.convert_unit(num=None, initial=None, final=None)

Converts units between two unit sets

Parameters
  • num (float, optional) – Number to convert. If not specified, will return the appropriate conversion factor. Default is 0 for temperature-based units, 1 otherwise.

  • initial (str) – Units that num is currently in. Different units must be sparated by a ‘ ‘ or ‘/’. Supports powers as numbers after units. e.g. ‘cm/s2’, ‘cm s-2’, or ‘cm s^-2’.

  • final (str) – Units you would like num to be in. Different units must be sparated by a ‘ ‘ or ‘/’. Supports powers as numbers after units. e.g. ‘cm/s2’, ‘cm s-2’, or ‘cm s^-2’.

Returns

conversion_num – num in the appropriate units

Return type

float

Raises

ValueError – If unit types are not consistent or not supported