Skip to content
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

Physics package #1710

Merged
merged 49 commits into from
Sep 27, 2024
Merged

Physics package #1710

merged 49 commits into from
Sep 27, 2024

Conversation

bnmajor
Copy link
Collaborator

@bnmajor bnmajor commented Jul 2, 2024

Relies on the HEXRD absorption-correction branch.

@pep8speaks
Copy link

pep8speaks commented Jul 2, 2024

Hello @bnmajor! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 71:80: E501 line too long (83 > 79 characters)

Line 529:80: E501 line too long (89 > 79 characters)

Line 1666:80: E501 line too long (82 > 79 characters)
Line 1667:80: E501 line too long (82 > 79 characters)

Line 76:80: E501 line too long (83 > 79 characters)
Line 200:80: E501 line too long (81 > 79 characters)

Line 157:80: E501 line too long (86 > 79 characters)

Comment last updated at 2024-09-27 00:43:31 UTC

@bnmajor bnmajor force-pushed the physics-package branch 5 times, most recently from 6a27124 to 509cb78 Compare July 3, 2024 19:55
@bnmajor bnmajor force-pushed the physics-package branch 2 times, most recently from 5c7c1ec to 20f5c79 Compare August 14, 2024 20:40
@bnmajor bnmajor force-pushed the physics-package branch 3 times, most recently from 343f64b to 689886d Compare September 2, 2024 12:28
@bnmajor
Copy link
Collaborator Author

bnmajor commented Sep 2, 2024

@psavery @saransh13 Some additional questions:

  1. We currently expect there to be a sample_materials and window_materials file like the pinhole_materials which we do not have - do we need to create these files (and if so which materials should be included)? Or should we just use the pinhole_materials file?
    1. Same question for filter/coating/phosphor for the absorption correction dialog
  2. We discussed automatically applying pinhole corrections and that the pinhole should be set to None if it is not needed but that is not currently an option.
    1. Do we want to change this condition to allow None as well? If so, is it safe to assume that we will never call calc_transmission (which calls calc_effective_pinhole_area) without a pinhole?
    2. Would it be simpler to say that if this is a TARDIS or PXRDIP (and eventually BBXRD) instrument we just automatically apply pinhole corrections?
  3. How should we handle inferring instrument type? Currently we set that automatically if users come from the LLNL import tool, but how should we handle this if they do not? We have engineering constraints to determine if it is TARDIS, but no clear solution for PXRDIP.
  4. Absorption correction is being normalized but still looked like it may be incorrect - @saransh13 I will need your feedback here for sure

@psavery
Copy link
Collaborator

psavery commented Sep 4, 2024

My thoughts are:

  1. Yes we probably need to make those files (but I think filter/coating/phosphor will just be a dict within HEXRD)
  2. I think we probably want to allow the transmission to be calculated without a pinhole (make the pinhole optional in transmission calculation)
  3. You can just use this function, Brianna. That detects both TARDIS and PXRDIP automatically (and only those two so far) based upon the detector names.
  4. It looks like we are finding the max transmission across all detectors and normalizing based upon that. I think that is the behavior we planned. Maybe something else is missing, @saransh13?

@bnmajor
Copy link
Collaborator Author

bnmajor commented Sep 4, 2024

  1. You can just use this function, Brianna. That detects both TARDIS and PXRDIP automatically (and only those two so far) based upon the detector names.

Looks like this only can guess TARDIS, or am I missing something? If not I can add PXRDIP

@bnmajor bnmajor force-pushed the physics-package branch 3 times, most recently from b1b8835 to 4be85f7 Compare September 6, 2024 21:51
Comment on lines 86 to 87
<property name="styleSheet">
<string notr="true">QDoubleSpinBox:disabled {background-color: LightGray;}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've found it usually better to not edit the style sheets (when possible), because when we do so, things like dark mode on the Mac don't change colors properly.

@@ -143,10 +143,11 @@ def serialize(self):

@classmethod
def deserialize(cls, d):
from hexrdgui.hexrd_config import HexrdConfig
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move this import down into the if statement right before it is used? That will help us to not import it unless we actually need it...

This could alternatively be imported at the top of the file, but I'm assuming there's a circular import issue or something like that.

@@ -11,7 +11,8 @@ def generate_pinhole_panel_buffer(instr, pinhole_radius, pinhole_thickness):
instr.beam_vector = np.r_[0., 0., -1.]
try:
for det_key, det in instr.detectors.items():
crit_angle = np.arctan(2 * pinhole_radius / pinhole_thickness)
crit_angle = np.arctan(
det.pinhole.diameter / det.pinhole.thickness)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really think the pinhole ought to be a property of the instrument rather than the detector (there is only one pinhole per experiment, there are not separate pinholes for separate detectors).

Can we change HEXRD to have the following be on the instrument: sample layer, window, pinhole. If the detector needs it for something, maybe we can pass them as arguments?

Let me know if that is a lot of work to do.

self.ui.button_box.rejected.connect(self.ui.reject)
for k, w in self.material_selectors.items():
w.currentIndexChanged.connect(
lambda index, k=k: self.material_changed(index, k))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've sometimes ran into trouble using loop variables in lambda expressions. Maybe this is fine - but can you just verify that all values of k (not just the last one) work properly?

Comment on lines +69 to +71
self.ui.button_box.accepted.connect(self.accept_changes)
self.ui.button_box.accepted.connect(self.ui.accept)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I usually think it's better to just connect to a signal once, and have an expression like on_accepted() that calls self.accept_changes() and self.ui.accept().

However, you don't need to change this! That's just FYI.

from hexrdgui import resource_loader
from hexrdgui.hexrd_config import HexrdConfig
from hexrdgui.ui_loader import UiLoader
import hexrdgui.resources.materials as module
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import hexrdgui.resources.materials as module
import hexrdgui.resources.materials as materials_resources

Can you rename this to something more specific than module?


absorption_length = self.get_rygg_absorption_length(i)
if np.isclose(value, absorption_length):
if name == HexrdConfig().pinhole_package.material:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we still letting users manually edit the absorption correction length in the Rygg pinhole correction editor? If not, I don't think we need this, right?

@bnmajor bnmajor force-pushed the physics-package branch 3 times, most recently from e7e50f6 to 0172e05 Compare September 20, 2024 13:36
Brianna Major and others added 23 commits September 26, 2024 19:13
Only expect additional material files for window and pinhole.

Signed-off-by: Brianna Major <[email protected]>
Signed-off-by: Brianna Major <[email protected]>
Signed-off-by: Brianna Major <[email protected]>
Signed-off-by: Brianna Major <[email protected]>
Signed-off-by: Brianna Major <[email protected]>
These do not work well on Mac

Signed-off-by: Brianna Major <[email protected]>
Signed-off-by: Brianna Major <[email protected]>
Not all instruments will need a physics package or detector coating information,
so we shouldn't save this information to the instrument. This will prevent
writing out extra information to the config file for users that do not want or
expect it.

Signed-off-by: Brianna Major <[email protected]>
The hexrd classes still expect a pinhole radius. Use that in the check.

Signed-off-by: Patrick Avery <[email protected]>
Otherwise, there are errors...

Signed-off-by: Patrick Avery <[email protected]>
@psavery psavery marked this pull request as ready for review September 27, 2024 00:41
We are running into trouble using it for other systems. For now,
disable them. We'll add them back in later.

Signed-off-by: Patrick Avery <[email protected]>
@saransh13 saransh13 merged commit e0df2b8 into HEXRD:master Sep 27, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants