Skip to content

Commit

Permalink
Added preview plotting
Browse files Browse the repository at this point in the history
Refs #10368
  • Loading branch information
DanNixon committed Oct 16, 2014
1 parent 60cb51e commit 7bb8ca9
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 7 deletions.
39 changes: 36 additions & 3 deletions Code/Mantid/MantidQt/CustomInterfaces/src/ApplyCorr.cpp
Expand Up @@ -38,6 +38,13 @@ namespace IDA

// Apply the validator to the input box for the Scale option.
uiForm().abscor_leScaleMultiplier->setValidator(m_valPosDbl);

// Create the plot
m_plots["ApplyCorrPlot"] = new QwtPlot(m_parentWidget);
m_plots["ApplyCorrPlot"]->setCanvasBackground(Qt::white);
/* m_plots["ApplyCorrPlot"]->setAxisFont(QwtPlot::xBottom, parent->font()); */
/* m_plots["ApplyCorrPlot"]->setAxisFont(QwtPlot::yLeft, parent->font()); */
m_uiForm.plotSpace->addWidget(m_plots["ApplyCorrPlot"]);
}

/**
Expand Down Expand Up @@ -76,6 +83,8 @@ namespace IDA
}

uiForm().abscor_ckUseCorrections->setEnabled(!isSqw);

plotMiniPlot(dataName, 0, "ApplyCorrPlot", "ApplyCorrSampleCurve");
}

bool ApplyCorr::validateScaleInput()
Expand Down Expand Up @@ -229,12 +238,36 @@ namespace IDA
}

pyInput += "plotResult = '" + plotResult + "'\n";

pyInput += "plotContrib = False\n";

pyInput += "abscorFeeder(sample, container, geom, useCor, corrections, Verbose=verbose, RebinCan=rebin_can, ScaleOrNotToScale=scale, factor=scaleFactor, Save=save, PlotResult=plotResult, PlotContrib=plotContrib)\n";
pyInput += "print abscorFeeder(sample, container, geom, useCor, corrections, Verbose=verbose, RebinCan=rebin_can, ScaleOrNotToScale=scale, factor=scaleFactor, Save=save, PlotResult=plotResult)\n";

QString pyOutput = runPythonCode(pyInput).trimmed();

if(pyOutput.toStdString != "None")
{
pyOutput += "0";
MatrixWorkspace_sptr outputWorkspace = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>(pyOutput.toStdString());
TextAxis* axis = dynamic_cast<TextAxis*>(outputWorkspace->getAxis(1));

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

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

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

replot("ApplyCorrPlot");
}
}

/**
Expand Down
10 changes: 6 additions & 4 deletions Code/Mantid/scripts/Inelastic/IndirectDataAnalysis.py
Expand Up @@ -1007,8 +1007,8 @@ def abscorFeeder(sample, container, geom, useCor, corrections, Verbose=False, Re
calc_plot = [cor_result + ext, sample]
res_plot = cor_result+'_rqw'
else:
if ( scaled_container == '' ):
sys.exit('ERROR *** Invalid options - nothing to do!')
if scaled_container == '':
raise RuntimeError('Invalid options - nothing to do!')
else:
sub_result = sam_name +'Subtract_'+ can_run
if Verbose:
Expand All @@ -1035,10 +1035,10 @@ def abscorFeeder(sample, container, geom, useCor, corrections, Verbose=False, Re
else:
res_plot = sub_result + '_red'

if (PlotResult != 'None'):
if PlotResult != 'None':
plotCorrResult(res_plot, PlotResult)

if ( mtd.doesExist(scaled_container) ):
if mtd.doesExist(scaled_container):
sws = mtd[sample]
cws = mtd[scaled_container]
names = 'Sample,Can,Calc'
Expand Down Expand Up @@ -1076,7 +1076,9 @@ def abscorFeeder(sample, container, geom, useCor, corrections, Verbose=False, Re
logger.notice('Output file created : '+res_path)

DeleteWorkspace(cws)

EndTime('ApplyCorrections')
return outNm

def plotCorrResult(inWS,PlotResult):
nHist = mtd[inWS].getNumberHistograms()
Expand Down

0 comments on commit 7bb8ca9

Please sign in to comment.