Skip to content

Commit

Permalink
Refs #11674. Added raw fit parameter output option to PoldiFitPeaks2D.
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Wedel committed May 22, 2015
1 parent 9418dae commit 084b3d8
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
Expand Up @@ -59,6 +59,10 @@ def PyInit(self):
doc=('If this is activated, plot the sum of residuals and calculated spectrum together '
'with the theoretical spectrum and the residuals.'))

self.declareProperty('OutputRawFitParameters', False, direction=Direction.Input,
doc=('Activating this option produces an output workspace which contains the raw '
'fit parameters.'))

self.declareProperty(WorkspaceProperty(name="OutputWorkspace", defaultValue="", direction=Direction.Output),
doc='WorkspaceGroup with result data from all processing steps.')

Expand Down Expand Up @@ -182,6 +186,12 @@ def runPeakFit2D(self, peaks):
refinedPeaksName = self.baseName + "_peaks_refined_2d"
refinedCellName = self.baseName + "_cell_refined"

rawFitParametersWorkspaceName = ''
outputRawFitParameters = self.getProperty('OutputRawFitParameters').value
if outputRawFitParameters:
rawFitParametersWorkspaceName = self.baseName + "_raw_fit_parameters"


pawleyFit = self.getProperty('PawleyFit').value

PoldiFitPeaks2D(InputWorkspace=self.inputWorkspace,
Expand All @@ -192,14 +202,18 @@ def runPeakFit2D(self, peaks):
OutputWorkspace=spectrum2DName,
Calculated1DSpectrum=spectrum1DName,
RefinedPoldiPeakWorkspace=refinedPeaksName,
RefinedCellParameters=refinedCellName)
RefinedCellParameters=refinedCellName,
RawFitParameters=rawFitParametersWorkspaceName)

workspaces = [AnalysisDataService.retrieve(spectrum2DName),
AnalysisDataService.retrieve(spectrum1DName),
AnalysisDataService.retrieve(refinedPeaksName)]
if AnalysisDataService.doesExist(refinedCellName):
workspaces.append(AnalysisDataService.retrieve(refinedCellName))

if AnalysisDataService.doesExist(rawFitParametersWorkspaceName):
workspaces.append(AnalysisDataService.retrieve(rawFitParametersWorkspaceName))

return workspaces

def runResidualAnalysis(self, calculated2DSpectrum):
Expand Down
13 changes: 13 additions & 0 deletions Code/Mantid/Framework/SINQ/src/PoldiFitPeaks2D.cpp
Expand Up @@ -1143,6 +1143,11 @@ void PoldiFitPeaks2D::init() {

declareProperty(new WorkspaceProperty<Workspace>(
"RefinedCellParameters", "", Direction::Output, PropertyMode::Optional));

declareProperty(new WorkspaceProperty<Workspace>("RawFitParameters", "",
Direction::Output,
PropertyMode::Optional),
"Table workspace that contains all raw fit parameters.");
}

/// Executes the algorithm
Expand Down Expand Up @@ -1245,6 +1250,14 @@ void PoldiFitPeaks2D::exec() {
g_log.warning() << "Warning: Cell parameter table is empty.";
}
}

// Optionally output the raw fitting parameters.
Property *rawFitParameters = getPointerToProperty("RawFitParameters");
if (!rawFitParameters->isDefault()) {
ITableWorkspace_sptr parameters =
fitAlgorithm->getProperty("OutputParameters");
setProperty("RawFitParameters", parameters);
}
}

} // namespace Poldi
Expand Down

0 comments on commit 084b3d8

Please sign in to comment.