ism3d.utils.misc.human_to_string¶
-
ism3d.utils.misc.
human_to_string
(q, format_string='{0.value:0.2f} {0.unit:shortname}', nospace=True)[source]¶ A slightly more fancy version of quality.to_string() add the option of 0.units:shortname in formating string syntax # https://docs.astropy.org/en/stable/units/format.html#astropy-units-format
- format: forwarded to .to_string(format):
options: generic, unscaled, cds, console, fits, latex, latex_inline, ogip, unicode, vounit
- format_string: {0:0.2f} {1}
help format you output when output=’string’
- output:
‘string’: a string represent the input quantity in best-guess unit
For time: try built-in astropy.utils.console.human_time() For file size: one may also use astropy.utils.concolse.human_file_size()
print(human_to_string(q,format_string=’{0.value:0.2f} {0.unit:shortname}’,nospace=False)) print(human_to_string(q,format_string=’{0.value:0.2f}{0.unit:shortname}’,nospace=True)) print(human_to_string(q,format_string=’{0.value:0.2f}{0.unit:cds}’,nospace=True)) print(human_to_string(q,format_string=’{0.value:0.2f} in {0.unit:shortname}’,nospace=True)) print(human_to_string(q,format_string=’{0.value:0.2f} in {0.unit:cds}’,nospace=True))