Skip to content
Snippets Groups Projects
Commit 282e913b authored by Michael Wedel's avatar Michael Wedel
Browse files

Refs #12777. Maximum peak width needs to be a parameter.

Updated tests and documentation as well.
parent 20527d7b
No related merge requests found
......@@ -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)
......
......@@ -135,6 +135,7 @@ protected:
API::WorkspaceGroup_sptr m_fitplots;
double m_fwhmMultiples;
double m_maxRelativeFwhm;
private:
void init();
......
......@@ -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");
......
......@@ -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() {
......
......@@ -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
-----
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment