diff --git a/Framework/Algorithms/CMakeLists.txt b/Framework/Algorithms/CMakeLists.txt index 6a30372e559ef7e900bc612d426bcd4f57e79783..1ed4cd93177258b516f60e54a132d52a9a37cbe4 100644 --- a/Framework/Algorithms/CMakeLists.txt +++ b/Framework/Algorithms/CMakeLists.txt @@ -155,7 +155,6 @@ set ( SRC_FILES src/He3TubeEfficiency.cpp src/IQTransform.cpp src/IdentifyNoisyDetectors.cpp - src/ImggTomographicReconstruction.cpp src/IntegrateByComponent.cpp src/Integration.cpp src/InterpolatingRebin.cpp @@ -469,7 +468,6 @@ set ( INC_FILES inc/MantidAlgorithms/He3TubeEfficiency.h inc/MantidAlgorithms/IQTransform.h inc/MantidAlgorithms/IdentifyNoisyDetectors.h - inc/MantidAlgorithms/ImggTomographicReconstruction.h inc/MantidAlgorithms/IntegrateByComponent.h inc/MantidAlgorithms/Integration.h inc/MantidAlgorithms/InterpolatingRebin.h @@ -792,7 +790,6 @@ set ( TEST_FILES He3TubeEfficiencyTest.h IQTransformTest.h IdentifyNoisyDetectorsTest.h - ImggTomographicReconstructionTest.h IntegrateByComponentTest.h IntegrationTest.h InterpolatingRebinTest.h diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ImggTomographicReconstruction.h b/Framework/Algorithms/inc/MantidAlgorithms/ImggTomographicReconstruction.h deleted file mode 100644 index f70373f41aa12af4654b86035053761efcd5178a..0000000000000000000000000000000000000000 --- a/Framework/Algorithms/inc/MantidAlgorithms/ImggTomographicReconstruction.h +++ /dev/null @@ -1,81 +0,0 @@ -#ifndef MANTID_ALGORITHMS_IMGGTOMOGRAPHICRECONSTRUCTION_H_ -#define MANTID_ALGORITHMS_IMGGTOMOGRAPHICRECONSTRUCTION_H_ - -#include "MantidAlgorithms/DllConfig.h" -#include "MantidAPI/Algorithm.h" -#include "MantidAPI/WorkspaceGroup_fwd.h" - -namespace Mantid { -namespace Algorithms { - -/** - ImggTomographicReconstruction: reconstruct volumes from a sequence - of 2D projections using tomographic reconstruction methods. - - Copyright © 2016 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 MANTID_ALGORITHMS_DLL ImggTomographicReconstruction - : public API::Algorithm { -public: - const std::string name() const override; - - int version() const override; - - const std::string category() const override; - - const std::string summary() const override; - -private: - void init() override; - - void exec() override; - - bool processGroups() override; - - std::map<std::string, std::string> validateInputs() override; - - std::unique_ptr<std::vector<float>> - prepareProjectionAngles(API::WorkspaceGroup_const_sptr wks, double minAngle, - double maxAngle) const; - - std::unique_ptr<std::vector<float>> - prepareInputData(size_t totalSize, API::WorkspaceGroup_const_sptr wsg); - - std::unique_ptr<std::vector<float>> prepareDataVol(size_t totalSize); - - std::unique_ptr<std::vector<float>> prepareCenters(int cor, size_t totalSize); - - size_t xSizeProjections(API::WorkspaceGroup_const_sptr wks) const; - - size_t pSizeProjections(API::WorkspaceGroup_const_sptr wks) const; - - size_t ySizeProjections(API::WorkspaceGroup_const_sptr wks) const; - - API::WorkspaceGroup_sptr buildOutputWks(const std::vector<float> &dataVol, - size_t xsize, size_t ysize, - size_t sliceSize); -}; - -} // namespace Algorithms -} // namespace Mantid - -#endif /* MANTID_ALGORITHMS_IMGGTOMOGRAPHICRECONSTRUCTION_H_ */ diff --git a/Framework/Algorithms/test/ImggTomographicReconstructionTest.h b/Framework/Algorithms/test/ImggTomographicReconstructionTest.h deleted file mode 100644 index 878c21dc91234bde38d01dd8c6ffedc824bef778..0000000000000000000000000000000000000000 --- a/Framework/Algorithms/test/ImggTomographicReconstructionTest.h +++ /dev/null @@ -1,287 +0,0 @@ -#ifndef MANTID_ALGORITHMS_IMGGTOMOGRAPHICRECONSTRUCTIONTEST_H_ -#define MANTID_ALGORITHMS_IMGGTOMOGRAPHICRECONSTRUCTIONTEST_H_ - -#include <cxxtest/TestSuite.h> - -#include "MantidAlgorithms/ImggTomographicReconstruction.h" -#include "MantidAPI/AlgorithmManager.h" -#include "MantidAPI/WorkspaceGroup.h" -#include "MantidKernel/Exception.h" - -#include "MantidTestHelpers/WorkspaceCreationHelper.h" - -#include <Poco/File.h> - -using Mantid::Algorithms::ImggTomographicReconstruction; -using namespace Mantid; - -class ImggTomographicReconstructionTest : 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 ImggTomographicReconstructionTest *createSuite() { - return new ImggTomographicReconstructionTest(); - } - - static void destroySuite(ImggTomographicReconstructionTest *suite) { - delete suite; - } - - void test_init() { - ImggTomographicReconstruction alg; - TS_ASSERT_THROWS_NOTHING(alg.initialize()); - TS_ASSERT(alg.isInitialized()); - - double relax; - TS_ASSERT_THROWS_NOTHING(relax = alg.getProperty("RelaxationParameter")); - TS_ASSERT_EQUALS(relax, 0.5); - } - - void test_errors_options() { - auto alg = API::AlgorithmManager::Instance().create( - "ImggTomographicReconstruction"); - - TS_ASSERT_THROWS_NOTHING( - alg->setPropertyValue("OutputWorkspace", "_unused_for_child")); - - TS_ASSERT_THROWS( - alg->setPropertyValue("BitDepth", "this_is_wrong_you_must_fail"), - std::runtime_error); - } - - void test_exec_fails_inexistent_workspace() { - ImggTomographicReconstruction alg; - TS_ASSERT_THROWS_NOTHING(alg.initialize()); - TS_ASSERT(alg.isInitialized()); - TS_ASSERT_THROWS( - alg.setPropertyValue("InputWorkspace", "inexistent_workspace_fails"), - std::invalid_argument); - - TS_ASSERT_THROWS(alg.execute(), std::runtime_error); - TS_ASSERT(!alg.isExecuted()); - } - - void test_exec_fails_wrong_workspace() { - API::MatrixWorkspace_sptr a = - WorkspaceCreationHelper::createWorkspaceSingleValue(3); - - ImggTomographicReconstruction alg; - TS_ASSERT_THROWS_NOTHING(alg.initialize()); - TS_ASSERT(alg.isInitialized()); - TS_ASSERT_THROWS_NOTHING(alg.setProperty("InputWorkspace", a)); - - TS_ASSERT_THROWS(alg.execute(), std::runtime_error); - TS_ASSERT(!alg.isExecuted()); - - API::MatrixWorkspace_sptr wsSingle = - WorkspaceCreationHelper::create2DWorkspace(10, 10); - - ImggTomographicReconstruction algTwo; - TS_ASSERT_THROWS_NOTHING(algTwo.initialize()); - TS_ASSERT(algTwo.isInitialized()); - TS_ASSERT_THROWS_NOTHING(algTwo.setProperty("InputWorkspace", wsSingle)); - - TS_ASSERT_THROWS(algTwo.execute(), std::runtime_error); - TS_ASSERT(!algTwo.isExecuted()); - } - - void test_exec_fails_single_proj() { - const std::string projectionsGrpName("only_one_projection"); - API::WorkspaceGroup_sptr projectionsGrp = - WorkspaceCreationHelper::createWorkspaceGroup(1, 4, 4, - projectionsGrpName); - - ImggTomographicReconstruction alg; - TS_ASSERT_THROWS_NOTHING(alg.initialize()); - TS_ASSERT(alg.isInitialized()); - TS_ASSERT_THROWS_NOTHING(alg.setProperty("InputWorkspace", projectionsGrp)); - TS_ASSERT_THROWS_NOTHING(alg.setProperty("MinProjectionAngle", 0.0)); - TS_ASSERT_THROWS_NOTHING(alg.setProperty("MaxProjectionAngle", 260.0)); - TS_ASSERT_THROWS_NOTHING(alg.setProperty("RelaxationParameter", 1.25)); - TS_ASSERT_THROWS_NOTHING(alg.setProperty("CenterOfRotation", 4)); - - TS_ASSERT_THROWS(alg.execute(), std::runtime_error); - TS_ASSERT(!alg.isExecuted()); - } - - void test_exec_fails_wrong_center() { - const std::string projectionsGrpName("only_two_small_projections"); - API::WorkspaceGroup_sptr projectionsGrp = - WorkspaceCreationHelper::createWorkspaceGroup(2, 4, 4, - projectionsGrpName); - - ImggTomographicReconstruction alg; - TS_ASSERT_THROWS_NOTHING(alg.initialize()); - TS_ASSERT(alg.isInitialized()); - TS_ASSERT_THROWS_NOTHING(alg.setProperty("InputWorkspace", projectionsGrp)); - TS_ASSERT_THROWS_NOTHING(alg.setProperty("MinProjectionAngle", 0.0)); - TS_ASSERT_THROWS_NOTHING(alg.setProperty("MaxProjectionAngle", 260.0)); - TS_ASSERT_THROWS_NOTHING(alg.setProperty("RelaxationParameter", 1.25)); - TS_ASSERT_THROWS_NOTHING(alg.setProperty("CenterOfRotation", 10000)); - - // should throw because of the wrong center / outside of image dimensions - TS_ASSERT_THROWS(alg.execute(), std::runtime_error); - TS_ASSERT(!alg.isExecuted()); - } - - void test_exec_runs() { - const std::string projectionsGrpName("only_four_proj"); - int ysize = 16; - int xsize = 16; - int numProj = 4; - API::WorkspaceGroup_sptr projectionsGrp = - WorkspaceCreationHelper::createWorkspaceGroup(numProj, ysize, xsize, - projectionsGrpName); - - for (size_t proj = 0; proj < static_cast<size_t>(proj); ++proj) { - API::Workspace_sptr ws; - TS_ASSERT_THROWS_NOTHING(ws = projectionsGrp->getItem(proj)); - API::MatrixWorkspace_sptr projWS; - TS_ASSERT_THROWS_NOTHING( - projWS = boost::dynamic_pointer_cast<API::MatrixWorkspace>(ws)); - MantidVec &dataY = projWS->dataY(7); - TS_ASSERT_THROWS_NOTHING(std::fill(dataY.begin(), dataY.end(), 5000.0)); - for (size_t idx = 0; idx < static_cast<size_t>(ysize); ++idx) { - projWS->dataY(ysize)[ysize - idx - 1] = 987.6; - } - } - - ImggTomographicReconstruction alg; - // getProperty with workspaceGroup isn't working with - // Algorithm::processGroups. So we need retrieveWS<>() below: - const std::string reconName = "recon_1"; - auto recon = runWithValidCenter(alg, projectionsGrp, 7, reconName); - // Fix when this works well - TSM_ASSERT("Expected that getProperty would return nullptr with " - "WorkspaceGroup when using processGroups()", - !recon); - - TS_ASSERT_THROWS_NOTHING( - recon = API::AnalysisDataService::Instance() - .retrieveWS<API::WorkspaceGroup>(reconName)); - TSM_ASSERT("The reconstruction/result workspace is not valid", recon); - - size_t grpSize = recon->size(); - TSM_ASSERT_EQUALS( - "The number of items in the output/reconstruction workspace is wrong", - grpSize, ysize); - - const size_t pix1x = 5; - const size_t pix1y = 14; - const double referencePix1 = 8.0; - const size_t pix2x = 7; - const size_t pix2y = 8; - const double referencePix2 = 8.0; - for (size_t idx = 0; idx < grpSize; ++idx) { - auto wks = recon->getItem(idx); - TSM_ASSERT( - "The output workspace group should have valid slice workspaces", wks); - auto sliceWS = boost::dynamic_pointer_cast<API::MatrixWorkspace>(wks); - TSM_ASSERT("The slice workspaces should be of type MatrixWorkspace", - sliceWS); - - TSM_ASSERT_EQUALS("Unexpected number of columns in output slices", - sliceWS->blocksize(), xsize); - TSM_ASSERT_EQUALS("Unexpected number of rows in output slices", - sliceWS->getNumberHistograms(), ysize); - TSM_ASSERT_DELTA("Unexpected value in output pixel", - sliceWS->readY(pix1y)[pix1x], referencePix1, 1e-4); - TSM_ASSERT_DELTA("Unexpected value in output pixel", - sliceWS->readY(pix2y)[pix2x], referencePix2, 1e-4); - } - } - - void test_exec_runs0s() { - const std::string projectionsGrpName("a_couple_0_images"); - int ysize = 8; - int xsize = 8; - int numProj = 2; - API::WorkspaceGroup_sptr projectionsGrp = - WorkspaceCreationHelper::createWorkspaceGroup(numProj, ysize, xsize, - projectionsGrpName); - - for (size_t proj = 0; proj < static_cast<size_t>(proj); ++proj) { - API::Workspace_sptr ws; - TS_ASSERT_THROWS_NOTHING(ws = projectionsGrp->getItem(proj)); - API::MatrixWorkspace_sptr projWS; - TS_ASSERT_THROWS_NOTHING( - projWS = boost::dynamic_pointer_cast<API::MatrixWorkspace>(ws)); - for (size_t row = 0; row < static_cast<size_t>(ysize); ++row) { - MantidVec &dataY = projWS->dataY(row); - TS_ASSERT_THROWS_NOTHING(std::fill(dataY.begin(), dataY.end(), 0.0)); - } - } - - ImggTomographicReconstruction alg; - const std::string reconName = "recon_0"; - auto recon = runWithValidCenter(alg, projectionsGrp, 7, reconName); - // Fix when this works well - TSM_ASSERT("Expected that getProperty would return nullptr with " - "WorkspaceGroup when using processGroups()", - !recon); - - TS_ASSERT_THROWS_NOTHING( - recon = API::AnalysisDataService::Instance() - .retrieveWS<API::WorkspaceGroup>(reconName)); - TSM_ASSERT("The reconstruction/result workspace is not valid", recon); - - size_t grpSize = recon->size(); - TSM_ASSERT_EQUALS( - "The number of items in the output/reconstruction workspace is wrong", - grpSize, ysize); - - const size_t pix1x = 5; - const size_t pix1y = 2; - const double referencePix1 = 0.0; - const size_t pix2x = 7; - const size_t pix2y = 7; - const double referencePix2 = 0.0; - for (size_t idx = 0; idx < grpSize; ++idx) { - auto wks = recon->getItem(idx); - TSM_ASSERT( - "The output workspace group should have valid slice workspaces", wks); - auto sliceWS = boost::dynamic_pointer_cast<API::MatrixWorkspace>(wks); - TSM_ASSERT("The slice workspaces should be of type MatrixWorkspace", - sliceWS); - - TSM_ASSERT_EQUALS("Unexpected number of columns in output slices", - sliceWS->blocksize(), xsize); - TSM_ASSERT_EQUALS("Unexpected number of rows in output slices", - sliceWS->getNumberHistograms(), ysize); - TSM_ASSERT_DELTA("Unexpected value in output pixel", - sliceWS->readY(pix1y)[pix1x], referencePix1, 1e-4); - TSM_ASSERT_DELTA("Unexpected value in output pixel", - sliceWS->readY(pix2y)[pix2x], referencePix2, 1e-4); - } - } - -private: - API::WorkspaceGroup_sptr runWithValidCenter(API::Algorithm &alg, - API::WorkspaceGroup_sptr wksg, - int center, - const std::string &outName) { - TS_ASSERT_THROWS_NOTHING(alg.initialize()); - TS_ASSERT(alg.isInitialized()); - TS_ASSERT_THROWS_NOTHING(alg.setProperty("InputWorkspace", wksg)); - TS_ASSERT_THROWS_NOTHING(alg.setProperty("MinProjectionAngle", 0.0)); - TS_ASSERT_THROWS_NOTHING(alg.setProperty("MaxProjectionAngle", 180.0)); - TS_ASSERT_THROWS_NOTHING(alg.setProperty("RelaxationParameter", 1.25)); - TS_ASSERT_THROWS_NOTHING(alg.setProperty("CenterOfRotation", center)); - - TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("OutputWorkspace", outName)); - TSM_ASSERT_THROWS_NOTHING( - "execute() throwed for an algorithm with a " - "supposedly correct center parameter for which no " - "failure was expected", - alg.execute()); - TSM_ASSERT("The algorithm execution didn't finish successfully when no " - "issues where expected ", - alg.isExecuted()); - - API::WorkspaceGroup_sptr result = alg.getProperty("OutputWorkspace"); - return result; - } -}; - -#endif /* MANTID_ALGORITHMS_IMGGTOMOGRAPHICRECONSTRUCTIONTEST_H_ */ diff --git a/Framework/DataHandling/CMakeLists.txt b/Framework/DataHandling/CMakeLists.txt index c6ee3ac5eb919b94d8404023a66a66609a4cbafb..41496fa6a91c74dbb6868e73e103f476a85de41d 100644 --- a/Framework/DataHandling/CMakeLists.txt +++ b/Framework/DataHandling/CMakeLists.txt @@ -27,7 +27,6 @@ set ( SRC_FILES src/H5Util.cpp src/ISISDataArchive.cpp src/ISISRunLogs.cpp - src/ImggAggregateWavelengths.cpp src/Load.cpp src/LoadANSTOHelper.cpp src/LoadAscii.cpp @@ -159,7 +158,6 @@ set ( SRC_FILES src/SaveTBL.cpp src/SaveReflThreeColumnAscii.cpp src/SaveSPE.cpp - src/SaveSavuTomoConfig.cpp src/SaveToSNSHistogramNexus.cpp src/SaveVTK.cpp src/SetBeam.cpp @@ -201,7 +199,6 @@ set ( INC_FILES inc/MantidDataHandling/H5Util.h inc/MantidDataHandling/ISISDataArchive.h inc/MantidDataHandling/ISISRunLogs.h - inc/MantidDataHandling/ImggAggregateWavelengths.h inc/MantidDataHandling/Load.h inc/MantidDataHandling/LoadANSTOHelper.h inc/MantidDataHandling/LoadAscii.h @@ -329,7 +326,6 @@ set ( INC_FILES inc/MantidDataHandling/SaveTBL.h inc/MantidDataHandling/SaveReflThreeColumnAscii.h inc/MantidDataHandling/SaveSPE.h - inc/MantidDataHandling/SaveSavuTomoConfig.h inc/MantidDataHandling/SaveToSNSHistogramNexus.h inc/MantidDataHandling/SaveVTK.h inc/MantidDataHandling/SetBeam.h @@ -374,7 +370,6 @@ set ( TEST_FILES GroupDetectorsTest.h H5UtilTest.h ISISDataArchiveTest.h - ImggAggregateWavelengthsTest.h InstrumentRayTracerTest.h LoadAsciiTest.h LoadAscii2Test.h @@ -493,7 +488,6 @@ set ( TEST_FILES SaveTBLTest.h SaveReflThreeColumnAsciiTest.h SaveSPETest.h - SaveSavuTomoConfigTest.h SaveToSNSHistogramNexusTest.h SetBeamTest.h SetSampleMaterialTest.h diff --git a/Framework/DataHandling/inc/MantidDataHandling/ImggAggregateWavelengths.h b/Framework/DataHandling/inc/MantidDataHandling/ImggAggregateWavelengths.h deleted file mode 100644 index c3c36be19a4870683da3775b4f510d1f58817f99..0000000000000000000000000000000000000000 --- a/Framework/DataHandling/inc/MantidDataHandling/ImggAggregateWavelengths.h +++ /dev/null @@ -1,120 +0,0 @@ -#ifndef MANTID_DATAHANDLING_IMGGAGGREGATEWAVELENGTHS_H_ -#define MANTID_DATAHANDLING_IMGGAGGREGATEWAVELENGTHS_H_ - -#include "MantidDataHandling/DllConfig.h" -#include "MantidAPI/Algorithm.h" -#include "MantidAPI/MatrixWorkspace_fwd.h" - -namespace Poco { -class Path; -} - -namespace Mantid { -namespace DataHandling { - -/** - ImggAggregateWavelengths : Aggregates images from multiple energy - bands - - Copyright © 2016 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 ImggAggregateWavelengths : public API::Algorithm { -public: - const std::string name() const override; - int version() const override; - const std::string category() const override; - const std::string summary() const override; - -private: - void init() override; - void exec() override; - - std::map<std::string, std::string> validateInputs() override; - - void aggUniformBands(const std::string &inputPath, - const std::string &outputPath, size_t bands); - - void aggIndexBands(const std::string &inputPath, - const std::string &outputPath, - const std::string &rangesSpec); - - void aggToFBands(const std::string & /*inputPath*/, - const std::string & /*outputPath*/, - const std::string & /*ranges*/); - - void processDirectory(const Poco::Path &inDir, size_t bands, - const std::string &outDir, - const std::vector<std::string> &outSubdirs, - const std::string &prefix, size_t outImgIndex); - - void processDirectory(const Poco::Path &inDir, - const std::vector<std::pair<size_t, size_t>> &ranges, - const std::string outDir, - const std::vector<std::string> &outSubdirs, - const std::string &prefix, size_t outImgIndex); - - std::vector<std::pair<size_t, size_t>> - rangesFromStringProperty(const std::string &rangesSpec, - const std::string &propName); - - std::vector<Poco::Path> findInputSubdirs(const Poco::Path &path); - - std::vector<Poco::Path> findInputImages(const Poco::Path &path); - - std::vector<std::pair<size_t, size_t>> - splitSizeIntoRanges(size_t availableCount, size_t bands); - - std::vector<std::string> buildOutputSubdirNamesFromUniformBands( - const std::vector<Poco::Path> &inputSubDirs, size_t bands); - - std::vector<std::string> buildOutputSubdirNamesFromIndexRangesBands( - const std::vector<std::pair<size_t, size_t>> &outRanges); - - bool isSupportedExtension(const std::string &extShort, - const std::string &extLong); - - void aggImage(API::MatrixWorkspace_sptr accum, - const API::MatrixWorkspace_sptr toAdd); - - void saveAggImage(const API::MatrixWorkspace_sptr accum, - const std::string &outDir, const std::string &prefix, - size_t outImgIndex); - - API::MatrixWorkspace_sptr loadFITS(const Poco::Path &imgPath, - const std::string &outName); - - void saveFITS(const API::MatrixWorkspace_sptr accum, - const std::string &filename); - - static const std::string outPrefixProjections; - static const std::string outPrefixBands; - static const std::string indexRangesPrefix; - static const std::string tofRangesPrefix; - static const std::string outSubdirsPrefixUniformBands; - static const std::string outSubdirsPrefixIndexBands; - static const std::string outSubdirsPrefixToFBands; -}; - -} // namespace DataHandling -} // namespace Mantid - -#endif /* MANTID_DATAHANDLING_IMGGAGGREGATEWAVELENGTHS_H_ */ diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveSavuTomoConfig.h b/Framework/DataHandling/inc/MantidDataHandling/SaveSavuTomoConfig.h deleted file mode 100644 index 2380256528ac1c41a95c22308b053fa5553d1347..0000000000000000000000000000000000000000 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveSavuTomoConfig.h +++ /dev/null @@ -1,86 +0,0 @@ -#ifndef MANTID_DATAHANDLING_SAVESAVUTOMOCONFIG_H_ -#define MANTID_DATAHANDLING_SAVESAVUTOMOCONFIG_H_ - -//--------------------------------------------------- -// Includes -//--------------------------------------------------- -#include "MantidAPI/Algorithm.h" -#include "MantidAPI/ITableWorkspace_fwd.h" - -namespace Mantid { -namespace DataHandling { - -/** - * Saves a configuration for a tomographic reconstruction into a - * NeXus/HDF5 file. - * - * Operates on table workspaces, with each row representing a plugin - * definition to add. - * - * Columns:4: id/params/name/cite - * - * Copyright © 2014-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 SaveSavuTomoConfig : public API::Algorithm { -public: - SaveSavuTomoConfig(); - /// Algorithm's name for identification overriding a virtual method - const std::string name() const override { return "SaveSavuTomoConfig"; } - - /// Summary of algorithms purpose - const std::string summary() const override { - return "Writes a configuration file for a tomographic reconstruction job."; - } - - /// Algorithm's version - int version() const override { return (1); } - - /// Algorithm's category for identification - const std::string category() const override { - return "DataHandling\\Imaging;"; - } - -private: - /// Initialisation code - void init() override; - /// Execution code : Single workspace - void exec() override; - - /// basic check on a table workspace properties - bool tableLooksGenuine(const API::ITableWorkspace_sptr &tws); - - /// get table workspaces (checking the workspace names given) - std::vector<API::ITableWorkspace_sptr> - checkTables(const std::vector<std::string> &workspaces); - /// write savu tomo config file - void saveFile(const std::string fname, - const std::vector<API::ITableWorkspace_sptr> &wss); - - // Number of info entries to read from the input table workspaces - unsigned int m_pluginInfoCount; -}; - -} // namespace DataHandling -} // namespace Mantid - -#endif // MANTID_DATAHANDLING_SAVESAVUTOMOCONFIG_H_ diff --git a/Framework/DataHandling/test/ImggAggregateWavelengthsTest.h b/Framework/DataHandling/test/ImggAggregateWavelengthsTest.h deleted file mode 100644 index 32bf6d381417969b040d791d656d61dfa1c94b81..0000000000000000000000000000000000000000 --- a/Framework/DataHandling/test/ImggAggregateWavelengthsTest.h +++ /dev/null @@ -1,109 +0,0 @@ -#ifndef MANTID_DATAHANDLING_IMGGAGGREGATEWAVELENGTHSTEST_H_ -#define MANTID_DATAHANDLING_IMGGAGGREGATEWAVELENGTHSTEST_H_ - -#include <cxxtest/TestSuite.h> - -#include "MantidDataHandling/ImggAggregateWavelengths.h" -#include "MantidAPI/AlgorithmManager.h" -#include "MantidKernel/Exception.h" - -using Mantid::DataHandling::ImggAggregateWavelengths; - -// This algorithm is all about I/O. No effective functional testing is -// done here, but in system tests -class ImggAggregateWavelengthsTest : 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 ImggAggregateWavelengthsTest *createSuite() { - return new ImggAggregateWavelengthsTest(); - } - - static void destroySuite(ImggAggregateWavelengthsTest *suite) { - delete suite; - } - - void test_init() { - ImggAggregateWavelengths alg; - TS_ASSERT_THROWS_NOTHING(alg.initialize()); - TS_ASSERT(alg.isInitialized()); - - int numProjs, numBands; - TS_ASSERT_THROWS_NOTHING(numProjs = alg.getProperty("NumProjections")); - TS_ASSERT_THROWS_NOTHING(numBands = alg.getProperty("NumBands")); - TS_ASSERT_EQUALS(numProjs, 0); - TS_ASSERT_EQUALS(numBands, 0); - } - - void test_exec_fail() { - ImggAggregateWavelengths alg; - // Don't put output in ADS by default - alg.setChild(true); - TS_ASSERT_THROWS_NOTHING(alg.initialize()) - TS_ASSERT(alg.isInitialized()) - TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("InputPath", ".")); - TS_ASSERT_THROWS(alg.setPropertyValue("OutputPath", "inexistent_fail"), - std::invalid_argument); - - TS_ASSERT_THROWS(alg.execute(), std::runtime_error); - TS_ASSERT(!alg.isExecuted()); - } - - void test_errors_options() { - auto alg = Mantid::API::AlgorithmManager::Instance().create( - "ImggAggregateWavelengths"); - - TS_ASSERT_THROWS( - alg->setPropertyValue("OutputWorkspace", "_unused_for_child"), - Mantid::Kernel::Exception::NotFoundError); - - TS_ASSERT_THROWS(alg->setPropertyValue("UniformBands", "fail"), - std::invalid_argument); - } - - void test_too_many_options() { - auto alg = Mantid::API::AlgorithmManager::Instance().create( - "ImggAggregateWavelengths"); - - alg->setPropertyValue("IndexRanges", "1-10"); - alg->setPropertyValue("ToFRanges", "5000-7000"); - TS_ASSERT_THROWS(alg->execute(), std::runtime_error); - TS_ASSERT(!alg->isExecuted()); - - auto alg2nd = Mantid::API::AlgorithmManager::Instance().create( - "ImggAggregateWavelengths"); - alg2nd->setPropertyValue("ToFRanges", "5000-7000"); - alg2nd->setPropertyValue("IndexRanges", "1-10"); - TS_ASSERT_THROWS(alg2nd->execute(), std::runtime_error); - TS_ASSERT(!alg2nd->isExecuted()); - - auto alg3rd = Mantid::API::AlgorithmManager::Instance().create( - "ImggAggregateWavelengths"); - alg3rd->setPropertyValue("UniformBands", "3"); - alg3rd->setPropertyValue("IndexRanges", "1-10"); - TS_ASSERT_THROWS(alg3rd->execute(), std::runtime_error); - TS_ASSERT(!alg3rd->isExecuted()); - } - - void test_formats() { - auto alg = Mantid::API::AlgorithmManager::Instance().create( - "ImggAggregateWavelengths"); - - alg->setPropertyValue("InputImageFormat", "FITS"); - TS_ASSERT_THROWS(alg->setPropertyValue("InputImageFormat", "Bla"); - , std::invalid_argument); - TS_ASSERT_THROWS(alg->setPropertyValue("InputImageFormat", "TIFF"); - , std::invalid_argument); - - auto alg2nd = Mantid::API::AlgorithmManager::Instance().create( - "ImggAggregateWavelengths"); - alg2nd->setPropertyValue("OutputImageFormat", "FITS"); - TS_ASSERT_THROWS(alg2nd->setPropertyValue("OutputImageFormat", "Wrong"); - , std::invalid_argument); - TS_ASSERT_THROWS(alg2nd->setPropertyValue("OutputImageFormat", "TIFF"); - , std::invalid_argument); - } -}; - -#endif /* MANTID_DATAHANDLING_IMGGAGGREGATEWAVELENGTHSTEST_H_ */ \ No newline at end of file diff --git a/Framework/RemoteAlgorithms/CMakeLists.txt b/Framework/RemoteAlgorithms/CMakeLists.txt index 81ca926dd3ceefd3beea0a13a7b1015f011f58ce..64e6979fcef9884a60d7f7f00a40b31ad36b037a 100644 --- a/Framework/RemoteAlgorithms/CMakeLists.txt +++ b/Framework/RemoteAlgorithms/CMakeLists.txt @@ -12,7 +12,6 @@ set( SRC_FILES src/QueryRemoteFile2.cpp src/QueryRemoteJob.cpp src/QueryRemoteJob2.cpp - src/SCARFTomoReconstruction.cpp src/SimpleJSON.cpp src/StartRemoteTransaction.cpp src/StartRemoteTransaction2.cpp @@ -38,7 +37,6 @@ set( INC_FILES inc/MantidRemoteAlgorithms/QueryRemoteFile2.h inc/MantidRemoteAlgorithms/QueryRemoteJob.h inc/MantidRemoteAlgorithms/QueryRemoteJob2.h - inc/MantidRemoteAlgorithms/SCARFTomoReconstruction.h inc/MantidRemoteAlgorithms/SimpleJSON.h inc/MantidRemoteAlgorithms/StartRemoteTransaction.h inc/MantidRemoteAlgorithms/StartRemoteTransaction2.h @@ -64,7 +62,6 @@ set ( TEST_FILES QueryRemoteFile2Test.h QueryRemoteJobTest.h QueryRemoteJob2Test.h - SCARFTomoReconstructionTest.h SimpleJSONTest.h StartRemoteTransactionTest.h StartRemoteTransaction2Test.h diff --git a/Framework/RemoteAlgorithms/inc/MantidRemoteAlgorithms/SCARFTomoReconstruction.h b/Framework/RemoteAlgorithms/inc/MantidRemoteAlgorithms/SCARFTomoReconstruction.h deleted file mode 100644 index 80f2d6f9637962895f38e4149039cd3177cbb2be..0000000000000000000000000000000000000000 --- a/Framework/RemoteAlgorithms/inc/MantidRemoteAlgorithms/SCARFTomoReconstruction.h +++ /dev/null @@ -1,180 +0,0 @@ -#ifndef REMOTE_SCARFTOMORECONSTRUCTION_H_ -#define REMOTE_SCARFTOMORECONSTRUCTION_H_ - -#include "MantidAPI/Algorithm.h" - -namespace Mantid { -namespace RemoteAlgorithms { -/*** - Algorithm to initiate, query about, or cancel a tomographic - reconstruction job on the SCARF computer cluster at RAL. - The algorithm can be used to send different commands to the job - queue, for example: log in, log out, start a reconstruction job, - retrieve information about jobs or to cancel a job. - - If the authentication is successfull, a cookie is received that is - stored internally and re-used for all subsequent interactions with - the compute resource. - - Copyright © 2014-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 SCARFTomoReconstruction : public Mantid::API::Algorithm { -public: - /// Constructor - SCARFTomoReconstruction(); - /// Algorithm's name - const std::string name() const override { return "SCARFTomoReconstruction"; } - /// Summary of algorithms purpose - const std::string summary() const override { - return "Perform a control action on jobs running on the SCARF computer " - "cluster at RAL, STFC (http://www.scarf.rl.ac.uk/)"; - } - /// Algorithm's version - int version() const override { return (1); } - /// Algorithm's category for identification - const std::string category() const override { return "Remote"; } - -protected: - /// different methods (HTTP requests) to process reconstruction job commands - virtual void doLogin(const std::string &username, - const std::string &password); - virtual void doLogout(const std::string &username); - virtual bool doPing(); - virtual void doSubmit(const std::string &username); - virtual void doQueryStatus(const std::string &username); - virtual void doQueryStatusById(const std::string &username, - const std::string &jobId); - virtual void doCancel(const std::string &username, const std::string &jobId); - virtual void doUploadFile(const std::string &username, - const std::string &destDir, - const std::string &filename); - virtual void doDownload(const std::string &username, const std::string &jobId, - const std::string &fname, - const std::string &localDir); - - typedef std::map<std::string, std::string> StringToStringMap; - - /// method that deals with the actual HTTP(S) connection (convenient to - /// mock up all inet messaging) - virtual int doSendRequestGetResponse( - const std::string &url, std::ostream &rss, - const StringToStringMap &headers = StringToStringMap(), - const std::string &method = std::string(), const std::string &body = ""); - -private: - void init() override; - /// Execution code - void exec() override; - - // helper for the submit request - std::string buildSubmitBody(const std::string &appName, - const std::string &boundary, - const std::string &inputFile, - const std::string &inputArgs, - const std::string &jobName); - - /// lower level helper to encode parameters - void encodeParam(std::string &body, const std::string &boundary, - const std::string ¶mName, const std::string ¶mVal); - - /// build body as headers + file as an octet string - std::string buildUploadBody(const std::string &boundary, - const std::string &destDir, - const std::string &filename); - - /// fill in output properties with job status and info - void genOutputStatusInfo(const std::string &resp, - const std::string &jobIDFilter = std::string()); - - /// Job sequence number (from here, nothing to do with the job id on the - /// cluster) - int jobSeqNo(); - - // cookie obtained after logging in - struct Token { - Token(std::string &u, std::string &t) : m_url(u), m_token_str(t){}; - std::string m_url; - std::string m_token_str; - }; - typedef std::pair<std::string, SCARFTomoReconstruction::Token> UsernameToken; - - class Action { - public: - typedef enum { - LOGIN = 0, - LOGOUT, - SUBMIT, - QUERYSTATUS, - QUERYSTATUSBYID, - PING, - CANCEL, - UPLOAD, - DOWNLOAD, - UNDEF - } Type; - }; - - /// helper to filter the action given by the user - Action::Type getAction(); - - /// helper to fetch and save one file from the compute resource - void getOneJobFile(const std::string &jobId, const std::string &remotePath, - const std::string &localPath, const Token &t); - - /// helper to fetch and save all the files for a remote job - void getAllJobFiles(const std::string &jobId, const std::string &localDir, - const Token &t); - - /// check if output file is writeable, overwritten, etc. - const std::string checkDownloadOutputFile(const std::string &localPath, - const std::string &fname) const; - - /// get a normal file name from a 'PAC Server*...' name - const std::string filterPACFilename(const std::string PACName) const; - - /// extremely simple parser for error messages from LSF PAC - std::string extractPACErrMsg(const std::string &response) const; - - // options passed to the algorithm - Action::Type m_action; - - // when submitting jobs - std::string m_runnablePath; - std::string m_jobOptions; - - // resource name - static const std::string m_SCARFComputeResource; - - // HTTP specifics for SCARF (IBM LSF PAC) - static std::string m_acceptType; - - // store for username-token pairs - static std::map<std::string, Token> m_tokenStash; - - // just to generate a sequence number for jobs started using this alg. - static int m_jobSeq; -}; - -} // end namespace RemoteAlgorithms -} // end namespace Mantid -#endif /*REMOTE_SCARFTOMORECONSTRUCTION_H_*/ diff --git a/MantidQt/CustomInterfaces/CMakeLists.txt b/MantidQt/CustomInterfaces/CMakeLists.txt index a4ecfad17c060bbac6e848679d8bcdf9093b96eb..55ab9b42e8c8a2d12463ba26e4d05c78d77409a8 100644 --- a/MantidQt/CustomInterfaces/CMakeLists.txt +++ b/MantidQt/CustomInterfaces/CMakeLists.txt @@ -457,18 +457,6 @@ set ( UI_FILES inc/MantidQtCustomInterfaces/DataComparison.ui inc/MantidQtCustomInterfaces/SANSRunWindow.ui inc/MantidQtCustomInterfaces/SANSEventSlicing.ui inc/MantidQtCustomInterfaces/StepScan.ui - inc/MantidQtCustomInterfaces/Tomography/ImageSelectCoRAndRegions.ui - inc/MantidQtCustomInterfaces/Tomography/ImggFormatsConvert.ui - inc/MantidQtCustomInterfaces/Tomography/TomographyIfaceQtGUI.ui - inc/MantidQtCustomInterfaces/Tomography/TomographyIfaceQtTabEnergy.ui - inc/MantidQtCustomInterfaces/Tomography/TomographyIfaceQtTabFiltersSettings.ui - inc/MantidQtCustomInterfaces/Tomography/TomographyIfaceQtTabRun.ui - inc/MantidQtCustomInterfaces/Tomography/TomographyIfaceQtTabVisualize.ui - inc/MantidQtCustomInterfaces/Tomography/TomographyIfaceQtTabSystemSettings.ui - inc/MantidQtCustomInterfaces/Tomography/TomoToolConfigAstra.ui - inc/MantidQtCustomInterfaces/Tomography/TomoToolConfigCustom.ui - inc/MantidQtCustomInterfaces/Tomography/TomoToolConfigSavu.ui - inc/MantidQtCustomInterfaces/Tomography/TomoToolConfigTomoPy.ui ) set ( TEST_FILES @@ -481,8 +469,6 @@ set ( TEST_FILES EnggDiffFittingPresenterTest.h EnggDiffractionPresenterTest.h IO_MuonGroupingTest.h - TomographyROIPresenterTest.h - ImggFormatsConvertPresenterTest.h MDFLogValueFinderTest.h MeasurementItemTest.h MuonAnalysisDataLoaderTest.h @@ -501,9 +487,6 @@ set ( TEST_FILES ReflSaveTabPresenterTest.h ReflSettingsPresenterTest.h ReflSettingsTabPresenterTest.h - StackOfImagesDirsTest.h - TomographyIfaceModelTest.h - TomographyIfacePresenterTest.h UserInputValidatorTest.h ) diff --git a/Testing/SystemTests/tests/analysis/ImagingAggregateWavelengths.py b/Testing/SystemTests/tests/analysis/ImagingAggregateWavelengths.py deleted file mode 100644 index 203c9baf428500496ff5165df7e71f572add7ab8..0000000000000000000000000000000000000000 --- a/Testing/SystemTests/tests/analysis/ImagingAggregateWavelengths.py +++ /dev/null @@ -1,134 +0,0 @@ -import os -import unittest -import stresstesting - -import mantid.simpleapi as msapi -from mantid import config - -#pylint: disable=too-many-public-methods - - -class ImagingAggregateTests(unittest.TestCase): - """ - Tests aggregation of wavelengths/energy bands, which at the moment - is done by the algorithm msapi.ImggAggregateWavelengths. - """ - - def setUp(self): - # example files to make a stack of images - data_root = config['datasearch.directories'].split(';')[0] - self._raw_files_dir = os.path.join(data_root, 'wavelength_dependent_images') - self._raw_files_subdirs = [ 'wavelength_dependent_images/angle0/', - 'wavelength_dependent_images/angle1/', - 'wavelength_dependent_images/angle2/', - 'wavelength_dependent_images/angle5/'] - - self._out_dir = os.path.join(os.getcwd(), 'summed_wavelengths_metals') - - self._expected_out_dir = 'bands_uniform_idx_0_to_6' - self._expected_out_fnames = [ - 'sum_projection_00000_bands_idx_0_to_6.fits', - 'sum_projection_00001_bands_idx_0_to_3.fits', - 'sum_projection_00002_bands_idx_0_to_2.fits', - 'sum_projection_00003_bands_idx_0_to_1.fits' - ] - self._expected_out_fnames = [os.path.join(self._expected_out_dir, exp) - for exp in self._expected_out_fnames] - - def tearDown(self): - pass - - def _cleanup_dirs_files(self): - # All these should be there at the end of the test - for fname in self._expected_out_fnames: - fpath = os.path.join(self._out_dir, fname) - os.remove(fpath) - os.rmdir(os.path.join(self._out_dir, self._expected_out_dir)) - os.rmdir(self._out_dir) - - def test_input_output_path_errors(self): - self.assertRaises(ValueError, - msapi.ImggAggregateWavelengths, - InputPath = self._raw_files_dir + '_should_fail', - OutputPath = self._out_dir) - - def test_run_ok(self): - if not os.path.exists(self._out_dir): - os.mkdir(self._out_dir) - - num_proj, num_bands = msapi.ImggAggregateWavelengths(InputPath = self._raw_files_dir, - OutputPath = self._out_dir) - - self.assertEquals(num_proj, 4) - self.assertEquals(num_bands, 6) - - # (x,y) coordinates of some pixels - ref_positions = [(44, 77), (312, 265), (480, 397), (118, 109), - (0, 0), (511, 0), (0, 511), (511, 511)] - # Their expected values in every of the output images - ref_values = [[0, 1, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], - [2, 1, 2, 3, 6, 5, 2, 3], [5, 3, 4, 7, 4, 1, 5, 5]] - for ref_val in ref_values: - self.assertEquals(len(ref_positions), len(ref_val)) - for image_idx, fname in enumerate(self._expected_out_fnames): - fname = os.path.join(self._out_dir, fname) - group_name = 'loaded_fits' - group = msapi.LoadFITS(Filename=fname, LoadAsRectImg=True, OutputWorkspace=group_name) - - self.assertEquals(image_idx+1, group.size()) - wks = group.getItem(group.size()-1) - - self.assertEquals(wks.getNumberHistograms(), 512) - self.assertEquals(wks.blocksize(), 512) - - for pos_idx, pos in enumerate(ref_positions): - self.assertEquals(wks.readY(pos[1])[pos[0]], ref_values[image_idx][pos_idx]) - - msapi.DeleteWorkspace(group_name) - - self._cleanup_dirs_files() - -# Runs the unittest tests defined above in the mantid stress testing framework - - -class ImagingAggregateWavelengths(stresstesting.MantidStressTest): - - _success = False - - def __init__(self, *args, **kwargs): - # super(ImagingAggregateWavelengths, self).__init__(*args, **kwargs) - # old-style - stresstesting.MantidStressTest.__init__(self, *args, **kwargs) - self._success = False - - self._raw_in_files = [ 'wavelength_dependent_images/angle0/foo.txt', - 'wavelength_dependent_images/angle0/LARMOR00005471_Metals_000_00000.fits', - 'wavelength_dependent_images/angle0/LARMOR00005471_Metals_000_00001.fits', - 'wavelength_dependent_images/angle0/LARMOR00005471_Metals_000_00002.fits', - 'wavelength_dependent_images/angle0/LARMOR00005471_Metals_000_00003.fits', - 'wavelength_dependent_images/angle0/LARMOR00005471_Metals_000_00004.fits', - 'wavelength_dependent_images/angle0/LARMOR00005471_Metals_000_00005.fits', - 'wavelength_dependent_images/angle1/LARMOR00005329_Metals_000_00000.fits', - 'wavelength_dependent_images/angle1/LARMOR00005329_Metals_000_00001.fits', - 'wavelength_dependent_images/angle1/LARMOR00005329_Metals_000_00002.fits', - 'wavelength_dependent_images/angle2/LARMOR00005330_Metals_000_01343.fits', - 'wavelength_dependent_images/angle2/LARMOR00005330_Metals_000_01344.fits', - 'wavelength_dependent_images/angle5/LARMOR00005333_Metals_000_00690.fits', - 'wavelength_dependent_images/angle5/bogus.txt', - 'wavelength_dependent_images/angle5/more_bogus'] - - def requiredFiles(self): - return set(self._raw_in_files) - - def runTest(self): - self._success = False - # Custom code to create and run this single test suite - suite = unittest.TestSuite() - suite.addTest(unittest.makeSuite(ImagingAggregateTests, "test") ) - runner = unittest.TextTestRunner() - # Run using either runner - res = runner.run(suite) - self._success = res.wasSuccessful() - - def validate(self): - return self._success diff --git a/Testing/SystemTests/tests/analysis/ImagingLoadSave.py b/Testing/SystemTests/tests/analysis/ImagingLoadSave.py deleted file mode 100644 index fb4085361d1fe2714f4e7528f0b420d6dad4eac4..0000000000000000000000000000000000000000 --- a/Testing/SystemTests/tests/analysis/ImagingLoadSave.py +++ /dev/null @@ -1,146 +0,0 @@ -import os -import unittest -import stresstesting - -import mantid.simpleapi as msapi -from mantid import config - - -def required_larmor_test_files(): - data_root = config['datasearch.directories'].split(';')[0] - fits_files_dir = os.path.join(data_root, 'wavelength_dependent_images') - - # subdir and filename components - fits_files_comps = [ - ('angle0', 'LARMOR00005471_Metals_000_00000.fits'), - ('angle0', 'LARMOR00005471_Metals_000_00001.fits'), - ('angle0', 'LARMOR00005471_Metals_000_00002.fits'), - ('angle0', 'LARMOR00005471_Metals_000_00003.fits'), - ('angle0', 'LARMOR00005471_Metals_000_00004.fits'), - ('angle0', 'LARMOR00005471_Metals_000_00005.fits'), - ('angle1', 'LARMOR00005329_Metals_000_00000.fits'), - ('angle1', 'LARMOR00005329_Metals_000_00001.fits'), - ('angle1', 'LARMOR00005329_Metals_000_00002.fits'), - ('angle2', 'LARMOR00005330_Metals_000_01343.fits'), - ('angle2', 'LARMOR00005330_Metals_000_01344.fits'), - ('angle5', 'LARMOR00005333_Metals_000_00690.fits') - ] - - file_paths = [os.path.join(fits_files_dir, comps[0], comps[1]) - for comps in fits_files_comps] - - return file_paths - -#pylint: disable=too-many-public-methods - - -class ImagingLoadSaveTests(unittest.TestCase): - """ - Tests load/save images. This is just around FITS format at the - moment. There should be tests on other formats and conversions - when we have the algorithms Load/SaveImage. - """ - - def setUp(self): - # Sharing some files with the ImggAggregateWavelengths system test - self._fits_paths = required_larmor_test_files() - - def test_load_all_indiv(self): - """ - Load a few files with different options and check they load correctly - """ - - group_name = 'all_fits_rect' - for fpath in self._fits_paths: - group = msapi.LoadFITS(Filename=fpath, LoadAsRectImg=True, OutputWorkspace=group_name) - - group_norect_name = 'all_fits_norect' - for fpath in self._fits_paths: - group_norect = msapi.LoadFITS(Filename=fpath, LoadAsRectImg=False, OutputWorkspace=group_norect_name) - - self.assertEquals(group.size(), group_norect.size()) - for idx in range(0, group.size()): - img_a = group.getItem(idx) - size_a = img_a.getNumberHistograms() * img_a.blocksize() - img_b = group_norect.getItem(idx) - size_b = img_b.getNumberHistograms() * img_b.blocksize() - self.assertEquals(size_a, size_b) - self.assertEquals(img_a.getTitle(), img_b.getTitle()) - - for row in [0, 100, 200, 300, 400, 511]: - self.assertEquals(img_a.readY(row)[0], img_b.readY(row*img_a.blocksize() + 0)) - - msapi.DeleteWorkspace(group_name) - msapi.DeleteWorkspace(group_norect_name) - - def test_load_all_at_once(self): - """ - A batch load, as when stacks are loaded at once - """ - all_filepaths = ','.join(self._fits_paths) - group = msapi.LoadFITS(Filename=all_filepaths, LoadAsRectImg=True) - - self.assertEquals(group.size(), len(self._fits_paths)) - - msapi.DeleteWorkspace(group) - - def test_load_save_load(self): - """ - Check that nothing is lost in a Load/Save/Load cycle - """ - group_name = 'all_indiv' - for fpath in self._fits_paths: - msapi.LoadFITS(Filename=fpath, LoadAsRectImg=True, OutputWorkspace=group_name) - group = msapi.mtd[group_name] - - for idx in range(0, group.size()): - # Save - img_loaded = group.getItem(idx) - save_filename = 'test.fits' - msapi.SaveFITS(Filename=save_filename, InputWorkspace=img_loaded) - - # Re-load and compare - reload_name = 'indiv_fits_reloaded' - grp_reloaded = msapi.LoadFITS(Filename=save_filename, LoadAsRectImg=True, OutputWorkspace=reload_name) - self.assertEquals(1, grp_reloaded.size()) - img_reloaded = grp_reloaded.getItem(0) - - self.assertEquals(img_loaded.getNumberHistograms(), img_reloaded.getNumberHistograms()) - self.assertEquals(img_loaded.blocksize(), img_reloaded.blocksize()) - - (comp_result, tbl_messages) = msapi.CompareWorkspaces(img_loaded, img_reloaded) - num_rows = tbl_messages.rowCount() - txt_messages = [tbl_messages.row(idx) for idx in range(0, num_rows)] - self.assertTrue(comp_result, - "Workspace comparison failed. Details: {0}".format(txt_messages)) - msapi.DeleteWorkspace(grp_reloaded) - - msapi.DeleteWorkspace(group_name) - -# Runs the unittest tests defined above in the mantid stress testing framework - - -class ImagingAggregateWavelengths(stresstesting.MantidStressTest): - - _success = False - - def __init__(self, *args, **kwargs): - # super(ImagingAggregateWavelengths, self).__init__(*args, **kwargs) - # old-style - stresstesting.MantidStressTest.__init__(self, *args, **kwargs) - self._success = False - - def requiredFiles(self): - return set(required_larmor_test_files()) - - def runTest(self): - self._success = False - # Custom code to create and run this single test suite - suite = unittest.TestSuite() - suite.addTest(unittest.makeSuite(ImagingLoadSaveTests, "test") ) - runner = unittest.TextTestRunner() - res = runner.run(suite) - self._success = res.wasSuccessful() - - def validate(self): - return self._success