Commit 941ce153 authored by Owen Arnold's avatar Owen Arnold
Browse files

refs #11056. Fix exposing peak to python.

Keep changes to setQLabFrame as expoesed to python instep with what's changed on the c++ side and test it.
parent 7db86202
......@@ -346,25 +346,14 @@ public:
V3D qLab = qLabDir * wavenumber_in_angstrom_times_tof_in_microsec;
//Peak peak(minimalInstrument, 1 /* detector id */, x[0] /*wavelength*/);
Peak peak; // Everything will be default
peak.setInstrument(minimalInstrument); // Can't do anything without the instrument
peak.setQLabFrame(qLab);
auto detector = peak.getDetector();
TSM_ASSERT("No detector", detector);
if(detector)
{
TS_ASSERT_EQUALS(1, detector->getID());
TS_ASSERT_EQUALS(detectorPos, detector->getPos());
}
// Test that wavelengths aggree firstly.
//TS_ASSERT_EQUALS(x[0], peak.getWavelength());
TS_ASSERT_EQUALS(1, detector->getID());
TS_ASSERT_EQUALS(detectorPos, detector->getPos());
}
/** Create peaks using Q in sample frame + a goniometer rotation matrix*/
......
......@@ -6,9 +6,13 @@ using Mantid::API::IPeak;
using namespace boost::python;
namespace {
Mantid::Geometry::PeakShape_sptr getPeakShape(IPeak& peak) {
// Use clone to make a copy of the PeakShape.
return Mantid::Geometry::PeakShape_sptr(peak.getPeakShape().clone());
Mantid::Geometry::PeakShape_sptr getPeakShape(IPeak &peak) {
// Use clone to make a copy of the PeakShape.
return Mantid::Geometry::PeakShape_sptr(peak.getPeakShape().clone());
}
void setQLabFrame(IPeak &peak, Mantid::Kernel::V3D qLabFrame, double distance) {
// Set the qlab frame
return peak.setQLabFrame(qLabFrame, distance);
}
}
......@@ -38,7 +42,8 @@ void export_IPeak()
"Using the instrument set in the peak, perform ray tracing to find the exact detector.")
.def("getQSampleFrame", &IPeak::getQSampleFrame, "Return the Q change (of the lattice, k_i - k_f) for this peak."
"The Q is in the Sample frame: the goniometer rotation WAS taken out. ")
.def("setQLabFrame", &IPeak::setQLabFrame, "Set the peak using the peak's position in reciprocal space, in the lab frame.")
.def("setQLabFrame", (void (IPeak::*)(Mantid::Kernel::V3D))&IPeak::setQLabFrame)
.def("setQLabFrame", setQLabFrame, "Set the peak using the peak's position in reciprocal space, in the lab frame.")
.def("setQSampleFrame", &IPeak::setQSampleFrame, "Set the peak using the peak's position in reciprocal space, in the sample frame.")
.def("setWavelength", &IPeak::setWavelength, "Set the incident wavelength of the neutron. Calculates the energy from this assuming elastic scattering.")
.def("getWavelength", &IPeak::getWavelength, "Return the incident wavelength")
......
......@@ -51,6 +51,22 @@ class IPeaksWorkspaceTest(unittest.TestCase):
# Peaks workspace will not be integrated by default.
self.assertTrue(not pws.hasIntegratedPeaks())
def test_peak_setQLab(self):
pws = WorkspaceCreationHelper.createPeaksWorkspace(1)
p = pws.getPeak(0)
try:
p.setQLabFrame(V3D(1,1,1))
except Exception:
self.fail("Tried setQLabFrame with one V3D argument")
try:
p.setQLabFrame(V3D(1,1,1), 1)
except Exception:
self.fail("Tried setQLabFrame with one V3D argument and a double distance")
if __name__ == '__main__':
unittest.main()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment