get_unit_conversion#
- ENS_GLOBALS.get_unit_conversion(from_system: str, to_system: str, dimensionality: str) Tuple[float, float] #
Return the linear conversion parameters for converting a variable from one unit system to another.
This method will return the M and B linear equation parameters for the equation:
y = Mx + b
that can be used to convert an entity of the dimensionality specified by dimension_string (e.g. L/TT) from the first unit system to the second (e.g. “SI” to “BIN”). If the conversion fails, this function will raise an exception. Otherwise, it returns a tuple of two floats. The list of valid unit systems can be obtained using:ensight.objs.core.unit_system()
.- Args:
- from_system:
The unit system to convert from.
- to_system:
The unit system to convert to.
- dimensionality:
The unit quantity dimension string to convert. See:
pyensight.ens_globals.ENS_GLOBALS.get_unit_dimensions()
- Returns:
A string describing the dimensionality of the variable.
- Examples:
# An example use case for a volume variable from the current unit system to BFT might be: var_dims = ensight.objs.core.get_unit_dimensions(ensight.objs.core.VARIABLES['EleSize'][0]) unit_system = ensight.objs.core.unit_system()[0] print(ensight.objs.core.get_unit_conversion(unit_system, "BFT", var_dims)) # Outputs: (35.31466672148858, 0.0)
- See also: