Skip to content

Commit

Permalink
Changed phase angle range as required by re #5542
Browse files Browse the repository at this point in the history
Signed-off-by: Karl Palmen <karl.palmen@stfc.ac.uk>
  • Loading branch information
KarlPalmen committed Jul 6, 2012
1 parent 9461ead commit b65765e
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
9 changes: 5 additions & 4 deletions Code/Mantid/Framework/CurveFitting/src/Abragam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,11 @@ void Abragam::setActiveParameter(size_t i,double value)
setParameter(j,fabs(value),false); // Make sigma positive
else if (parameterName(j) == "Phi")
{
double a = fmod(value, 2*M_PI); // Put angle in range of 0 to 360 degrees
if( a<0 ) a += 2*M_PI;
setParameter(j,a,false);
}
// Put angle in range of (-180 to 180] degrees
double a = fmod(value, 2*M_PI);
if( a<=-M_PI ) a += 2*M_PI;
if( a>M_PI ) a-= 2*M_PI;
setParameter(j,a,false); }
else
setParameter(j,value,false);
}
Expand Down
8 changes: 5 additions & 3 deletions Code/Mantid/Framework/CurveFitting/src/ExpDecayOsc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,11 @@ void ExpDecayOsc::setActiveParameter(size_t i,double value)
size_t j = i;

if (parameterName(j) == "Phi")
{
double a = fmod(value, 2*M_PI); // Put angle in range of 0 to 360 degrees
if( a<0 ) a += 2*M_PI;
{
// Put angle in range of (-180 to 180] degrees
double a = fmod(value, 2*M_PI);
if( a<=-M_PI ) a += 2*M_PI;
if( a>M_PI ) a-= 2*M_PI;
setParameter(j,a,false);
}
else
Expand Down
9 changes: 5 additions & 4 deletions Code/Mantid/Framework/CurveFitting/src/GausOsc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,11 @@ void GausOsc::setActiveParameter(size_t i,double value)
setParameter(j,fabs(value),false); // Make sigma positive
else if (parameterName(j) == "Phi")
{
double a = fmod(value, 2*M_PI); // Put angle in range of 0 to 360 degrees
if( a<0 ) a += 2*M_PI;
setParameter(j,a,false);
}
// Put angle in range of (-180 to 180] degrees
double a = fmod(value, 2*M_PI);
if( a<=-M_PI ) a += 2*M_PI;
if( a>M_PI ) a-= 2*M_PI;
setParameter(j,a,false); }
else
setParameter(j,value,false);
}
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/CurveFitting/test/GausOscTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ class GausOscTest : public CxxTest::TestSuite
TS_ASSERT_DELTA( out->getParameter("A"), 128.7 ,0.9);
TS_ASSERT_DELTA( out->getParameter("Sigma"), 0.35 ,0.005);
TS_ASSERT_DELTA( out->getParameter("Frequency"), 1/8.0 ,0.01); // Period of 8
TS_ASSERT_DELTA( out->getParameter("Phi"), 3.1415926536/4.0 ,0.01); // 360 + 45 degrees
TS_ASSERT_DELTA( out->getParameter("Phi"), 3.1415926536/4.0 ,0.01); // 45 degrees

// check its categories
const std::vector<std::string> categories = out->categories();
Expand Down

0 comments on commit b65765e

Please sign in to comment.