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 algorithm for calculating Wildes polarization efficiencies #37753

Conversation

rbauststfc
Copy link
Contributor

@rbauststfc rbauststfc commented Aug 6, 2024

Description of work

Summary of work

Adds new algorithm PolarizationEfficienciesWildes that calculates the polarization efficiencies for a two-flipper instrument setup according to the Wildes 2006 paper. This implementation is based on the implementation that POLREF are currently using in their reduction code.

It is one of three algorithms that will be written under the linked issue.

Refs #35682.

Further detail of work

See linked issue for detailed description of what was required, and see the algorithm documentation (or the appropriate sections of the Wildes 2006 paper, as referenced in the linked issue) for the equations that have been implemented.

Note that the errors currently use the default Mantid errors. This is discussed on the main issue and, as stated there, we've agreed with our scientists that this is what should be done for the first version of this algorithm.

I will be adding a system test at a later stage (but before closing the linked issue), potentially for the whole workflow rather than specifically for this algorithm.

To test:

  • Build the docs-html target and check that the algorithm documentation renders OK and is understandable.

  • The following script can be used to test the algorithm functionality:

ws00 = CreateSampleWorkspace(XUnit="Wavelength", NumBanks=1, BankPixelWidth=1, Function="User Defined", UserDefinedFunction="name=UserFunction, Formula=x*0+12")
ws01 = CreateSampleWorkspace(XUnit="Wavelength", NumBanks=1, BankPixelWidth=1, Function="User Defined", UserDefinedFunction="name=UserFunction, Formula=x*0+1")
ws10 = CreateSampleWorkspace(XUnit="Wavelength", NumBanks=1, BankPixelWidth=1, Function="User Defined", UserDefinedFunction="name=UserFunction, Formula=x*0+2")
ws11 = CreateSampleWorkspace(XUnit="Wavelength", NumBanks=1, BankPixelWidth=1, Function="User Defined", UserDefinedFunction="name=UserFunction, Formula=x*0+10")

nonMag = GroupWorkspaces([ws00, ws01, ws10, ws11])

wsM00 = CreateSampleWorkspace(XUnit="Wavelength", NumBanks=1, BankPixelWidth=1, Function="User Defined", UserDefinedFunction="name=UserFunction, Formula=x*0+6")
wsM01 = CreateSampleWorkspace(XUnit="Wavelength", NumBanks=1, BankPixelWidth=1, Function="User Defined", UserDefinedFunction="name=UserFunction, Formula=x*0+0.2")
wsM10 = CreateSampleWorkspace(XUnit="Wavelength", NumBanks=1, BankPixelWidth=1, Function="User Defined", UserDefinedFunction="name=UserFunction, Formula=x*0+0.3")
wsM11 = CreateSampleWorkspace(XUnit="Wavelength", NumBanks=1, BankPixelWidth=1, Function="User Defined", UserDefinedFunction="name=UserFunction, Formula=x*0+1")

mag = GroupWorkspaces([wsM00, wsM01, wsM10, wsM11])

PolarizationEfficienciesWildes('nonMag', 'mag', Flippers='00,01,10,11', IncludeDiagnosticOutputs=True, OutputFpEfficiency="fp", OutputFaEfficiency="fa", OutputPolarizerEfficiency="p", OutputAnalyserEfficiency="a")
  • If you would like to test with real calibration runs then talk to Rachel.

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 Reflectometry Issues and pull requests related to reflectometry ISIS Team: LSS Issue and pull requests managed by the LSS subteam at ISIS labels Aug 6, 2024
@rbauststfc rbauststfc added this to the Release 6.11 milestone Aug 6, 2024
@rbauststfc rbauststfc force-pushed the 35682_Wildes_efficiencies_algorithm branch from b328da0 to 43a39bf Compare August 6, 2024 12:48
@sf1919
Copy link
Contributor

sf1919 commented Aug 6, 2024

@rbauststfc please ignore the 200+ OSX test failures - problem with a machine. PR should run on a different machine next time you push a commit.

@rbauststfc rbauststfc force-pushed the 35682_Wildes_efficiencies_algorithm branch from 43a39bf to ef350c7 Compare August 6, 2024 14:20
@rbauststfc rbauststfc marked this pull request as ready for review August 7, 2024 07:23
@github-actions github-actions bot added the Has Conflicts Used by the bot to label pull requests that have conflicts label Aug 7, 2024
Copy link

github-actions bot commented Aug 7, 2024

👋 Hi, @rbauststfc,

Conflicts have been detected against the base branch. Please rebase your branch against the base branch.

@rbauststfc rbauststfc removed the Has Conflicts Used by the bot to label pull requests that have conflicts label Aug 7, 2024
@rbauststfc rbauststfc force-pushed the 35682_Wildes_efficiencies_algorithm branch from ef350c7 to 536fa47 Compare August 7, 2024 14:44
@cailafinn cailafinn self-assigned this Aug 19, 2024
Copy link
Contributor

@cailafinn cailafinn left a comment

Choose a reason for hiding this comment

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

Code looks really good, just a few very minor comments. Docs looking good, just a note on the See Also section.

Functionally tested using the provided script, which worked really well. Some further functional testing revealed an issue when either the OutputPolarizerEfficiency or OutputAnalyzerEfficiency workspace names are not provided. This only occurs in the algorithm dialog if it has been set to Keep open, run once with the flipper/polariser names set, and then run again with the names removed.

Error in execution of algorithm PolarizationEfficienciesWildes:
Add Data Object with empty name

Includes inputs, outputs and validation, with unit tests
The algorithm uses private member variables that need to be cleared to
prevent previously calculated values being returned if an instance of
the algorithm is run twice. In addition, the algorithm provides some
optional diagnostic output properties that we provide default values for. If the algorithm is being run as a child
then these can incorrectly remain populated with previous values if we do not clear them when they are not required. It seems that setting the property value to it's current value (to deliberately retain any edits the user has made to that) is sufficient to clear the associated output workspace.
@rbauststfc rbauststfc force-pushed the 35682_Wildes_efficiencies_algorithm branch from 536fa47 to b9643f4 Compare August 20, 2024 16:10
@rbauststfc rbauststfc requested a review from cailafinn August 21, 2024 07:16
Copy link
Contributor

@cailafinn cailafinn left a comment

Choose a reason for hiding this comment

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

Changes to the code look good, functionally working well for multiple runs, documentation looking good. Nice work, happy to approve :shipit:

@SilkeSchomann SilkeSchomann self-assigned this Aug 21, 2024
@SilkeSchomann SilkeSchomann merged commit 39ab5dd into mantidproject:main Aug 21, 2024
10 checks passed
@rbauststfc rbauststfc deleted the 35682_Wildes_efficiencies_algorithm branch September 30, 2024 12:15
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 Reflectometry Issues and pull requests related to reflectometry
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants