sunpeek.common.unit_uncertainty.to_pint#

sunpeek.common.unit_uncertainty.to_pint(s, unit=None, absolute_uncertainty=None, relative_uncertainty=None, relative_unit=None, use_relative_abs=True)#

Converts pandas Series s to a pint Quantity object, holding unit and uncertainty.

Parameters:
  • s (pd.Series) – Data series to convert.

  • unit (string, optional) – Unit string to be used as units(unit). If not provided or None, unit will be dimensionless.

  • absolute_uncertainty (pint.quantity.Quantity, optional) – pint Quantity object. Must be compatible with unit.

  • relative_uncertainty (float or pint.quantity.Quantity, optional) – Float (e.g. 0.1) or dimensionless pint Quantity object (e.g. Quantity(10, ‘percent’).

  • relative_unit (string, optional) – Unit string to be used for calculating relative uncertainty. Only required for things involing temperatures.

  • use_relative_abs (boolean, optional) – If true: In calculation of relative uncertainty, use the absolute values of s. Applies e.g. to the calculation of resistance thermometer uncertainty, typically given as \(a + r * abs(T)\) according to DIN EN 60751.

Returns:

Unit and uncertainty aware pint Quantity object.

Return type:

pobj

Notes

Drops the series index!

Examples

# >>> Q = units.Quantity # >>> x = to_pint(df[‘x’], unit=’mm’, absolute_uncertainty = Q(1, ‘mm’), relative_uncertainty = Q(10, ‘percent’))