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
5206b27e
Commit
5206b27e
authored
May 21, 2018
by
Whitfield, Ross
Browse files
Add wavelength parameter to WAND²
And make use of wavelength parameter in FindPeaksMD and PeaksWorkspace.
parent
0ea8f261
Changes
4
Hide whitespace changes
Inline
Side-by-side
Framework/DataObjects/src/PeaksWorkspace.cpp
View file @
5206b27e
...
...
@@ -285,18 +285,20 @@ Peak *PeaksWorkspace::createPeakQSample(const V3D &position) const {
Geometry
::
Goniometer
goniometer
;
LogManager_const_sptr
props
=
getLogs
();
if
(
props
->
hasProperty
(
"wavelength"
)
||
props
->
hasProperty
(
"energy"
))
{
// Assume constant wavelenth
// Calculate Q lab from Q sample and wavelength
double
wavelength
;
if
(
props
->
hasProperty
(
"energy"
))
{
wavelength
=
Kernel
::
UnitConversion
::
run
(
"Energy"
,
"Wavelength"
,
props
->
getPropertyValueAsType
<
double
>
(
"energy"
),
0
,
0
,
0
,
Kernel
::
DeltaEMode
::
Elastic
,
0
);
}
else
{
wavelength
=
props
->
getPropertyValueAsType
<
double
>
(
"wavelength"
);
}
// See if we can get a wavelength/energy
// Then assume constant wavelenth
double
wavelength
(
0
);
if
(
props
->
hasProperty
(
"wavelength"
))
{
wavelength
=
props
->
getPropertyValueAsType
<
double
>
(
"wavelength"
);
}
else
if
(
props
->
hasProperty
(
"energy"
))
{
wavelength
=
Kernel
::
UnitConversion
::
run
(
"Energy"
,
"Wavelength"
,
props
->
getPropertyValueAsType
<
double
>
(
"energy"
),
0
,
0
,
0
,
Kernel
::
DeltaEMode
::
Elastic
,
0
);
}
else
if
(
getInstrument
()
->
hasParameter
(
"wavelength"
))
{
wavelength
=
getInstrument
()
->
getNumberParameter
(
"wavelength"
).
at
(
0
);
}
if
(
wavelength
>
0
)
{
goniometer
.
calcFromQSampleAndWavelength
(
position
,
wavelength
);
g_log
.
information
()
<<
"Found goniometer rotation to be "
<<
goniometer
.
getEulerAngles
()[
0
]
...
...
Framework/MDAlgorithms/src/FindPeaksMD.cpp
View file @
5206b27e
...
...
@@ -197,7 +197,8 @@ void FindPeaksMD::init() {
auto
nonNegativeDbl
=
boost
::
make_shared
<
BoundedValidator
<
double
>>
();
nonNegativeDbl
->
setLower
(
0
);
declareProperty
(
"Wavelength"
,
DBL_MAX
,
nonNegativeDbl
,
"Wavelength to use when calculating goniometer angle"
);
"Wavelength to use when calculating goniometer angle. If not"
"set will use the wavelength parameter on the instrument."
);
setPropertySettings
(
"Wavelength"
,
make_unique
<
EnabledWhenProperty
>
(
...
...
@@ -296,6 +297,16 @@ FindPeaksMD::createPeak(const Mantid::Kernel::V3D &Q, const double binCount,
if
(
calcGoniometer
)
{
// Calculate Q lab from Q sample and wavelength
double
wavelength
=
getProperty
(
"Wavelength"
);
if
(
wavelength
==
DBL_MAX
)
{
if
(
inst
->
hasParameter
(
"wavelength"
))
{
wavelength
=
inst
->
getNumberParameter
(
"wavelength"
).
at
(
0
);
}
else
{
throw
std
::
runtime_error
(
"Could not get wavelength, neither Wavelength algorithm property "
"set nor instrument wavelength parameter"
);
}
}
Geometry
::
Goniometer
goniometer
;
goniometer
.
calcFromQSampleAndWavelength
(
Q
,
wavelength
);
g_log
.
information
()
<<
"Found goniometer rotation to be "
...
...
@@ -757,11 +768,6 @@ std::map<std::string, std::string> FindPeaksMD::validateInputs() {
"as the input."
;
}
double
wavelength
=
getProperty
(
"Wavelength"
);
if
(
getProperty
(
"CalculateGoniometerForCW"
)
&&
wavelength
==
DBL_MAX
)
result
[
"Wavelength"
]
=
"Must set wavelength when using CalculateGoniometerForCW option"
;
return
result
;
}
...
...
docs/source/concepts/PeaksWorkspace.rst
View file @
5206b27e
...
...
@@ -53,14 +53,15 @@ Calculate Goniometer For Constant Wavelength
--------------------------------------------
If you set the `wavelength` (in Å) or `energy` (in meV) property on a
PeaksWorkspace when the createPeak method is used the goniometer
rotation with be calculated. This allows you to use one instrument
definition for multiple goniometer rotations, for example adding peaks
in Slice Viewer from multiple combined MD workspaces. It only works
for a constant wavelength source and only for Q sample workspaces. It
also assumes the goniometer rotation is around the y-axis only. For
details on the calculation see "Calculate Goniometer For Constant
Wavelength" at :ref:`FindPeaksMD <algm-FindPeaksMD>`.
PeaksWorkspace, or if the instrument on the PeaksWorkspace has the
`wavelength` parameter, the goniometer rotation will be calculated
when the createPeak method is used. This allows you to use one
instrument definition for multiple goniometer rotations, for example
adding peaks in Slice Viewer from multiple combined MD workspaces. It
only works for a constant wavelength source and only for Q sample
workspaces. It also assumes the goniometer rotation is around the
y-axis only. For details on the calculation see "Calculate Goniometer
For Constant Wavelength" at :ref:`FindPeaksMD <algm-FindPeaksMD>`.
.. code-block:: python
...
...
instrument/WAND_Parameters.xml
View file @
5206b27e
<?xml version="1.0" encoding="UTF-8" ?>
<parameter-file
instrument=
"WAND"
valid-from=
"2017-12-01 00:00:00"
>
<component-link
name=
"WAND"
>
<parameter
name=
"wavelength"
type=
"float"
>
<value
val=
"1.488"
/>
</parameter>
<parameter
name=
"sample_logs_sum"
type=
"string"
>
<value
val=
"duration"
/>
</parameter>
...
...
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