Skip to content

Commit

Permalink
Refs #11674. Added possibility to skip residual analysis in workflow.
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Wedel committed May 22, 2015
1 parent 6bf72dc commit 9418dae
Showing 1 changed file with 22 additions and 13 deletions.
Expand Up @@ -3,6 +3,7 @@
from mantid.api import *
from mantid.kernel import *


class PoldiDataAnalysis(PythonAlgorithm):
"""
This workflow algorithm uses all of the POLDI specific algorithms to perform a complete data analysis,
Expand Down Expand Up @@ -44,6 +45,11 @@ def PyInit(self):
self.declareProperty("PawleyFit", False, direction=Direction.Input,
doc='Should the 2D-fit determine lattice parameters?')

self.declareProperty("AnalyseResiduals", True, direction=Direction.Input,
doc=('If this option is chosen, the residuals are calculated. The PlotResult option is '
'ignored if the residual analysis is disabled. The MultipleRun option only works '
'when AnalyseResiduals is active.'))

self.declareProperty("MultipleRuns", False, direction=Direction.Input,
doc=('If this is activated, peaks are searched again in the'
'residuals and the 1D- and 2D-fit is repeated '
Expand Down Expand Up @@ -109,22 +115,24 @@ def runMainAnalysis(self, correlationSpectrum):
spectrum2D = fitPeaks2DResult[0]
spectrum1D = fitPeaks2DResult[1]

residuals = self.runResidualAnalysis(spectrum2D)
outputWorkspaces.append(residuals)
analyseResiduals = self.getProperty('AnalyseResiduals').value
if analyseResiduals:
residuals = self.runResidualAnalysis(spectrum2D)
outputWorkspaces.append(residuals)

totalName = self.baseName + "_sum"
Plus(LHSWorkspace=spectrum1D, RHSWorkspace=residuals, OutputWorkspace=totalName)
total = AnalysisDataService.retrieve(totalName)
outputWorkspaces.append(total)
totalName = self.baseName + "_sum"
Plus(LHSWorkspace=spectrum1D, RHSWorkspace=residuals, OutputWorkspace=totalName)
total = AnalysisDataService.retrieve(totalName)
outputWorkspaces.append(total)

if self.numberOfExecutions == 1:
self._plotResult(total, spectrum1D, residuals)
if self.numberOfExecutions == 1:
self._plotResult(total, spectrum1D, residuals)

runTwice = self.getProperty('MultipleRuns').value
if runTwice and self.numberOfExecutions == 1:
return self.runMainAnalysis(total)
else:
return outputWorkspaces
runTwice = self.getProperty('MultipleRuns').value
if runTwice and self.numberOfExecutions == 1:
return self.runMainAnalysis(total)

return outputWorkspaces

def runPeakSearch(self, correlationWorkspace):
peaksName = self.baseName + "_peaks_raw"
Expand Down Expand Up @@ -218,6 +226,7 @@ def _plotResult(self, total, spectrum1D, residuals):

if plotResults:
from IndirectImport import import_mantidplot

plot = import_mantidplot()

plotWindow = plot.plotSpectrum(total, 0, type=1)
Expand Down

0 comments on commit 9418dae

Please sign in to comment.