Skip to content
Snippets Groups Projects
Commit 0869969b authored by Elliot Oram's avatar Elliot Oram
Browse files

Added Rebin step in algorithm to ensure rebin before minus

Refs #13993
parent 027f1cc8
No related branches found
No related tags found
No related merge requests found
......@@ -247,6 +247,12 @@ class ApplyPaalmanPingsCorrection(PythonAlgorithm):
Do a simple container subtraction (when no corrections are given).
"""
logger.information('Rebining can to ensure Minus')
RebinToWorkspace(WorkspaceToRebin=self._can_ws_name,
WorkspaceToMatch=self._sample_ws_name,
OutputWorkspace=self._can_ws_name)
logger.information('Using simple container subtraction')
Minus(LHSWorkspace=self._sample_ws_name,
......
......@@ -28,8 +28,6 @@ private:
virtual bool validate();
virtual void loadSettings(const QSettings &settings);
void addRebinStep(QString toRebin, QString toMatch);
Ui::ContainerSubtraction m_uiForm;
std::string m_originalSampleUnits;
};
......
......@@ -36,8 +36,6 @@ void ContainerSubtraction::run() {
sampleWsName.toStdString());
m_originalSampleUnits = sampleWs->getAxis(0)->unit()->unitID();
// If not in wavelength then do conversion
if (m_originalSampleUnits != "Wavelength") {
g_log.information(
......@@ -61,6 +59,13 @@ void ContainerSubtraction::run() {
scaleX->setProperty("Factor", m_uiForm.spShift->value());
scaleX->setProperty("Operation", "Add");
scaleX->execute();
IAlgorithm_sptr rebinAlg =
AlgorithmManager::Instance().create("RebinToWorkspace");
rebinAlg->initialize();
rebinAlg->setProperty("WorkspaceToRebin", canWs);
rebinAlg->setProperty("WorkspaceToMatch", sampleWs);
rebinAlg->setProperty("OutputWorkspace", canWsName.toStdString());
rebinAlg->execute();
}
// If not in wavelength then do conversion
......@@ -88,9 +93,7 @@ void ContainerSubtraction::run() {
QMessageBox::Yes, QMessageBox::No,
QMessageBox::NoButton);
if (result == QMessageBox::Yes) {
addRebinStep(sampleWsName, canWsName);
} else {
if (result != QMessageBox::Yes) {
m_batchAlgoRunner->clearQueue();
g_log.error("Cannot apply absorption corrections using a sample and "
"container with different binning.");
......@@ -125,28 +128,6 @@ void ContainerSubtraction::run() {
m_pythonExportWsName = outputWsName.toStdString();
}
/**
* Adds a rebin to workspace step to the calculation for when using a sample and
*container that
* have different binning.
*
* @param toRebin
* @param toMatch
*/
void ContainerSubtraction::addRebinStep(QString toRebin, QString toMatch) {
API::BatchAlgorithmRunner::AlgorithmRuntimeProps rebinProps;
rebinProps["WorkspaceToMatch"] = toMatch.toStdString();
IAlgorithm_sptr rebinAlg =
AlgorithmManager::Instance().create("RebinToWorkspace");
rebinAlg->initialize();
rebinAlg->setProperty("WorkspaceToRebin", toRebin.toStdString());
rebinAlg->setProperty("OutputWorkspace", toRebin.toStdString());
m_batchAlgoRunner->addAlgorithm(rebinAlg, rebinProps);
}
/**
* Validates the user input in the UI
* @return if the input was valid
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment