Skip to content

Commit

Permalink
Refs #10235 Replicate calculation quirks of refl_gui.py in new UI
Browse files Browse the repository at this point in the history
  • Loading branch information
Harry Jeffery committed Oct 3, 2014
1 parent d8f487f commit aec9b72
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
Expand Up @@ -4,6 +4,7 @@
#include "MantidGeometry/Instrument/ParameterMap.h"
#include "MantidKernel/Strings.h"
#include "MantidKernel/TimeSeriesProperty.h"
#include "MantidKernel/Utils.h"
#include "MantidQtCustomInterfaces/ReflMainView.h"

#include <boost/regex.hpp>
Expand Down Expand Up @@ -171,7 +172,7 @@ namespace MantidQt
throw std::runtime_error("Value for two theta could not be found in log.");

//Update the model
m_model->String(rowNo, COL_ANGLE) = Strings::toString<double>(thetaVal);
m_model->String(rowNo, COL_ANGLE) = Strings::toString<double>(Utils::roundToDP(thetaVal, 3));
}

//If we need to calculate the resolution, do.
Expand Down Expand Up @@ -346,8 +347,8 @@ namespace MantidQt
try
{
const Instrument_const_sptr instrument = ws->getInstrument();
lmin = instrument->getNumberParameter("LambdaMin")[0];
lmax = instrument->getNumberParameter("LambdaMax")[0];
lmin = instrument->getNumberParameter("LambdaMin")[0] + 1;
lmax = instrument->getNumberParameter("LambdaMax")[0] - 2;
}
catch(std::exception&)
{
Expand All @@ -356,6 +357,11 @@ namespace MantidQt

double qmin = 4 * M_PI / lmax * sin(theta * M_PI / 180.0);
double qmax = 4 * M_PI / lmin * sin(theta * M_PI / 180.0);
qmin = Utils::roundToDP(qmin, 3);
qmax = Utils::roundToDP(qmax, 3);

//The old refl_gui performs this additional calculation on the last workspace of a stitch group
//qmax = 4 * M_PI / ((4 * M_PI / qmax * sin(theta * M_PI / 180)) - 0.5) * sin(theta * M_PI / 180);

std::vector<double> ret;
ret.push_back(qmin);
Expand Down
Expand Up @@ -577,15 +577,15 @@ class ReflLoadedMainViewPresenterTest : public CxxTest::TestSuite

//Check the table was updated as expected
ws = AnalysisDataService::Instance().retrieveWS<ITableWorkspace>("TestWorkspace");
TS_ASSERT_EQUALS(ws->String(0, ThetaCol), "0.70002");
TS_ASSERT_EQUALS(ws->String(0, DQQCol), "0.0340292");
TS_ASSERT_EQUALS(ws->String(0, QMinCol), "0.00903104");
TS_ASSERT_EQUALS(ws->String(0, QMaxCol), "0.153528");
TS_ASSERT_EQUALS(ws->String(0, ThetaCol), "0.7");
TS_ASSERT_EQUALS(ws->String(0, DQQCol), "0.0340301");
TS_ASSERT_EQUALS(ws->String(0, QMinCol), "0.01");
TS_ASSERT_EQUALS(ws->String(0, QMaxCol), "0.077");

TS_ASSERT_EQUALS(ws->String(1, ThetaCol), "2.3");
TS_ASSERT_EQUALS(ws->String(1, DQQCol), "0.0340505");
TS_ASSERT_EQUALS(ws->String(1, QMinCol), "0.0296654");
TS_ASSERT_EQUALS(ws->String(1, QMaxCol), "0.504311");
TS_ASSERT_EQUALS(ws->String(1, QMinCol), "0.034");
TS_ASSERT_EQUALS(ws->String(1, QMaxCol), "0.252");

//Tidy up
AnalysisDataService::Instance().remove("TestWorkspace");
Expand Down

0 comments on commit aec9b72

Please sign in to comment.