Skip to content

Enable changing of wildes flipper config via the ISIS Reflectometry GUI#41353

Open
MialLewis wants to merge 6 commits into
mainfrom
enable_changing_of_wildes_flipper_config
Open

Enable changing of wildes flipper config via the ISIS Reflectometry GUI#41353
MialLewis wants to merge 6 commits into
mainfrom
enable_changing_of_wildes_flipper_config

Conversation

@MialLewis
Copy link
Copy Markdown
Contributor

@MialLewis MialLewis commented May 5, 2026

Description of work

  • Generalised the ISIS Reflectometry polarization input spin-state order so the GUI value can be used for both Fredrikze and Wildes corrections.
  • Reused SpinStateValidator for spin-state family validation. This is used to check if Wildes flipper config is being used for a Fredrikze correction and vice-versa.
  • Added warnings when Fredrikze or Wildes spin-state defaults are missing from the instrument parameter file and algorithm defaults are used.
  • Added/updated tests covering GUI propagation, Fredrikze/Wildes validation, IPF defaults, and fallback behaviour.
  • Extracted polarization correction code out of ReflectometryReductionOneAuto to a helper class ReflectometryPolarizationCorrectionISIS to aid readability.

Closes #41041

To test:

Follow test instructions on this PR:
#38783

Ensure to test the different errors expected when you use Wildes correction for Fredriekze, 2 spin states inputs when 4 is expected etc.

Also test changing the defaults in the instrument parameter files, ensure those values are pulled through correctly.

To test a realistic polarised reduction:

from mantid.simpleapi import *

Load(Filename='/Users/mial.lewis/data/PNR/POLREF00047039.nxs', OutputWorkspace='POLREF00047039')
Load(Filename='/Users/mial.lewis/data/PNR/POLREF00047041.nxs', OutputWorkspace='POLREF00047041')
Load(Filename='/Users/mial.lewis/data/PNR/polref_pol_corr_05_03_26.nxs', OutputWorkspace='polref_pol_corr_05_03_26')
LoadInstrument(Workspace='POLREF00047039', InstrumentName='POLREF', RewriteSpectraMap=False)
LoadInstrument(Workspace='POLREF00047041', InstrumentName='POLREF', RewriteSpectraMap=False)
LoadInstrument(Workspace='polref_pol_corr_05_03_26', InstrumentName='POLREF', RewriteSpectraMap=False)
ReflectometryReductionOneAuto(InputWorkspace='POLREF00047041',
                          ThetaIn=0.4, ProcessingInstructions='272-288',
                          WavelengthMin=1, WavelengthMax=15, I0MonitorIndex=2, MonitorBackgroundWavelengthMin=15,
                          MonitorBackgroundWavelengthMax=16, MonitorIntegrationWavelengthMin=4, MonitorIntegrationWavelengthMax=10,
                          SubtractBackground=True, BackgroundProcessingInstructions='360-450', FirstTransmissionRun='POLREF00047039', PolarizationAnalysis=True, PolarizationEfficiencies='polref_pol_corr_05_03_26')

Reviewer

Your comments will be used as part of the gatekeeper process. Comment clearly on what you have checked and tested during your review. Provide an audit trail for any changes requested.

As per the review guidelines:

  • Is the code of an acceptable quality? (Code standards/GUI standards)
  • Has a thorough functional test been performed? Do the changes handle unexpected input/situations?
  • Are appropriately scoped unit and/or system tests provided?
  • Do the release notes conform to the guidelines and describe the changes appropriately?
  • Has the relevant (user and developer) documentation been added/updated?
  • If the PR author isn’t in the mantid-developers or mantid-contributors teams, add a review comment rerun ci to authorize/rerun the CI

Gatekeeper

As per the gatekeeping guidelines:

  • Has a thorough first line review been conducted, including functional testing?
  • At a high-level, is the code quality sufficient?
  • Are the base, milestone and labels correct?

@github-actions github-actions Bot added this to the Release 6.16 milestone May 5, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 6, 2026

System test results

810 tests   792 ✅  2h 13m 52s ⏱️
 48 suites   17 💤
 48 files      1 ❌

Results for commit 0572532.

@MialLewis MialLewis marked this pull request as ready for review May 6, 2026 12:33
@github-actions github-actions Bot added the Has Conflicts Used by the bot to label pull requests that have conflicts label May 14, 2026
@github-actions
Copy link
Copy Markdown
Contributor

👋 Hi, @MialLewis,

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

@MialLewis MialLewis force-pushed the enable_changing_of_wildes_flipper_config branch from 0572532 to 4bb2aba Compare May 20, 2026 12:57
@github-actions github-actions Bot removed the Has Conflicts Used by the bot to label pull requests that have conflicts label May 20, 2026
@MialLewis MialLewis changed the base branch from main to group_workspace_history_change May 20, 2026 12:59
Base automatically changed from group_workspace_history_change to main May 20, 2026 14:29
@github-actions github-actions Bot added the Has Conflicts Used by the bot to label pull requests that have conflicts label May 20, 2026
@github-actions
Copy link
Copy Markdown
Contributor

👋 Hi, @MialLewis,

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

@github-actions github-actions Bot removed the Has Conflicts Used by the bot to label pull requests that have conflicts label May 20, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Unit test results (Linux)

2 870 tests   2 869 ✅  13h 41m 25s ⏱️
    1 suites      0 💤
    1 files        1 ❌

Results for commit 3c6cc3a.

