Mantid
Loading...
Searching...
No Matches
Classes | Typedefs | Enumerations | Functions | Variables
Mantid::CurveFitting::ParameterEstimator Namespace Reference

Classes

class  LinearFunction
 A linear function. More...
 

Typedefs

using FunctionMapType = std::map< std::string, std::pair< size_t, Function > >
 

Enumerations

enum  Function { None , Gaussian , Lorentzian , BackToBackExponential }
 

Functions

void MANTID_CURVEFITTING_DLL estimate (API::IFunction &function, const API::FunctionDomain1D &domain, const API::FunctionValues &values)
 ParameterEstimator estimates parameter values of some fitting functions from fitting data. More...
 
void extractValues (const API::FunctionDomain1D &domain, const API::FunctionValues &values, std::vector< double > &x, std::vector< double > &y)
 Extract values from domain and values objects to vectors. More...
 
const FunctionMapTypegetFunctionMapType ()
 Returns a reference to the static functionMapType. More...
 
double getPeakCentre (double centre, const SimpleChebfun &der1)
 Improve an estimate of a peak centre. More...
 
std::pair< double, double > getPeakHWHM (double centre, double height, const SimpleChebfun &fun)
 Get displacements from peak centre where peak reaches half the maximum. More...
 
std::pair< double, double > getPeakLeftRightExtent (double centre, const SimpleChebfun &der2)
 Get the peak's extent on either side of the centre. More...
 
std::pair< double, double > getPeakLeftRightWidth (double centre, const SimpleChebfun &der2, size_t n=1)
 Get a measure of peak's width. More...
 
double getPeakWidth (double centre, const SimpleChebfun &der2)
 Estimate a peak width from a second derivative of the data. More...
 
void initFunctionLookup (FunctionMapType &functionMapType)
 Initializes a FunctionMapType object. More...
 
bool needSettingInitialValues (const API::IFunction &function)
 Test if initial values need to be set before fitting. More...
 
void setBackToBackExponential (API::IFunction &function, const SimpleChebfun &fun, const SimpleChebfun &der1, const SimpleChebfun &der2)
 Set initial values to a BackToBackExponential. More...
 
void setValues (API::IFunction &function, const SimpleChebfun &fun, const SimpleChebfun &der1, const SimpleChebfun &der2)
 Set initial values to a function if it needs to. More...
 
Function whichFunction (const API::IFunction &function)
 Return a function code for a function if it needs setting values or None otherwise. More...
 

Variables

Kernel::Logger g_log ("ParameterEstimator")
 The logger. More...
 

Typedef Documentation

◆ FunctionMapType

using Mantid::CurveFitting::ParameterEstimator::FunctionMapType = typedef std::map<std::string, std::pair<size_t, Function> >

Definition at line 32 of file ParameterEstimator.cpp.

Enumeration Type Documentation

◆ Function

Enumerator
None 
Gaussian 
Lorentzian 
BackToBackExponential 

Definition at line 31 of file ParameterEstimator.cpp.

Function Documentation

◆ estimate()

void Mantid::CurveFitting::ParameterEstimator::estimate ( API::IFunction function,
const API::FunctionDomain1D domain,
const API::FunctionValues values 
)

ParameterEstimator estimates parameter values of some fitting functions from fitting data.

Parameters
function:: A function to estimate parameters for.
domain:: A domain with fitting data arguments.
values:: A FunctionValues object with the fitting data.

Definition at line 391 of file ParameterEstimator.cpp.

References Mantid::CurveFitting::Functions::SimpleChebfun::derivative(), extractValues(), needSettingInitialValues(), setValues(), Mantid::Geometry::x, and Mantid::Geometry::y.

Referenced by Mantid::CurveFitting::IMWDomainCreator::setInitialValues(), and Mantid::CurveFitting::TableWorkspaceDomainCreator::setInitialValues().

◆ extractValues()

void Mantid::CurveFitting::ParameterEstimator::extractValues ( const API::FunctionDomain1D domain,
const API::FunctionValues values,
std::vector< double > &  x,
std::vector< double > &  y 
)

Extract values from domain and values objects to vectors.

Parameters
domain:: A domain with fitting data arguments.
values:: A FunctionValues object with the fitting data.
x:: A vector to store the domain values
y:: A vector to store the fitting data values.

Definition at line 91 of file ParameterEstimator.cpp.

References Mantid::API::FunctionValues::getFitData(), Mantid::API::FunctionDomain1D::getPointerAt(), n, Mantid::API::FunctionDomain1D::size(), Mantid::Geometry::x, and Mantid::Geometry::y.

Referenced by estimate().

◆ getFunctionMapType()

const FunctionMapType & Mantid::CurveFitting::ParameterEstimator::getFunctionMapType ( )

Returns a reference to the static functionMapType.

Returns
:: a const reference to the functionMapType

Definition at line 48 of file ParameterEstimator.cpp.

References initFunctionLookup().

Referenced by whichFunction().

◆ getPeakCentre()

double Mantid::CurveFitting::ParameterEstimator::getPeakCentre ( double  centre,
const SimpleChebfun der1 
)

Improve an estimate of a peak centre.

Parameters
centre:: A rough estimate of the centre.
der1:: A first derivative of a function.
Returns
:: Improved estimate for the centre.

Definition at line 216 of file ParameterEstimator.cpp.

References fabs, n, Mantid::CurveFitting::Functions::SimpleChebfun::roughRoots(), and Mantid::CurveFitting::Functions::SimpleChebfun::width().

Referenced by setBackToBackExponential().

◆ getPeakHWHM()

std::pair< double, double > Mantid::CurveFitting::ParameterEstimator::getPeakHWHM ( double  centre,
double  height,
const SimpleChebfun fun 
)

