Ticket #6621: MultiDomainFit.py

File MultiDomainFit.py, 977 bytes (added by Roman Tolchenov, 8 years ago)

This is my working progress

Line 
1Load(r'C:\Users\hqs74821\Work\mantid\Test\AutoTestData\MUSR00015189.nxs',OutputWorkspace='musr')
2inputWS = 'musr_1'
3nHist = 3#mtd[inputWS].getNumberHistograms()
4outNm = 'output' #getWSprefix(inputWS) + 'fury'
5f1 = """(
6    composite=CompositeFunction,$domains=i;
7    name=LinearBackground,A0=0,A1=0,ties=(A1=0);
8    name=UserFunction,Formula=Intensity*exp(-(x/Tau)^Beta),Intensity=1.0,Tau=0.1,Beta=1;ties=(f1.Intensity=1-f0.A0)
9);
10"""#.replace('$WORKSPACE$',inputWS)
11func= 'composite=MultiDomainFunction,NumDeriv=1;'
12ties='ties=('
13kwargs = {}
14for i in range(0,nHist):
15    func+=f1
16    if i > 0:
17        ties += 'f' + str(i) + '.f1.Beta=f0.f1.Beta'
18        if i < nHist-1:
19            ties += ','
20        kwargs['InputWorkspace_' + str(i)] = inputWS
21        kwargs['WorkspaceIndex_' + str(i)] = i
22       
23ties+=')'
24func += ties
25logger.notice(func)
26logger.notice(str(kwargs))
27Fit(Function=func,InputWorkspace=inputWS,WorkspaceIndex=0,Output=outNm,Minimizer='Levenberg-MarquardtMD,Debug=1',**kwargs)