diff --git a/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Indirect/ApplyCorr.h b/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Indirect/ApplyCorr.h index d266e4f2bd86..4bf60a5e015b 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Indirect/ApplyCorr.h +++ b/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Indirect/ApplyCorr.h @@ -35,7 +35,6 @@ namespace IDA virtual void loadSettings(const QSettings & settings); void addRebinStep(QString toRebin, QString toMatch); - std::string addUnitConversionStep(Mantid::API::MatrixWorkspace_sptr ws); void addInterpolationStep(Mantid::API::MatrixWorkspace_sptr toInterpolate, std::string toMatch); Ui::ApplyCorr m_uiForm; diff --git a/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Indirect/IDATab.h b/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Indirect/IDATab.h index ada19ebb3932..c77d08e199d9 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Indirect/IDATab.h +++ b/Code/Mantid/MantidQt/CustomInterfaces/inc/MantidQtCustomInterfaces/Indirect/IDATab.h @@ -67,6 +67,8 @@ namespace IDA /// Check the binning between two workspaces match bool checkWorkspaceBinningMatches(Mantid::API::MatrixWorkspace_const_sptr left, Mantid::API::MatrixWorkspace_const_sptr right); + /// Adds a conversion to wavelength step to the algorithm queue + std::string addConvertToWavelengthStep(Mantid::API::MatrixWorkspace_sptr ws); /// DoubleEditorFactory DoubleEditorFactory* m_dblEdFac; diff --git a/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/ApplyCorr.cpp b/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/ApplyCorr.cpp index 3ceb793b8db8..6472cdb99164 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/ApplyCorr.cpp +++ b/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/ApplyCorr.cpp @@ -71,7 +71,7 @@ namespace IDA if(sampleXUnit->caption() != "Wavelength") { g_log.information("Sample workspace not in wavelength, need to convert to continue."); - absCorProps["SampleWorkspace"] = addUnitConversionStep(sampleWs); + absCorProps["SampleWorkspace"] = addConvertToWavelengthStep(sampleWs); } else { @@ -89,7 +89,7 @@ namespace IDA if(canXUnit->caption() != "Wavelength") { g_log.information("Container workspace not in wavelength, need to convert to continue."); - absCorProps["CanWorkspace"] = addUnitConversionStep(canWs); + absCorProps["CanWorkspace"] = addConvertToWavelengthStep(canWs); } else { @@ -208,31 +208,6 @@ namespace IDA } - /** - * Adds a unit converstion step to the batch algorithm queue. - * - * @param ws Pointer to the workspace to convert - * @return Name of output workspace - */ - std::string ApplyCorr::addUnitConversionStep(MatrixWorkspace_sptr ws) - { - std::string outputName = ws->name() + "_inWavelength"; - - IAlgorithm_sptr convertAlg = AlgorithmManager::Instance().create("ConvertUnits"); - convertAlg->initialize(); - - convertAlg->setProperty("InputWorkspace", ws->name()); - convertAlg->setProperty("OutputWorkspace", outputName); - convertAlg->setProperty("Target", "Wavelength"); - convertAlg->setProperty("EMode", getEMode(ws)); - convertAlg->setProperty("EFixed", getEFixed(ws)); - - m_batchAlgoRunner->addAlgorithm(convertAlg); - - return outputName; - } - - /** * Adds a rebin to workspace step to the calculation for when using a sample and container that * have different binning. diff --git a/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/CalcCorr.cpp b/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/CalcCorr.cpp index 40680f73f944..6bd8a1e5e066 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/CalcCorr.cpp +++ b/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/CalcCorr.cpp @@ -45,19 +45,29 @@ namespace IDA void CalcCorr::run() { - //TODO: check sample binning matches can binning, ask if should rebin to match - // Get correct corrections algorithm QString sampleShape = m_uiForm.cbSampleShape->currentText(); QString algorithmName = sampleShape.replace(" ", "") + "PaalmanPingsCorrection"; + API::BatchAlgorithmRunner::AlgorithmRuntimeProps absCorProps; IAlgorithm_sptr absCorAlgo = AlgorithmManager::Instance().create(algorithmName.toStdString()); absCorAlgo->initialize(); // Sample details QString sampleWsName = m_uiForm.dsSample->getCurrentDataName(); MatrixWorkspace_sptr sampleWs = AnalysisDataService::Instance().retrieveWS(sampleWsName.toStdString()); - absCorAlgo->setProperty("SampleWorkspace", sampleWsName.toStdString()); + + // If not in wavelength then do conversion + Mantid::Kernel::Unit_sptr sampleXUnit = sampleWs->getAxis(0)->unit(); + if(sampleXUnit->caption() != "Wavelength") + { + g_log.information("Sample workspace not in wavelength, need to convert to continue."); + absCorProps["SampleWorkspace"] = addConvertToWavelengthStep(sampleWs); + } + else + { + absCorProps["SampleWorkspace"] = sampleWsName.toStdString(); + } double sampleNumberDensity = m_uiForm.spSampleNumberDensity->value(); absCorAlgo->setProperty("SampleNumberDensity", sampleNumberDensity); @@ -72,7 +82,19 @@ namespace IDA if(useCan) { QString canWsName = m_uiForm.dsContainer->getCurrentDataName(); - absCorAlgo->setProperty("CanWorkspace", canWsName.toStdString()); + MatrixWorkspace_sptr canWs = AnalysisDataService::Instance().retrieveWS(canWsName.toStdString()); + + // If not in wavelength then do conversion + Mantid::Kernel::Unit_sptr canXUnit = canWs->getAxis(0)->unit(); + if(canXUnit->caption() != "Wavelength") + { + g_log.information("Container workspace not in wavelength, need to convert to continue."); + absCorProps["CanWorkspace"] = addConvertToWavelengthStep(canWs); + } + else + { + absCorProps["CanWorkspace"] = canWsName.toStdString(); + } double canNumberDensity = m_uiForm.spCanNumberDensity->value(); absCorAlgo->setProperty("CanNumberDensity", canNumberDensity); @@ -106,7 +128,7 @@ namespace IDA absCorAlgo->setProperty("OutputWorkspace", outputWsName.toStdString()); // Add corrections algorithm to queue - m_batchAlgoRunner->addAlgorithm(absCorAlgo); + m_batchAlgoRunner->addAlgorithm(absCorAlgo, absCorProps); // Add save algorithms if required bool save = m_uiForm.ckSave->isChecked(); diff --git a/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/IDATab.cpp b/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/IDATab.cpp index 0cabe7f5e333..2109630a715d 100644 --- a/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/IDATab.cpp +++ b/Code/Mantid/MantidQt/CustomInterfaces/src/Indirect/IDATab.cpp @@ -32,6 +32,7 @@ namespace IDA m_blnEdFac = new QtCheckBoxFactory(this); } + /** * Loads the tab's settings. * @@ -44,6 +45,7 @@ namespace IDA loadSettings(settings); } + /** * Slot that can be called when a user edits an input. */ @@ -52,6 +54,7 @@ namespace IDA validate(); } + /** * Check that the binning between two workspaces matches. * @@ -74,6 +77,31 @@ namespace IDA } } + + /** + * Adds a unit converstion into wavelength step to the batch algorithm queue. + * + * @param ws Pointer to the workspace to convert + * @return Name of output workspace + */ + std::string IDATab::addConvertToWavelengthStep(MatrixWorkspace_sptr ws) + { + std::string outputName = ws->name() + "_inWavelength"; + + IAlgorithm_sptr convertAlg = AlgorithmManager::Instance().create("ConvertUnits"); + convertAlg->initialize(); + + convertAlg->setProperty("InputWorkspace", ws->name()); + convertAlg->setProperty("OutputWorkspace", outputName); + convertAlg->setProperty("Target", "Wavelength"); + convertAlg->setProperty("EMode", getEMode(ws)); + convertAlg->setProperty("EFixed", getEFixed(ws)); + + m_batchAlgoRunner->addAlgorithm(convertAlg); + + return outputName; + } + } // namespace IDA } // namespace CustomInterfaces } // namespace MantidQt