\(\renewcommand\AA{\unicode{x212B}}\)

ExtractQENSMembers v1

../_images/ImageNotFound.png

Enable screenshots using DOCS_SCREENSHOTS in CMake

Summary

Extracts the fit members from a QENS fit

Properties

Name

Direction

Type

Default

Description

InputWorkspace

Input

MatrixWorkspace

The input workspace used in the fit. Ignored if ‘InputWorkspaces’ property is provided.

InputWorkspaces

Input

str list

List of the workspaces used in the fit.

ResultWorkspace

Input

WorkspaceGroup

Mandatory

The result group workspace produced in a QENS fit.

RenameConvolvedMembers

Input

boolean

False

If true, renames the n-th ‘Convolution’ member, to the n-th supplied name in the ConvolvedMembers property.

ConvolvedMembers

Input

str list

A list of the names of the members which were convolved before being output by the fit routine. These must be provided in the same order as originally provided to the fit.

OutputWorkspace

Output

WorkspaceGroup

Mandatory

The output workspace group, containing the fit members.

Description

Extracts the fit members from a QENS fit and stores each of them in a group workspace.

Usage

Example

# Load sample and resolution files
sample = Load('irs26176_graphite002_red.nxs', OutputWorkspace='irs26176_graphite002_red')
resolution = Load('irs26173_graphite002_red.nxs')

# Set up fit algorithm parameters
function = """name=LinearBackground,A0=0,A1=0,ties=(A0=0.000000,A1=0.0);
(composite=Convolution,FixResolution=true,NumDeriv=true;
name=Resolution,Workspace=resolution,WorkspaceIndex=0;
name=Lorentzian,Amplitude=1,PeakCentre=0,FWHM=0.0175)"""
startX = -0.547608
endX = 0.543217
specMin = 0
specMax = sample.getNumberHistograms() - 1
convolve = True  # Convolve the fitted model components with the resolution
minimizer = "Levenberg-Marquardt"
maxIt = 500
output_ws_name = "irs26176_graphite002_conv_1LFixF_s0_to_9"

# Run ConvolutionFitSequential algorithm
ConvolutionFitSequential(InputWorkspace=sample, Function=function,
                         PassWSIndexToFunction=True, StartX=startX, EndX=endX,
                         SpecMin=specMin, SpecMax=specMax, OutputCompositeMembers=convolve, ConvolveMembers=convolve,
                         Minimizer=minimizer, MaxIterations=maxIt,
                         OutputWorkspace=output_ws_name)

# Extract members from the output of the ConvolutionFitSequential algorithm
members_ws = ExtractQENSMembers(InputWorkspace=sample, ResultWorkspace=output_ws_name+"_Workspaces",
                                RenameConvolvedMembers=True, ConvolvedMembers=["Lorentzian"],
                                OutputWorkspace=output_ws_name+"_Members")

for member_ws in members_ws:
    print(member_ws.getName())

Output:

irs26176_graphite002_conv_1LFixF_s0_to_9_Members_Data
irs26176_graphite002_conv_1LFixF_s0_to_9_Members_Calc
irs26176_graphite002_conv_1LFixF_s0_to_9_Members_Diff
irs26176_graphite002_conv_1LFixF_s0_to_9_Members_LinearBackground
irs26176_graphite002_conv_1LFixF_s0_to_9_Members_Lorentzian
# Load sample and resolution files
sample = Load('irs26176_graphite002_red.nxs', OutputWorkspace='irs26176_graphite002_red')
resolution = Load('irs26173_graphite002_red.nxs')

# Set up fit algorithm parameters
function = """name=LinearBackground,A0=0,A1=0,ties=(A0=0.000000,A1=0.0);
(composite=Convolution,FixResolution=true,NumDeriv=true;
name=Resolution,Workspace=resolution,WorkspaceIndex=0;
name=Lorentzian,Amplitude=1,PeakCentre=0,FWHM=0.0175)"""
startX = -0.547608
endX = 0.543217
specMin = 0
specMax = sample.getNumberHistograms() - 1
convolve = True  # Convolve the fitted model components with the resolution
minimizer = "Levenberg-Marquardt"
maxIt = 500
output_ws_name = "irs26176_graphite002_conv_1LFixF_s0_to_9"

# Run ConvolutionFitSequential algorithm with ExtractMembers property
ConvolutionFitSequential(InputWorkspace=sample, Function=function, PassWSIndexToFunction=True,
                         StartX=startX, EndX=endX, SpecMin=specMin, SpecMax=specMax, OutputCompositeMembers=convolve,
                         ConvolveMembers=convolve, Minimizer=minimizer, MaxIterations=maxIt,
                         ExtractMembers=True, OutputWorkspace=output_ws_name)

members_ws = mtd[output_ws_name + "_Members"]

for member_ws in members_ws:
    print(member_ws.getName())
irs26176_graphite002_conv_1LFixF_s0_to_9_Members_Data
irs26176_graphite002_conv_1LFixF_s0_to_9_Members_Calc
irs26176_graphite002_conv_1LFixF_s0_to_9_Members_Diff
irs26176_graphite002_conv_1LFixF_s0_to_9_Members_LinearBackground
irs26176_graphite002_conv_1LFixF_s0_to_9_Members_Lorentzian

Categories: AlgorithmIndex | Workflow\MIDAS

Source

C++ header: ExtractQENSMembers.h

C++ source: ExtractQENSMembers.cpp