| @@ -0,0 +1,109 @@ | ||
| #include "MantidAlgorithms/MaskBinsFromTable.h" | ||
| #include "MantidKernel/System.h" | ||
| #include "MantidAPI/WorkspaceProperty.h" | ||
| #include "MantidAPI/WorkspaceValidators.h" | ||
| #include "MantidAPI/MatrixWorkspace.h" | ||
| #include "MantidAPI/TableRow.h" | ||
|
|
||
| using namespace Mantid::Kernel; | ||
| using namespace Mantid::API; | ||
|
|
||
| namespace Mantid | ||
| { | ||
| namespace Algorithms | ||
| { | ||
|
|
||
|
|
||
| //---------------------------------------------------------------------------------------------- | ||
| /** Constructor | ||
| */ | ||
| MaskBinsFromTable::MaskBinsFromTable() | ||
| { | ||
| } | ||
|
|
||
| //---------------------------------------------------------------------------------------------- | ||
| /** Destructor | ||
| */ | ||
| MaskBinsFromTable::~MaskBinsFromTable() | ||
| { | ||
| } | ||
|
|
||
| void MaskBinsFromTable::initDocs() | ||
| { | ||
| this->setWikiSummary("Mask bins from a table workspace. "); | ||
| this->setOptionalMessage("Mask bins from a table workspace. "); | ||
| } | ||
|
|
||
| void MaskBinsFromTable::init() | ||
| { | ||
| this->declareProperty(new WorkspaceProperty<>("InputWorkspace","",Direction::Input, boost::make_shared<HistogramValidator>()), | ||
| "Input Workspace to mask bins. "); | ||
| this->declareProperty(new WorkspaceProperty<>("OutputWorkspace","",Direction::Output), | ||
| "Output Workspace with bins masked."); | ||
| this->declareProperty(new WorkspaceProperty<DataObjects::TableWorkspace>("MaskingInformation", "", Direction::Input), | ||
| "Input TableWorkspace containing parameters, SpectraList, XMin and XMax."); | ||
|
|
||
| return; | ||
| } | ||
|
|
||
| void MaskBinsFromTable::exec() | ||
| { | ||
| MatrixWorkspace_const_sptr inputWS = getProperty("InputWorkspace"); | ||
| DataObjects::TableWorkspace_sptr paramWS = getProperty("MaskingInformation"); | ||
|
|
||
| // 1. Check input table workspace | ||
| g_log.debug() << "Lines of parameters workspace = " << paramWS->rowCount() << std::endl; | ||
|
|
||
| // 2. Loop over all rows | ||
| bool firstloop = true; | ||
| API::MatrixWorkspace_sptr outputws; | ||
|
|
||
| for (size_t ib = 0; ib < paramWS->rowCount(); ++ib) | ||
| { | ||
| API::TableRow therow = paramWS->getRow(ib); | ||
| double xmin, xmax; | ||
| std::string speclist; | ||
| therow >> xmin >> xmax >> speclist; | ||
|
|
||
| g_log.debug() << "Row " << ib << " XMin = " << xmin << " XMax = " << xmax << " SpectraList = " << speclist << std::endl; | ||
|
|
||
| API::IAlgorithm_sptr maskbins = this->createSubAlgorithm("MaskBins", 0, 0.3, true); | ||
| maskbins->initialize(); | ||
| if (firstloop) | ||
| { | ||
| maskbins->setPropertyValue("InputWorkspace", this->getPropertyValue("InputWorkspace")); | ||
| firstloop = false; | ||
| } | ||
| else | ||
| { | ||
| maskbins->setProperty("InputWorkspace", outputws); | ||
| } | ||
| maskbins->setProperty("OutputWorkspace", this->getPropertyValue("OutputWorkspace")); | ||
| maskbins->setPropertyValue("SpectraList", speclist); | ||
| maskbins->setProperty("XMin", xmin); | ||
| maskbins->setProperty("XMax", xmax); | ||
|
|
||
| bool isexec = maskbins->execute(); | ||
| if (!isexec) | ||
| { | ||
| g_log.error() << "MaskBins() is not executed for row " << ib << std::endl; | ||
| throw std::runtime_error("MaskBins() is not executed"); | ||
| } | ||
|
|
||
| outputws = maskbins->getProperty("OutputWorkspace"); | ||
| if (!outputws) | ||
| { | ||
| g_log.error() << "OutputWorkspace is not retrieved for row " << ib << ". " << std::endl; | ||
| throw std::runtime_error("OutputWorkspace is not got from MaskBins"); | ||
| } | ||
| } | ||
|
|
||
| setProperty("OutputWorkspace", outputws); | ||
|
|
||
| return; | ||
| } | ||
|
|
||
|
|
||
|
|
||
| } // namespace Mantid | ||
| } // namespace Algorithms |
| @@ -0,0 +1,227 @@ | ||
| #ifndef MANTID_ALGORITHMS_MASKDETECTORBINSTEST_H_ | ||
| #define MANTID_ALGORITHMS_MASKDETECTORBINSTEST_H_ | ||
|
|
||
| #include <cxxtest/TestSuite.h> | ||
| #include "MantidKernel/Timer.h" | ||
| #include "MantidKernel/System.h" | ||
| #include <iostream> | ||
| #include <iomanip> | ||
|
|
||
| #include "MantidTestHelpers/WorkspaceCreationHelper.h" | ||
| #include "MantidAlgorithms/MaskBinsFromTable.h" | ||
| #include "MantidAPI/TableRow.h" | ||
|
|
||
| using namespace Mantid; | ||
| using namespace Mantid::Algorithms; | ||
| using namespace Mantid::API; | ||
|
|
||
| class MaskBinsFromTableTest : 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 MaskBinsFromTableTest *createSuite() { return new MaskBinsFromTableTest(); } | ||
| static void destroySuite( MaskBinsFromTableTest *suite ) { delete suite; } | ||
|
|
||
| /* | ||
| * In-place single mask test. | ||
| * Same as the test in MaskBins() | ||
| */ | ||
| void test_MaskBinWithSingleLine() | ||
| { | ||
| // 1. Create a dummy workspace | ||
| const std::string workspaceName("raggedMask"); | ||
| int nBins = 10; | ||
| MatrixWorkspace_sptr WS = WorkspaceCreationHelper::Create2DWorkspaceBinned(5, nBins, 0.0); | ||
| AnalysisDataService::Instance().add(workspaceName,WS); | ||
|
|
||
| // 2. Generate a TableWorskpace | ||
| DataObjects::TableWorkspace_sptr tablews = boost::shared_ptr<DataObjects::TableWorkspace>(new DataObjects::TableWorkspace()); | ||
| tablews->addColumn("double", "XMin"); | ||
| tablews->addColumn("double", "XMax"); | ||
| tablews->addColumn("str", "SpectraList"); | ||
|
|
||
| API::TableRow row0 = tablews->appendRow(); | ||
| row0 << 3.0 << 6.0 << "1-3"; | ||
|
|
||
| // 3. Execute | ||
| MaskBinsFromTable maskalg; | ||
| TS_ASSERT_THROWS_NOTHING(maskalg.initialize()); | ||
| maskalg.setPropertyValue("InputWorkspace", workspaceName); | ||
| maskalg.setPropertyValue("OutputWorkspace",workspaceName); | ||
| maskalg.setProperty("MaskingInformation", tablews); | ||
| TS_ASSERT_THROWS_NOTHING(maskalg.execute()); | ||
| TS_ASSERT(maskalg.isExecuted()); | ||
|
|
||
| // 4. Check | ||
| WS = boost::dynamic_pointer_cast<API::MatrixWorkspace>(AnalysisDataService::Instance().retrieve(workspaceName)); | ||
| TS_ASSERT(WS); | ||
| for (int wi=1; wi<=3; wi++) | ||
| { | ||
| for (int bin=3; bin<6;bin++) | ||
| { | ||
| TS_ASSERT_EQUALS( WS->dataY(wi)[bin], 0.0 ); | ||
| } | ||
| } | ||
|
|
||
| // 5. Clean | ||
| AnalysisDataService::Instance().remove(workspaceName); | ||
|
|
||
| return; | ||
| } | ||
|
|
||
| /* | ||
| * Out-of-place single mask test. | ||
| * Same as the test in MaskBins() | ||
| */ | ||
| void test_MaskBinWithSingleLineOutPlace() | ||
| { | ||
| // 1. Create a dummy workspace | ||
| const std::string workspaceName("raggedMask"); | ||
| const std::string opWSName("maskedWorkspace"); | ||
| int nBins = 10; | ||
| MatrixWorkspace_sptr WS = WorkspaceCreationHelper::Create2DWorkspaceBinned(5, nBins, 0.0); | ||
| AnalysisDataService::Instance().add(workspaceName,WS); | ||
|
|
||
| // 2. Generate a TableWorskpace | ||
| DataObjects::TableWorkspace_sptr tablews = boost::shared_ptr<DataObjects::TableWorkspace>(new DataObjects::TableWorkspace()); | ||
| tablews->addColumn("double", "XMin"); | ||
| tablews->addColumn("double", "XMax"); | ||
| tablews->addColumn("str", "SpectraList"); | ||
|
|
||
| API::TableRow row0 = tablews->appendRow(); | ||
| row0 << 3.0 << 6.0 << "1-3"; | ||
|
|
||
| // 3. Execute | ||
| MaskBinsFromTable maskalg; | ||
| TS_ASSERT_THROWS_NOTHING(maskalg.initialize()); | ||
| maskalg.setPropertyValue("InputWorkspace", workspaceName); | ||
| maskalg.setPropertyValue("OutputWorkspace",opWSName); | ||
| maskalg.setProperty("MaskingInformation", tablews); | ||
| TS_ASSERT_THROWS_NOTHING(maskalg.execute()); | ||
| TS_ASSERT(maskalg.isExecuted()); | ||
|
|
||
| // 4. Check | ||
| MatrixWorkspace_sptr outWS = | ||
| boost::dynamic_pointer_cast<API::MatrixWorkspace>(AnalysisDataService::Instance().retrieve(opWSName)); | ||
| TS_ASSERT(outWS); | ||
| for (int wi=1; wi<=3; wi++) | ||
| { | ||
| for (int bin=3; bin<6;bin++) | ||
| { | ||
| TS_ASSERT_EQUALS( outWS->dataY(wi)[bin], 0.0 ); | ||
| } | ||
| } | ||
|
|
||
| // 5. Clean | ||
| AnalysisDataService::Instance().remove(workspaceName); | ||
| AnalysisDataService::Instance().remove(opWSName); | ||
|
|
||
| return; | ||
| } | ||
|
|
||
|
|
||
| /* | ||
| * Multiple lines out-of-place test. | ||
| * This is a real test | ||
| */ | ||
| void test_MaskBinWithMultiLines() | ||
| { | ||
| // 1. Create a dummy workspace | ||
| const std::string workspaceName("raggedMask"); | ||
| int nBins = 10; | ||
| int nHist = 12; | ||
| MatrixWorkspace_sptr WS = WorkspaceCreationHelper::Create2DWorkspaceBinned(nHist, nBins, 0.0); | ||
| AnalysisDataService::Instance().add(workspaceName,WS); | ||
|
|
||
| // 2. Generate a TableWorskpace | ||
| DataObjects::TableWorkspace_sptr tablews = boost::shared_ptr<DataObjects::TableWorkspace>(new DataObjects::TableWorkspace()); | ||
| tablews->addColumn("double", "XMin"); | ||
| tablews->addColumn("double", "XMax"); | ||
| tablews->addColumn("str", "SpectraList"); | ||
|
|
||
| API::TableRow row0 = tablews->appendRow(); | ||
| row0 << 3.0 << 6.0 << "1-3"; | ||
| API::TableRow row1 = tablews->appendRow(); | ||
| row1 << 4.0 << 7.0 << "5, 6-8"; | ||
| API::TableRow row2 = tablews->appendRow(); | ||
| row2 << 0.0 << 1.0 << "9"; | ||
|
|
||
| // 3. Execute | ||
| MaskBinsFromTable maskalg; | ||
| TS_ASSERT_THROWS_NOTHING(maskalg.initialize()); | ||
| maskalg.setPropertyValue("InputWorkspace", workspaceName); | ||
| maskalg.setPropertyValue("OutputWorkspace",workspaceName); | ||
| maskalg.setProperty("MaskingInformation", tablews); | ||
| TS_ASSERT_THROWS_NOTHING(maskalg.execute()); | ||
| TS_ASSERT(maskalg.isExecuted()); | ||
|
|
||
| // 4. Check | ||
| WS = boost::dynamic_pointer_cast<API::MatrixWorkspace>(AnalysisDataService::Instance().retrieve(workspaceName)); | ||
| TS_ASSERT(WS); | ||
|
|
||
| // a) Table Line 0 | ||
| for (int wi=1; wi<=3; wi++) | ||
| { | ||
| for (size_t bin = 0; bin < WS->dataY(wi).size(); ++bin) | ||
| { | ||
| if (bin >= 3 && bin < 6) | ||
| { | ||
| TS_ASSERT_EQUALS( WS->dataY(wi)[bin], 0.0 ); | ||
| } | ||
| else | ||
| { | ||
| TS_ASSERT_EQUALS( WS->dataY(wi)[bin], 2.0 ); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // b) Table Line 1 | ||
| std::vector<int> speclist; | ||
| speclist.push_back(5); | ||
| speclist.push_back(6); | ||
| speclist.push_back(7); | ||
| speclist.push_back(8); | ||
| for (size_t iws = 0; iws < speclist.size(); ++iws) | ||
| { | ||
| const MantidVec& yvec = WS->readY(speclist[iws]); | ||
| for (size_t bin = 0; bin < yvec.size(); ++bin) | ||
| { | ||
| if (bin >= 4 && bin < 7) | ||
| { | ||
| TS_ASSERT_EQUALS(yvec[bin], 0.0); | ||
| } | ||
| else | ||
| { | ||
| TS_ASSERT_EQUALS(yvec[bin], 2.0); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // c) Table Line 2 | ||
| for (size_t iws = 9; iws < 10; ++iws) | ||
| { | ||
| const MantidVec& yvec = WS->readY(iws); | ||
| for (size_t bin = 0; bin < yvec.size(); ++bin) | ||
| { | ||
| if (bin == 0) | ||
| { | ||
| TS_ASSERT_EQUALS(yvec[bin], 0.0); | ||
| } | ||
| else | ||
| { | ||
| TS_ASSERT_EQUALS(yvec[bin], 2.0); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // 5. Clean | ||
| AnalysisDataService::Instance().remove(workspaceName); | ||
|
|
||
| return; | ||
| } | ||
|
|
||
| }; | ||
|
|
||
|
|
||
| #endif /* MANTID_ALGORITHMS_MASKDETECTORBINSTEST_H_ */ |
| @@ -0,0 +1,85 @@ | ||
| #ifndef MANTID_MDEVENTS_REFLECTOMETRYTRANSFORMKIKF_H_ | ||
| #define MANTID_MDEVENTS_REFLECTOMETRYTRANSFORMKIKF_H_ | ||
|
|
||
| #include "MantidKernel/System.h" | ||
| #include "MantidKernel/ClassMacros.h" | ||
| #include "MantidAPI/MatrixWorkspace.h" | ||
| #include "MantidAPI/IMDEventWorkspace.h" | ||
| #include "MantidMDEvents/ReflectometryMDTransform.h" | ||
|
|
||
| namespace Mantid | ||
| { | ||
| namespace MDEvents | ||
| { | ||
| /** | ||
| class CalculateReflectometryK: Calculation type for converting to ki or kf given a theta value (in degrees) and a wavelength | ||
| */ | ||
| class CalculateReflectometryK | ||
| { | ||
| private: | ||
| double to_radians_factor; | ||
| double two_pi; | ||
| double m_theta; | ||
| public: | ||
| CalculateReflectometryK(double theta) : to_radians_factor(3.14159265/180), two_pi(6.28318531), m_theta(theta) {} | ||
| ~CalculateReflectometryK(){}; | ||
| double execute(const double& wavelength) | ||
| { | ||
| double wavenumber = two_pi/wavelength; | ||
| return wavenumber * sin(to_radians_factor*m_theta); | ||
| } | ||
| }; | ||
|
|
||
| /** ReflectometryTransformKiKf : Type to transform from R vs Wavelength workspace to a 2D MDEW with dimensions of Ki and Kf. | ||
| @date 2012-06-06 | ||
| Copyright © 2012 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://svn.mantidproject.org/mantid/trunk/Code/Mantid> | ||
| Code Documentation is available at: <http://doxygen.mantidproject.org> | ||
| */ | ||
| class DLLExport ReflectometryTransformKiKf : public ReflectometryMDTransform | ||
| { | ||
| private: | ||
| const double m_kiMin; | ||
| const double m_kiMax; | ||
| const double m_kfMin; | ||
| const double m_kfMax; | ||
| /// Object performing raw caclcation to determine Ki | ||
| mutable CalculateReflectometryK m_KiCalculation; | ||
|
|
||
| public: | ||
| ReflectometryTransformKiKf(double kiMin, double kiMax, double kfMin, double kfMax, double incidentTheta); | ||
| virtual ~ReflectometryTransformKiKf(); | ||
|
|
||
| /// Execute transformation | ||
| virtual Mantid::API::IMDEventWorkspace_sptr execute(Mantid::API::MatrixWorkspace_const_sptr inputWs) const; | ||
|
|
||
| private: | ||
|
|
||
| DISABLE_DEFAULT_CONSTRUCT(ReflectometryTransformKiKf) | ||
| DISABLE_COPY_AND_ASSIGN(ReflectometryTransformKiKf) | ||
|
|
||
| }; | ||
|
|
||
|
|
||
| } // namespace MDEvents | ||
| } // namespace Mantid | ||
|
|
||
| #endif /* MANTID_MDEVENTS_REFLECTOMETRYTRANSFORMKIKF_H_ */ |
| @@ -0,0 +1,118 @@ | ||
| #ifndef MANTID_MDEVENTS_REFLECTOMETRYTRANSFORMP_H_ | ||
| #define MANTID_MDEVENTS_REFLECTOMETRYTRANSFORMP_H_ | ||
|
|
||
| #include "MantidKernel/System.h" | ||
| #include "MantidMDEvents/ReflectometryMDTransform.h" | ||
|
|
||
| namespace Mantid | ||
| { | ||
| namespace MDEvents | ||
| { | ||
|
|
||
| /** | ||
| class CalculateReflectometryPBase: Base class for p-type transforms. | ||
| */ | ||
| class CalculateReflectometryPBase | ||
| { | ||
| protected: | ||
| const double to_radians_factor; | ||
| const double two_pi; | ||
| double m_sinThetaInitial; | ||
| double m_sinThetaFinal; | ||
|
|
||
| CalculateReflectometryPBase(const double& thetaIncident) : to_radians_factor(3.14159265/180), two_pi(6.28318531) | ||
| { | ||
| m_sinThetaInitial = sin(to_radians_factor*thetaIncident); | ||
| } | ||
| ~CalculateReflectometryPBase(){} | ||
| public: | ||
| void setThetaFinal(const double& thetaFinal) | ||
| { | ||
| m_sinThetaFinal = sin(to_radians_factor*thetaFinal); | ||
| } | ||
| }; | ||
|
|
||
| /** | ||
| class CalculateReflectometryDiffP: Calculates difference between ki and kf. | ||
| */ | ||
| class CalculateReflectometryDiffP : public CalculateReflectometryPBase | ||
| { | ||
| public: | ||
| CalculateReflectometryDiffP(const double& thetaInitial) : CalculateReflectometryPBase(thetaInitial){} | ||
| ~CalculateReflectometryDiffP(){}; | ||
| double execute(const double& wavelength) | ||
| { | ||
| double wavenumber = two_pi/wavelength; | ||
| double ki = wavenumber * m_sinThetaInitial; | ||
| double kf = wavenumber * m_sinThetaFinal; | ||
| return ki - kf; | ||
| } | ||
| }; | ||
|
|
||
| /** | ||
| class CalculateReflectometrySumP: Calculates sum of ki and kf. | ||
| */ | ||
| class CalculateReflectometrySumP : public CalculateReflectometryPBase | ||
| { | ||
| public: | ||
| CalculateReflectometrySumP(const double& thetaInitial) : CalculateReflectometryPBase(thetaInitial){} | ||
| ~CalculateReflectometrySumP(){}; | ||
| double execute(const double& wavelength) | ||
| { | ||
| double wavenumber = two_pi/wavelength; | ||
| double ki = wavenumber * m_sinThetaInitial; | ||
| double kf = wavenumber * m_sinThetaFinal; | ||
| return ki + kf; | ||
| } | ||
| }; | ||
|
|
||
|
|
||
|
|
||
| /** ReflectometryTransformP : TODO: DESCRIPTION | ||
| @date 2012-06-06 | ||
| Copyright © 2012 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://svn.mantidproject.org/mantid/trunk/Code/Mantid> | ||
| Code Documentation is available at: <http://doxygen.mantidproject.org> | ||
| */ | ||
| class DLLExport ReflectometryTransformP : public ReflectometryMDTransform | ||
| { | ||
| private: | ||
| const double m_kiMin; | ||
| const double m_kiMax; | ||
| const double m_kfMin; | ||
| const double m_kfMax; | ||
| /// Object performing raw calculation to determine pzi + pzf | ||
| mutable CalculateReflectometrySumP m_pSumCalculation; | ||
| /// Object performing raw calculation to determine pzi - pzf | ||
| mutable CalculateReflectometryDiffP m_pDiffCalculation; | ||
|
|
||
| public: | ||
| ReflectometryTransformP(double kiMin, double kiMax, double kfMin, double kfMax, double incidentTheta); | ||
| virtual ~ReflectometryTransformP(); | ||
| virtual Mantid::API::IMDEventWorkspace_sptr execute(Mantid::API::MatrixWorkspace_const_sptr inputWs) const; | ||
|
|
||
| }; | ||
|
|
||
|
|
||
| } // namespace MDEvents | ||
| } // namespace Mantid | ||
|
|
||
| #endif /* MANTID_MDEVENTS_REFLECTOMETRYTRANSFORMP_H_ */ |
| @@ -0,0 +1,101 @@ | ||
| #include "MantidMDEvents/ReflectometryTransformKiKf.h" | ||
| #include "MantidMDEvents/MDEventWorkspace.h" | ||
| #include "MantidGeometry/MDGeometry/MDHistoDimension.h" | ||
| #include <stdexcept> | ||
|
|
||
| using namespace Mantid::Kernel; | ||
| using namespace Mantid::Geometry; | ||
| using namespace Mantid::API; | ||
|
|
||
| namespace Mantid | ||
| { | ||
| namespace MDEvents | ||
| { | ||
|
|
||
| /* | ||
| Constructor | ||
| @param kiMin: min ki value (extent) | ||
| @param kiMax: max ki value (extent) | ||
| @param kfMin: min kf value (extent) | ||
| @param kfMax; max kf value (extent) | ||
| @param incidentTheta: Predetermined incident theta value | ||
| */ | ||
| ReflectometryTransformKiKf::ReflectometryTransformKiKf(double kiMin, double kiMax, double kfMin, double kfMax, double incidentTheta) | ||
| : m_kiMin(kiMin), m_kiMax(kiMax), m_kfMin(kfMin), m_kfMax(kfMax), m_KiCalculation(incidentTheta) | ||
| { | ||
| if(kiMin >= kiMax) | ||
| { | ||
| throw std::invalid_argument("min ki bounds must be < max ki bounds"); | ||
| } | ||
| if(kfMin >= kfMax) | ||
| { | ||
| throw std::invalid_argument("min kf bounds must be < max kf bounds"); | ||
| } | ||
| if(incidentTheta < 0 || incidentTheta > 90) | ||
| { | ||
| throw std::out_of_range("incident theta angle must be > 0 and < 90"); | ||
| } | ||
| } | ||
|
|
||
| //---------------------------------------------------------------------------------------------- | ||
| /** Destructor | ||
| */ | ||
| ReflectometryTransformKiKf::~ReflectometryTransformKiKf() | ||
| { | ||
| } | ||
|
|
||
| /* | ||
| Execute the transformtion. Generates an output IMDEventWorkspace. | ||
| @return the constructed IMDEventWorkspace following the transformation. | ||
| @param ws: Input MatrixWorkspace const shared pointer | ||
| */ | ||
| Mantid::API::IMDEventWorkspace_sptr ReflectometryTransformKiKf::execute(Mantid::API::MatrixWorkspace_const_sptr inputWs) const | ||
| { | ||
| const size_t nbinsx = 10; | ||
| const size_t nbinsz = 10; | ||
|
|
||
| auto ws = boost::make_shared<MDEventWorkspace<MDLeanEvent<2>,2> >(); | ||
| MDHistoDimension_sptr kiDim = MDHistoDimension_sptr(new MDHistoDimension("Ki","ki","(Ang^-1)", static_cast<Mantid::coord_t>(m_kiMin), static_cast<Mantid::coord_t>(m_kiMax), nbinsx)); | ||
| MDHistoDimension_sptr kfDim = MDHistoDimension_sptr(new MDHistoDimension("Kf","kf","(Ang^-1)", static_cast<Mantid::coord_t>(m_kfMin), static_cast<Mantid::coord_t>(m_kfMax), nbinsz)); | ||
|
|
||
| ws->addDimension(kiDim); | ||
| ws->addDimension(kfDim); | ||
|
|
||
| // Set some reasonable values for the box controller | ||
| BoxController_sptr bc = ws->getBoxController(); | ||
| bc->setSplitInto(2); | ||
| bc->setSplitThreshold(10); | ||
|
|
||
| // Initialize the workspace. | ||
| ws->initialize(); | ||
|
|
||
| // Start with a MDGridBox. | ||
| ws->splitBox(); | ||
|
|
||
| auto spectraAxis = inputWs->getAxis(1); | ||
| for(size_t index = 0; index < inputWs->getNumberHistograms(); ++index) | ||
| { | ||
| auto counts = inputWs->readY(index); | ||
| auto wavelengths = inputWs->readX(index); | ||
| auto errors = inputWs->readE(index); | ||
| const size_t nInputBins = wavelengths.size() -1 ; | ||
| const double theta_final = spectraAxis->getValue(index); | ||
| CalculateReflectometryK kfCalculation(theta_final); | ||
| //Loop over all bins in spectra | ||
| for(size_t binIndex = 0; binIndex < nInputBins; ++binIndex) | ||
| { | ||
| const double& wavelength = 0.5*(wavelengths[binIndex] + wavelengths[binIndex+1]); | ||
| double _ki = m_KiCalculation.execute(wavelength); | ||
| double _kf = kfCalculation.execute(wavelength); | ||
| double centers[2] = {_ki, _kf}; | ||
|
|
||
| ws->addEvent(MDLeanEvent<2>(float(counts[binIndex]), float(errors[binIndex]*errors[binIndex]), centers)); | ||
| } | ||
| ws->splitAllIfNeeded(NULL); | ||
| } | ||
| return ws; | ||
| } | ||
|
|
||
|
|
||
| } // namespace Mantid | ||
| } // namespace MDEvents |
| @@ -0,0 +1,98 @@ | ||
| #include "MantidMDEvents/ReflectometryTransformP.h" | ||
| #include "MantidKernel/System.h" | ||
| #include "MantidMDEvents/MDEventWorkspace.h" | ||
| #include "MantidGeometry/MDGeometry/MDHistoDimension.h" | ||
| #include <stdexcept> | ||
|
|
||
| using namespace Mantid::Kernel; | ||
| using namespace Mantid::API; | ||
| using namespace Mantid::Geometry; | ||
|
|
||
| namespace Mantid | ||
| { | ||
| namespace MDEvents | ||
| { | ||
| /* | ||
| Constructor | ||
| @param kiMin: min ki value (extent) | ||
| @param kiMax: max ki value (extent) | ||
| @param kfMin: min kf value (extent) | ||
| @param kfMax; max kf value (extent) | ||
| @param incidentTheta: Predetermined incident theta value | ||
| */ | ||
| ReflectometryTransformP::ReflectometryTransformP(double kiMin, double kiMax, double kfMin, double kfMax, double incidentTheta) | ||
| : m_kiMin(kiMin), m_kiMax(kiMax), m_kfMin(kfMin), m_kfMax(kfMax), m_pSumCalculation(incidentTheta), m_pDiffCalculation(incidentTheta) | ||
| { | ||
| if(kiMin >= kiMax) | ||
| { | ||
| throw std::invalid_argument("min ki bounds must be < max ki bounds"); | ||
| } | ||
| if(kfMin >= kfMax) | ||
| { | ||
| throw std::invalid_argument("min kf bounds must be < max kf bounds"); | ||
| } | ||
| if(incidentTheta < 0 || incidentTheta > 90) | ||
| { | ||
| throw std::out_of_range("incident theta angle must be > 0 and < 90"); | ||
| } | ||
| } | ||
|
|
||
| //---------------------------------------------------------------------------------------------- | ||
| /** Destructor | ||
| */ | ||
| ReflectometryTransformP::~ReflectometryTransformP() | ||
| { | ||
| } | ||
|
|
||
| Mantid::API::IMDEventWorkspace_sptr ReflectometryTransformP::execute(Mantid::API::MatrixWorkspace_const_sptr inputWs) const | ||
| { | ||
| const size_t nbinsx = 10; | ||
| const size_t nbinsz = 10; | ||
|
|
||
| auto ws = boost::make_shared<MDEventWorkspace<MDLeanEvent<2>,2> >(); | ||
| MDHistoDimension_sptr pSumDim = MDHistoDimension_sptr(new MDHistoDimension("Pz_i + Pz_f","sum_pz","(Ang^-1)", static_cast<Mantid::coord_t>(m_kiMin + m_kfMin), static_cast<Mantid::coord_t>(m_kiMax + m_kfMax), nbinsx)); | ||
| MDHistoDimension_sptr pDiffDim = MDHistoDimension_sptr(new MDHistoDimension("Pz_i - Pz_f","diff_pz","(Ang^-1)", static_cast<Mantid::coord_t>(m_kiMin - m_kfMin), static_cast<Mantid::coord_t>(m_kiMax - m_kfMax), nbinsz)); | ||
|
|
||
| ws->addDimension(pSumDim); | ||
| ws->addDimension(pDiffDim); | ||
|
|
||
| // Set some reasonable values for the box controller | ||
| BoxController_sptr bc = ws->getBoxController(); | ||
| bc->setSplitInto(2); | ||
| bc->setSplitThreshold(10); | ||
|
|
||
| // Initialize the workspace. | ||
| ws->initialize(); | ||
|
|
||
| // Start with a MDGridBox. | ||
| ws->splitBox(); | ||
|
|
||
| auto spectraAxis = inputWs->getAxis(1); | ||
| for(size_t index = 0; index < inputWs->getNumberHistograms(); ++index) | ||
| { | ||
| auto counts = inputWs->readY(index); | ||
| auto wavelengths = inputWs->readX(index); | ||
| auto errors = inputWs->readE(index); | ||
| const size_t nInputBins = wavelengths.size() -1; | ||
| const double theta_final = spectraAxis->getValue(index); | ||
| m_pSumCalculation.setThetaFinal(theta_final); | ||
| m_pDiffCalculation.setThetaFinal(theta_final); | ||
| //Loop over all bins in spectra | ||
| for(size_t binIndex = 0; binIndex < nInputBins; ++binIndex) | ||
| { | ||
| const double& wavelength = 0.5*(wavelengths[binIndex] + wavelengths[binIndex+1]); | ||
| double _qx = m_pSumCalculation.execute(wavelength); | ||
| double _qz = m_pDiffCalculation.execute(wavelength); | ||
| double centers[2] = {_qx, _qz}; | ||
|
|
||
| ws->addEvent(MDLeanEvent<2>(float(counts[binIndex]), float(errors[binIndex]*errors[binIndex]), centers)); | ||
| } | ||
| ws->splitAllIfNeeded(NULL); | ||
| } | ||
| return ws; | ||
| } | ||
|
|
||
|
|
||
|
|
||
| } // namespace Mantid | ||
| } // namespace MDEvents |
| @@ -134,14 +134,6 @@ class ConvertToReflectometryQTest : public CxxTest::TestSuite | ||
| TS_ASSERT_THROWS_NOTHING(alg->execute()); | ||
| } | ||
|
|
||
| void test_execute() | ||
| { | ||
| auto alg = make_standard_algorithm(); | ||
| @@ -0,0 +1,127 @@ | ||
| #ifndef MANTID_MDEVENTS_REFLECTOMETRYTRANSFORMKIKFTEST_H_ | ||
| #define MANTID_MDEVENTS_REFLECTOMETRYTRANSFORMKIKFTEST_H_ | ||
|
|
||
| #define PI 3.14159265 | ||
|
|
||
| #include <cxxtest/TestSuite.h> | ||
| #include "MantidKernel/Timer.h" | ||
| #include "MantidKernel/System.h" | ||
| #include <iostream> | ||
| #include <iomanip> | ||
|
|
||
| #include "MantidMDEvents/ReflectometryTransformKiKf.h" | ||
|
|
||
|
|
||
| using namespace Mantid::MDEvents; | ||
|
|
||
| class ReflectometryTransformKiKfTest : 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 ReflectometryTransformKiKfTest *createSuite() { return new ReflectometryTransformKiKfTest(); } | ||
| static void destroySuite( ReflectometryTransformKiKfTest *suite ) { delete suite; } | ||
|
|
||
| void test_kimin_greater_than_kimax_throws() | ||
| { | ||
| double kiMin = 2; | ||
| double kiMax = 1; //Smaller than kiMin! | ||
| double kfMin = 1; | ||
| double kfMax = 2; | ||
| double incidentTheta = 1; | ||
| TS_ASSERT_THROWS(ReflectometryTransformKiKf(kiMin, kiMax, kfMin, kfMax, incidentTheta), std::invalid_argument); | ||
| } | ||
|
|
||
| void test_kimin_equal_to_kimax_throws() | ||
| { | ||
| double kiMin = 1; | ||
| double kiMax = 1; //Equal to kiMin! | ||
| double kfMin = 1; | ||
| double kfMax = 2; | ||
| double incidentTheta = 1; | ||
| TS_ASSERT_THROWS(ReflectometryTransformKiKf(kiMin, kiMax, kfMin, kfMax, incidentTheta), std::invalid_argument); | ||
| } | ||
|
|
||
| void test_kfmin_greater_than_kfmax_throws() | ||
| { | ||
| double kiMin = 1; | ||
| double kiMax = 2; | ||
| double kfMin = 2; | ||
| double kfMax = 1; //Smaller than kfMin! | ||
| double incidentTheta = 1; | ||
| TS_ASSERT_THROWS(ReflectometryTransformKiKf(kiMin, kiMax, kfMin, kfMax, incidentTheta), std::invalid_argument); | ||
| } | ||
|
|
||
| void test_kfmin_equal_to_kfmax_throws() | ||
| { | ||
| double kiMin = 1; | ||
| double kiMax = 2; | ||
| double kfMin = 1; | ||
| double kfMax = 1; //Equal to kfMin! | ||
| double incidentTheta = 1; | ||
| TS_ASSERT_THROWS(ReflectometryTransformKiKf(kiMin, kiMax, kfMin, kfMax, incidentTheta), std::invalid_argument); | ||
| } | ||
|
|
||
| void test_incident_theta_negative() | ||
| { | ||
| double kiMin = 1; | ||
| double kiMax = 2; | ||
| double kfMin = 1; | ||
| double kfMax = 3; | ||
| double incidentTheta = -0.001; //Negative | ||
| TS_ASSERT_THROWS(ReflectometryTransformKiKf(kiMin, kiMax, kfMin, kfMax, incidentTheta), std::out_of_range); | ||
| } | ||
|
|
||
| void test_incident_theta_too_large() | ||
| { | ||
| double kiMin = 1; | ||
| double kiMax = 2; | ||
| double kfMin = 1; | ||
| double kfMax = 3; | ||
| double incidentTheta = 90.001; //Too large | ||
| TS_ASSERT_THROWS(ReflectometryTransformKiKf(kiMin, kiMax, kfMin, kfMax, incidentTheta), std::out_of_range); | ||
| } | ||
|
|
||
| void test_valid_construction_inputs() | ||
| { | ||
| double kiMin = 1; | ||
| double kiMax = 2; | ||
| double kfMin = 1; | ||
| double kfMax = 2; | ||
| double incidentTheta = 1; | ||
| TS_ASSERT_THROWS_NOTHING(ReflectometryTransformKiKf(kiMin, kiMax, kfMin, kfMax, incidentTheta)); | ||
| } | ||
|
|
||
| void test_calulate_k() | ||
| { | ||
| const double wavelength = 1; | ||
|
|
||
| //Sine 0 = 0 | ||
| CalculateReflectometryK A(0); | ||
| TS_ASSERT_EQUALS(0, A.execute(wavelength)); | ||
|
|
||
| //Sine 90 = 1 | ||
| CalculateReflectometryK B(90); | ||
| TS_ASSERT_DELTA(2*PI/wavelength, B.execute(wavelength), 0.0001); | ||
|
|
||
| //Sine 270 = -1 | ||
| CalculateReflectometryK C(270); | ||
| TS_ASSERT_DELTA(-2*PI/wavelength, C.execute(wavelength), 0.0001); | ||
| } | ||
|
|
||
| void test_recalculate_k() | ||
| { | ||
| const double wavelength = 1; | ||
|
|
||
| CalculateReflectometryK A(90); | ||
| TS_ASSERT_DELTA(2*PI/wavelength, A.execute(wavelength), 0.0001); | ||
|
|
||
| //Now re-execute on the same calculation object. | ||
| TS_ASSERT_DELTA(PI/wavelength, A.execute(2*wavelength), 0.0001); | ||
| } | ||
|
|
||
|
|
||
| }; | ||
|
|
||
|
|
||
| #endif /* MANTID_MDEVENTS_REFLECTOMETRYTRANSFORMKIKFTEST_H_ */ |
| @@ -0,0 +1,141 @@ | ||
| #ifndef MANTID_MDEVENTS_REFLECTOMETRYTRANSFORMPTEST_H_ | ||
| #define MANTID_MDEVENTS_REFLECTOMETRYTRANSFORMPTEST_H_ | ||
|
|
||
| #define PI 3.14159265 | ||
|
|
||
| #include <cxxtest/TestSuite.h> | ||
| #include "MantidKernel/Timer.h" | ||
| #include "MantidKernel/System.h" | ||
| #include <iostream> | ||
| #include <iomanip> | ||
| #include "MantidMDEvents/ReflectometryTransformP.h" | ||
|
|
||
| using namespace Mantid; | ||
| using namespace Mantid::MDEvents; | ||
| using namespace Mantid::API; | ||
|
|
||
| class ReflectometryTransformPTest : 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 ReflectometryTransformPTest *createSuite() { return new ReflectometryTransformPTest(); } | ||
| static void destroySuite( ReflectometryTransformPTest *suite ) { delete suite; } | ||
|
|
||
|
|
||
| void test_kimin_greater_than_kimax_throws() | ||
| { | ||
| double kiMin = 2; | ||
| double kiMax = 1; //Smaller than kiMin! | ||
| double kfMin = 1; | ||
| double kfMax = 2; | ||
| double incidentTheta = 1; | ||
| TS_ASSERT_THROWS(ReflectometryTransformP(kiMin, kiMax, kfMin, kfMax, incidentTheta), std::invalid_argument); | ||
| } | ||
|
|
||
| void test_kimin_equal_to_kimax_throws() | ||
| { | ||
| double kiMin = 1; | ||
| double kiMax = 1; //Equal to kiMin! | ||
| double kfMin = 1; | ||
| double kfMax = 2; | ||
| double incidentTheta = 1; | ||
| TS_ASSERT_THROWS(ReflectometryTransformP(kiMin, kiMax, kfMin, kfMax, incidentTheta), std::invalid_argument); | ||
| } | ||
|
|
||
| void test_kfmin_greater_than_kfmax_throws() | ||
| { | ||
| double kiMin = 1; | ||
| double kiMax = 2; | ||
| double kfMin = 2; | ||
| double kfMax = 1; //Smaller than kfMin! | ||
| double incidentTheta = 1; | ||
| TS_ASSERT_THROWS(ReflectometryTransformP(kiMin, kiMax, kfMin, kfMax, incidentTheta), std::invalid_argument); | ||
| } | ||
|
|
||
| void test_kfmin_equal_to_kfmax_throws() | ||
| { | ||
| double kiMin = 1; | ||
| double kiMax = 2; | ||
| double kfMin = 1; | ||
| double kfMax = 1; //Equal to kfMin! | ||
| double incidentTheta = 1; | ||
| TS_ASSERT_THROWS(ReflectometryTransformP(kiMin, kiMax, kfMin, kfMax, incidentTheta), std::invalid_argument); | ||
| } | ||
|
|
||
| void test_incident_theta_negative() | ||
| { | ||
| double kiMin = 1; | ||
| double kiMax = 2; | ||
| double kfMin = 1; | ||
| double kfMax = 3; | ||
| double incidentTheta = -0.001; //Negative | ||
| TS_ASSERT_THROWS(ReflectometryTransformP(kiMin, kiMax, kfMin, kfMax, incidentTheta), std::out_of_range); | ||
| } | ||
|
|
||
| void test_incident_theta_too_large() | ||
| { | ||
| double kiMin = 1; | ||
| double kiMax = 2; | ||
| double kfMin = 1; | ||
| double kfMax = 3; | ||
| double incidentTheta = 90.001; //Too large | ||
| TS_ASSERT_THROWS(ReflectometryTransformP(kiMin, kiMax, kfMin, kfMax, incidentTheta), std::out_of_range); | ||
| } | ||
|
|
||
| void test_valid_construction_inputs() | ||
| { | ||
| double kiMin = 1; | ||
| double kiMax = 2; | ||
| double kfMin = 1; | ||
| double kfMax = 2; | ||
| double incidentTheta = 1; | ||
| TS_ASSERT_THROWS_NOTHING(ReflectometryTransformP(kiMin, kiMax, kfMin, kfMax, incidentTheta)); | ||
| } | ||
|
|
||
| void test_calulate_diff_p() | ||
| { | ||
| const double wavelength = 1; | ||
|
|
||
| CalculateReflectometryDiffP A(0); | ||
| A.setThetaFinal(0); | ||
| TS_ASSERT_EQUALS(0, A.execute(wavelength)); | ||
|
|
||
| CalculateReflectometryDiffP B(90); | ||
| B.setThetaFinal(0); | ||
| TS_ASSERT_DELTA(2*PI/wavelength, B.execute(wavelength), 0.0001); | ||
|
|
||
| CalculateReflectometryDiffP C(0); | ||
| C.setThetaFinal(90); | ||
| TS_ASSERT_DELTA(-2*PI/wavelength, C.execute(wavelength), 0.0001); | ||
|
|
||
| CalculateReflectometryDiffP D(90); | ||
| D.setThetaFinal(90); | ||
| TS_ASSERT_EQUALS(0, A.execute(wavelength)); | ||
| } | ||
|
|
||
| void test_calulate_sum_p() | ||
| { | ||
| const double wavelength = 1; | ||
|
|
||
| CalculateReflectometrySumP A(0); | ||
| A.setThetaFinal(0); | ||
| TS_ASSERT_EQUALS(0, A.execute(wavelength)); | ||
|
|
||
| CalculateReflectometrySumP B(90); | ||
| B.setThetaFinal(0); | ||
| TS_ASSERT_DELTA(2*PI/wavelength, B.execute(wavelength), 0.0001); | ||
|
|
||
| CalculateReflectometrySumP C(0); | ||
| C.setThetaFinal(90); | ||
| TS_ASSERT_DELTA(2*PI/wavelength, C.execute(wavelength), 0.0001); | ||
|
|
||
| CalculateReflectometrySumP D(90); | ||
| D.setThetaFinal(90); | ||
| TS_ASSERT_DELTA(4*PI/wavelength, D.execute(wavelength), 0.0001); | ||
| } | ||
|
|
||
| }; | ||
|
|
||
|
|
||
| #endif /* MANTID_MDEVENTS_REFLECTOMETRYTRANSFORMPTEST_H_ */ |
| @@ -0,0 +1,158 @@ | ||
| """*WIKI* | ||
| Liquids Reflectometer (REFL) NeXus viewer | ||
| This routine will display some of the metadata defined by the IS | ||
| for a given run or set of runs. | ||
| *WIKI*""" | ||
|
|
||
| from MantidFramework import * | ||
| from mantidsimple import * | ||
| from numpy import zeros, shape, arange | ||
| import math | ||
| import sfCalculator | ||
|
|
||
| class RefLview(PythonAlgorithm): | ||
|
|
||
| def category(self): | ||
| return "Reflectometry" | ||
|
|
||
| def name(self): | ||
| return "RefLview" | ||
|
|
||
| def version(self): | ||
| return 1 | ||
|
|
||
| def PyInit(self): | ||
| self.declareListProperty("RunNumbers", [0], | ||
| Validator=ArrayBoundedValidator(Lower=0), | ||
| Description="List of run numbers to process") | ||
|
|
||
| def PyExec(self): | ||
|
|
||
| import os | ||
| import numpy | ||
| import math | ||
| from reduction.instruments.reflectometer import wks_utility | ||
|
|
||
| from mantid import mtd | ||
| #remove all previous workspaces | ||
| list_mt = mtd.getObjectNames() | ||
| for _mt in list_mt: | ||
| if _mt.find('_scaled') != -1: | ||
| mtd.remove(_mt) | ||
| if _mt.find('_reflectivity') != -1: | ||
| mtd.remove(_mt) | ||
| from mantidsimple import mtd | ||
|
|
||
| bDebug = False | ||
| if bDebug: | ||
| print '====== Running in mode DEBUGGING =======' | ||
|
|
||
| run_numbers = self.getProperty("RunNumbers") | ||
| if bDebug: | ||
| print 'run_numbers (before getSequenceRuns): ' | ||
| print str(run_numbers) | ||
| run_numbers = wks_utility.getSequenceRuns(run_numbers) | ||
| if bDebug: | ||
| print 'run_numbers (after getSequenceRuns): ' | ||
| print str(run_numbers) | ||
|
|
||
| for _run in run_numbers: | ||
|
|
||
| #make sure we are working with integer | ||
| _run = int(_run) | ||
|
|
||
| print '********* Working with run: ' + str(_run) + ' *********' | ||
|
|
||
| #Pick a good workspace name | ||
| ws_name = "refl%d" % _run | ||
| ws_event_data = ws_name+"_evt" | ||
|
|
||
| _File = FileFinder.findRuns("REF_L%d" %_run) | ||
| if len(_File)>0 and os.path.isfile(_File[0]): | ||
| data_file = _File[0] | ||
| if bDebug: | ||
| print 'DEBUG: full file name is ' + _File[0] | ||
| else: | ||
| msg = "RefLReduction: could not find run %d\n" % _run | ||
| msg += "Add your data folder to your User Data Directories in the File menu" | ||
| if bDebug: | ||
| print 'DEBUG: file name could not be found !' | ||
| raise RuntimeError(msg) | ||
|
|
||
| if not mtd.workspaceExists(ws_event_data): | ||
| LoadEventNexus(Filename=data_file, | ||
| OutputWorkspace=ws_event_data) | ||
|
|
||
| #retrieve list of metadata | ||
| mt_run = mtd[ws_event_data].getRun() | ||
|
|
||
| #run_title | ||
| run_title = mt_run.getProperty('run_title').value | ||
| _line = ' Run title: ' + run_title | ||
| print _line | ||
|
|
||
| #run_start | ||
| run_start = mt_run.getProperty('run_start').value | ||
| _line = ' Run start: ' + run_start | ||
| print _line | ||
|
|
||
| #Lambda Requested | ||
| lambda_request_value = mt_run.getProperty('LambdaRequest').value[0] | ||
| lambda_request_units = mt_run.getProperty('LambdaRequest').units | ||
| _line = ' Lambda requested: ' + str(lambda_request_value) | ||
| _line += ' ' + lambda_request_units | ||
| print _line | ||
|
|
||
| #tthd | ||
| tthd_value = mt_run.getProperty('tthd').value[0] | ||
| tthd_units = mt_run.getProperty('tthd').units | ||
| _line = ' tthd: {0:.4f}'.format(tthd_value) | ||
| _line += ' ' + tthd_units | ||
| print _line | ||
|
|
||
| #thi | ||
| thi_value = mt_run.getProperty('thi').value[0] | ||
| thi_units = mt_run.getProperty('thi').units | ||
| _line = ' thi: {0:.4f}'.format(thi_value) | ||
| _line += ' ' + thi_units | ||
| print _line | ||
|
|
||
| #ths | ||
| ths_value = mt_run.getProperty('ths').value[0] | ||
| ths_units = mt_run.getProperty('ths').units | ||
| _line = ' ths: {0:.4f}'.format(ths_value) | ||
| _line += ' ' + ths_units | ||
| print _line | ||
|
|
||
| #s1h | ||
| s1h_value, s1h_units = wks_utility.getS1h(mtd[ws_event_data]) | ||
| _line = ' s1h: {0:.4f}'.format(s1h_value) | ||
| _line += ' ' + s1h_units | ||
| print _line | ||
|
|
||
| #s2h | ||
| s2h_value, s2h_units = wks_utility.getS2h(mtd[ws_event_data]) | ||
| _line = ' s2h: {0:.4f}'.format(s2h_value) | ||
| _line += ' ' + s2h_units | ||
| print _line | ||
|
|
||
| #s1w | ||
| s1w_value, s1w_units = wks_utility.getS1w(mtd[ws_event_data]) | ||
| _line = ' s1w: {0:.4f}'.format(s1w_value) | ||
| _line += ' ' + s1w_units | ||
| print _line | ||
|
|
||
| #s2w | ||
| s2w_value, s2w_units = wks_utility.getS2w(mtd[ws_event_data]) | ||
| _line = ' s2w: {0:.4f}'.format(s2w_value) | ||
| _line += ' ' + s2w_units | ||
| print _line | ||
|
|
||
| print '********************************' | ||
|
|
||
| mtd.registerPyAlgorithm(RefLview()) |
| @@ -0,0 +1,59 @@ | ||
| #ifndef MANTID_WORKFLOWALGORITHMS_DGSREDUCTION_H_ | ||
| #define MANTID_WORKFLOWALGORITHMS_DGSREDUCTION_H_ | ||
|
|
||
| #include "MantidKernel/System.h" | ||
| #include "MantidAPI/Algorithm.h" | ||
|
|
||
| namespace Mantid | ||
| { | ||
| namespace WorkflowAlgorithms | ||
| { | ||
|
|
||
| /** DgsReduction : This is the top-level workflow algorithm for controlling | ||
| * direct geometry spectrometer reduction. | ||
| @date 2012-06-06 | ||
| Copyright © 2012 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://svn.mantidproject.org/mantid/trunk/Code/Mantid> | ||
| Code Documentation is available at: <http://doxygen.mantidproject.org> | ||
| */ | ||
| class DLLExport DgsReduction : public API::Algorithm | ||
| { | ||
| public: | ||
| DgsReduction(); | ||
| virtual ~DgsReduction(); | ||
|
|
||
| virtual const std::string name() const; | ||
| virtual int version() const; | ||
| virtual const std::string category() const; | ||
|
|
||
| private: | ||
| virtual void initDocs(); | ||
| void init(); | ||
| void exec(); | ||
|
|
||
|
|
||
| }; | ||
|
|
||
|
|
||
| } // namespace WorkflowAlgorithms | ||
| } // namespace Mantid | ||
|
|
||
| #endif /* MANTID_WORKFLOWALGORITHMS_DGSREDUCTION_H_ */ |
| @@ -0,0 +1,78 @@ | ||
| /*WIKI* | ||
| This is the top-level workflow algorithm for direct geometry spectrometer | ||
| data reduction. This algorithm is responsible for gathering the necessary | ||
| parameters and generating calls to other workflow or standard algorithms. | ||
| *WIKI*/ | ||
|
|
||
| #include "MantidWorkflowAlgorithms/DgsReduction.h" | ||
| #include "MantidKernel/System.h" | ||
|
|
||
| using namespace Mantid::Kernel; | ||
| using namespace Mantid::API; | ||
|
|
||
| namespace Mantid | ||
| { | ||
| namespace WorkflowAlgorithms | ||
| { | ||
|
|
||
| // Register the algorithm into the AlgorithmFactory | ||
| DECLARE_ALGORITHM(DgsReduction) | ||
|
|
||
|
|
||
|
|
||
| //---------------------------------------------------------------------------------------------- | ||
| /** Constructor | ||
| */ | ||
| DgsReduction::DgsReduction() | ||
| { | ||
| } | ||
|
|
||
| //---------------------------------------------------------------------------------------------- | ||
| /** Destructor | ||
| */ | ||
| DgsReduction::~DgsReduction() | ||
| { | ||
| } | ||
|
|
||
|
|
||
| //---------------------------------------------------------------------------------------------- | ||
| /// Algorithm's name for identification. @see Algorithm::name | ||
| const std::string DgsReduction::name() const { return "DgsReduction";}; | ||
|
|
||
| /// Algorithm's version for identification. @see Algorithm::version | ||
| int DgsReduction::version() const { return 1;}; | ||
|
|
||
| /// Algorithm's category for identification. @see Algorithm::category | ||
| const std::string DgsReduction::category() const { return "Workflow";} | ||
|
|
||
| //---------------------------------------------------------------------------------------------- | ||
| /// Sets documentation strings for this algorithm | ||
| void DgsReduction::initDocs() | ||
| { | ||
| this->setWikiSummary("Top-level workflow algorithm for DGS reduction."); | ||
| this->setOptionalMessage("Top-level workflow algorithm for DGS reduction."); | ||
| } | ||
|
|
||
| //---------------------------------------------------------------------------------------------- | ||
| /** Initialize the algorithm's properties. | ||
| */ | ||
| void DgsReduction::init() | ||
| { | ||
| declareProperty(new WorkspaceProperty<>("InputWorkspace","",Direction::Input), "An input workspace."); | ||
| declareProperty(new WorkspaceProperty<>("OutputWorkspace","",Direction::Output), "An output workspace."); | ||
| } | ||
|
|
||
| //---------------------------------------------------------------------------------------------- | ||
| /** Execute the algorithm. | ||
| */ | ||
| void DgsReduction::exec() | ||
| { | ||
| // TODO Auto-generated execute stub | ||
| } | ||
|
|
||
|
|
||
|
|
||
| } // namespace Mantid | ||
| } // namespace WorkflowAlgorithms |
| @@ -116,7 +116,6 @@ Graph::Graph(int x, int y, int width, int height, QWidget* parent, Qt::WFlags f) | ||
| : QWidget(parent, f) //QwtPlot(parent) | ||
| { | ||
| setWindowFlags(f); | ||
| n_curves=0; | ||
|
|
||
| d_waterfall_offset_x = 0; | ||
| @@ -50,9 +50,7 @@ class MdiSubWindowParent_t: public QWidget | ||
| MdiSubWindowParent_t(QWidget* parent, Qt::WFlags f = 0): | ||
| QWidget(parent,f), | ||
| m_widget(NULL) | ||
| {} | ||
| void setWidget(QWidget* w) | ||
| { | ||
| if (w == NULL) | ||
| @@ -133,7 +133,7 @@ void CreateMDWorkspace::initLayout() | ||
| while(it != names.end()) | ||
| { | ||
| m_uiForm.workspaceSelector->addItem((*it).c_str()); | ||
| ++it; | ||
| } | ||
|
|
||
| } | ||