Skip to content

Commit

Permalink
Add ocde to plot res norm fit
Browse files Browse the repository at this point in the history
Refs #10723
  • Loading branch information
DanNixon committed Jan 13, 2015
1 parent 3a1d375 commit 1808fc7
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 20 deletions.
24 changes: 12 additions & 12 deletions Code/Mantid/MantidQt/CustomInterfaces/src/Quasi.cpp
Expand Up @@ -6,7 +6,7 @@ namespace MantidQt
{
namespace CustomInterfaces
{
Quasi::Quasi(QWidget * parent) :
Quasi::Quasi(QWidget * parent) :
IndirectBayesTab(parent)
{
m_uiForm.setupUi(parent);
Expand All @@ -30,7 +30,7 @@ namespace MantidQt
m_properties["EMax"] = m_dblManager->addProperty("EMax");
m_properties["SampleBinning"] = m_dblManager->addProperty("Sample Binning");
m_properties["ResBinning"] = m_dblManager->addProperty("Resolution Binning");

m_dblManager->setDecimals(m_properties["EMin"], NUM_DECIMALS);
m_dblManager->setDecimals(m_properties["EMax"], NUM_DECIMALS);
m_dblManager->setDecimals(m_properties["SampleBinning"], INT_DECIMALS);
Expand Down Expand Up @@ -60,7 +60,7 @@ namespace MantidQt
/**
* Set the data selectors to use the default save directory
* when browsing for input files.
*
*
* @param settings :: The current settings
*/
void Quasi::loadSettings(const QSettings& settings)
Expand All @@ -77,15 +77,15 @@ namespace MantidQt

/**
* Validate the form to check the program can be run
*
*
* @return :: Whether the form was valid
*/
bool Quasi::validate()
{
UserInputValidator uiv;
uiv.checkDataSelectorIsValid("Sample", m_uiForm.dsSample);
uiv.checkDataSelectorIsValid("Resolution", m_uiForm.dsResolution);

//check that the ResNorm file is valid if we are using it
if(m_uiForm.chkUseResNorm->isChecked())
{
Expand Down Expand Up @@ -124,7 +124,7 @@ namespace MantidQt
* Collect the settings on the GUI and build a python
* script that runs Quasi
*/
void Quasi::run()
void Quasi::run()
{
using namespace Mantid::API;

Expand All @@ -141,7 +141,7 @@ namespace MantidQt
QString useResNorm("False");
QString resNormFile("");

QString pyInput =
QString pyInput =
"from IndirectBayes import QLRun\n";

QString sampleName = m_uiForm.dsSample->getCurrentDataName();
Expand All @@ -167,8 +167,8 @@ namespace MantidQt
if(m_uiForm.chkElasticPeak->isChecked()) { elasticPeak = "True"; }
if(m_uiForm.chkSequentialFit->isChecked()) { sequence = "True"; }

if(m_uiForm.chkFixWidth->isChecked())
{
if(m_uiForm.chkFixWidth->isChecked())
{
fixedWidth = "True";
fixedWidthFile = m_uiForm.mwFixWidthDat->getFirstFilename();
}
Expand Down Expand Up @@ -231,14 +231,14 @@ namespace MantidQt
m_curves[specName]->setPen(QColor(Qt::green));
}
}

replot("QuasiPlot");
}

/**
* Plots the loaded file to the miniplot and sets the guides
* and the range
*
*
* @param filename :: The name of the workspace to plot
*/
void Quasi::handleSampleInputReady(const QString& filename)
Expand Down Expand Up @@ -266,7 +266,7 @@ namespace MantidQt
*/
void Quasi::maxValueChanged(double max)
{
m_dblManager->setValue(m_properties["EMax"], max);
m_dblManager->setValue(m_properties["EMax"], max);
}

/**
Expand Down
43 changes: 35 additions & 8 deletions Code/Mantid/MantidQt/CustomInterfaces/src/ResNorm.cpp
@@ -1,11 +1,12 @@
#include "MantidAPI/TextAxis.h"
#include "MantidQtCustomInterfaces/ResNorm.h"
#include "MantidQtCustomInterfaces/UserInputValidator.h"

namespace MantidQt
{
namespace CustomInterfaces
{
ResNorm::ResNorm(QWidget * parent) :
ResNorm::ResNorm(QWidget * parent) :
IndirectBayesTab(parent)
{
m_uiForm.setupUi(parent);
Expand All @@ -28,7 +29,7 @@ namespace MantidQt
m_properties["EMin"] = m_dblManager->addProperty("EMin");
m_properties["EMax"] = m_dblManager->addProperty("EMax");
m_properties["VanBinning"] = m_dblManager->addProperty("Van Binning");

m_dblManager->setDecimals(m_properties["EMin"], NUM_DECIMALS);
m_dblManager->setDecimals(m_properties["EMax"], NUM_DECIMALS);
m_dblManager->setDecimals(m_properties["VanBinning"], INT_DECIMALS);
Expand All @@ -51,7 +52,7 @@ namespace MantidQt

/**
* Validate the form to check the program can be run
*
*
* @return :: Whether the form was valid
*/
bool ResNorm::validate()
Expand All @@ -74,12 +75,14 @@ namespace MantidQt
* Collect the settings on the GUI and build a python
* script that runs ResNorm
*/
void ResNorm::run()
void ResNorm::run()
{
using namespace Mantid::API;

QString verbose("False");
QString save("False");

QString pyInput =
QString pyInput =
"from IndirectBayes import ResNormRun\n";

// get the file names
Expand All @@ -103,12 +106,36 @@ namespace MantidQt
" Save="+save+", Plot='"+plot+"', Verbose="+verbose+")\n";

runPythonScript(pyInput);

// Update mini plot
QString outWsName = VanName.left(VanName.size() - 1) + "_ResNorm_Fit";
MatrixWorkspace_sptr outputWorkspace = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>(outWsName.toStdString());
TextAxis* axis = dynamic_cast<TextAxis*>(outputWorkspace->getAxis(1));

for(size_t histIndex = 0; histIndex < outputWorkspace->getNumberHistograms(); histIndex++)
{
QString specName = QString::fromStdString(axis->label(histIndex));

if(specName.contains("fit"))
{
plotMiniPlot(outputWorkspace, histIndex, "ResNormPlot", specName);
m_curves[specName]->setPen(QColor(Qt::red));
}

if(specName.contains("diff"))
{
plotMiniPlot(outputWorkspace, histIndex, "ResNormPlot", specName);
m_curves[specName]->setPen(QColor(Qt::green));
}
}

replot("ResNormPlot");
}

/**
* Set the data selectors to use the default save directory
* when browsing for input files.
*
*
* @param settings :: The current settings
*/
void ResNorm::loadSettings(const QSettings& settings)
Expand All @@ -120,7 +147,7 @@ namespace MantidQt
/**
* Plots the loaded file to the miniplot and sets the guides
* and the range
*
*
* @param filename :: The name of the workspace to plot
*/
void ResNorm::handleVanadiumInputReady(const QString& filename)
Expand Down Expand Up @@ -163,7 +190,7 @@ namespace MantidQt
*/
void ResNorm::maxValueChanged(double max)
{
m_dblManager->setValue(m_properties["EMax"], max);
m_dblManager->setValue(m_properties["EMax"], max);
}

/**
Expand Down

0 comments on commit 1808fc7

Please sign in to comment.