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 method to BaseSX to plot result of IntegratePeaksMD and save in pdf #36947

Merged

Conversation

RichardWaiteSTFC
Copy link
Contributor

@RichardWaiteSTFC RichardWaiteSTFC commented Mar 1, 2024

Description of work

Add static method to BaseSX class to allow single-crystal users of SXD and WISH to plot result of IntegratePeaksMD and save in pdf

It plots 3 colorfill plots for each peak, taking the axes and extent for the call to BinMD from the peak shape (typically ellipsoid or sphere).

The axes of the cut are along the eigenvectors of the ellipsoid and the extents along each axis are +/- the outer background shell radius multiplied by some scale factor (it uses the peak radius if no background is supplied). This means that if the colorfill axes extents are set to [-1,1] (i.e. the axes are normalised by the radii along the ellipsoid axes) then the ellipse in each plot can be plotted as a circle.

Fixes #35708

Report to: Pascal (WISH)

To test:

(1) Run this script

from mantid.simpleapi import *
from Diffraction.single_crystal.base_sx import BaseSX

Load(Filename=r'SXD23767.raw', OutputWorkspace='SXD23767')
ws = ConvertToDiffractionMDWorkspace(InputWorkspace='SXD23767', OutputWorkspace='SXD23767_MD', 
                                OneEventPerBin=False, SplitThreshold=30)
peaks = FindPeaksMD(InputWorkspace='SXD23767_MD', PeakDistanceThreshold=0.4, MaxPeaks=10, 
            PeakFindingStrategy='NumberOfEventsNormalization', SignalThresholdFactor=10, 
            OutputType='Peak', OutputWorkspace='SingleCrystalPeakTable', EdgePixels=1) 
AddPeak(PeaksWorkspace=peaks, RunWorkspace='SXD23767', TOF=1364.7318584074724, DetectorID=35004, Height=384, BinCount=19.811577095134769)

peaks_int = IntegratePeaksMD(InputWorkspace='SXD23767_MD', PeakRadius='0.12', BackgroundInnerRadius='0.13', BackgroundOuterRadius='0.19', PeaksWorkspace='SingleCrystalPeakTable', OutputWorkspace='peaks_int', Ellipsoid=True, FixQAxis=True, CylinderLength=1, PercentBackground=1, UseOnePercentBackgroundCorrection=False, UseCentroid=True, MaskEdgeTubes=False)

BaseSX.plot_integrated_peaks_MD(ws, peaks_int, "/babylon/Public/RWaite/test_plot_MD.pdf", nbins_max=21, extent=1.5, log_norm=True)

A typical peak will look like this
image

(2) Integrate peaks without a background and re-run

peaks_int = IntegratePeaksMD(InputWorkspace='SXD23767_MD', PeakRadius='0.12',  PeaksWorkspace='SingleCrystalPeakTable', OutputWorkspace='peaks_int', Ellipsoid=True, FixQAxis=True, CylinderLength=1, PercentBackground=1, UseOnePercentBackgroundCorrection=False, UseCentroid=True, MaskEdgeTubes=False)

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.

@RichardWaiteSTFC RichardWaiteSTFC added Diffraction Issues and pull requests related to diffraction Single Crystal Issues and pull requests related to single crystal ISIS Team: Diffraction Issue and pull requests managed by the Diffraction subteam at ISIS labels Mar 1, 2024
@RichardWaiteSTFC RichardWaiteSTFC added this to the Release 6.10 milestone Mar 1, 2024
@robertapplin robertapplin self-assigned this Mar 5, 2024
@RichardWaiteSTFC RichardWaiteSTFC force-pushed the 35708_add_func_to_plot_MD_peak_integration_summary branch from 2d8bf24 to f5b7fe8 Compare March 5, 2024 09:43
Copy link
Contributor

@robertapplin robertapplin left a comment

Choose a reason for hiding this comment

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

Works really well, I just had a few suggestions - feel free to push back

Copy link
Contributor

@robertapplin robertapplin left a 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 really good! Just had a few minor suggestions then happy to approve this :)

Copy link
Contributor

@robertapplin robertapplin left a 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, this PR adds some really nice plotting functionality for the output of IntegratePeaksMD. Works really well, and a test has been added

@SilkeSchomann SilkeSchomann merged commit cbd9ae1 into main Mar 8, 2024
9 checks passed
@SilkeSchomann SilkeSchomann deleted the 35708_add_func_to_plot_MD_peak_integration_summary branch March 8, 2024 11:37
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 ISIS Team: Diffraction Issue and pull requests managed by the Diffraction subteam at ISIS Single Crystal Issues and pull requests related to single crystal
Projects
Status: Merged
Archived in project
Development

Successfully merging this pull request may close these issues.

Add pdf plot for IntegratePeaksMD in BaseSX class
3 participants