perturbopy.postproc.utils.constants.standardize_units_name

perturbopy.postproc.utils.constants.standardize_units_name(user_input_units, units_dict)

Converts any units to their standard name as specified in units_dict. Uses find_prefix_and_base_units to convert user_input_units to a prefix and standardized base units, then combines them into one string.

Parameters:
  • user_input_units (str) – The units to be standardized

  • units_dict (dict) – A dictionary specifying the standard unit name corresponding to a set of possible units names (case-insensitive). See prefix_and_base_units for details.

Returns:

standard_units – The standardized units name.

Return type:

str

Examples

>>> find_prefix_and_base_units('nm', {'m':['m', 'meter']})
'nm'
>>> find_prefix_and_base_units('nmeter', {'m':['m', 'meter']})
'nm'
>>> find_prefix_and_base_units('a.u.', {'m':['m', 'meter']}, 'bohr': ['bohr', 'a.u.'])
'bohr'