oasys-elettra-kit / OASYS1-Wiser

The implementation of WISER into OASYS
MIT License
0 stars 1 forks source link

Units #39

Closed capitanevs closed 3 years ago

capitanevs commented 3 years ago

We have encountered problems with the units conversion.

An option could be eliminate it (but can we do that? Or is it something that Luca should do?)

Waiting more info from Michele: if we use meters, is everything ok, or we still have problems?

aljosahafner commented 3 years ago

If we use meters I think everything is ok, at least I haven't encountered issues

capitanevs commented 3 years ago

Question: I have no prejudice against setting everything into meters. However there is something which is still not totally clear: -How would it be related with OASYS from Luca? Is this a change that we are coordinating with Luca, or is it something that we would do on our own? -Interaction between WISER and rest-of-the-world (SRW, SHADOW), backcompatibility etc could present some issues?

aljosahafner commented 3 years ago
capitanevs commented 3 years ago

Yeah, I remember you commented on Luca's point. But who is doing that? He or you? Will be the old *.ow files working with no problem? (I guess so, as he would not undertake such a decision).

aljosahafner commented 3 years ago

But SRW is already in metres, only SHADOW supports this feature (and now Wiser (not :) ))

aljosahafner commented 3 years ago

Should I go ahead with this - keep all units in m?

capitanevs commented 3 years ago

I double checked with Luca (I asked him some general clarification, all things you probably already knew).

Yes, let's go on! We should improve the formatting for certain specific "sizes". For instance, using meters for the detector size is uncomfortable immagine but if we could use scientific formatting (%0.2e, for example), I it would just be ok. The same for the slit size.

There is no general rule, but typically

how about that?

aljosahafner commented 3 years ago

I can investigate that, yes. We can also use another unit, such as mm or um (for slit size and/or size of detector).

I'll remove the unit switching...

capitanevs commented 3 years ago

The question is whether to hardcode the unit (um, mm, m) or give visual aid with the format. If the second options is doable, I let's try with that. There are pros and cons in both cases. Let's take the more general one.

double check: You are going the unit switching only from wiser widget, right? So ShadowOUI will still be affected (as stated in the disclaimer) but all the rest of the world, not.

aljosahafner commented 3 years ago

It's just about WIser, it's all coded in each individual widget...

capitanevs commented 3 years ago

Allright. Let's go for it, if not gone yet.

aljosahafner commented 3 years ago

I removed the unit switcher entirely. I think with line edits it is not possible to change the display format to scientific. You can input in scientific format, e. g. 1e-6, but display will be in decimal numbers.

capitanevs commented 3 years ago

Subclassing PyQT classes (as Luca suggests) is not an option right now.

I don't know how you are settings the string in the text box. If you use the method setNum(), you can probably set the format

https://doc.qt.io/qt-5/qstring.html#setNum-9 ( immagine

immagine

If you can get it through with that, good. It would be greatly reccomended, as no extra conversion code is necessary (with possible errors). If not, let'sjust hardcode the units to save time.

aljosahafner commented 3 years ago

This has to be investigated a bit better, maybe with Luca. I did something, but my knowledge of (Py)Qt is not sufficient to make a bulletproof and nice solution.