Skip to content

Commit

Permalink
Refs #5027. Changed name to fwhm.
Browse files Browse the repository at this point in the history
  • Loading branch information
peterfpeterson committed Mar 27, 2012
1 parent 875ce63 commit 0d3c843
Show file tree
Hide file tree
Showing 31 changed files with 87 additions and 88 deletions.
4 changes: 2 additions & 2 deletions Code/Mantid/Framework/API/inc/MantidAPI/IPeakFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ class MANTID_API_DLL IPeakFunction : public IFunctionWithLocation
/// Constructor
IPeakFunction();
/// Returns the peak FWHM
virtual double width()const = 0;
virtual double fwhm()const = 0;

/// Sets the parameters such that FWHM = w
virtual void setWidth(const double w) = 0;
virtual void setFwhm(const double w) = 0;

/// General implementation of the method for all peaks.
void functionMW(double* out, const double* xValues, const size_t nData)const;
Expand Down
4 changes: 2 additions & 2 deletions Code/Mantid/Framework/API/src/IPeakFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ IPeakFunction::IPeakFunction()
void IPeakFunction::functionMW(double* out, const double* xValues, const size_t nData)const
{
double c = this->centre();
double dx = fabs(s_peakRadius*this->width());
double dx = fabs(s_peakRadius*this->fwhm());
int i0 = -1;
int n = 0;
for(size_t i = 0; i < nData; ++i)
Expand Down Expand Up @@ -106,7 +106,7 @@ void IPeakFunction::functionMW(double* out, const double* xValues, const size_t
void IPeakFunction::functionDerivMW(Jacobian* out, const double* xValues, const size_t nData)
{
double c = this->centre();
double dx = fabs(s_peakRadius*this->width());
double dx = fabs(s_peakRadius*this->fwhm());
int i0 = -1;
int n = 0;
for(size_t i = 0; i < nData; ++i)
Expand Down
4 changes: 2 additions & 2 deletions Code/Mantid/Framework/API/test/CompositeFunctionTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class Gauss: public IPeakFunction, public CompositeFunctionTest_IFunction
return getParameter(1);
}

double width()const
double fwhm()const
{
return getParameter(2);
}
Expand All @@ -152,7 +152,7 @@ class Gauss: public IPeakFunction, public CompositeFunctionTest_IFunction
setParameter(1,h);
}

void setWidth(const double w)
void setFwhm(const double w)
{
setParameter(2,w);
}
Expand Down
4 changes: 2 additions & 2 deletions Code/Mantid/Framework/API/test/ParameterTieTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class ParameterTieTest_Gauss: public IPeakFunction
return getParameter(1);
}

double width()const
double fwhm()const
{
return getParameter(2);
}
Expand All @@ -72,7 +72,7 @@ class ParameterTieTest_Gauss: public IPeakFunction
setParameter(1,h);
}

