cratermaker.utils.general_utils.format_large_units#
- cratermaker.utils.general_utils.format_large_units(value, quantity)[source]#
Format a value and automatically shift units based on threshold.
- Parameters:
value (float) – The value to be formatted and converted to appropriate units.
quantity ({‘length’, ‘area’, ‘volume’, ‘velocity’, ‘time’, ‘pressure’}) – The type of quantity being formatted. “area”. The function will determine the appropriate units and thresholds based on the quantity type.
- Returns:
str – A string representation of the value with appropriate units, formatted to a reasonable number of significant digits based on the magnitude of the value.
Examples
>>> from cratermaker.utils.general_utils import format_large_units >>> format_large_units(1500, "length") '1.500 km' >>> format_large_units(3920, "time") '3.920 Gy'