Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
mantidproject
mantid
Commits
faa7ca4b
Commit
faa7ca4b
authored
Jul 19, 2016
by
Lynch, Vickie
Browse files
Refs #16812 get user script working
parent
6609b3d8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Framework/Algorithms/src/CreatePeaksWorkspace.cpp
View file @
faa7ca4b
...
...
@@ -43,6 +43,7 @@ void CreatePeaksWorkspace::exec() {
Progress
progress
(
this
,
0
,
1
,
NumberOfPeaks
);
out
->
setInstrument
(
instWS
->
getInstrument
());
out
->
mutableRun
().
setGoniometer
(
instWS
->
run
().
getGoniometer
().
getR
(),
false
);
// Create some default peaks
for
(
int
i
=
0
;
i
<
NumberOfPeaks
;
i
++
)
{
out
->
addPeak
(
Peak
(
out
->
getInstrument
(),
...
...
Framework/DataObjects/src/PeaksWorkspace.cpp
View file @
faa7ca4b
...
...
@@ -192,7 +192,19 @@ const Peak &PeaksWorkspace::getPeak(const int peakNum) const {
Geometry
::
IPeak
*
PeaksWorkspace
::
createPeak
(
Kernel
::
V3D
QLabFrame
,
boost
::
optional
<
double
>
detectorDistance
)
const
{
return
new
Peak
(
this
->
getInstrument
(),
QLabFrame
,
detectorDistance
);
Geometry
::
Goniometer
goniometer
=
this
->
run
().
getGoniometer
();
// create a peak using the qLab frame
auto
peak
=
new
Peak
(
this
->
getInstrument
(),
QLabFrame
,
detectorDistance
);
// Set the goniometer
peak
->
setGoniometerMatrix
(
goniometer
.
getR
());
// Take the run number from this
peak
->
setRunNumber
(
this
->
getRunNumber
());
return
peak
;
}
/**
...
...
Framework/PythonInterface/mantid/api/src/Exports/IPeak.cpp
View file @
faa7ca4b
...
...
@@ -2,6 +2,8 @@
#include
"MantidGeometry/Crystal/IPeak.h"
#include
<boost/python/class.hpp>
#include
<boost/python/register_ptr_to_python.hpp>
#include
"MantidPythonInterface/kernel/Converters/PyObjectToMatrix.h"
#include
<boost/optional.hpp>
using
Mantid
::
Geometry
::
IPeak
;
using
namespace
boost
::
python
;
...
...
@@ -9,6 +11,7 @@ using namespace boost::python;
GET_POINTER_SPECIALIZATION
(
IPeak
)
namespace
{
using
namespace
Mantid
::
PythonInterface
;
Mantid
::
Geometry
::
PeakShape_sptr
getPeakShape
(
IPeak
&
peak
)
{
// Use clone to make a copy of the PeakShape.
return
Mantid
::
Geometry
::
PeakShape_sptr
(
peak
.
getPeakShape
().
clone
());
...
...
@@ -33,6 +36,10 @@ void setQSampleFrame2(IPeak &peak, Mantid::Kernel::V3D qSampleFrame,
// Set the qsample frame. Detector distance specified.
return
peak
.
setQSampleFrame
(
qSampleFrame
,
distance
);
}
void
setGoniometerMatrix
(
IPeak
&
self
,
const
object
&
data
)
{
self
.
setGoniometerMatrix
(
Converters
::
PyObjectToMatrix
(
data
)());
}
}
void
export_IPeak
()
{
...
...
@@ -131,6 +138,9 @@ void export_IPeak() {
"Return the # of counts in the bin at its peak"
)
.
def
(
"setBinCount"
,
&
IPeak
::
setBinCount
,
(
arg
(
"self"
),
arg
(
"bin_count"
)),
"Set the # of counts in the bin at its peak"
)
.
def
(
"setGoniometerMatrix"
,
&
setGoniometerMatrix
,
(
arg
(
"self"
),
arg
(
"goniometerMatrix"
)),
"Set the goniometer of the peak"
)
.
def
(
"getRow"
,
&
IPeak
::
getRow
,
arg
(
"self"
),
"For RectangularDetectors only, returns "
"the row (y) of the pixel of the "
...
...
Framework/PythonInterface/test/python/mantid/api/IPeaksWorkspaceTest.py
View file @
faa7ca4b
...
...
@@ -70,11 +70,17 @@ class IPeaksWorkspaceTest(unittest.TestCase):
p
.
setQLabFrame
(
V3D
(
1
,
1
,
1
))
except
Exception
:
self
.
fail
(
"Tried setQLabFrame with one V3D argument"
)
self
.
assertAlmostEquals
(
p
.
getQLabFrame
().
X
(),
-
1.4976057446828845
,
places
=
10
)
self
.
assertAlmostEquals
(
p
.
getQLabFrame
().
Y
(),
0.059904229787315376
,
places
=
10
)
self
.
assertAlmostEquals
(
p
.
getQLabFrame
().
Z
(),
1.4400957702126842
,
places
=
10
)
try
:
p
.
setQLabFrame
(
V3D
(
1
,
1
,
1
),
1
)
except
Exception
:
self
.
fail
(
"Tried setQLabFrame with one V3D argument and a double distance"
)
self
.
assertAlmostEquals
(
p
.
getQLabFrame
().
X
(),
1.0
,
places
=
10
)
self
.
assertAlmostEquals
(
p
.
getQLabFrame
().
Y
(),
1.0
,
places
=
10
)
self
.
assertAlmostEquals
(
p
.
getQLabFrame
().
Z
(),
1.0
,
places
=
10
)
def
test_peak_setQSampleFrame
(
self
):
pws
=
WorkspaceCreationHelper
.
createPeaksWorkspace
(
1
,
True
)
...
...
@@ -83,11 +89,17 @@ class IPeaksWorkspaceTest(unittest.TestCase):
p
.
setQSampleFrame
(
V3D
(
1
,
1
,
1
))
except
Exception
:
self
.
fail
(
"Tried setQSampleFrame with one V3D argument"
)
self
.
assertAlmostEquals
(
p
.
getQSampleFrame
().
X
(),
-
1.4976057446828845
,
places
=
10
)
self
.
assertAlmostEquals
(
p
.
getQSampleFrame
().
Y
(),
0.059904229787315376
,
places
=
10
)
self
.
assertAlmostEquals
(
p
.
getQSampleFrame
().
Z
(),
1.4400957702126842
,
places
=
10
)
try
:
p
.
setQSampleFrame
(
V3D
(
1
,
1
,
1
),
1
)
except
Exception
:
self
.
fail
(
"Tried setQSampleFrame with one V3D argument and a double distance"
)
self
.
assertAlmostEquals
(
p
.
getQSampleFrame
().
X
(),
1.0
,
places
=
10
)
self
.
assertAlmostEquals
(
p
.
getQSampleFrame
().
Y
(),
1.0
,
places
=
10
)
self
.
assertAlmostEquals
(
p
.
getQSampleFrame
().
Z
(),
1.0
,
places
=
10
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment