Closed coldfix closed 6 years ago
A separate issue are the units for values that madx/tao returns. For tao, I'm thinking that adding a units field in the information returned by the Tao "python" command would be good. The alternative is to hard wire madqt/pytao to know the units of returned quantities. I don't like this since it looks to be more complicated.
Ideally, I'd prefer to have a python command that exports a map of all units used for different quantities in tao. This way the database doesn't have to be maintained in madqt and could be of potential use for other users too.
I believe only exporting the unit alongside the value is not enough, because sometimes you want to update a value into tao without querying it first - and for that you have to know the unit that it is expected to have.
I'm trying to think of a case where you want to update a value and have not previously queried for the value before hand and you need to know the units for the update.
The reason why I would like the units information to come from bmad is that then it would be available for other programs to use. There would not be a problem to create a tao python command to just dump all of the units if needed.
So let me propose this: I modify the tao python commands to add a units field where needed. And also add a new command to just return the units of any given parameter or all parameters. I think this should cover all the bases.
I just realized that for some parameters the units cannot be known beforehand. For example, a Tao datum has model, high_lim, low_lim, step, etc. parameters that all have the same units but will be different from datum to datum. The same is true for Tao variables. Thus there cannot be a database for the units created before data and variables are defined.
One way around this is to simply ignore the units for Tao data and variables and only display units for lattice and lattice element parameters.
For some datums it's impossible. But others have datatypes, for which the unit can be known in advance, right? So, I wouldn't look up based on high_lim
, low_lim
etc but rather based on the data type.
Yes that is correct.
BTW: Finally, I will work on the GUI for at least the next two weeks.
Great! What do you want to the units string to be of parameters that have units of radians/2Pi ?
The Tao python command has a new command to show the units of a parameter:
Tao> python lat_param_units k1
1/m^2
Great. After some bug fixes this is the next thing I'm going to work on.
Great! What do you want to the units string to be of parameters that have units of radians/2Pi ?
You mean rad divided by 2pi? In this case, I don't care maybe 1
or count
. Or you mean rad
?, in this case rad
is good.
I'm trying to think of a case where you want to update a value and have not previously queried for the value before hand and you need to know the units for the update.
For example if initializing values from a saved data file or the control system.
Also, even in the case of querying a value + unit, then doing something (user input/calculations) with it and storing it back to tao: on the way the unit can be changed to a different prefix or by some scale factor (eg, MeV/GeV/J). This means the program has to keep track of the expected unit for serialization independently of the unit of the value itself anyway.
You mean rad divided by 2pi?
Yes. For example, the rf cavity phase phi0. Right now you get:
Tao> python lat_param_units phi0 rad/2Pi
I like this since it is very clear what the units are but this is not good for mathematical calculations. One fix would be to translate this on the python side. What do you think?
I can translate it on python side.
So far I'm using a unit library (Pint) to add units to numbers obtained from madx/tao (partially implemented). The idea was that all quantities the application handles internally and which the user can access always have proper units. However, removing+readding units from numbers drags through a lot of the application in a very unclean way such that I was long beginning to wonder whether we should just convert all units on I/O to a defined standard and internally only store numbers.