diff --git a/Code/Mantid/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/PoldiDataAnalysis.py b/Code/Mantid/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/PoldiDataAnalysis.py index 6998aa8c751fe4ef085cef3c2661a69b09cfa9d9..a29fdd91361b3580d43e5aedd86324f33085b15e 100644 --- a/Code/Mantid/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/PoldiDataAnalysis.py +++ b/Code/Mantid/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/PoldiDataAnalysis.py @@ -48,6 +48,9 @@ class PoldiDataAnalysis(PythonAlgorithm): doc=('Minimum height of peaks. If it is left at 0, the minimum peak height is calculated' 'from background noise.')) + self.declareProperty("MaximumRelativeFwhm", 0.02, direction=Direction.Input, + doc=('Peaks with a relative FWHM larger than this are removed during the 1D fit.')) + self.declareProperty("ScatteringContributions", "1", direction=Direction.Input, doc=('If there is more than one compound, you may supply estimates of their scattering ' 'contributions, which sometimes improves indexing.')) @@ -93,6 +96,7 @@ class PoldiDataAnalysis(PythonAlgorithm): self.expectedPeaks = self.getProperty("ExpectedPeaks").value self.profileFunction = self.getProperty("ProfileFunction").value self.useGlobalParameters = self.getProperty("TieProfileParameters").value + self.maximumRelativeFwhm = self.getProperty("MaximumRelativeFwhm").value self.globalParameters = '' if self.useGlobalParameters: @@ -178,6 +182,7 @@ class PoldiDataAnalysis(PythonAlgorithm): PoldiFitPeaks1D(InputWorkspace=correlationWorkspace, PoldiPeakTable=rawPeaks, FwhmMultiples=3.0, + MaximumRelativeFwhm=self.maximumRelativeFwhm, PeakFunction=self.profileFunction, OutputWorkspace=refinedPeaksName, FitPlotsWorkspace=plotNames) diff --git a/Code/Mantid/Framework/SINQ/inc/MantidSINQ/PoldiFitPeaks1D2.h b/Code/Mantid/Framework/SINQ/inc/MantidSINQ/PoldiFitPeaks1D2.h index 1bc1d922cdf06f836c3112b76d7dd660f5176b06..a4b145e1869b3907dae5c1c233a5294b9dc051d5 100644 --- a/Code/Mantid/Framework/SINQ/inc/MantidSINQ/PoldiFitPeaks1D2.h +++ b/Code/Mantid/Framework/SINQ/inc/MantidSINQ/PoldiFitPeaks1D2.h @@ -135,6 +135,7 @@ protected: API::WorkspaceGroup_sptr m_fitplots; double m_fwhmMultiples; + double m_maxRelativeFwhm; private: void init(); diff --git a/Code/Mantid/Framework/SINQ/src/PoldiFitPeaks1D2.cpp b/Code/Mantid/Framework/SINQ/src/PoldiFitPeaks1D2.cpp index 5b147786813bdaf98ddd9681a4ab360b534cf3c8..2c962ed6f56141010ae51ea9bc9ce3528e291ed5 100644 --- a/Code/Mantid/Framework/SINQ/src/PoldiFitPeaks1D2.cpp +++ b/Code/Mantid/Framework/SINQ/src/PoldiFitPeaks1D2.cpp @@ -118,7 +118,7 @@ DECLARE_ALGORITHM(PoldiFitPeaks1D2) PoldiFitPeaks1D2::PoldiFitPeaks1D2() : m_peaks(), m_profileTemplate(), m_fitplots(new WorkspaceGroup), - m_fwhmMultiples(1.0) {} + m_fwhmMultiples(1.0), m_maxRelativeFwhm(0.02) {} PoldiFitPeaks1D2::~PoldiFitPeaks1D2() {} @@ -150,6 +150,11 @@ void PoldiFitPeaks1D2::init() { "If a fraction larger than this value overlaps with the next " "range, the ranges are merged."); + declareProperty("MaximumRelativeFwhm", 0.02, + "Peaks with a relative FWHM higher" + "than this value will be excluded.", + Direction::Input); + std::vector<std::string> peakFunctions = FunctionFactory::Instance().getFunctionNames<IPeakFunction>(); @@ -373,7 +378,8 @@ PoldiPeakCollection_sptr PoldiFitPeaks1D2::getReducedPeakCollection( } bool PoldiFitPeaks1D2::peakIsAcceptable(const PoldiPeak_sptr &peak) const { - return peak->intensity() > 0 && peak->fwhm(PoldiPeak::Relative) < 0.02 && + return peak->intensity() > 0 && + peak->fwhm(PoldiPeak::Relative) < m_maxRelativeFwhm && peak->fwhm(PoldiPeak::Relative) > 0.001; } @@ -382,6 +388,7 @@ void PoldiFitPeaks1D2::exec() { // Number of points around the peak center to use for the fit m_fwhmMultiples = getProperty("FwhmMultiples"); + m_maxRelativeFwhm = getProperty("MaximumRelativeFwhm"); // try to construct PoldiPeakCollection from provided TableWorkspace TableWorkspace_sptr poldiPeakTable = getProperty("PoldiPeakTable"); diff --git a/Code/Mantid/Framework/SINQ/test/PoldiFitPeaks1D2Test.h b/Code/Mantid/Framework/SINQ/test/PoldiFitPeaks1D2Test.h index 200958bbdca33c81feae6e85ac3dc813bbbdf769..b58e303c0f060b877e00ebcf9e4d965fd1cb034c 100644 --- a/Code/Mantid/Framework/SINQ/test/PoldiFitPeaks1D2Test.h +++ b/Code/Mantid/Framework/SINQ/test/PoldiFitPeaks1D2Test.h @@ -97,7 +97,7 @@ public: Mantid::Poldi::PoldiFitPeaks1D2 fitPeaks1D; fitPeaks1D.initialize(); - TS_ASSERT_EQUALS(fitPeaks1D.propertyCount(), 7); + TS_ASSERT_EQUALS(fitPeaks1D.propertyCount(), 8); std::vector<Property *> properties = fitPeaks1D.getProperties(); std::set<std::string> names; @@ -108,6 +108,7 @@ public: TS_ASSERT_EQUALS(names.count("InputWorkspace"), 1); TS_ASSERT_EQUALS(names.count("FwhmMultiples"), 1); + TS_ASSERT_EQUALS(names.count("MaximumRelativeFwhm"), 1); TS_ASSERT_EQUALS(names.count("PeakFunction"), 1); TS_ASSERT_EQUALS(names.count("PoldiPeakTable"), 1); TS_ASSERT_EQUALS(names.count("OutputWorkspace"), 1); @@ -239,6 +240,7 @@ public: void testPeakIsAcceptable() { TestablePoldiFitPeaks1D2 poldiPeakFit; + poldiPeakFit.m_maxRelativeFwhm = 0.02; // The testpeak is acceptable TS_ASSERT(poldiPeakFit.peakIsAcceptable(m_testPeak)); @@ -249,20 +251,19 @@ public: negativeIntensity->setIntensity(UncertainValue(-190.0)); TS_ASSERT(!poldiPeakFit.peakIsAcceptable(negativeIntensity)); - // 2. FWHM too large (rel. > 0.02) + // 2a. FWHM too large (rel. > 0.02) PoldiPeak_sptr tooBroad = m_testPeak->clone(); tooBroad->setFwhm(UncertainValue(0.021), PoldiPeak::Relative); TS_ASSERT(!poldiPeakFit.peakIsAcceptable(tooBroad)); + // 2b. Changing acceptable FWHM + poldiPeakFit.m_maxRelativeFwhm = 0.03; + TS_ASSERT(poldiPeakFit.peakIsAcceptable(tooBroad)); + // 3. FWHM too small (rel. < 0.001) PoldiPeak_sptr tooNarrow = m_testPeak->clone(); tooNarrow->setFwhm(UncertainValue(0.0009), PoldiPeak::Relative); TS_ASSERT(!poldiPeakFit.peakIsAcceptable(tooNarrow)); - - // 4. Position precision is too low. (rel error > 1e-3) - PoldiPeak_sptr lowPrecision = m_testPeak->clone(); - lowPrecision->setD(UncertainValue(1, 0.0011)); - TS_ASSERT(!poldiPeakFit.peakIsAcceptable(lowPrecision)); } void testGetBestChebyshevPolynomialDegree() { diff --git a/Code/Mantid/docs/source/algorithms/PoldiFitPeaks1D-v2.rst b/Code/Mantid/docs/source/algorithms/PoldiFitPeaks1D-v2.rst index 9882ddde3fdf0e1d823d260605287f8d41474013..990c747c367175e2ef2f6155156612185ce53c7a 100644 --- a/Code/Mantid/docs/source/algorithms/PoldiFitPeaks1D-v2.rst +++ b/Code/Mantid/docs/source/algorithms/PoldiFitPeaks1D-v2.rst @@ -13,6 +13,8 @@ Version two of PoldiFitPeaks1D was introduced to solve problems with overlapping Another thing that's different from version 1 of the algorithm is the background description. When peaks overlap, the description with a quadratic function is not particularly suitable. Instead, Chebyshev-polynomes of degrees 0, 1 and 2 are fitted and the best solution (with respect to quality of the fit) is selected automatically. +Furthermore, after fitting peaks are inspected for meaningful results. Peaks with intensities below zero, too narrow or too broad profiles (the upper limit is specified by the MaximumRelativeFwhm-parameters) are excluded. + Usage -----