labscript-suite-temp-2 / lyse

lyse is an analysis framework. It coordinates the running of python analysis scripts on experiment data as it becomes availiable, updating plots in real time.
BSD 2-Clause "Simplified" License
0 stars 0 forks source link

Add units to globals #21

Closed philipstarkey closed 7 years ago

philipstarkey commented 7 years ago

Original report (archived issue) by Jan Werkmann (Bitbucket: PhyNerd, GitHub: PhyNerd).


It would be quite useful to add the units to the global variables, that are displayed in lyse.

philipstarkey commented 7 years ago

Original comment by Chris Billington (Bitbucket: cbillington, GitHub: chrisjbillington).


My concern is that units would take up a lot of column space. Would it be sufficient for the units to be in the tooltip when you mouse-over a global? Different shots needn't have the same units for the same global, so it doesn't make sense to put them in the column header either.

philipstarkey commented 7 years ago

Original comment by Jan Werkmann (Bitbucket: PhyNerd, GitHub: PhyNerd).


I guess a tooltip should do just fine since one can usually guess the unit from the global's name. The main case where this would be handy is when using different orders of magnitude of the same unit for globals (e.g. s and us). Maybe it would be best to first convert the unit to a SI unit and then apply the scientific_notation function to it.(in addition to the tooltip)

philipstarkey commented 7 years ago

Original comment by Chris Billington (Bitbucket: cbillington, GitHub: chrisjbillington).


The units entered in runmanager are so far used only as a comment - when you access a global you always get its value as typed in, without regard to the units, so I think it would be misleading to have the value displayed in lyse differ from the number you would get if you accessed that item from the dataframe for that shot.

So I think I'll add the tooltip, but the fact that the displayed number isn't necessarily SI I think is best addressed by making the globals themselves in SI units. Runmanager globals are evaluated in a namespace (runmanager/functions.py) with a few constants defined to help this:

#!python

ns = 1e-9
us = 1e-6
ms = 1e-3
s = 1
Hz = 1
kHz = 1e3
MHz = 1e6
GHz = 1e9

So you can write in runmanager a global with value 5 * kHz, and write the units as Hz - the global will be stored as equal to 5000 and displayed in lyse as '5 k', and the tooltip will say 5000 (Hz) once I add the units there.

philipstarkey commented 7 years ago

Original comment by Jan Werkmann (Bitbucket: PhyNerd, GitHub: PhyNerd).


Your solution sounds great. I knew that units where only comments so far(maybe this could be changed at a later time?), but I didn't think of writing variables in runmanager the way you described. Will definitely do this is the future. And in combination with a tooltip this will become even better!

philipstarkey commented 7 years ago

Original comment by Chris Billington (Bitbucket: cbillington, GitHub: chrisjbillington).


Excellent, sounds like a plan.

philipstarkey commented 7 years ago

Original comment by Jan Werkmann (Bitbucket: PhyNerd, GitHub: PhyNerd).


issue solved