Get displacements from peak centre where peak reaches half the maximum.

Parameters
centre:: Peak centre.
height:: Peak height above background. height == fun(centre) - background.
fun:: A function which is expected to be a peak on a background.
Returns
:: The left and right displacements from peak centre.

Definition at line 176 of file ParameterEstimator.cpp.

References Mantid::CurveFitting::Functions::SimpleChebfun::endX(), height, left, right, Mantid::CurveFitting::Functions::SimpleChebfun::roughRoots(), and Mantid::CurveFitting::Functions::SimpleChebfun::startX().

Referenced by setBackToBackExponential().

◆ getPeakLeftRightExtent()

std::pair< double, double > Mantid::CurveFitting::ParameterEstimator::getPeakLeftRightExtent ( double  centre,
const SimpleChebfun der2 
)

Get the peak's extent on either side of the centre.

Parameters
centre:: An approximate peak centre.
der2:: A second derivative of a function.
Returns
:: The left and right boundaries.

Definition at line 165 of file ParameterEstimator.cpp.

References getPeakLeftRightWidth().

Referenced by setBackToBackExponential().

◆ getPeakLeftRightWidth()

std::pair< double, double > Mantid::CurveFitting::ParameterEstimator::getPeakLeftRightWidth ( double  centre,
const SimpleChebfun der2,
size_t  n = 1 
)

Get a measure of peak's width.

It finds approximate zeros of the second derivative of a function. Zeros nearest to the centre are interpreted as the peak's inflection points. The next zero is interpreted as peak boundary.

Parameters
centre:: Approximate peak centre.
der2:: A second derivative of a peak. It is expected to have a minimum at centre.
n:: An order of the zeros to look for. If n == 1 it's the inflection points, if n == 2 it's the boundary.
Returns
:: A pair of zero points on either side of the centre.

Definition at line 134 of file ParameterEstimator.cpp.

References left, n, right, Mantid::CurveFitting::Functions::SimpleChebfun::roughRoots(), and Mantid::CurveFitting::Functions::SimpleChebfun::xPoints().

Referenced by getPeakLeftRightExtent(), and getPeakWidth().

◆ getPeakWidth()

double Mantid::CurveFitting::ParameterEstimator::getPeakWidth ( double  centre,
const SimpleChebfun der2 
)

Estimate a peak width from a second derivative of the data.

Parameters
centre:: Approximate peak centre.
der2:: An approximation to the second derivative.

Definition at line 206 of file ParameterEstimator.cpp.

References fabs, and getPeakLeftRightWidth().

Referenced by setBackToBackExponential(), and setValues().

◆ initFunctionLookup()

void Mantid::CurveFitting::ParameterEstimator::initFunctionLookup ( FunctionMapType functionMapType)

Initializes a FunctionMapType object.

Parameters
functionMapType:: the function map to initialize

Definition at line 38 of file ParameterEstimator.cpp.

Referenced by getFunctionMapType().

◆ needSettingInitialValues()

bool Mantid::CurveFitting::ParameterEstimator::needSettingInitialValues ( const API::IFunction function)

Test if initial values need to be set before fitting.

Parameters
function:: A fitting function to test.

Definition at line 73 of file ParameterEstimator.cpp.

References needSettingInitialValues(), None, and whichFunction().

Referenced by estimate(), and needSettingInitialValues().

◆ setBackToBackExponential()

void Mantid::CurveFitting::ParameterEstimator::setBackToBackExponential ( API::IFunction function,
const SimpleChebfun fun,
const SimpleChebfun der1,
const SimpleChebfun der2 
)

Set initial values to a BackToBackExponential.

Parameters
function:: A fitting BackToBackExponential function.
fun:: A smooth approximation of the fitting data.
der1:: The first derivative of the fitting data.
der2:: The second derivative of the fitting data.

Definition at line 252 of file ParameterEstimator.cpp.

References Mantid::Kernel::Logger::debug(), Mantid::CurveFitting::Functions::SimpleChebfun::derivative(), Mantid::API::IFunction::fix(), Mantid::API::g_log, Mantid::API::IFunction::getParameter(), getPeakCentre(), getPeakHWHM(), getPeakLeftRightExtent(), getPeakWidth(), height, Mantid::CurveFitting::Functions::SimpleChebfun::order(), Mantid::API::IFunction::setParameter(), and sigma.

Referenced by setValues().

◆ setValues()

void Mantid::CurveFitting::ParameterEstimator::setValues ( API::IFunction function,
const SimpleChebfun fun,
const SimpleChebfun der1,
const SimpleChebfun der2 
)

Set initial values to a function if it needs to.

Parameters
function:: A fitting function.
fun:: A smooth approximation of the fitting data.
der1:: The first derivative of the fitting data.
der2:: The second derivative of the fitting data.

Definition at line 356 of file ParameterEstimator.cpp.

References Mantid::API::IFunction::getParameter(), getPeakWidth(), setBackToBackExponential(), Mantid::API::IFunction::setParameter(), setValues(), and whichFunction().

Referenced by estimate(), and setValues().

◆ whichFunction()

Function Mantid::CurveFitting::ParameterEstimator::whichFunction ( const API::IFunction function)

Return a function code for a function if it needs setting values or None otherwise.

Definition at line 60 of file ParameterEstimator.cpp.

References getFunctionMapType(), index, Mantid::API::IFunction::isExplicitlySet(), Mantid::API::IFunction::name(), and None.

Referenced by needSettingInitialValues(), and setValues().

Variable Documentation

◆ g_log

Kernel::Logger Mantid::CurveFitting::ParameterEstimator::g_log("ParameterEstimator") ( "ParameterEstimator"  )

The logger.