Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feature/8534_muon_new_workflow_alg'
Browse files Browse the repository at this point in the history
  • Loading branch information
Anders-Markvardsen committed Dec 4, 2013
2 parents 1f76e39 + 509b508 commit c205013
Show file tree
Hide file tree
Showing 11 changed files with 1,139 additions and 505 deletions.
3 changes: 3 additions & 0 deletions Code/Mantid/Framework/Algorithms/src/AsymmetryCalc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ void AsymmetryCalc::exec()
//Copy the imput time bins on to the output
outputWS->dataX(0) = inputWS->readX(0);

// Update Y axis label
outputWS->setYUnitLabel("Asymmetry");

setProperty("OutputWorkspace", outputWS);
}

Expand Down
3 changes: 3 additions & 0 deletions Code/Mantid/Framework/Algorithms/src/RemoveExpDecay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,9 @@ void MuonRemoveExpDecay::exec()
PARALLEL_CHECK_INTERUPT_REGION
}

// Update Y axis label
outputWS->setYUnitLabel("Asymmetry");

setProperty("OutputWorkspace", outputWS);
}

Expand Down
24 changes: 24 additions & 0 deletions Code/Mantid/Framework/Algorithms/test/AsymmetryCalcTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,30 @@ class AsymmetryCalcTest : public CxxTest::TestSuite
TS_ASSERT_EQUALS( outputWS->readY(0)[9], -0.5 ); // == (1 - 3)/(1 + 3)
}

void test_yUnitLabel()
{
const std::string outputWSName = "AsymmetryCalcTest_yUnitLabel_OutputWS";

auto ws = WorkspaceCreationHelper::Create2DWorkspace(2,1);

AsymmetryCalc alg;
alg.initialize();
alg.setProperty("InputWorkspace", ws);
alg.setProperty("OutputWorkspace", outputWSName);
alg.execute();

auto result = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>(outputWSName);

TS_ASSERT(result);

if( result )
{
TS_ASSERT_EQUALS( result->YUnitLabel(), "Asymmetry" );
}

AnalysisDataService::Instance().remove(outputWSName);
}

private:
AsymmetryCalc asymCalc;
Mantid::DataHandling::LoadMuonNexus2 loader;
Expand Down
32 changes: 29 additions & 3 deletions Code/Mantid/Framework/Algorithms/test/RemoveExpDecayTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@

#include <cxxtest/TestSuite.h>

#include "MantidAPI/AnalysisDataService.h"
#include "MantidAPI/Workspace.h"
#include "MantidAlgorithms/RemoveExpDecay.h"
#include "MantidDataHandling/LoadInstrument.h"
#include "MantidDataHandling/LoadMuonNexus2.h"
#include "MantidAlgorithms/RemoveExpDecay.h"
#include "MantidAPI/Workspace.h"
#include "MantidDataObjects/Workspace2D.h"
#include "MantidAPI/AnalysisDataService.h"
#include "MantidTestHelpers/WorkspaceCreationHelper.h"

#include <stdexcept>

using namespace Mantid::Algorithms;
Expand Down Expand Up @@ -90,6 +92,30 @@ class RemoveExpDecayTest : public CxxTest::TestSuite
}
}

void test_yUnitLabel()
{
const std::string outputWSName = "RemoveExpDecayTest_yUnitLabel_OutputWS";

auto ws = WorkspaceCreationHelper::Create2DWorkspace(1,1);

MuonRemoveExpDecay alg;
alg.initialize();
alg.setProperty("InputWorkspace", ws);
alg.setProperty("OutputWorkspace", outputWSName);
alg.execute();

auto result = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>(outputWSName);

TS_ASSERT(result);

if( result )
{
TS_ASSERT_EQUALS( result->YUnitLabel(), "Asymmetry" );
}

AnalysisDataService::Instance().remove(outputWSName);
}


private:
MuonRemoveExpDecay alg;
Expand Down
3 changes: 3 additions & 0 deletions Code/Mantid/Framework/WorkflowAlgorithms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ set ( SRC_FILES
src/HFIRInstrument.cpp
src/HFIRLoad.cpp
src/HFIRSANSNormalise.cpp
src/MuonCalculateAsymmetry.cpp
src/RefReduction.cpp
src/RefRoi.cpp
src/SANSBeamFinder.cpp
Expand Down Expand Up @@ -54,6 +55,7 @@ set ( INC_FILES
inc/MantidWorkflowAlgorithms/HFIRInstrument.h
inc/MantidWorkflowAlgorithms/HFIRLoad.h
inc/MantidWorkflowAlgorithms/HFIRSANSNormalise.h
inc/MantidWorkflowAlgorithms/MuonCalculateAsymmetry.h
inc/MantidWorkflowAlgorithms/RefReduction.h
inc/MantidWorkflowAlgorithms/RefRoi.h
inc/MantidWorkflowAlgorithms/SANSBeamFinder.h
Expand All @@ -67,6 +69,7 @@ set ( INC_FILES
)

set ( TEST_FILES
MuonCalculateAsymmetryTest.h
SANSSolidAngleCorrectionTest.h
StepScanTest.h
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#ifndef MANTID_WORKFLOWALGORITHMS_MUONCALCULATEASYMMETRY_H_
#define MANTID_WORKFLOWALGORITHMS_MUONCALCULATEASYMMETRY_H_

#include "MantidKernel/System.h"
#include "MantidAPI/Algorithm.h"

namespace Mantid
{
namespace WorkflowAlgorithms
{
using namespace Kernel;
using namespace API;

/** MuonCalculateAsymmetry : converts loaded/prepared Muon data to a data suitable for analysis.
Copyright &copy; 2013 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory
This file is part of Mantid.
Mantid is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
Mantid is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
File change history is stored at: <https://github.com/mantidproject/mantid>
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
class DLLExport MuonCalculateAsymmetry : public API::Algorithm
{
public:
MuonCalculateAsymmetry();
virtual ~MuonCalculateAsymmetry();

virtual const std::string name() const;
virtual int version() const;
virtual const std::string category() const;

private:
virtual void initDocs();
void init();
void exec();

/// Converts given workspace according to the OutputType
MatrixWorkspace_sptr convertWorkspace(MatrixWorkspace_sptr ws);

/// Merges two period workspaces according to PeriodOperation specified
MatrixWorkspace_sptr mergePeriods(MatrixWorkspace_sptr ws1, MatrixWorkspace_sptr ws2);
};


} // namespace WorkflowAlgorithms
} // namespace Mantid

#endif /* MANTID_WORKFLOWALGORITHMS_MUONCALCULATEASYMMETRY_H_ */

0 comments on commit c205013

Please sign in to comment.