Unit Conversion

Functions that convert between units

Each function should accept a single float as an argument and return a single float

Used by the GUI to display values in different units. Widgets use these as

  • _convert_in functions to convert units from the base unit to the displayed unit and

  • _convert_out functions to convert units from the displayed unit to the base unit.

Note

Unit conversions are cosmetic – values are always kept as the base unit internally (ie. cmH2O for pressure) and all that is changed is the displayed value in the GUI.

Functions:

cmH2O_to_hPa(pressure)

Convert cmH2O to hPa

hPa_to_cmH2O(pressure)

Convert hPa to cmH2O

rounded_string(value[, decimals])

Create a rounded string of a number that doesnt have trailing .0 when decimals = 0

pvp.common.unit_conversion.cmH2O_to_hPa(pressure: float)float[source]

Convert cmH2O to hPa

Parameters

pressure (float) – Pressure in cmH2O

Returns

Pressure in hPa (pressure / 1.0197162129779)

Return type

float

pvp.common.unit_conversion.hPa_to_cmH2O(pressure: float)float[source]

Convert hPa to cmH2O

Parameters

pressure (float) – Pressure in hPa

Returns

Pressure in cmH2O (pressure * 1.0197162129779)

Return type

float

pvp.common.unit_conversion.rounded_string(value: float, decimals: int = 0)str[source]

Create a rounded string of a number that doesnt have trailing .0 when decimals = 0

Parameters
  • value (float) – Value to stringify

  • decimals (int) – Number of decimal places to round to

Returns

Clean rounded string version of number

Return type

str