void setWidth(const double w)
void setFwhm(const double w)
{
setParameter(2,w);
}
Expand Down
5 changes: 2 additions & 3 deletions Code/Mantid/Framework/Algorithms/src/FindPeaks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1214,7 +1214,6 @@ void FindPeaks::addRow(const int spectrum, const std::vector<double> &params, co
* @param effParams This will always be centre, width, height, backA0, backA1, backA2 reguarless of how many
* parameters the function actually has.
* @param rawParams The actual parameters of the fit function.
* @param peakFuncType Since this is a static method.
*/
void getComponentFunctions(IFitFunction_sptr compositeFunc, std::vector<double> &effParams, std::vector<double> &rawParams, const std::string & peakFuncType)
{
Expand Down Expand Up @@ -1257,7 +1256,7 @@ void getComponentFunctions(IFitFunction_sptr compositeFunc, std::vector<double>
if (peakFuncType.compare("Gaussian") == 0) // TODO stupid hack because "width" is FWHM rather than sigma
effParams[1] = peakFunc->getParameter(2);
else
effParams[1] = peakFunc->width();
effParams[1] = peakFunc->fwhm();
effParams[2] = peakFunc->height();
}
if (backFunc)
Expand Down Expand Up @@ -1369,7 +1368,7 @@ IFitFunction_sptr FindPeaks::createFunction(const double height, const double ce
IPeakFunction *peakFunc = dynamic_cast<IPeakFunction *>(tempPeakFunc);
peakFunc->setHeight(height);
peakFunc->setCentre(centre);
peakFunc->setWidth(sigma);
peakFunc->setFwhm(sigma);

// put the two together and return
CompositeFunctionMW* fitFunc = new CompositeFunctionMW();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ namespace Mantid
peak->setHeight(peakHeight);
peak->setCentre(peakLoc);
const double sigma(10.0);
peak->setWidth(2.0*std::sqrt(2.0*std::log(2.0))*sigma);
peak->setFwhm(2.0*std::sqrt(2.0*std::log(2.0))*sigma);

CompositeFunctionMW* fitFunc = new CompositeFunctionMW(); //Takes ownership of the functions
fitFunc->addFunction(background);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ namespace Mantid
/// overwrite IPeakFunction base class methods
virtual double centre()const {return getParameter("X0");};
virtual double height()const {return getParameter("I");}; // note height can likely be defined more accurately, here set equal to intensity
virtual double width()const {return 2*getParameter("S");}; // can likely be defined more accurately
virtual double fwhm()const {return 2*getParameter("S");}; // can likely be defined more accurately
virtual void setCentre(const double c) {setParameter("X0",c);};
virtual void setHeight(const double h) {setParameter("I",h);};
virtual void setWidth(const double w) {setParameter("S",w/2.0);};
virtual void setFwhm(const double w) {setParameter("S",w/2.0);};


/// overwrite IFunction base class methods
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ namespace Mantid
/// overwrite IPeakFunction base class methods
virtual double centre()const {return 0;}
virtual double height()const {return getParameter("Height");}
virtual double width()const {return 0;}
virtual double fwhm()const {return 0;}
virtual void setCentre(const double c) { UNUSED_ARG(c); }
virtual void setHeight(const double h) {setParameter("Height",h);}
virtual void setWidth(const double w) { UNUSED_ARG(w); }
virtual void setFwhm(const double w) { UNUSED_ARG(w); }
virtual double HeightPrefactor()const { return 1.0; } //modulates the Height of the Delta function
/// overwrite IFunction base class methods
std::string name()const{return "DeltaFunction";}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ namespace Mantid
/// overwrite IPeakFunction base class methods
virtual double centre()const {return getParameter("PeakCentre");}
virtual double height()const {return getParameter("Height");}
virtual double width()const {return 2.0*sqrt(2.0*std::log(2.0))*getParameter("Sigma");}
virtual double fwhm()const {return 2.0*sqrt(2.0*std::log(2.0))*getParameter("Sigma");}
virtual void setCentre(const double c) {setParameter("PeakCentre",c);}
virtual void setHeight(const double h) {setParameter("Height",h);}
virtual void setWidth(const double w) {setParameter("Sigma",w/(2.0*sqrt(2.0*std::log(2.0))));}
virtual void setFwhm(const double w) {setParameter("Sigma",w/(2.0*sqrt(2.0*std::log(2.0))));}


/// overwrite IFunction base class methods
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ namespace Mantid
/// overwrite IPeakFunction base class methods
virtual double centre()const;
virtual double height()const;
virtual double width()const;
virtual double fwhm()const;
virtual void setCentre(const double c);
virtual void setHeight(const double h);
virtual void setWidth(const double w);
virtual void setFwhm(const double w);

/// overwrite IFunction base class methods
std::string name()const{return "IkedaCarpenterPV";}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ namespace Mantid
/// overwrite IPeakFunction base class methods
virtual double centre()const {return getParameter("PeakCentre");}
virtual double height()const {return getParameter("Height");}
virtual double width()const {return 2*getParameter("HWHM");}
virtual double fwhm()const {return 2*getParameter("HWHM");}
virtual void setCentre(const double c) {setParameter("PeakCentre",c);}
virtual void setHeight(const double h) {setParameter("Height",h);}
virtual void setWidth(const double w) {setParameter("HWHM",w/2.0);}
virtual void setFwhm(const double w) {setParameter("HWHM",w/2.0);}


/// overwrite IFunction base class methods
Expand Down
4 changes: 2 additions & 2 deletions Code/Mantid/Framework/CurveFitting/src/IkedaCarpenterPV.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ double IkedaCarpenterPV::height()const
return h0;
};

double IkedaCarpenterPV::width()const
double IkedaCarpenterPV::fwhm()const
{
double sigmaSquared = getParameter("SigmaSquared");
double gamma = getParameter("Gamma");
Expand All @@ -89,7 +89,7 @@ double IkedaCarpenterPV::width()const
return sqrt(8.0*M_LN2*sigmaSquared)+gamma;
};

void IkedaCarpenterPV::setWidth(const double w)
void IkedaCarpenterPV::setFwhm(const double w)
{
setParameter("SigmaSquared", w*w/(32.0*M_LN2)); // used 4.0 * 8.0 = 32.0
setParameter("Gamma", w/2.0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class CurveFittingGauss: public IPeakFunction, public ITestFunction
return getParameter(1);
}

double width()const
double fwhm()const
{
return getParameter(2);
}
Expand All @@ -90,7 +90,7 @@ class CurveFittingGauss: public IPeakFunction, public ITestFunction
setParameter(1,h);
}

void setWidth(const double w)
void setFwhm(const double w)
{
setParameter(2,w);
}
Expand Down
4 changes: 2 additions & 2 deletions Code/Mantid/Framework/CurveFitting/test/ConvolutionTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class ConvolutionTest_Gauss: public IPeakFunction
return getParameter(1);
}

double width()const
double fwhm()const
{
return getParameter(2);
}
Expand All @@ -100,7 +100,7 @@ class ConvolutionTest_Gauss: public IPeakFunction
setParameter(1,h);
}

