I'd like to normalize measurements of different timespans to per-annum:
import pint
from pint import get_application_registry
ureg = get_application_registry()
x = ureg('kg/d')
print(f"x = {x}")
# x = 1.0 kilogram / d
print(f"x = {x.to('kg/a')}")
# x = 365.2499999999999 kilogram / a
# QUESTION: how do I manipulate x to just change the time dimension to '/a' regardless of other dimensions, resulting in kg/a (in this case)?
I tried reading the documentation, but it does not appear straightforward. I have also looked at similar questions, but they do not apply.
One way to go would be to multiply by the number of days in a year
ureg("a").to("d"), then divide byureg("a")to obtain the result per year:Update: finding the unit with the
time^-1dimensionalityAlthough this is probably not the most straightforward way to do it, one could filter the
dictreturned by thepint.util.to_units_containerfunction:Then you can use this to convert to
/aas above:x * ureg('a').to(time_unit) / ureg('a').