1 | def furyfitSeq(inputWS, func, ftype, startx, endx, Save, Plot, Verbose=True): |
---|
2 | StartTime('FuryFit Mult') |
---|
3 | workdir = config['defaultsave.directory'] |
---|
4 | option = ftype[:-2] |
---|
5 | if Verbose: |
---|
6 | logger.notice('Option: '+option) |
---|
7 | input = inputWS+',i0' |
---|
8 | nHist = mtd[inputWS].getNumberHistograms() |
---|
9 | for i in range(1,nHist): |
---|
10 | input += ';'+inputWS+',i'+str(i) |
---|
11 | outNm = getWSprefix(inputWS) + 'fury' |
---|
12 | f1 = """( |
---|
13 | composite=CompositeFunctionMW,Workspace=$WORKSPACE$,WSParam=(WorkspaceIndex=$INDEX$); |
---|
14 | name=LinearBackground,A0=0,A1=0,ties=(A1=0); |
---|
15 | name=UserFunction,Formula=Intensity*exp(-(x/Tau)^Beta),Intensity=1.0,Tau=0.1,Beta=1;ties=(f1.Intensity=1-f0.A0) |
---|
16 | ); |
---|
17 | """.replace('$WORKSPACE$',inputWS) |
---|
18 | func= 'composite=MultiBG;' |
---|
19 | ties='ties=(' |
---|
20 | for i in range(0,nHist): |
---|
21 | func+=f1.replace('$INDEX$',str(i)) |
---|
22 | if i > 0: |
---|
23 | ties += 'f' + str(i) + '.f1.Beta=f0.f1.Beta' |
---|
24 | if i < nHist-1: |
---|
25 | ties += ',' |
---|
26 | ties+=')' |
---|
27 | func += ties |
---|
28 | logger.notice(func) |
---|
29 | Fit(InputWorkspace=inputWS,Function=func,Output=outNm) |
---|
30 | wsname = furyfitMultParsToWS(outNm, inputWS) |
---|
31 | if Save: |
---|
32 | opath = os.path.join(workdir, wsname+'.nxs') # path name for nxs file |
---|
33 | SaveNexusProcessed(InputWorkspace=wsname, Filename=opath) |
---|
34 | if Verbose: |
---|
35 | logger.notice('Output file : '+opath) |
---|
36 | if ( Plot != 'None' ): |
---|
37 | furyfitPlotMult(wsname, Plot) |
---|
38 | EndTime('FuryFit') |
---|
39 | |
---|