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 error calculation to FlipperEfficiency algorithm #37523

Conversation

rbauststfc
Copy link
Contributor

Description of work

Summary of work

Calculates the errors using the equation given on the linked issue. This is required because default Mantid error calculation is not sufficiently accurate when applying polarisation corrections.

Fixes #37458

Further detail of work

This change should be a direct implementation of the equation on the linked issue. The only exception is that the equation shown includes the modulus symbol around the square of the partial derivatives, which I haven't included in the implementation. My understanding is that because the values are being squared it won't make a difference here, but please let me know if this is not correct.

To test:

Can be tested with the following script:

CreateSampleWorkspace(OutputWorkspace='out_00', Function='User Defined', UserDefinedFunction='name=Lorentzian, Amplitude=48000, PeakCentre=2.65, FWHM=1.2', XUnit='wavelength', NumBanks=1, BankPixelWidth=1, XMin=0, XMax=16.5, BinWidth=0.1)
CreateSampleWorkspace(OutputWorkspace='out_11', Function='User Defined', UserDefinedFunction='name=Lorentzian, Amplitude=47000, PeakCentre=2.65, FWHM=1.2', XUnit='wavelength', NumBanks=1, BankPixelWidth=1, XMin=0, XMax=16.5, BinWidth=0.1)
CreateSampleWorkspace(OutputWorkspace='out_10', Function='User Defined', UserDefinedFunction='name=Lorentzian, Amplitude=22685, PeakCentre=2.55, FWHM=0.6', XUnit='wavelength', NumBanks=1, BankPixelWidth=1, XMin=0, XMax=16.5, BinWidth=0.1)
CreateSampleWorkspace(OutputWorkspace='out_01', Function='User Defined', UserDefinedFunction='name=Lorentzian, Amplitude=22685, PeakCentre=2.55, FWHM=0.6', XUnit='wavelength', NumBanks=1, BankPixelWidth=1, XMin=0, XMax=16.5, BinWidth=0.1)

group = GroupWorkspaces(['out_00','out_11','out_10','out_01'])

group = ConvertUnits(group, "Wavelength")

out = FlipperEfficiency(group, SpinStates="00, 11, 10, 01")

# Should give result approximately equal to 0.024600439254069618
print(out.readE(0)[0])

To check the documentation changes, build the docs-html target.

This does not require release notes because it is a change to an algorithm that is new in version 6.10.


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.

@rbauststfc rbauststfc added SANS Issues and pull requests related to SANS ISIS Team: LSS Issue and pull requests managed by the LSS subteam at ISIS labels Jun 14, 2024
@rbauststfc rbauststfc added this to the Release 6.10 milestone Jun 14, 2024
@rbauststfc rbauststfc force-pushed the 37458_FlipperEfficiency_alg_errors branch from 4e85847 to 052dc3c Compare June 14, 2024 14:53
@jclarkeSTFC jclarkeSTFC self-assigned this Jun 14, 2024
@rbauststfc rbauststfc force-pushed the 37458_FlipperEfficiency_alg_errors branch from 052dc3c to d499857 Compare June 14, 2024 15:01
@rbauststfc rbauststfc marked this pull request as ready for review June 17, 2024 07:22
@rbauststfc rbauststfc linked an issue Jun 17, 2024 that may be closed by this pull request
Copy link
Contributor

@jclarkeSTFC jclarkeSTFC left a comment

Choose a reason for hiding this comment

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

Partial derivatives agree with Wolfram Alpha, algorithm runs as expected. The errors are now much smaller than they were previously (ZOOM 22708), as expected:

image

@RichardWaiteSTFC RichardWaiteSTFC merged commit 0e8d466 into mantidproject:release-next Jun 17, 2024
10 checks passed
@rbauststfc rbauststfc deleted the 37458_FlipperEfficiency_alg_errors branch July 4, 2024 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ISIS Team: LSS Issue and pull requests managed by the LSS subteam at ISIS SANS Issues and pull requests related to SANS
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FlipperEfficiency algorithm needs proper error calculation
3 participants