unit_system#
- ENS_GLOBALS.unit_system(name: str | None = None, silent: int = 1, enumerate: int = -1, record: int = 0) Tuple[str, str, bool, dict] #
Get/set the current unit system to the named value (see ENS_UNITS_SYSTEM).
With no arguments, this method simply returns a tuple:
('unit system string', 'unit system name', True if this is the session unit system, a dictionary of the unit labels)
. If a units system name is passed as ‘name’, the method will attempt to set the current unit system. In this case, ‘name’ should be set to the simple string name of the unit system (e.g. ‘SI’). If the unit system has been locked (e.g. a dataset has been loaded), the method will throw an exception unless ‘silent=1’ (the default) has been specified. If ‘record’ is non-zero and the unit system was changed, the change will be recorded in command language. If enumerate is set to a number greater than -1, it will walk the list of known unit systems. When the end of the list is reached, an exception will be thrown.- Args:
- name:
The name of a unit system, optional.
- silent:
If non-zero suppress exceptions.
- enumerate:
If 0 or greater, return details of the ‘n-th’ unit system.
- record:
If non-zero, any operation that changes the unit system will be recorded to command language.
- Returns:
A tuple describing the selected unit system
- Example:
# The following snippet will dump the unit system table in EnSight. idx = 0 while True: try: print(ensight.objs.core.unit_system(enumerate=idx)) except: break idx += 1 # Outputs: ('USER', 'User defined units', False, {'A': '', 'D': '', 'I': '', 'K': '', 'M': '', 'L': '', 'Q': '', 'T': ''}) ('SI', 'Metric SI', False, {'A': 'mol', 'D': 'rad', 'I': 'cd', 'K': 'K', 'M': 'kg', 'L': 'm', 'Q': 'A', 'T': 's'}) ('CGS', 'Metric CGS', False, {'A': 'mol', 'D': 'rad', 'I': 'cd', 'K': 'C', 'M': 'g', 'L': 'cm', 'Q': 'A', 'T': 's'}) ('BFT', 'US ft Consistent', False, {'A': 'slugmol', 'D': 'rad', 'I': 'cd', 'K': 'F', 'M': 'slug', 'L': 'ft', 'Q': 'A', 'T': 's'}) ('BIN', 'US in Consistent', False, {'A': 'lbmmol', 'D': 'rad', 'I': 'cd', 'K': 'F', 'M': 'slinch', 'L': 'in', 'Q': 'A', 'T': 's'}) ('MKS', 'Metric MKS', False, {'A': 'mol', 'D': 'rad', 'I': 'cd', 'K': 'C', 'M': 'kg', 'L': 'm', 'Q': 'A', 'T': 's'}) ('MPA', 'Metric MPA', False, {'A': 'mol', 'D': 'rad', 'I': 'cd', 'K': 'C', 'M': 'tonne', 'L': 'mm', 'Q': 'mA', 'T': 's'}) ('uMKS', 'Metric uMKS', False, {'A': 'mol', 'D': 'rad', 'I': 'cd', 'K': 'C', 'M': 'kg', 'L': 'um', 'Q': 'pA', 'T': 's'}) ('CGSK', 'Metric CGSK', False, {'A': 'mol', 'D': 'rad', 'I': 'cd', 'K': 'K', 'M': 'g', 'L': 'cm', 'Q': 'A', 'T': 's'}) ('NMM', 'Metric NMM', False, {'A': 'mol', 'D': 'rad', 'I': 'cd', 'K': 'C', 'M': 'kg', 'L': 'mm', 'Q': 'mA', 'T': 's'}) ('uMKSS', 'Metric uMKSS', False, {'A': 'mol', 'D': 'rad', 'I': 'cd', 'K': 'C', 'M': 'kg', 'L': 'um', 'Q': 'mA', 'T': 's'}) ('NMMDAT', 'Metric NMMDAT', False, {'A': 'mol', 'D': 'rad', 'I': 'cd', 'K': 'C', 'M': 'decatonne', 'L': 'mm', 'Q': 'mA', 'T': 's'}) ('NMMTON', 'Metric NMMTON', False, {'A': 'mol', 'D': 'rad', 'I': 'cd', 'K': 'C', 'M': 'tonne', 'L': 'mm', 'Q': 'mA', 'T': 's'}) ('BFTS', 'US ft', False, {'A': 'lbmmol', 'D': 'rad', 'I': 'cd', 'K': 'F', 'M': 'lbm', 'L': 'ft', 'Q': 'A', 'T': 's'}) ('BINS', 'US in', False, {'A': 'lbmmol', 'D': 'rad', 'I': 'cd', 'K': 'F', 'M': 'lbm', 'L': 'in', 'Q': 'A', 'T': 's'}) ('USENG', 'US Engineering', False, {'A': 'lbmmol', 'D': 'rad', 'I': 'cd', 'K': 'R', 'M': 'lb', 'L': 'in', 'Q': 'A', 'T': 's'}) ('Unknown', 'From first loaded case', False, {'A': '', 'D': '', 'I': '', 'K': '', 'M': '', 'L': '', 'Q': '', 'T': ''})
- See also: