Skip to content

Commit

Permalink
Refs #8387 Updated Bayes scripts to clear Fortran arrays.
Browse files Browse the repository at this point in the history
Also added code to tidy up the generated files if you didn't
choose to save the output.
  • Loading branch information
Samuel Jackson committed Nov 11, 2013
1 parent c50d276 commit dcfd895
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion Code/Mantid/scripts/Inelastic/IndirectBayes.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ def GetResNorm(resnormWS,ngrp):
dtn=PadArray(dtnorm,51) # pad for Fortran call
xsc=PadArray(xscale,51)
return dtn,xsc

#Remove any files output from the Fortran code
def removeGeneratedFiles(flist, workdir):
for fname in flist:
fname = os.path.join(workdir, fname)
if os.path.isfile(fname):
os.remove(fname)


def ReadNormFile(readRes,resnormWS,nsam,Verbose): # get norm & scale values
if readRes: # use ResNorm file option=o_res
Expand Down Expand Up @@ -139,7 +147,7 @@ def ReadWidthFile(readWidth,widthFile,numSampleGroups,Verbose):
# QLines programs
def QLRun(program,samWS,resWS,resnormWS,erange,nbins,Fit,wfile,Loop,Verbose,Plot,Save):
StartTime(program)

#expand fit options
elastic, background, width, resnorm = Fit

Expand Down Expand Up @@ -249,6 +257,7 @@ def QLRun(program,samWS,resWS,resnormWS,erange,nbins,Fit,wfile,Loop,Verbose,Plot
numb = [nsam, nsp, ntc, Ndat, nbin, Imin, Imax, Nb, nrbin]
rscl = 1.0
reals = [efix, theta[m], rscl, bnorm]

if prog == 'QLr':
nd,xout,yout,eout,yfit,yprob=QLr.qlres(numb,Xv,Yv,Ev,reals,fitOp,
Xdat,Xb,Yb,Wy,We,dtn,xsc,
Expand Down Expand Up @@ -361,6 +370,13 @@ def QLRun(program,samWS,resWS,resnormWS,erange,nbins,Fit,wfile,Loop,Verbose,Plot
if Verbose:
logger.notice('Output fit file created : ' + fit_path)
logger.notice('Output paramter file created : ' + out_path)
else:
#remove any files generated by the Fortran code
flist = [fname+'.ql'+str(i) for i in range(1,4)]
flist.append(fname+'.lpt')

removeGeneratedFiles(flist, workdir)

EndTime(program)


Expand Down Expand Up @@ -759,6 +775,15 @@ def QuestRun(samWS,resWS,nbs,erange,nbins,Fit,Loop,Verbose,Plot,Save):
if Verbose:
logger.notice('Output file for Fit : ' + fpath)
logger.notice('Output file for Contours : ' + cpath)
else:
#remove files generated by Fortran code
flist = []
flist.append(fname+'.lpt')
flist.append(samWS[:-4] + '_Qsb.ql1')
flist.append(samWS[:-4] + '_Qss.ql2')

removeGeneratedFiles(flist, workdir)

if (Plot != 'None'):
QuestPlot(fname,Plot)
EndTime('Quest')
Expand Down Expand Up @@ -848,6 +873,10 @@ def ResNormRun(vname,rname,erange,nbin,Verbose=False,Plot='None',Save=False):
if Verbose:
logger.notice('Parameter file created : ' + par_path)
logger.notice('Fit file created : ' + fit_path)
else:
#Remove any files generated by Fortran code
removeGeneratedFiles([fname + '_resnrm.lpt'], workdir)

if (Plot != 'None'):
ResNormPlot(fname,Plot)
EndTime('ResNorm')
Expand Down
Binary file modified Code/Mantid/scripts/Inelastic/QLdata_win32.pyd
Binary file not shown.
Binary file modified Code/Mantid/scripts/Inelastic/QLdata_win64.pyd
Binary file not shown.
Binary file modified Code/Mantid/scripts/Inelastic/QLres_win32.pyd
Binary file not shown.
Binary file modified Code/Mantid/scripts/Inelastic/QLres_win64.pyd
Binary file not shown.
Binary file modified Code/Mantid/scripts/Inelastic/QLse_win32.pyd
Binary file not shown.
Binary file modified Code/Mantid/scripts/Inelastic/QLse_win64.pyd
Binary file not shown.
Binary file modified Code/Mantid/scripts/Inelastic/Quest_win32.pyd
Binary file not shown.
Binary file modified Code/Mantid/scripts/Inelastic/Quest_win64.pyd
Binary file not shown.
Binary file modified Code/Mantid/scripts/Inelastic/ResNorm_win32.pyd
Binary file not shown.
Binary file modified Code/Mantid/scripts/Inelastic/ResNorm_win64.pyd
Binary file not shown.

0 comments on commit dcfd895

Please sign in to comment.