Unit handling#

Perform conversions between different variables used.

pygaps.units.converter_mode.c_pressure(value: float, mode_from: str, mode_to: str, unit_from: str, unit_to: str, adsorbate=None, temp: float | None = None)[source]#

Convert pressure units and modes.

Adsorbate name and temperature have to be specified when converting between modes.

Parameters:
  • value (float) -- The value to convert.

  • mode_from (str) -- Whether to convert from a mode.

  • mode_to (str) -- Whether to convert to a mode.

  • unit_from (str) -- Unit from which to convert.

  • unit_to (str) -- Unit to which to convert.

  • adsorbate (Adsorbate, optional) -- Adsorbate on which the pressure is to be converted. Required for mode change.

  • temp (float, optional) -- Temperature at which the pressure is measured, in K. Required for mode changes to relative pressure.

Returns:

float -- Pressure converted as requested.

Raises:

ParameterError -- If the mode selected is not an option.

pygaps.units.converter_mode.c_loading(value: float, basis_from: str, basis_to: str, unit_from: str, unit_to: str, adsorbate=None, temp: float | None = None, basis_material: str | None = None, unit_material: str | None = None)[source]#

Convert loading units and basis.

Adsorbate name and temperature have to be specified when converting between basis.

Parameters:
  • value (float) -- The value to convert.

  • basis_from (str) -- Whether to convert from a basis.

  • basis_to (str) -- Whether to convert to a basis.

  • unit_from (str) -- Unit from which to convert.

  • unit_to (str) -- Unit to which to convert.

  • adsorbate (str, optional) -- Adsorbate for which the pressure is to be converted. Only required for some conversions.

  • temp (float, optional) -- Temperature at which the loading is measured, in K. Only required for some conversions.

  • basis_material (str, optional) -- The basis of the material. Only required for conversions involving percentage/fraction.

  • unit_material (str, optional) -- The unit of the material. Only required for conversions involving percentage/fraction.

Returns:

float -- Loading converted as requested.

Raises:

ParameterError -- If the mode selected is not an option.

pygaps.units.converter_mode.c_material(value: float, basis_from: str, basis_to: str, unit_from: str, unit_to: str, material=None)[source]#

Convert material units and basis.

The name of the material has to be specified when converting between basis.

Parameters:
  • value (float) -- The value to convert.

  • basis_from (str) -- Whether to convert from a basis.

  • basis_to (str) -- Whether to convert to a basis.

  • unit_from (str) -- Unit from which to convert.

  • unit_to (str) -- Unit to which to convert.

  • material (str) -- Name of the material on which the value is based.

Returns:

float -- Loading converted as requested.

Raises:

ParameterError -- If the mode selected is not an option.

pygaps.units.converter_mode.c_temperature(value: float, unit_from: str, unit_to: str)[source]#

Convert temperatures.

Parameters:
  • value (float) -- The value to convert.

  • unit_from (str) -- Unit from which to convert.

  • unit_to (str) -- Unit to which to convert.

Returns:

float -- Temperature converted as requested.

Raises:

ParameterError -- If the unit selected is not an option.

Define and perform conversions between different units used.

pygaps.units.converter_unit.c_unit(unit_list, value, unit_from, unit_to, sign=1)[source]#

Convert units based on their proportions in a dictionary.

Parameters:
  • unit_list (dict) -- The dictionary with the units and their relationship.

  • value (dict) -- The value to convert.

  • unit_from (str) -- Unit from which to convert.

  • unit_from (str) -- Unit to which to convert.

  • sign (int) -- If the conversion is inverted or not.

Returns:

float -- Value converted as requested.

Raises:

ParameterError -- If the unit selected is not an option.