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] = {'Seconds': 1.0, 'hr': 3600.0, 'min': 60.0, 's': 1.0}#
- A dictionary of time units and their corresponding factors. 
 - unit_dict: Dict[str, str] = {'%': 'Percentage', 'A': 'Current', 'A.h': 'Capacity', 'Ah': 'Capacity', 'C': 'Temperature', 'Ohms': 'Resistance', 'Seconds': 'Time', '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 
 
 
- split_quantity_unit(name, regular_expression='^(.*?)(?:\\s*\\[([^\\]]+)\\])?$')#
- Split a column name into quantity and unit. - Parameters:
- name (str) – The column name (e.g. “Current [A]” or “Temperature”) 
- regular_expression (str) – The pattern to match the column name. 
 
- Returns:
- The quantity and unit. 
- Return type:
- Tuple[str, str] 
 
- unit_from_regexp(name, regular_expression='^(.*?)(?:\\s*\\[([^\\]]*)\\])?$')#
- Create an instance of a units class from column name and regular expression. - Parameters:
- name (str) – The column name (e.g. “Current [A]” or “Temperature”) 
- regular_expression (str) – The pattern to match the column name. 
 
- Returns:
- Instance with quantity and unit (empty string if no unit found) 
- Return type: