-
Notifications
You must be signed in to change notification settings - Fork 128
Enable user defined sample and container geometry for abs correction #38887
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
Conversation
for more information, see https://pre-commit.ci
…ntid into abs_can_geo_def
for more information, see https://pre-commit.ci
@peterfpeterson I put in the implementation to define the gauge volume for sample and container separately to account for the beam size. I think you are right -- the way that gauge volume definition works is that the defined gauge volume will just replace the part of the sample shined by the beam. I did the test with a gauge volume larger than the sample size and in that case, as we change the gauge volume, the absorption spectrum is changing accordingly. This indicates that the gauge volume is not working as what I thought it would work, i.e., calculate the intersection region between the sample and the defined gauge volume. As I put above, I think this is fine. We then just need to define the gauge volume to follow exactly the shape of the sample but with different height and position so only the defined gauge volume region will be taken as the integration volume. When calculating L2 (i.e., the path after the scattering all the way to detectors), still the original sample volume will be used -- I think this is how the codes are currently working but it will be nice to double check to make sure. We also need to do the same thing for the container separately, just like what we did with the sample, and the gauge volume for sure needs to be defined separately for the container to follow its shape (usually, a hollow cylinder). All these can be done in the absorption util script for |
@peterfpeterson could you please leave this open while I am testing to see whether the currently implementation is doing its job properly? Or should I just change to draft? |
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.
This appears to be right for simple absorption calculations. It is unclear if this would work for Paalman-Pings with the current state of the calculations.
tl;dr use for simple absorption only
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.
Blocking for now for more testing
Hi @peterfpeterson I just tested this out, making some more changes to the code and from the test result, it seems to be working fine. For the new changes,
|
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.
absorptioncorrutils
is not used in the ISIS powder reduction - so I don't want to hold this up! Here are a few suggestions/questions. Also it seems like some of the PR testing instructions could be used to make a system test? However if this work is in-progress/beta I understand wanting to wait a bit until it's been validated.
I would push this part of work to another user story that the team here is working on. That work is about a once-for-all solution where the beam itself can be defined and can be used for the gauge volume definition. I think we will create some systematic system tests there. Thanks! |
I've been having a bit of a poke around in the Unfortunately, as far as I am aware, the concept of gauge volume understood within texture analysis is: "the region of the object that is gauged by the instrument corresponds to a cuboid, which results from the intersection of the incident and diffracted beams" [https://doi.org/10.1107/S1600576714012710], so requiring definition of the full illuminated region would not be very intuitive. Additionally if the sample shape is complex, and imported as an STL/mesh, it might be challenging for a user to explicitly define the resultant illuminated volume. An option I proposed to fix this is to pass both the sample shape and the gauge volume to the Rasterize function and allow the intersection of the two volumes to be handled within. I think this would fix my problem case, but a lower level change to |
I guess a concern is, from the I agree in the case of cubes, the element size could probably be set to be quite large and speed might not be an issue, but for gauge volumes with surfaces where the element sizes are required to be small issues might arise? Also voxels are only evaluated as within volumes at their centre points, so necessitating using large elements to run in a reasonable amount of time could lead to issues there... |
I don't know if there is an ORNL preference for how the different interpretations of the gauge volume should be handled? @peterfpeterson @Kvieta1990 |
We have a user story here to be worked on where we are going to implement the beam definition and using it for defining the gauge volume. With the current PR, we are assuming the user knows what they are doing with the gauge volume definition and it is up to the users to give a proper definition of the gauge volume, i.e., the portion of the sample (and/or container) that is exposed to the beam. Technically, this is totally feasible and I have done tests with real data and it is working fine. |
@RichardWaiteSTFC I will finish the new implementation today to account for the coordinate system direction and it will be very nice if you and @peterfpeterson can help approve the PR so that we can use it (for |
Yep will do - thanks for the changes. |
That makes a lot of sense. I will talk to Pete and will get back to you about the meeting for discussion. |
@RichardWaiteSTFC @peterfpeterson Just got the new implementation in place to cope with the potentially different coordinate system being used. I think in most cases the up direction is defined as positive-y, but it makes sense to implement the checking for direction just in case. Thanks a lot @RichardWaiteSTFC for bringing this up and your code snippet suggestion! |
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.
Thanks for the changes, looks good - sorry for delaying this when you're obviously v busy with local contacting! FYI in future I think you can also use f-strings rather than .format
which is perhaps more readable - but super minor and not worth holding this up!
I'm approving, but I don't have access to the data so can't do functional testing - I'll leave that to ORNL as this change doesn't affect ISIS!
Thanks a lot for all your comments and sure I will be using the |
…antidproject#38887) * enable user defined sample and container geometry for abs correction * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * add in release doc * fix logic * fix beam height issue * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * remove redundant checks * fix gauge volume issue * container gauge vol definition * fix quite a few issues with the implementation * fix vanadium gauge volume def issue * add in gauge volume exception * implemented coord system checking --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: y8z <zhangy3@ornl.gov>
…- ornl-next (#39085) Enable user defined sample and container geometry for abs correction (#38887) * enable user defined sample and container geometry for abs correction * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * add in release doc * fix logic * fix beam height issue * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * remove redundant checks * fix gauge volume issue * container gauge vol definition * fix quite a few issues with the implementation * fix vanadium gauge volume def issue * add in gauge volume exception * implemented coord system checking --------- Co-authored-by: Yuanpeng Zhang <zyroc1990@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: y8z <zhangy3@ornl.gov>
Description of work
Summary of work
With this PR, we enable user defined sample and container geometry for absorption correction. Top level changes are in place for
SNSPowderReduction
and accordingly necessary parameters are introduced for those bottom level algorithms concerning the setup of the absorption correction inputs. The defined sample and container geometry is finally passed toSetSample
. This gives users the flexibility to define their own geometry as needed. For example, on POWGEN, some times irregular containers that are not defined in the sample environment XML file will be used for the measurement, e.g., the annular container where the sample is loaded into the hollow cylinder wall.Also, we implement the definition of beam gauge volume for absorption correction. Without this implementation, the assumption would be that the beam size is the same as the sample size. In practice, this is often not true. In that case, the absorption correction is imperfect in principle. Detailed discussion about this is posted here.
To test:
This is the one for testing the gauge volume definition
Here is the one for testing the geometry definition,
Here is another one for testing the geometry definition, with only beam height defined (and therefore the gauge volume will be defined internally in Mantid by assuming the beam location),
Reviewer
Please comment on the points listed below (full description).
Your comments will be used as part of the gatekeeper process, so please comment clearly on what you have checked during your review. If changes are made to the PR during the review process then your final comment will be the most important for gatekeepers. In this comment you should make it clear why any earlier review is still valid, or confirm that all requested changes have been addressed.
Code Review
Functional Tests
Does everything look good? Mark the review as Approve. A member of
@mantidproject/gatekeepers
will take care of it.Gatekeeper
If you need to request changes to a PR then please add a comment and set the review status to "Request changes". This will stop the PR from showing up in the list for other gatekeepers.