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

Enable user defined sample and container geometry for abs correction #38887

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

Kvieta1990
Copy link
Contributor

@Kvieta1990 Kvieta1990 commented Feb 19, 2025

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 to SetSample. 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

from mantid.simpleapi import *

gauge_vol = '''<cuboid id="shape">
     <left-front-bottom-point x="0.01" y="-0.1" z="0.0"  />
     <left-front-top-point  x="0.01" y="-0.1" z="0.02"  />
     <left-back-bottom-point  x="-0.01" y="-0.1" z="0.0"  />
     <right-front-bottom-point  x="0.01" y="0.1" z="0.0"  />
   </cuboid>'''

SNSPowderReduction(
    Filename='/SNS/PG3/IPTS-34523/nexus/PG3_58812.nxs.h5',
    CalibrationFile='/SNS/PG3/shared/CALIBRATION/2025-1_11A_CAL/PG3_OC_d58772_2025-02-12.h5',
    CharacterizationRunsFile='/SNS/PG3/shared/CALIBRATION/2025-1_11A_CAL/PG3_char_2025_2-HighRes_OC.txt,/SNS/PG3/shared/CALIBRATION/2025-1_11A_CAL/PG3_char_2025_2_OC_limit.txt',
    RemovePromptPulseWidth=50,
    Binning='-0.0008',
    BackgroundSmoothParams='5, 2',
    FilterBadPulses=90,
    ScaleData=100,
    TypeOfCorrection='SampleAndContainer',
    SampleFormula='Ba-Nb-Cr-Ru',
    MeasuredMassDensity='6.0',
    SampleGeometry={'Height': 5},
    SampleNumberDensity='0.088',
    ContainerShape='PAC06',
    GaugeVolume=gauge_vol,
    SaveAs='gsas topas and fullprof',
    OutputDirectory='/SNS/NOM/shared/tmp',
    CacheDir='/SNS/NOM/shared/tmp'
)

Here is the one for testing the geometry definition,

from mantid.simpleapi import *

sam_geo = {
    'Shape': 'HollowCylinder', 'Height': 4.0,
    'InnerRadius': 2.0,
    'OuterRadius': 3.0,
    'Center': [0.,0.,0.]
}

c_geo = {
    'Shape': 'HollowCylinderHolder',
    'Height': 4.0,
    'InnerRadius': 1.5,
    'InnerOuterRadius': 2.0,
    'OuterInnerRadius': 3.0,
    'OuterRadius': 4.0,
    'Center': [0.,0.,0.]
}

c_mat = {
    'ChemicalFormula': 'V',
    'NumberDensity': 0.072324
}

gauge_vol = '''<cuboid id="shape">
     <left-front-bottom-point x="0.01" y="-0.1" z="0.0"  />
     <left-front-top-point  x="0.01" y="-0.1" z="0.02"  />
     <left-back-bottom-point  x="-0.01" y="-0.1" z="0.0"  />
     <right-front-bottom-point  x="0.01" y="0.1" z="0.0"  />
   </cuboid>'''

SNSPowderReduction(
    Filename='/SNS/PG3/IPTS-34523/nexus/PG3_58812.nxs.h5',
    CalibrationFile='/SNS/PG3/shared/CALIBRATION/2025-1_11A_CAL/PG3_OC_d58772_2025-02-12.h5',
    CharacterizationRunsFile='/SNS/PG3/shared/CALIBRATION/2025-1_11A_CAL/PG3_char_2025_2-HighRes_OC.txt,/SNS/PG3/shared/CALIBRATION/2025-1_11A_CAL/PG3_char_2025_2_OC_limit.txt',
    RemovePromptPulseWidth=50,
    Binning='-0.0008',
    BackgroundSmoothParams='5, 2',
    FilterBadPulses=90,
    ScaleData=100,
    TypeOfCorrection='SampleAndContainer',
    SampleFormula='Ba-Nb-Cr-Ru',
    MeasuredMassDensity='6.0',
    SampleGeometry=sam_geo,
    SampleNumberDensity='0.088',
    ContainerGeometry=c_geo,
    ContainerMaterial=c_mat,
    GaugeVolume=gauge_vol,
    SaveAs='gsas topas and fullprof',
    OutputDirectory='/SNS/NOM/shared/tmp',
    CacheDir='/SNS/NOM/shared/tmp'
)

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

  • Is the code of an acceptable quality?
  • Does the code conform to the coding standards?
  • Are the unit tests small and test the class in isolation?
  • If there is GUI work does it follow the GUI standards?
  • If there are changes in the release notes then do they describe the changes appropriately?
  • Do the release notes conform to the release notes guide?

Functional Tests

  • Do changes function as described? Add comments below that describe the tests performed?
  • Do the changes handle unexpected situations, e.g. bad input?
  • Has the relevant (user and developer) documentation been added/updated?

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.

@Kvieta1990 Kvieta1990 self-assigned this Feb 19, 2025
@Kvieta1990 Kvieta1990 added Diffraction Issues and pull requests related to diffraction Powder Issues and pull requests related to powder diffraction Absorption Corrections Issues and pull requests related to absorption corrections labels Feb 19, 2025
@sf1919 sf1919 added this to the Release 6.13 milestone Feb 19, 2025
@peterfpeterson peterfpeterson changed the title enable user defined sample and container geometry for abs correction Enable user defined sample and container geometry for abs correction Feb 20, 2025
)

if beam_height != Property.EMPTY_DBL and not gauge_vol:
gauge_vol = """<cuboid id="shape">
Copy link
Member

Choose a reason for hiding this comment

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

This is strange in a way similar to the DefineGaugeVolume user docs. I think it is configured that

  • front-back is x-dimension
  • left/right is y-dimension (beam height)
  • top/bottom is z-dimension

It would be good to also add in the beam width for the dimension that has that

Adding a comment explaining that will help future people who see this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The DefineGaugeVolume user docs is indeed a bit confusing in the explanation of how the gauge volume is defined. Here are several comments,

  1. For the cuboid volume definition, I created an image to demonstrate the idea,
    Cuboid volume definition demo

  2. Ideally, indeed the gauge volume could be defined as above a a cuboid and Mantid then worries about constructing the intersection area between the sample and the defined gauge volume. However, the construction of the intersection area is not implemented yet. So, we cannot go with this route.

  3. However, the gauge volume can be defined as with the same shape as the sample, e.g., cylinder or hollow cylinder and current implementation can meet our need without problems. We do need some further implementation in this PR to define the gauge volume for the sample and container separately.

  4. The implementation for SampleOnly and SampleAndContainer method is straightforward -- just define the gauge volume twice here

  5. For the PaalmanPingsAbsorptionCorrection method, I am not sure how to do that -- the same principle applies but I am not so familiar with the CPP codes.

Copy link
Contributor

Choose a reason for hiding this comment

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

At ISIS we are also interested in starting to use DefineGaugeVolume with other attenuation algorithms such as MonteCarloAbsoption for use on our engineering beamline ENGIN-X. For us we would need to consider the case of when the gauge volume is not wholly occupied by the sample, both for attenuation correction and normalising by the illuminated sample volume. If you do implement this let us know! Not sure how this fits in with your plans? Happy to discuss!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Absorption Corrections Issues and pull requests related to absorption corrections Diffraction Issues and pull requests related to diffraction Powder Issues and pull requests related to powder diffraction
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants