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

Draft
wants to merge 33 commits into
base: master
Choose a base branch
from
Draft

Physics package #1710

wants to merge 33 commits into from

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 75:80: E501 line too long (83 > 79 characters)

Comment last updated at 2024-09-06 21:52:01 UTC

Signed-off-by: Brianna Major <brianna.major@taloid.khq.kitware.com>
Signed-off-by: Brianna Major <brianna.major@kitware.com>
@bnmajor bnmajor force-pushed the physics-package branch 5 times, most recently from 6a27124 to 509cb78 Compare July 3, 2024 19:55
Brianna Major added 3 commits July 11, 2024 15:47
Signed-off-by: Brianna Major <brianna.major@taloid.khq.kitware.com>
Signed-off-by: Brianna Major <brianna.major@taloid.khq.kitware.com>
Signed-off-by: Brianna Major <brianna.major@taloid.khq.kitware.com>
Brianna Major added 10 commits August 28, 2024 09:38
Signed-off-by: Brianna Major <brianna.major@taloid.khq.kitware.com>
Signed-off-by: Brianna Major <brianna.major@taloid.khq.kitware.com>
Signed-off-by: Brianna Major <brianna.major@taloid.khq.kitware.com>
Signed-off-by: Brianna Major <brianna.major@taloid.khq.kitware.com>
Signed-off-by: Brianna Major <brianna.major@taloid.khq.kitware.com>
The default values are correct for TARDIS.

Signed-off-by: Brianna Major <brianna.major@taloid.khq.kitware.com>
Signed-off-by: Brianna Major <brianna.major@taloid.khq.kitware.com>
Signed-off-by: Brianna Major <brianna.major@taloid.khq.kitware.com>
Signed-off-by: Brianna Major <brianna.major@taloid.khq.kitware.com>
Signed-off-by: Brianna Major <brianna.major@taloid.khq.kitware.com>
Brianna Major added 5 commits August 28, 2024 10:15
Signed-off-by: Brianna Major <brianna.major@taloid.khq.kitware.com>
Signed-off-by: Brianna Major <brianna.major@taloid.khq.kitware.com>
Signed-off-by: Brianna Major <brianna.major@taloid.khq.kitware.com>
Signed-off-by: Brianna Major <brianna.major@taloid.khq.kitware.com>
Signed-off-by: Brianna Major <brianna.major@taloid.khq.kitware.com>
Brianna Major added 4 commits September 1, 2024 18:05
Signed-off-by: Brianna Major <brianna.major@taloid.khq.kitware.com>
Signed-off-by: Brianna Major <brianna.major@taloid.khq.kitware.com>
Signed-off-by: Brianna Major <brianna.major@taloid.khq.kitware.com>
Signed-off-by: Brianna Major <brianna.major@taloid.khq.kitware.com>
Signed-off-by: Brianna Major <brianna.major@taloid.khq.kitware.com>
@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

Brianna Major added 3 commits September 6, 2024 15:56
Only expect additional material files for window and pinhole.

Signed-off-by: Brianna Major <brianna.major@taloid.khq.kitware.com>
Signed-off-by: Brianna Major <brianna.major@taloid.khq.kitware.com>
Signed-off-by: Brianna Major <brianna.major@taloid.khq.kitware.com>
Signed-off-by: Brianna Major <brianna.major@taloid.khq.kitware.com>
Brianna Major added 4 commits September 6, 2024 16:48
Signed-off-by: Brianna Major <brianna.major@taloid.khq.kitware.com>
Signed-off-by: Brianna Major <brianna.major@taloid.khq.kitware.com>
Signed-off-by: Brianna Major <brianna.major@taloid.khq.kitware.com>
Signed-off-by: Brianna Major <brianna.major@taloid.khq.kitware.com>
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 +70
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?

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.

3 participants