Repository navigation
Description
I think from the discussion https://github.com/orgs/python-accelerator-middle-layer/discussions/49 it follows that the simplest approach is to use SI units in pyAML and to convert to SI on user input using pint.
P.S I would also add that TAURUS (library to built GUIs with TANGO [and EPICS too]) is already using pint.
Original proposal by @JeanLucPons bellow:
It would be very convenient that all get() return SI (expect for eV) value and all set() take SI values as input.
AT works already in SI.
Using SI in PyAML
i.e.
- type: pyaml.bpm.bpm
name: BPMZ5D1R
model:
type: pyaml.bpm.bpm_simple_model
x_pos_index: 0
y_pos_index: 1
x_pos:
type: pyaml_cs_oa.epicsR
read_pvname: ORBITCC:rdPos
unit: nm
si_unit: m
y_pos:
type: pyaml_cs_oa.epicsR
read_pvname: ORBITCC:rdPos
unit: nm
si_unit: msr.design.get_bpm("BPMZ5D1R").positions.get() # already SI
sr.live.get_bpm("BPMZ5D1R").positions.get() # should return values always in [m], conversion to SI should be handle internally using pint def get(self) -> float | list[float]:
"""Return the setpoint(s) [or readback(s) when read only variable] of a control system device variable in SI"""
value = self.signal.read() # Raw value from control system
Q = value * ureg(self.unit)
return Q.to(self.si_unit).m # Will it work like this for arrays using pint ?How we deal with unit conv in Tango
We have this configuration:

Unit is the unit displayed
Display Unit the conversion factor to go from the raw device value to displayed value
Standard Unit is the conversion factor to go from the raw device value to SI
Problem:
We often make errors by sending the value displayed in application to the raw device when we write script.
Originally posted by @JeanLucPons in python-accelerator-middle-layer/governance#49 (comment)
Activity
Address review of SI unit conversion (#350)
Convert tune devices reporting a frequency to tunes (#350)
Move revolution_frequency() to the RF plant (#350)
Simplify SI unit code and consolidate unit tests (#350)
Merge main into 350-si-unit-conversion (#350)