@MialLewis MialLewis requested a review from cailafinn May 21, 2026 08:44
</property>
<property name="text">
<string>Fredrikze Input SpinState Order</string>
<string>Input SpinState Order</string>
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I plan to change this to Input Flipper/SpinState order, I'll make the change when addressing review comments.

Copy link
Copy Markdown
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.

Functionally tested according to instructions, getting good error messages for wrong correction alg type (p,a vs 0, 1) and for numbers of spin states. But there is a slightly unexpected one for if the wrong form is used. E.g Wildes PNR & (00, 11):

Error in execution of algorithm ReflectometryISISLoadAndProcess:
Add Data Object with empty name
  at line 111 in '/Users/caila.finn/repos/mantid-r/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ReflectometryISISLoadAndProcess.py'
  caused by line 656 in '/Users/caila.finn/repos/mantid-r/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ReflectometryISISLoadAndProcess.py'

Just one note on the release note and the GUI change that you'd already spotted.

Comment on lines +1 to +5
- The ISIS Reflectometry GUI polarization input spin state order field can now be used to specify the Wildes flipper
configuration as well as the Fredrikze input spin state order. Leaving the field empty continues to use the defaults
from the instrument parameter file or correction algorithm.
- The reduction now reports when a Fredrikze spin state order is supplied for a Wildes correction, or a Wildes flipper
configuration is supplied for a Fredrikze correction.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Are there docs links we could be including here?

@MialLewis
Copy link
Copy Markdown
Contributor Author

Functionally tested according to instructions, getting good error messages for wrong correction alg type (p,a vs 0, 1) and for numbers of spin states. But there is a slightly unexpected one for if the wrong form is used. E.g Wildes PNR & (00, 11):

Error in execution of algorithm ReflectometryISISLoadAndProcess:
Add Data Object with empty name
  at line 111 in '/Users/caila.finn/repos/mantid-r/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ReflectometryISISLoadAndProcess.py'
  caused by line 656 in '/Users/caila.finn/repos/mantid-r/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ReflectometryISISLoadAndProcess.py'

Just one note on the release note and the GUI change that you'd already spotted.

Good spot, I didn't consider this case

@samtygier-stfc samtygier-stfc changed the base branch from main to release-next May 21, 2026 15:48
@sf1919 sf1919 moved this to Ready for Review in v6.16.0 release May 22, 2026
@sf1919 sf1919 removed this from v6.16.0 release May 22, 2026
@MialLewis MialLewis force-pushed the enable_changing_of_wildes_flipper_config branch from 3c6cc3a to 9966697 Compare May 22, 2026 11:04
@github-actions github-actions Bot added the Has Conflicts Used by the bot to label pull requests that have conflicts label May 22, 2026
@github-actions
Copy link
Copy Markdown
Contributor

👋 Hi, @MialLewis,

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

@github-actions github-actions Bot removed the Has Conflicts Used by the bot to label pull requests that have conflicts label May 22, 2026
@MialLewis MialLewis force-pushed the enable_changing_of_wildes_flipper_config branch from a8cc46f to 1473807 Compare May 22, 2026 11:08
@github-actions github-actions Bot added the Has Conflicts Used by the bot to label pull requests that have conflicts label May 22, 2026
@github-actions
Copy link
Copy Markdown
Contributor

👋 Hi, @MialLewis,

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

MialLewis added 2 commits May 22, 2026 13:34
Improve polarization spin state validation

refactor to utilise existing spin state validation

Improve Fredrikze spin state count validation

Refactor reflectometry polarization correction handling

Address reflectometry polarization review comments
@MialLewis MialLewis force-pushed the enable_changing_of_wildes_flipper_config branch from 1473807 to b40613d Compare May 22, 2026 12:34
@github-actions github-actions Bot removed the Has Conflicts Used by the bot to label pull requests that have conflicts label May 22, 2026
@MialLewis MialLewis requested a review from cailafinn May 22, 2026 12:39
@MialLewis
Copy link
Copy Markdown
Contributor Author

MialLewis commented May 22, 2026

Functionally tested according to instructions, getting good error messages for wrong correction alg type (p,a vs 0, 1) and for numbers of spin states. But there is a slightly unexpected one for if the wrong form is used. E.g Wildes PNR & (00, 11):

Error in execution of algorithm ReflectometryISISLoadAndProcess:
Add Data Object with empty name
  at line 111 in '/Users/caila.finn/repos/mantid-r/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ReflectometryISISLoadAndProcess.py'
  caused by line 656 in '/Users/caila.finn/repos/mantid-r/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ReflectometryISISLoadAndProcess.py'

Just one note on the release note and the GUI change that you'd already spotted.

Good spot, I didn't consider this case

I didn't make a change with regards to this. It turns out that 00, 11 is a valid input spin states to PolarizationCorrectionWildes, which deals with the validation: https://docs.mantidproject.org/v6.15.0/algorithms/PolarizationCorrectionWildes-v1.html

It has always been possible to encounter this error so it's not a regression, though one would have had to previously edit the parameters file.

I'll need to discuss how this should behave in the context of the Polarised Reflectivity workflow with the Reflectometry scientists.

Issue: #41469

@MialLewis MialLewis force-pushed the enable_changing_of_wildes_flipper_config branch from db9333d to aab892a Compare May 22, 2026 14:04
@github-actions github-actions Bot added the Has Conflicts Used by the bot to label pull requests that have conflicts label May 22, 2026
@github-actions
Copy link
Copy Markdown
Contributor

👋 Hi, @MialLewis,

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

@github-actions github-actions Bot removed the Has Conflicts Used by the bot to label pull requests that have conflicts label May 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enable the changing of Wildes flipper config via the GUI

3 participants