'pint: electron_volt as base unit
Is there any way to have the composed unit eV
as a base unit in pint using a straight forward combination of @system
, @group
and possibly some contextual conversions in a definition file?
What I want to achieve is something like
import pint
ureg = pint.UnitRegistry()
ureg.load_definitions('./mystem_def.txt')
ureg.default_system = 'mysytem'
(1 * ureg.J / ureg.s**2).to_base_units().u
>> electron_volt / second ** 2
with to_base_units()
as something like a general method, without explicitly using to("eV / m**2)
such that it would be applicable to all sorts of quantities. Maybe there is another more appropriate method available in pint
which I have overseen?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|