diff --git a/Code/Mantid/Framework/Algorithms/CMakeLists.txt b/Code/Mantid/Framework/Algorithms/CMakeLists.txt index d7ddd3c179cc5e94ee82375c415e9cec96eae9b6..fcc90de6499f274018a6175a7c188eb9b9ce6a87 100644 --- a/Code/Mantid/Framework/Algorithms/CMakeLists.txt +++ b/Code/Mantid/Framework/Algorithms/CMakeLists.txt @@ -52,6 +52,7 @@ set ( SRC_FILES src/ConvertToMatrixWorkspace.cpp src/ConvertToPointData.cpp src/ConvertUnits.cpp + src/ConvertUnitsUsingDetectorTable.cpp src/CopyDetectorMapping.cpp src/CopyInstrumentParameters.cpp src/CopyLogs.cpp @@ -308,6 +309,7 @@ set ( INC_FILES inc/MantidAlgorithms/ConvertToMatrixWorkspace.h inc/MantidAlgorithms/ConvertToPointData.h inc/MantidAlgorithms/ConvertUnits.h + inc/MantidAlgorithms/ConvertUnitsUsingDetectorTable.h inc/MantidAlgorithms/CopyDetectorMapping.h inc/MantidAlgorithms/CopyInstrumentParameters.h inc/MantidAlgorithms/CopyLogs.h @@ -575,6 +577,7 @@ set ( TEST_FILES ConvertToMatrixWorkspaceTest.h ConvertToPointDataTest.h ConvertUnitsTest.h + ConvertUnitsUsingDetectorTableTest.h CopyDetectorMappingTest.h CopyInstrumentParametersTest.h CopyLogsTest.h diff --git a/Code/Mantid/Framework/Algorithms/inc/MantidAlgorithms/ConvertUnitsUsingDetectorTable.h b/Code/Mantid/Framework/Algorithms/inc/MantidAlgorithms/ConvertUnitsUsingDetectorTable.h new file mode 100644 index 0000000000000000000000000000000000000000..8c29a2f6af802bd5a7bb79639e79da48a0952c26 --- /dev/null +++ b/Code/Mantid/Framework/Algorithms/inc/MantidAlgorithms/ConvertUnitsUsingDetectorTable.h @@ -0,0 +1,56 @@ +#ifndef MANTID_ALGORITHMS_CONVERTUNITSUSINGDETECTORTABLE_H_ +#define MANTID_ALGORITHMS_CONVERTUNITSUSINGDETECTORTABLE_H_ + +#include "MantidKernel/System.h" +#include "MantidAPI/Algorithm.h" + +namespace Mantid +{ +namespace Algorithms +{ + + /** ConvertUnitsUsingDetectorTable : Converts the units in which a workspace is represented. + + Copyright © 2015 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge National Laboratory & European Spallation Source + + 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 ConvertUnitsUsingDetectorTable : public API::Algorithm + { + public: + ConvertUnitsUsingDetectorTable(); + virtual ~ConvertUnitsUsingDetectorTable(); + + virtual const std::string name() const; + virtual int version() const; + virtual const std::string category() const; + virtual const std::string summary() const; + + private: + void init(); + void exec(); + + + }; + + +} // namespace Algorithms +} // namespace Mantid + +#endif /* MANTID_ALGORITHMS_CONVERTUNITSUSINGDETECTORTABLE_H_ */ diff --git a/Code/Mantid/Framework/Algorithms/src/ConvertUnitsUsingDetectorTable.cpp b/Code/Mantid/Framework/Algorithms/src/ConvertUnitsUsingDetectorTable.cpp new file mode 100644 index 0000000000000000000000000000000000000000..8e5b413c7aa24cd606401ea16ea1f377c8efa83b --- /dev/null +++ b/Code/Mantid/Framework/Algorithms/src/ConvertUnitsUsingDetectorTable.cpp @@ -0,0 +1,65 @@ +#include "MantidAlgorithms/ConvertUnitsUsingDetectorTable.h" + +namespace Mantid +{ +namespace Algorithms +{ + + using Mantid::Kernel::Direction; + using Mantid::API::WorkspaceProperty; + + // Register the algorithm into the AlgorithmFactory + DECLARE_ALGORITHM(ConvertUnitsUsingDetectorTable) + + + + //---------------------------------------------------------------------------------------------- + /** Constructor + */ + ConvertUnitsUsingDetectorTable::ConvertUnitsUsingDetectorTable() + { + } + + //---------------------------------------------------------------------------------------------- + /** Destructor + */ + ConvertUnitsUsingDetectorTable::~ConvertUnitsUsingDetectorTable() + { + } + + + //---------------------------------------------------------------------------------------------- + + /// Algorithms name for identification. @see Algorithm::name + const std::string ConvertUnitsUsingDetectorTable::name() const { return "ConvertUnitsUsingDetectorTable"; } + + /// Algorithm's version for identification. @see Algorithm::version + int ConvertUnitsUsingDetectorTable::version() const { return 1;} + + /// Algorithm's category for identification. @see Algorithm::category + const std::string ConvertUnitsUsingDetectorTable::category() const { return "Transforms\\Units";} + + /// Algorithm's summary for use in the GUI and help. @see Algorithm::summary + const std::string ConvertUnitsUsingDetectorTable::summary() const { return "Performs a unit change on the X values of a workspace";} + + //---------------------------------------------------------------------------------------------- + /** Initialize the algorithm's properties. + */ + void ConvertUnitsUsingDetectorTable::init() + { + declareProperty(new WorkspaceProperty<>("InputWorkspace","",Direction::Input), "An input workspace."); + declareProperty(new WorkspaceProperty<>("OutputWorkspace","",Direction::Output), "An output workspace."); + } + + //---------------------------------------------------------------------------------------------- + /** Execute the algorithm. + */ + void ConvertUnitsUsingDetectorTable::exec() + { + // TODO Auto-generated execute stub + } + + + +} // namespace Algorithms +} // namespace Mantid diff --git a/Code/Mantid/Framework/Algorithms/test/ConvertUnitsUsingDetectorTableTest.h b/Code/Mantid/Framework/Algorithms/test/ConvertUnitsUsingDetectorTableTest.h new file mode 100644 index 0000000000000000000000000000000000000000..38db2ab818c5fe3ab58c82a137d6ab414de525f2 --- /dev/null +++ b/Code/Mantid/Framework/Algorithms/test/ConvertUnitsUsingDetectorTableTest.h @@ -0,0 +1,61 @@ +#ifndef MANTID_ALGORITHMS_CONVERTUNITSUSINGDETECTORTABLETEST_H_ +#define MANTID_ALGORITHMS_CONVERTUNITSUSINGDETECTORTABLETEST_H_ + +#include <cxxtest/TestSuite.h> + +#include "MantidAlgorithms/ConvertUnitsUsingDetectorTable.h" + +using Mantid::Algorithms::ConvertUnitsUsingDetectorTable; +using namespace Mantid::API; + +class ConvertUnitsUsingDetectorTableTest : public CxxTest::TestSuite +{ +public: + // This pair of boilerplate methods prevent the suite being created statically + // This means the constructor isn't called when running other tests + static ConvertUnitsUsingDetectorTableTest *createSuite() { return new ConvertUnitsUsingDetectorTableTest(); } + static void destroySuite( ConvertUnitsUsingDetectorTableTest *suite ) { delete suite; } + + + void test_Init() + { + ConvertUnitsUsingDetectorTable alg; + TS_ASSERT_THROWS_NOTHING( alg.initialize() ) + TS_ASSERT( alg.isInitialized() ) + } + + void test_exec() + { + // Name of the output workspace. + std::string outWSName("ConvertUnitsUsingDetectorTableTest_OutputWS"); + + ConvertUnitsUsingDetectorTable alg; + TS_ASSERT_THROWS_NOTHING( alg.initialize() ) + TS_ASSERT( alg.isInitialized() ) + TS_ASSERT_THROWS_NOTHING( alg.setPropertyValue("REPLACE_PROPERTY_NAME_HERE!!!!", "value") ); + TS_ASSERT_THROWS_NOTHING( alg.setPropertyValue("OutputWorkspace", outWSName) ); + TS_ASSERT_THROWS_NOTHING( alg.execute(); ); + TS_ASSERT( alg.isExecuted() ); + + // Retrieve the workspace from data service. TODO: Change to your desired type + Workspace_sptr ws; + TS_ASSERT_THROWS_NOTHING( ws = AnalysisDataService::Instance().retrieveWS<Workspace>(outWSName) ); + TS_ASSERT(ws); + if (!ws) return; + + // TODO: Check the results + + // Remove workspace from the data service. + AnalysisDataService::Instance().remove(outWSName); + } + + void test_Something() + { + TSM_ASSERT( "You forgot to write a test!", 0); + } + + +}; + + +#endif /* MANTID_ALGORITHMS_CONVERTUNITSUSINGDETECTORTABLETEST_H_ */ \ No newline at end of file diff --git a/Code/Mantid/docs/source/algorithms/ConvertUnitsUsingDetectorTable-v1.rst b/Code/Mantid/docs/source/algorithms/ConvertUnitsUsingDetectorTable-v1.rst new file mode 100644 index 0000000000000000000000000000000000000000..45dcc2f25e5a33ad24691746343903d0de6de888 --- /dev/null +++ b/Code/Mantid/docs/source/algorithms/ConvertUnitsUsingDetectorTable-v1.rst @@ -0,0 +1,44 @@ + +.. algorithm:: + +.. summary:: + +.. alias:: + +.. properties:: + +Description +----------- + +TODO: Enter a full rst-markup description of your algorithm here. + + +Usage +----- +.. Try not to use files in your examples, + but if you cannot avoid it then the (small) files must be added to + autotestdata\UsageData and the following tag unindented + .. include:: ../usagedata-note.txt + +**Example - ConvertUnitsUsingDetectorTable** + +.. testcode:: ConvertUnitsUsingDetectorTableExample + + # Create a host workspace + ws = CreateWorkspace(DataX=range(0,3), DataY=(0,2)) + or + ws = CreateSampleWorkspace() + + wsOut = ConvertUnitsUsingDetectorTable() + + # Print the result + print "The output workspace has %i spectra" % wsOut.getNumberHistograms() + +Output: + +.. testoutput:: ConvertUnitsUsingDetectorTableExample + + The output workspace has ?? spectra + +.. categories:: +