Skip to content
Snippets Groups Projects
Commit 7b9b7c0d authored by Joseph Ramsay's avatar Joseph Ramsay
Browse files

Re #22265 Add run label to gpx filename if refining multiple runs

parent 27f7eb41
No related branches found
No related tags found
No related merge requests found
......@@ -478,6 +478,9 @@ The following parameters are also required:
- **New GSAS-II Project** - GSASIIRefineFitPeaks creates a new
``.gpx`` project here, which can be opened and inspected from the
GSAS-II GUI
- Note, if running **Refine All** on more than one run, the run
number and bank ID will be appended to the filename
- **GSAS-II Installation Directory**
- This is the directory containing the GSAS-II executables and
......@@ -515,6 +518,9 @@ To do a refinement, take the following steps:
coefficients) and lattice parameters should be displayed in the
**Fit Results** section.
- You can also click **Refine All** to run refinement on all runs
loaded into to GSAS tab
You can toggle the fitted peaks on and off with the **Plot Fitted
Peaks** checkbox, remove runs from the list with the **Remove Run**
button, and plot the run and fitted peaks to a larger, separate plot
......
......@@ -2,6 +2,20 @@
#include "EnggDiffGSASRefinementMethod.h"
#include "MantidQtWidgets/LegacyQwt/QwtHelper.h"
namespace {
std::string addRunNumberToGSASIIProjectFile(
const std::string &filename,
const MantidQt::CustomInterfaces::RunLabel &runLabel) {
const auto dotPosition = filename.find_last_of(".");
return filename.substr(0, dotPosition) + "_" +
std::to_string(runLabel.runNumber) + "_" +
std::to_string(runLabel.bank) +
filename.substr(dotPosition, filename.length());
}
} // anonymous namespace
namespace MantidQt {
namespace CustomInterfaces {
......@@ -34,7 +48,7 @@ void EnggDiffGSASFittingPresenter::notify(
case IEnggDiffGSASFittingPresenter::RefineAll:
processRefineAll();
break;
case IEnggDiffGSASFittingPresenter::SelectRun:
processSelectRun();
break;
......@@ -53,13 +67,23 @@ std::vector<GSASIIRefineFitPeaksParameters>
EnggDiffGSASFittingPresenter::collectAllInputParameters() const {
const auto runLabels = m_multiRunWidget->getAllRunLabels();
std::vector<GSASIIRefineFitPeaksParameters> inputParams;
std::vector<std::string> GSASIIProjectFiles;
inputParams.reserve(runLabels.size());
GSASIIProjectFiles.reserve(runLabels.size());
const auto refinementMethod = m_view->getRefinementMethod();
const auto instParamFile = m_view->getInstrumentFileName();
const auto phaseFiles = m_view->getPhaseFileNames();
const auto pathToGSASII = m_view->getPathToGSASII();
const auto GSASIIProjectFile = m_view->getGSASIIProjectPath();
if (runLabels.size() == 1) {
GSASIIProjectFiles = std::vector<std::string>({GSASIIProjectFile});
} else {
for (const auto &runLabel : runLabels) {
GSASIIProjectFiles.push_back(
addRunNumberToGSASIIProjectFile(GSASIIProjectFile, runLabel));
}
}
const auto dMin = m_view->getPawleyDMin();
const auto negativeWeight = m_view->getPawleyNegativeWeight();
......@@ -68,11 +92,13 @@ EnggDiffGSASFittingPresenter::collectAllInputParameters() const {
const auto refineSigma = m_view->getRefineSigma();
const auto refineGamma = m_view->getRefineGamma();
for (const auto &runLabel : runLabels) {
for (size_t i = 0; i < runLabels.size(); i++) {
const auto runLabel = runLabels[i];
const auto inputWS = *(m_multiRunWidget->getFocusedRun(runLabel));
inputParams.push_back(GSASIIRefineFitPeaksParameters(
inputWS, runLabel, refinementMethod, instParamFile, phaseFiles,
pathToGSASII, GSASIIProjectFile, dMin, negativeWeight, xMin, xMax,
inputWS, runLabels[i], refinementMethod, instParamFile, phaseFiles,
pathToGSASII, GSASIIProjectFiles[i], dMin, negativeWeight, xMin, xMax,
refineSigma, refineGamma));
}
return inputParams;
......
......@@ -117,7 +117,7 @@
<item row="3" column="0">
<widget class="QLabel" name="label_gsasProjPath">
<property name="toolTip">
<string>The name of a new *.gpx project to write refinement results out to. This can be opened and used for more complex refinements in GSAS-II</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;The name of a new *.gpx project to write refinement results out to. This can be opened and used for more complex refinements in GSAS-II.&lt;/p&gt;&lt;p&gt;Note, if refining more than one run, the run number and bank ID will be appended to this&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>New GSAS-II Project</string>
......
......@@ -232,13 +232,13 @@ public:
const GSASIIRefineFitPeaksParameters params1(
WorkspaceCreationHelper::create2DWorkspaceBinned(1, 100),
RunLabel(123, 1), GSASRefinementMethod::RIETVELD, "Instrument file",
{"Phase1", "Phase2"}, "GSASHOME", "GPX.gpx", boost::none, boost::none,
10000, 40000, true, false);
{"Phase1", "Phase2"}, "GSASHOME", "GPX_123_1.gpx", boost::none,
boost::none, 10000, 40000, true, false);
const GSASIIRefineFitPeaksParameters params2(
WorkspaceCreationHelper::create2DWorkspaceBinned(2, 200),
RunLabel(456, 2), GSASRefinementMethod::RIETVELD, "Instrument file",
{"Phase1", "Phase2"}, "GSASHOME", "GPX.gpx", boost::none, boost::none,
10000, 40000, true, false);
{"Phase1", "Phase2"}, "GSASHOME", "GPX_456_2.gpx", boost::none,
boost::none, 10000, 40000, true, false);
const std::vector<RunLabel> runLabels({params1.runLabel, params2.runLabel});
EXPECT_CALL(*m_mockMultiRunWidgetPtr, getAllRunLabels())
......@@ -262,7 +262,7 @@ public:
.WillOnce(Return(params1.gsasHome));
EXPECT_CALL(*m_mockViewPtr, getGSASIIProjectPath())
.Times(1)
.WillOnce(Return(params1.gsasProjectFile));
.WillOnce(Return("GPX.gpx"));
EXPECT_CALL(*m_mockViewPtr, getPawleyDMin())
.Times(1)
.WillOnce(Return(params1.dMin));
......
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