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

Add check if sample details exists before applying absorption correction in diffraction script #36809

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

Conversation

MohamedAlmaki
Copy link
Contributor

@MohamedAlmaki MohamedAlmaki commented Feb 5, 2024

Description of work

This PR adds a check before applying absorption corrections in powder diffraction scripts. Previously, the error wasn't clear. This addition is added to make sure the error message is clear.

Fixes #36017.

Further detail of work

To test:

1- Run the following script in Python editor (contact me for the files):

from mantid.simpleapi import *
from isis_powder.osiris import Osiris
from isis_powder import SampleDetails

osiris_focus = Osiris(
    user_name="Calib",
    output_directory=r"C:\Users\joy22959\Documents\test_files\osiris\OsirisCalibrationFiles\output",
    config_file=r"C:\Users\joy22959\Documents\test_files\osiris\OsirisCalibrationFiles\Config.yaml",
    calibration_directory=r"C:\Users\joy22959\Documents\test_files\osiris\OsirisCalibrationFiles\Calibration_files",
    calibration_mapping_file=r"C:\Users\joy22959\Documents\test_files\osiris\OsirisCalibrationFiles\Calibration_files\osiris_run_mapping.yaml"
)

sample_details = SampleDetails(radius=1.1, height=8, center=[0, 0, 0], shape='cylinder')
sample_details.set_material(chemical_formula='Cr2-Ga-N', number_density=10.0)
sample_details.set_container(
    chemical_formula='Al',
    mass_density=2.7,
    radius=1.2
)

# osiris_focus.set_sample_details(sample=sample_details)

osiris_focus.create_vanadium(run_number="120033")

osiris_focus.focus(
    run_number="120033",
    absorb_corrections=True,
    merge_drange=False
)

2- You should see a value error
3- Uncomment the set_sample_details call and the script should run normally

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.

@MohamedAlmaki MohamedAlmaki added ISIS Team: Diffraction Issue and pull requests managed by the Diffraction subteam at ISIS Diffraction Issues and pull requests related to diffraction Maintenance Unassigned issues to be addressed in the next maintenance period. and removed ISIS Team: Diffraction Issue and pull requests managed by the Diffraction subteam at ISIS labels Feb 5, 2024
@MohamedAlmaki MohamedAlmaki added this to the Release 6.10 milestone Feb 5, 2024
@MohamedAlmaki MohamedAlmaki marked this pull request as ready for review February 23, 2024 10:03
@warunawickramasingha warunawickramasingha self-assigned this Feb 26, 2024
@warunawickramasingha
Copy link
Contributor

warunawickramasingha commented Feb 27, 2024

I followed the same steps on a Windows machine and at step 2, I am getting an Attribute error rather than a Value error like below. However after step 3, there are no errors and the script succeeds.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Diffraction Issues and pull requests related to diffraction Maintenance Unassigned issues to be addressed in the next maintenance period.
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

Add check if sample details exists before applying absorption correction in diffraction scripts
2 participants