0

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?

red-isso
  • 305
  • 1
  • 7

1 Answers1

0

I had a similar question (https://github.com/hgrecco/pint/issues/1556) and my impression is that it's not possible in the pint package to set base units with different dimensionality than the SI base units. I ended up writing a function to essentially convert to an arbitrary unit base though, which you can find in that thread -- maybe that or something similar will be useful to you.

Eric Aya
  • 69,473
  • 35
  • 181
  • 253
cdeimert
  • 1
  • 2