Skip to content

Commit

Permalink
Refs #8506. Update PlotAsymmetryByLogValue.
Browse files Browse the repository at this point in the history
Is using scoped workspaces now so it doesn't care whether workspaces
are groups or not.
  • Loading branch information
arturbekasov committed Nov 28, 2013
1 parent 2ac07b6 commit f271e78
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 15 deletions.
71 changes: 57 additions & 14 deletions Code/Mantid/Framework/Algorithms/src/PlotAsymmetryByLogValue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,18 @@ There is a python script PlotAsymmetryByLogValue.py which if called in MantidPlo
#include <iomanip>
#include <sstream>

#include "MantidAlgorithms/PlotAsymmetryByLogValue.h"
#include "MantidDataObjects/Workspace2D.h"
#include "MantidKernel/TimeSeriesProperty.h"
#include "MantidKernel/PropertyWithValue.h"
#include "MantidAPI/FileProperty.h"
#include "MantidAPI/Progress.h"
#include "MantidAPI/ScopedWorkspace.h"
#include "MantidAPI/TableRow.h"
#include "MantidAPI/TextAxis.h"
#include "MantidAlgorithms/PlotAsymmetryByLogValue.h"
#include "MantidDataObjects/Workspace2D.h"
#include "MantidKernel/ArrayProperty.h"
#include "MantidKernel/ListValidator.h"
#include "MantidKernel/MandatoryValidator.h"
#include "MantidAPI/Progress.h"
#include "MantidAPI/TextAxis.h"
#include "MantidKernel/PropertyWithValue.h"
#include "MantidKernel/TimeSeriesProperty.h"

#include <boost/shared_ptr.hpp>
#include <boost/lexical_cast.hpp>
Expand Down Expand Up @@ -211,22 +212,61 @@ namespace Mantid
}
outWS->replaceAxis(1,tAxis);

const std::string dtcType = getPropertyValue("DeadTimeCorrType");

Workspace_sptr customDeadTimes;

if ( dtcType == "FromSpecifiedFile" )
{
IAlgorithm_sptr loadDeadTimes = createChildAlgorithm("LoadNexusProcessed");
loadDeadTimes->initialize();
loadDeadTimes->setPropertyValue( "Filename", getPropertyValue("DeadTimeCorrFile") );
loadDeadTimes->execute();

customDeadTimes = loadDeadTimes->getProperty("OutputWorkspace");
}

Progress progress(this,0,1,ie-is+2);
for(size_t i=is;i<=ie;i++)
{
std::ostringstream fn,fnn;
fnn << std::setw(w) << std::setfill('0') << i ;
fn << fnBase << fnn.str() << ext;

// Load a muon nexus file with auto_group set to true
IAlgorithm_sptr loadAlg = createChildAlgorithm("MuonApplyDTC");
loadAlg->initialize();
loadAlg->setPropertyValue("Filename", fn.str());
loadAlg->setPropertyValue("DtcType", getPropertyValue("DeadTimeCorrType"));
loadAlg->setPropertyValue("DtcFile", getPropertyValue("DeadTimeCorrFile"));
loadAlg->execute();
IAlgorithm_sptr load = createChildAlgorithm("LoadMuonNexus");
load->initialize();
load->setPropertyValue("Filename", fn.str());
load->execute();

Workspace_sptr loadedWs = load->getProperty("OutputWorkspace");

if ( dtcType != "None" )
{
IAlgorithm_sptr applyCorr = createChildAlgorithm("ApplyDeadTimeCorr", -1, -1, false);
applyCorr->initialize();

ScopedWorkspace ws(loadedWs);
applyCorr->setPropertyValue("InputWorkspace", ws.name());
applyCorr->setPropertyValue("OutputWorkspace", ws.name());

Workspace_sptr loadedWs = loadAlg->getProperty("OutputWorkspace");
ScopedWorkspace deadTimes;

if ( dtcType == "FromSpecifiedFile" )
{
deadTimes.set(customDeadTimes);
}
else
{
deadTimes.set( load->getProperty("DeadTimeTable") );
}

applyCorr->setPropertyValue( "DeadTimeTable", deadTimes.name() );
applyCorr->execute();

// Workspace should've been replaced in the ADS by ApplyDeadTimeCorr, so need to
// re-assign it
loadedWs = ws.retrieve();
}

if(m_autogroup)
{
Expand Down Expand Up @@ -263,6 +303,7 @@ namespace Mantid
{
DataObjects::Workspace2D_sptr ws_red;
DataObjects::Workspace2D_sptr ws_green;


// Run through the periods of the loaded file and do calculations on the selected ones
for(int mi = 0; mi < loadedGroup->getNumberOfEntries(); mi++)
Expand Down Expand Up @@ -291,6 +332,8 @@ namespace Mantid
}

}


// red & green claculation
if (green != EMPTY_INT())
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,13 @@ void PlotAsymmetryByLogValueDialog::fillLogBox(const QString&)

m_uiForm.logBox->clear();

Mantid::API::IAlgorithm_sptr alg = Mantid::API::AlgorithmFactory::Instance().create("LoadNexus",-1);
Mantid::API::IAlgorithm_sptr alg = Mantid::API::AlgorithmFactory::Instance().create("LoadMuonNexus",-1);
alg->initialize();
try
{
alg->setPropertyValue("Filename",nexusFileName.toStdString());
alg->setPropertyValue("OutputWorkspace","PlotAsymmetryByLogValueDialog_tmp");
alg->setPropertyValue("DeadTimeTable", ""); // Don't need it for now
alg->setPropertyValue("SpectrumMin","0");
alg->setPropertyValue("SpectrumMax","0");
alg->execute();
Expand Down

0 comments on commit f271e78

Please sign in to comment.