ExtractMembers option in ConvolutionFitSequential

I am using ConvlutionFitSequential to fit a Fourier transformed stretched exponential function to the Quasielastic spectra with the following python code-

fit_str = ConvolutionFitSequential(InputWorkspace=lino3,Function=function, BackgroundType=bgType,
StartX=startX, EndX=endX, SpecMin=specMin, SpecMax=specMax,
Convolve=convolve, PassWSIndexToFunction=True, Minimizer=minimizer,
MaxIterations=maxIt,ExtractMembers=True)

This returns the following error:


RuntimeError Traceback (most recent call last)
in ()
13 fit_str = ConvolutionFitSequential(InputWorkspace=lino3,Function=function, BackgroundType=bgType,
14 StartX=startX, EndX=endX, SpecMin=specMin, SpecMax=specMax,
—> 15 Convolve=convolve, PassWSIndexToFunction=True, Minimizer=minimizer, MaxIterations=maxIt,ExtractMembers=True)

/opt/Mantid/bin/mantid/simpleapi.pyc in algorithm_wrapper(InputWorkspace,Function,StartX,EndX,PassWSIndexToFunction=None,BackgroundType=None,SpecMin=None,SpecMax=None,Convolve=None,ExtractMembers=None,Minimizer=None,MaxIterations=None,PeakRadius=None, Version=1)
1024 set_properties(algm, *args, **final_keywords)
1025 try:
→ 1026 algm.execute()
1027 except RuntimeError as e:
1028 if e.args[0] == ‘Some invalid Properties found’:

RuntimeError: Number of members is incorrect.

While, if I keep

ExtractMembers=False

in the function, I don’t get this error. But I require these member functions of the fit in a separate workspace.

Can you write down the Mantid version you’re using, the values for the variables you’re passing to the optional arguments of ConvolutionFitSequential, and upload the resolution and data workspaces as nexus files?

Sorry for the delay!! I am using Mantid 3.11. I have uploaded the files after renaming them with '.txt ’ extension, since other formats are not allowed.

sample.txt (371.2 KB)
resolution.txt (618.8 KB)

the nexus files are renamed as txt files

Hi Harish,

Would you be able to provide the values you supplied for the remaining parameters?

Following on Brandon’s question, can you post a screenshot of the dialog for the ConvolutionFitSequential algorithm with the arguments filled for your particular case?

Also please post the string representation of your fit function. For instance, something like:

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)"""

Documentation for the algorithm: http://docs.mantidproject.org/nightly/algorithms/ConvolutionFitSequential-v1.html

I wasn’t using GUI yet, nevertheless I will try and post it. Does Conv Fit in Indirect → Analysis use the ‘ConvolutionFitSequential’ procedure?

This is the python code

function = “”"(composite=Convolution,FixResolution=true,NumDeriv=true;
name=TabulatedFunction,Workspace=res,WorkspaceIndex=0;
name=StretchedExpFT,Height=1.0,Tau=100,Beta=0.51,Centre=0)"""
bgType = “Fit Linear”
startX = -0.3
endX = 1.2
specMin = 0
specMax = sample.getNumberHistograms()-1
convolve = False
minimizer = “Levenberg-Marquardt”
maxIt = 500
fit_str = ConvolutionFitSequential(InputWorkspace=sample,Function=function, BackgroundType=bgType,
StartX=startX, EndX=endX, SpecMin=specMin, SpecMax=specMax,
Convolve=convolve, Minimizer=minimizer, MaxIterations=maxIt,ExtractMembers=False)

Hi Harish,

The ConvFit interface does indeed use the ConvolutionFitSequential algorithm.

