Commit 5206b27e authored by Whitfield, Ross's avatar Whitfield, Ross
Browse files

Add wavelength parameter to WAND²

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