Skip to content

Commit

Permalink
Merge branch 'feature/5421_IDA_bayes_interface' into develop
Browse files Browse the repository at this point in the history
Conflicts:
	Code/Mantid/MantidQt/CustomInterfaces/CMakeLists.txt
	Code/Mantid/scripts/Inelastic/IndirectBayes.py

Refs #5421
  • Loading branch information
Samuel Jackson committed Oct 24, 2013
2 parents dffbf1e + 29c6613 commit a284f05
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 29 deletions.
1 change: 0 additions & 1 deletion Code/Mantid/MantidQt/CustomInterfaces/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ set ( MOC_FILES inc/MantidQtCustomInterfaces/Background.h
inc/MantidQtCustomInterfaces/CreateMDWorkspace.h
inc/MantidQtCustomInterfaces/CreateMDWorkspaceAlgDialog.h
inc/MantidQtCustomInterfaces/Elwin.h

inc/MantidQtCustomInterfaces/Fury.h
inc/MantidQtCustomInterfaces/FuryFit.h
inc/MantidQtCustomInterfaces/Homer.h
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/MantidQt/CustomInterfaces/src/JumpFit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ namespace MantidQt
QString pyInput =
"from IndirectJumpFit import JumpRun\n";

pyInput += "JumpRun("+sample+","+fitFunction+","+widthTxt+","+QMin+","+QMax+","
pyInput += "JumpRun('"+sample+"','"+fitFunction+"',"+widthTxt+","+QMin+","+QMax+","
"Save="+save+", Plot='"+plot+"', Verbose="+verbose+")\n";

runPythonScript(pyInput);
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/MantidQt/CustomInterfaces/src/Stretch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ namespace MantidQt
if(m_uiForm.chkElasticPeak->isChecked()) { elasticPeak = "True"; }
if(m_uiForm.chkSequentialFit->isChecked()) { sequence = "True"; }

QString fitOps = "[" + elasticPeak + ", '" + background + "', 0, 0]";
QString fitOps = "[" + elasticPeak + ", '" + background + "', False, False]";

//Collect input from the properties browser
QString eMin = m_properties["EMin"]->valueText();
Expand Down
59 changes: 34 additions & 25 deletions Code/Mantid/scripts/Inelastic/IndirectBayes.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ def GetXYE(inWS,n,array_len):
E=PadArray(Ein,array_len)
return N,X,Y,E


def GetResNorm(resnormWS,ngrp):
if ngrp == 0: # read values from WS
dtnorm = mtd[resnormWS+'_Intensity'].readY(0)
Expand All @@ -75,7 +74,7 @@ def ReadNormFile(readRes,resnormWS,nsam,Verbose): # get norm & scale
sys.exit(error)
Xin = mtd[resnormWS+'_Stretch'].readX(0) # no. points from length of x array
if len(Xin) == 0:
error = 'ResNorm file has no xscale points'
error = 'ResNorm file has no xscale points'
logger.notice('ERROR *** ' + error)
sys.exit(error)
if nrm != nsam: # check that no. groups are the same
Expand Down Expand Up @@ -140,6 +139,7 @@ def ReadWidthFile(readWidth,widthFile,numSampleGroups,Verbose):

# QLines programs
def QLRun(program,samWS,resWS,resnormWS,erange,nbins,Fit,wfile,Loop,Verbose=False,Plot='None',Save=False):

StartTime(program)

#expand fit options
Expand Down Expand Up @@ -218,8 +218,9 @@ def QLRun(program,samWS,resWS,resnormWS,erange,nbins,Fit,wfile,Loop,Verbose=Fals
wrkr=resWS
wrkr.ljust(140,' ')
wrk = [wrks, wrkr]
#
if program == 'QL': # initialise probability list

# initialise probability list
if program == 'QL':
prob0 = []
prob1 = []
prob2 = []
Expand Down Expand Up @@ -333,12 +334,19 @@ def QLRun(program,samWS,resWS,resnormWS,erange,nbins,Fit,wfile,Loop,Verbose=Fals
outWS = C2Se(fname)
if (Plot != 'None'):
QLPlotQSe(fname,Plot,res_plot,Loop)


#Add some sample logs to the output workspace
AddSampleLog(Workspace=outWS, LogName="Fit Program", LogType="String", LogText=prog)
AddSampleLog(Workspace=outWS, LogName="Energy min", LogType="Number", LogText=str(erange[0]))
AddSampleLog(Workspace=outWS, LogName="Energy max", LogType="Number", LogText=str(erange[1]))
AddSampleLog(Workspace=outWS, LogName="Elastic", LogType="String", LogText=str(elastic))

AddSampleLog(Workspace=outWS, LogName="ResNorm", LogType="String", LogText=str(resnorm))
if resnorm:
AddSampleLog(Workspace=outWS, LogName="ResNorm file", LogType="String", LogText=resnormWS)

AddSampleLog(Workspace=outWS, LogName="Width", LogType="String", LogText=str(width))

if width:
AddSampleLog(Workspace=outWS, LogName="Width file", LogType="String", LogText=wfile)

Expand Down Expand Up @@ -467,6 +475,7 @@ def C2Fw(prog,sname):

CreateWorkspace(OutputWorkspace=outWS, DataX=dataX, DataY=dataY, DataE=dataE, Nspec=nhist,
UnitX='MomentumTransfer', VerticalAxisUnit='Text', VerticalAxisValues=Vaxis, YUnitLabel='')

return outWS

def SeBlock(a,first): #read Ascii block of Integers
Expand Down Expand Up @@ -601,7 +610,6 @@ def QLPlotQSe(inputWS,Plot,res_plot,Loop):
f_plot=mp.plotSpectrum(fWS,res_plot,False)

# Quest programs

def CheckBetSig(nbs):
Nsig = int(nbs[1])
if Nsig == 0:
Expand All @@ -623,10 +631,25 @@ def CheckBetSig(nbs):
sys.exit(error)
return Nbet,Nsig

def QuestRun(samWS,resWS,rsname,nbs,erange,nbins,Fit,Loop,Verbose,Plot,Save):
def QuestRun(samWS,resWS,nbs,erange,nbins,Fit,Loop,Verbose,Plot,Save):
StartTime('Quest')
#expand fit options
elastic, background, width, resnorm = Fit

#convert true/false to 1/0 for fortran
o_el = 1 if elastic else 0
o_w1 = 1 if width else 0
o_res = 1 if resnorm else 0

resnorm = (Fit[:3] == 1)
#fortran code uses background choices defined using the following numbers
if background == 'Sloping':
o_bgd = 2
elif background == 'Flat':
o_bgd = 1
elif background == 'Zero':
o_bgd = 0

fitOp = [o_el, o_bgd, o_w1, o_res]

workdir = config['defaultsave.directory']
array_len = 4096 # length of array in Fortran
Expand All @@ -637,22 +660,10 @@ def QuestRun(samWS,resWS,rsname,nbs,erange,nbins,Fit,Loop,Verbose,Plot,Save):
logger.notice('Resolution is ' + resWS)
CheckAnalysers(samWS,resWS,Verbose)
nsam,ntc = CheckHistZero(samWS)

if Loop != True:
nsam = 1
if Fit[0]:
elastic = True
o_el = 1
else:
elastic = False
o_el = 0
if Fit[1] == 'Sloping':
o_bgd = 2
if Fit[1] == 'Flat':
o_bgd = 1
if Fit[1] == 'Zero':
o_bgd = 0
background = Fit[1]
fitOp = [o_el, o_bgd, 0, 0]

efix = getEfixed(samWS)
theta,Q = GetThetaQ(samWS)
nres,ntr = CheckHistZero(resWS)
Expand All @@ -666,7 +677,6 @@ def QuestRun(samWS,resWS,rsname,nbs,erange,nbins,Fit,Loop,Verbose,Plot,Save):
logger.notice(' Number of spectra = '+str(nsam))
logger.notice(' Erange : '+str(erange[0])+' to '+str(erange[1]))

dtn,xsc = ReadNormFile(resnorm,rsname,nsam,Verbose)
fname = samWS[:-4] + '_'+ prog
wrks=workdir + samWS[:-4]
if Verbose:
Expand Down Expand Up @@ -757,8 +767,7 @@ def QuestPlot(inputWS,Plot):
mp.mergePlots(sig_plot,beta_plot)

# ResNorm programs

def ResNormRun(vname,rname,erange,nbin,Verbose=False,Plot=False,Save=False):
def ResNormRun(vname,rname,erange,nbin,Verbose=False,Plot='None',Save=False):
StartTime('ResNorm')
workdir = config['defaultsave.directory']
array_len = 4096 # length of Fortran array
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/scripts/Inelastic/IndirectJumpFit.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,4 @@ def JumpRun(samWS,jumpFunc,width,qmin,qmax,Verbose=False,Plot=False,Save=False):
EndTime('Jump fit : '+jumpFunc+' ; ')

def JumpPlot(inputWS):
j_plot=mp.plotSpectrum(inputWS,[0,1,2],True)
mp.plotSpectrum(inputWS,[0,1,2],True)

0 comments on commit a284f05

Please sign in to comment.