pyprobe.units module#

A module for unit conversion of PyProBE data.

class Units(input_quantity, input_unit)#

Bases: object

A class to store unit conversion information about columns.

Parameters:
  • input_quantity (str) – The quantity of the column.

  • input_unit (str) – The unit of the column.

prefix_dict: Dict[str, float] = {'M': 1000000.0, 'k': 1000.0, 'm': 0.001, 'n': 1e-09, 'p': 1e-12, 'µ': 1e-06}#

A dictionary of SI prefixes and their corresponding factors.

time_unit_dict: Dict[str, float] = {'hr': 3600.0, 'min': 60.0, 's': 1.0}#

A dictionary of time units and their corresponding factors.

unit_dict: Dict[str, str] = {'A': 'Current', 'A.h': 'Capacity', 'Ah': 'Capacity', 'C': 'Temperature', 'Ohms': 'Resistance', 'V': 'Voltage', 's': 'Time'}#

A dictionary of units and their corresponding quantities.

from_default_unit()#

Convert the column from the default unit.

Returns:

The converted column expression.

Return type:

pl.Expr

to_default_unit()#

Convert the column to the default unit.

Returns:

The converted column expression.

Return type:

pl.Expr

unit_from_regexp(name, regular_expression='([\\w\\s]+?)\\s*\\[(\\w+)\\]')#

Create an instance of a units class from column name and regular expression.

Parameters:
  • name (str) – The column name.

  • regular_expression (str) – The pattern to match the column name.

Return type:

Units