Skip to content

Record processGroups parent history for reflectometry reductions#41345

Draft
MialLewis wants to merge 7 commits intorefactor_rroafrom
group_workspace_history_change
Draft

Record processGroups parent history for reflectometry reductions#41345
MialLewis wants to merge 7 commits intorefactor_rroafrom
group_workspace_history_change

Conversation

@MialLewis
Copy link
Copy Markdown
Contributor

@MialLewis MialLewis commented May 5, 2026

Description of work

In Algorithm::doCallProcessGroups, the history associated with the initial call to on the group workspace is not saved on resultant output workspace. This is because historically the initial call is expected to in turn make repeated calls to the algorithm on the workspace members, which would in turn provide the history.

For some workflows, such as RelfectometryReductionOneAuto, this is not the case. If the algorithm is called on a WorkspaceGroup containing polarized data, each member of the workspace group represents a spin state. A unique polarisation analysis path is followed, where the reductions are interlinked via the calculation of the polarization efficiencies.

This PR therefore adds a flag (and exposes it to python) that allows the writer of an algorithm to select how workspace history works with groups:

m_recordHistoryForProcessGroups = False -> Workspace history for initial algorithm call disregarded. History can be added to output workspaces for each individual algorithm call, if the writer so chooses.

m_recordHistoryForProcessGroups = False -> Workspace history for initial algorithm call is kept, subsequent algorithms can be called as a child and their history will be rolled up into that of the parent.

Closes #36985

To test:

Run these test scripts before and after these changes, see that the algorithm histories for ReflectometryISISLoadAndProcess and ReflectometryReductionOneAuto and nicely rolled up under their parents.

For first test, ask for data, or second test use test data.

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')
# import mantid algorithms, numpy and matplotlib
from mantid.simpleapi import *
import matplotlib.pyplot as plt
import numpy as np

inputs = Load(Filename='ISISReflectometryTestRuns.nxs')
run_number="45222"
run_name=str(run_number)
first_transmission_runs=["45226"]
second_transmission_runs=["45227"]
time_interval=None
if time_interval is not None:
    do_slicing = True
else:
    do_slicing = False
suffix="_IvsQ"
ReflectometryISISLoadAndProcess(
    InputRunList=run_name,
    ProcessingInstructions="4",
    StartOverlap=10,
    EndOverlap=12,
    FirstTransmissionRunList=",".join(first_transmission_runs),
    SecondTransmissionRunList=",".join(second_transmission_runs),
    SliceWorkspace=do_slicing,
    TimeInterval=time_interval,
    UseNewFilterAlgorithm=False,
    OutputWorkspaceBinned=run_name + suffix + "_binned",
    OutputWorkspace=run_name + suffix,
    OutputWorkspaceWavelength=run_name + "_lam",
    debug=False
)

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

github-actions Bot commented May 5, 2026

Unit test results

2 868 tests   2 867 ✅  2h 21m 6s ⏱️
    1 suites      0 💤
    1 files        1 ❌

Results for commit d351792.

♻️ This comment has been updated with latest results.

@MialLewis MialLewis force-pushed the group_workspace_history_change branch from ae5cecc to d351792 Compare May 5, 2026 15:33
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.

1 participant