ConvolutionFitSequential v1

../_images/ConvolutionFitSequential-v1_dlg.png

ConvolutionFitSequential dialog.

Summary

Performs a sequential fit for a convolution workspace

Properties

Name Direction Type Default Description
InputWorkspace Input MatrixWorkspace Mandatory The input workspace for the fit.
Function Input string Mandatory The function that describes the parameters of the fit.
PassWSIndexToFunction Input boolean False For each spectrum in Input pass its workspace index to all functions that have attribute WorkspaceIndex.
BackgroundType Input string Fixed Flat The Type of background used in the fitting. Allowed values: [‘Fixed Flat’, ‘Fit Flat’, ‘Fit Linear’]
StartX Input number Mandatory The start of the range for the fit function.
EndX Input number Mandatory The end of the range for the fit function.
SpecMin Input number 0 The first spectrum to be used in the fit. Spectra values can not be negative
SpecMax Input number 0 The final spectrum to be used in the fit. Spectra values can not be negative
Convolve Input boolean True If true, output fitted model components will be convolved with the resolution.
ExtractMembers Input boolean False If true, then each member of the convolution fit will be extracted, into their own workspace. These workspaces will have a histogram for each spectrum (Q-value) and will be grouped.
Minimizer Input string Levenberg-Marquardt Minimizer to use for fitting. Minimizers available are ‘Levenberg-Marquardt’, ‘Simplex’, ‘FABADA’, ‘Conjugate gradient (Fletcher-Reeves imp.)’, ‘Conjugate gradient (Polak-Ribiere imp.)’ and ‘BFGS’
MaxIterations Input number 500 The maximum number of iterations permitted
PeakRadius Input number 0 A value of the peak radius the peak functions should use. A peak radius defines an interval on the x axis around the centre of the peak where its values are calculated. Values outside the interval are not calculated and assumed zeros.Numerically the radius is a whole number of peak widths (FWHM) that fit into the interval on each side from the centre. The default value of 0 means the whole x axis.
OutputWorkspace Output MatrixWorkspace Mandatory The OutputWorkspace containing the results of the fit.

Description

An algorithm designed mainly as a sequential call to PlotPeakByLogValue but used within the ConvFit tab within the Indirect Analysis interface to fit Convolution Functions.

Usage

Example - ConvolutionFitSequential

from __future__ import print_function

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

# Set up 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)"""
bgType = "Fixed Flat"
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

# Run algorithm
result_ws = ConvolutionFitSequential(InputWorkspace=sample,
    Function=function, PassWSIndexToFunction=True, BackgroundType=bgType,
    StartX=startX, EndX=endX, SpecMin=specMin, SpecMax=specMax,
    Convolve=convolve, Minimizer=minimizer, MaxIterations=maxIt)

print("Result has %i Spectra" %result_ws.getNumberHistograms())

print("Amplitude 0: %.3f" %(result_ws.readY(0)[0]))
print("Amplitude 1: %.3f" %(result_ws.readY(0)[1]))
print("Amplitude 2: %.3f" %(result_ws.readY(0)[2]))

print("X axis at 0: %.5f" %(result_ws.readX(0)[0]))
print("X axis at 1: %.5f" %(result_ws.readX(0)[1]))
print("X axis at 2: %.5f" %(result_ws.readX(0)[2]))

print("Amplitude Err 0: %.5f" %(result_ws.readE(0)[0]))
print("Amplitude Err 1: %.5f" %(result_ws.readE(0)[1]))
print("Amplitude Err 2: %.5f" %(result_ws.readE(0)[2]))

Output:

Result has 2 Spectra

Amplitude 0: 4.314
Amplitude 1: 4.213
Amplitude 2: 4.555

X axis at 0: 0.52531
X axis at 1: 0.72917
X axis at 2: 0.92340

Amplitude Err 0: 0.00460
Amplitude Err 1: 0.00468
Amplitude Err 2: 0.00577

Categories: Algorithms | Workflow\MIDAS

Source

C++ source: ConvolutionFitSequential.cpp (last modified: 2018-02-07)

C++ header: ConvolutionFitSequential.h (last modified: 2018-01-29)