void setWidth(const double w)
void setFwhm(const double w)
{
setParameter(2,w);
}
Expand Down
4 changes: 2 additions & 2 deletions Code/Mantid/Framework/CurveFitting/test/DeltaFunctionTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class DeltaFunctionTest_Gauss: public IPeakFunction
return getParameter(1);
}

double width()const
double fwhm()const
{
return getParameter(2);
}
Expand All @@ -80,7 +80,7 @@ class DeltaFunctionTest_Gauss: public IPeakFunction
setParameter(1,h);
}

void setWidth(const double w)
void setFwhm(const double w)
{
setParameter(2,w);
}
Expand Down
4 changes: 2 additions & 2 deletions Code/Mantid/Framework/CurveFitting/test/DiffSphereTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class DiffSphereTest_Gauss: public IPeakFunction
return getParameter(1);
}

double width()const
double fwhm()const
{
return getParameter(2);
}
Expand All @@ -81,7 +81,7 @@ class DiffSphereTest_Gauss: public IPeakFunction
setParameter(1,h);
}

void setWidth(const double w)
void setFwhm(const double w)
{
setParameter(2,w);
}
Expand Down
4 changes: 2 additions & 2 deletions Code/Mantid/Framework/CurveFitting/test/FitTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class FitTest_Gauss: public IPeakFunction
return getParameter(1);
}

double width()const
double fwhm()const
{
return getParameter(2);
}
Expand All @@ -104,7 +104,7 @@ class FitTest_Gauss: public IPeakFunction
setParameter(1,h);
}

void setWidth(const double w)
void setFwhm(const double w)
{
setParameter(2,w);
}
Expand Down
4 changes: 2 additions & 2 deletions Code/Mantid/Framework/CurveFitting/test/FunctionTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class FunctionTestGauss: public IPeakFunction
return getParameter(1);
}

double width()const
double fwhm()const
{
return getParameter(2);
}
Expand All @@ -81,7 +81,7 @@ class FunctionTestGauss: public IPeakFunction
setParameter(1,h);
}

void setWidth(const double w)
void setFwhm(const double w)
{
setParameter(2,w);
}
Expand Down

0 comments on commit 0d3c843

Please sign in to comment.