-
Notifications
You must be signed in to change notification settings - Fork 3
Gui improvements #148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gui improvements #148
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.
src/ess/reflectometry/gui.py
Outdated
| self.working_label = widgets.Label( | ||
| "...working", layout=widgets.Layout(display='none') | ||
| ) | ||
| self.widget = widgets.HBox( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this and the other classes you have that have a self.widget = HBox(...), you might want to look at how we make custom widgets in Plopp, so you can directly embed them into other widgets, without having to use the .widget attribute: https://github.com/scipp/plopp/blob/main/src/plopp/widgets/checkboxes.py
| workflow[ZIndexLimits] = (0, 16 * 32) | ||
| workflow[WavelengthBins] = sc.geomspace( | ||
| 'wavelength', | ||
| 2, | ||
| 13.5, | ||
| 2001, | ||
| unit='angstrom', | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess these are not taking into account what is set in the tab where you have Z and L parameters in a table.
Should it be in sync?
Also, 2000 wavelength bins is quite a lot, we could make the figures lighter by reducing that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess these are not taking into account what is set in the tab where you have Z and L parameters in a table.
Should it be in sync?
Yes that's right. No I don't have the impression they should be in sync. This view is independent from the reduction settings.
Also, 2000 wavelength bins is quite a lot, we could make the figures lighter by reducing that?
I think 2000 is a good setting for now. In the future this might be a user defined setting. For now I think we shouldn't tweak this before getting some feedback from the ids.
| da.bins.data[...] = sc.scalar(1.0, variance=1.0, unit=da.bins.unit) | ||
| da.bins.unit = 'counts' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure why we need to do this here? Can we not histogram the data in ReducibleData ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what you mean here. If you're asking why we're setting the weights to 1, it's because we don't want any weights applied, we just want the detector counts.
| da.bins.data[...] = sc.scalar(1.0, variance=1.0, unit=da.bins.unit) | ||
| da.bins.unit = 'counts' | ||
| da.masks.clear() | ||
| da.bins.masks.clear() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need to remove masks? Is the workflow setting masks somewhere?
I guess we have no interface to add masks in the GUI right now.
If there are masks on the data, they should be visible on the figure, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes the workflow is adding masks to the data.
In this case we don't want to view the masks, we only want the raw count data.
That's also the reason whey the counts are set to 1.0, we don't want any corrections applied.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you just want raw counts, it sounds like we should compute another result from the workflow than the ReducibleData[SampleRun] (e.g. RawDetectorData)?
Computing something and then settings values to 1 seems strange to me. I still don't understand why you want to do that above...
Is it because you need the coordinates to compute the wavelengths to make the figure that you are using ReducibleData?
Maybe it's a sign that there should be an additional step in the workflow that splits this up, so you can compute a raw data with coordinates before masks and corrections are added?
Not sure if this would work with the current order in which operations are applied.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you just want raw counts, it sounds like we should compute another result from the workflow than the
Problem is that RawDetectorData doesn't have wavelengths.
Is it because you need the coordinates to compute the wavelengths to make the figure that you are using
ReducibleData?
Yes
Maybe it's a sign that there should be an additional step in the workflow that splits this up, so you can compute a raw data with coordinates before masks and corrections are added?
We could do that. But then you could say, what if I just want those coordinates and not those, what if I want those corrections but not those, what if I want those masks but not those, etc, and we would need to define a whole range of "domain types" for each of the combinations. That said, maybe this particular case is common enough that we do want to introduce a separate type that can be used here.
Not sure if this would work with the current order in which operations are applied.
It would work 👍
I agree it's a bit odd to set the weights to 1 and clear all masks. But on the other hand, concretely, what is the drawback? (besides performance, which is probably not that relevant)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The drawback is that the GUI is starting to feel (at least to me) like it contains quite a few hacks.
However, because I don't want to get too deeply involved in the GUI side of things, I'll let you decide what you want to do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The drawback is that the GUI is starting to feel (at least to me) like it contains quite a few hacks.
That's a concern we should take seriously and try to adress.
If the issues you're referring to are not directly related to the changes in this PR I think we should adress them in separate PRs. If you have concrete problems or changes in mind feel free to open issues to fix those. If your concerns are too vauge to be directly converted to issues, let's sit down have a chat about them and see if we can figure something out.
Like I said above, I'm not against adding a DetectorDataWithCoords domain type. I just don't see the advantage, and I see that adding more domain types complicates the package and makes it more confusing for users, so if possible I'd prefer to avoid it.
src/ess/reflectometry/gui.py
Outdated
| self.tabs.set_title(len(self.tabs.children) - 2, "Nexus Explorer") | ||
| self.tabs.set_title(len(self.tabs.children) - 1, "Detector View") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use self.tabs.titles = [ SOME LIST OF NAMES ] ?
| def on_tab_change(change): | ||
| old = self.tabs.children[change['old']] | ||
| new = self.tabs.children[change['new']] | ||
| if hasattr(old, 'is_active_tab'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess you could even leave the hasattr check out, just setting the attribute on the old object, even if it doesn't exist to begin with, should be allowed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the benefit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simpler code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the simplification is removing the hasattr checks, at the cost of adding attributes to random objects, that's not worth it in my opinion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't call them completely 'random', but it was just a suggestion. You can take it or leave it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry that came of as dismissive, I didn't mean it like that. I appreciate your suggestions and the effort you put into the review
src/ess/reflectometry/gui.py
Outdated
| self.tabs.set_title(1, "Settings") | ||
| self.tabs.set_title(2, "Log") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also use .titles = [...]?
Uh oh!
There was an error while loading. Please reload this page.