If it’s not required that you use a python script to perform this fitting, the interface is a tool which will allow you to visualise and plot your data as well as the result of the fit. Note that the interface has undergone changes between Mantid versions 3.11 and 3.12 (outlined here -
http://docs.mantidproject.org/v3.12.0/release/v3.12.0/indirect_inelastic.html)

StretchedExpFT is an available function found in the drop-down menu labelled Fit Type of the ConvFit interface.

Hi Brandon,

Thank you for that information. May I know what algorithm it uses. I guess then it uses PlotPeakByLogValues if am not wrong.

Indeed, I can use the ConvFit GUI tool. But I had two things that I couldn’t find how to do in it,

  1. Fix the values of some parameters only for some Q-values (keep it free for others). Or set constraints to the value of parameters.
  2. I needed a convolution of (StretchedExpFT and Lorentzian) for my fit. This is the reason why I tried to write and learn python script for just StretchedExpFT.

Hi Harish,

In answer to both of your questions:

  1. In Mantid 3.11 constraints were not a possibility within the ConvFit interface. As of Mantid 3.12, this has now changed. You are able to set the Constraint/Fix/Tie for a parameter by right-clicking on it and choosing from the available options.
  2. This was also not possible within Mantid 3.11. In Mantid 3.12 you can now add additional functions not in the Fit Type drop-down menu, by right clicking on Functions and selecting Add Function. This will provide you with a grouped list of available functions within Mantid.

Hi Brandon,

Thank you for your patient replies. Will update to 3.12 and let you know how things go. :slight_smile:

PS: Just an aside, is it possible to get the python script for the ConvFit job I am doing? I couldn’t get it working alright in the earlier version. Thank a ton.

Hi Brandon,

I tried to fit the data with the function (convolution of Lorentzian and StretchedexpFT), unfortunately, it returned an error. I am attaching the screenshot with results log at bottom right.

I guess from the error shown that fit didn’t converge. Is that the case? Is there a better way to do this?

An update after increasing the number of iterations, FitStatus returned ‘success’, but again an error regarding the GroupWorkspaces popped up. I am attaching Error log for this case below:

ConvolutionFitSequential started
ConvertSpectrumAxis started (child)
ConvertSpectrumAxis successful, Duration 0.00 seconds
Fit started
Numeric derivatives should be used when non-constant ties defined.
Fit status: success
Stopped after 1840 iterations
Fit successful, Duration 5 minutes 45.32 seconds
GroupWorkspaces started
GroupWorkspaces successful, Duration 0.00 seconds
GroupWorkspaces started
GroupWorkspaces successful, Duration 0.00 seconds
GroupWorkspaces started
GroupWorkspaces successful, Duration 0.00 seconds
ConvolutionFitSequential successful, Duration 5 minutes 45.33 seconds
Unexpected exception: Invalid value for property Workspace (Workspace) “300_conv_FitL_s0_Workspaces”: Workspace “300_conv_FitL_s0_Workspaces” was not found in the Analysis Data Service
Unexpected exception: Invalid value for property Workspace (Workspace) “300_conv_FitL_s0_Workspaces”: Workspace “300_conv_FitL_s0_Workspaces” was not found in the Analysis Data Service
Unexpected exception: Invalid value for property Workspace (Workspace) “300_conv_FitL_s0_Workspaces”: Workspace “300_conv_FitL_s0_Workspaces” was not found in the Analysis Data Service
Continue working.

Thank you

Hi Harish,

Apologies for the slow response, I have been away on Annual Leave.

This in fact looks like an issue with how the ConvolutionFitSequential algorithm names the output workspaces. The fit here has ran successfully but unfortunately, the ExtractMembers stage of the routine has been provided the wrong name.

Thank you for bringing attention to this problem. At the present, adding an underscore character at the end of the name of the sample file, prior to supplying it to the ConvFit interface, should fix this issue - a more permanent solution to this issue is now being worked on.

Hi Brandon,

Do you mean change the workspace name by adding an underscore at the end? Like for example,

sample → sample_

Thanks
Harish

Hi Harish,

Yes, before supplying this workspace (or file) to the ConvFit interface.

Hi,

In my case it still doesn’t seem to work. I changed my filename from 365_sub.nxs to 365_sub_.nxs and likewise for resolution file too. Here is the screenshot

Harish
Some hints for fitting that you might find useful.

  1. Try the Bayes routines if you are using Windows. The gui is Bayes>Quasi.
    If you think you have 2 peaks the Lorentzian option will give you the probabilities for 1,2 & 3 peaks.
    If you think you have a stretched option use that option and it will give you the tau & beta.
    It should also show if any spectra have poor fitting.
  2. For stretched exponential try transforming to I(q,t) and then use IqtFit. You can start with a simple exp & then move to stretched. Again this will show which function is most appropriate.

Regarding extracting members, there are 2 forms: the bare function and the convolved function. The former would be appropriate for comparing with theory & the latter checking the Fit.

Spencer
Spencer.howells@stfc.ac.uk

Hi Spencer,

Thank you for the suggestions.

  1. I am using Ubuntu 14.04 (Linux), seems like Bayes>Quasi is showing some error. Is it possible to use it only in Windows with the current version?

Harish

Harish
The programs are in Fortran and are only distributed on Windows.
I do have a set of files for Ubuntu and I will send them next weds when I am in ISIS. You just copy them into Mantid - instructions will be included.
Spencer

1 Like

Str_exp_beta.txt (15.6 KB)
Str_exp_tau.txt (15.4 KB)

pdf files of results of fit using ConvFit with background & StretchedExpFT