Commit 3a2d7743 authored by Savici, Andrei T's avatar Savici, Andrei T
Browse files

Merge pull request #15930 from mantidproject/15929_PDFFourierTransForm_errors

Correct with sqrt
parents 465094e4 ab47ad56
......@@ -166,12 +166,11 @@ void PDFFourierTransform::exec() {
// nothing to do
} else if (inputXunit == "dSpacing") {
// convert the x-units to Q/MomentumTransfer
const double PI_2(2. * M_PI);
std::for_each(inputQ.begin(), inputQ.end(),
[&PI_2](double &Q) { Q /= PI_2; });
std::transform(inputDQ.begin(), inputDQ.end(), inputQ.begin(),
inputDQ.begin(), std::divides<double>());
const double PI_2(2. * M_PI);
std::transform(inputQ.begin(), inputQ.end(), inputQ.begin(),
std::bind1st(std::divides<double>(), PI_2));
// reverse all of the arrays
std::reverse(inputQ.begin(), inputQ.end());
std::reverse(inputDQ.begin(), inputDQ.end());
......@@ -209,8 +208,7 @@ void PDFFourierTransform::exec() {
if (soqType == S_OF_Q) {
g_log.information() << "Subtracting one from all values\n";
// there is no error propagation for subtracting one
std::transform(inputFOfQ.begin(), inputFOfQ.end(), inputFOfQ.begin(),
std::bind2nd(std::minus<double>(), 1.));
std::for_each(inputFOfQ.begin(), inputFOfQ.end(), [](double &F) { F--; });
soqType = S_OF_Q_MINUS_ONE;
}
if (soqType == S_OF_Q_MINUS_ONE) {
......@@ -316,8 +314,7 @@ void PDFFourierTransform::exec() {
sinus *= sin(q * rdelta) / (q * rdelta);
}
fs += sinus * inputFOfQ[q_index];
error +=
q * q * (sinus * inputDfOfQ[q_index]) * (sinus * inputDfOfQ[q_index]);
error += (sinus * inputDfOfQ[q_index]) * (sinus * inputDfOfQ[q_index]);
// g_log.debug() << "q[" << i << "] = " << q << " dq = " << deltaq << "
// S(q) =" << s;
// g_log.debug() << " d(gr) = " << temp << " gr = " << gr << std::endl;
......@@ -325,7 +322,7 @@ void PDFFourierTransform::exec() {
// put the information into the output
outputY[r_index] = fs * 2 / M_PI;
outputE[r_index] = error * 2 / M_PI; // TODO: Wrong!
outputE[r_index] = sqrt(error) * 2 / M_PI;
}
// convert to the correct form of PDF
......@@ -348,7 +345,7 @@ void PDFFourierTransform::exec() {
} else if (pdfType == LITTLE_G_OF_R) {
const double factor = 1. / (4. * M_PI * rho0);
for (size_t i = 0; i < outputY.size(); ++i) {
// error propogation - assuming uncertainty in r = 0
// error propagation - assuming uncertainty in r = 0
outputE[i] = outputE[i] / outputR[i];
// transform the data
outputY[i] = 1. + factor * outputY[i] / outputR[i];
......@@ -356,7 +353,7 @@ void PDFFourierTransform::exec() {
} else if (pdfType == RDF_OF_R) {
const double factor = 4. * M_PI * rho0;
for (size_t i = 0; i < outputY.size(); ++i) {
// error propogation - assuming uncertainty in r = 0
// error propagation - assuming uncertainty in r = 0
outputE[i] = outputE[i] * outputR[i];
// transform the data
outputY[i] = outputR[i] * outputY[i] + factor * outputR[i] * outputR[i];
......
......@@ -17,11 +17,19 @@ spectral density :math:`S(Q)`, :math:`S(Q)-1`, or :math:`Q[S(Q)-1]`
The input Workspace spectrum should be in the Q-space (\ **MomentumTransfer**\ ) `units <http://www.mantidproject.org/Units>`_ .
(d-spacing is not supported any more. Contact development team to fix that and enable **dSpacing** again)
References
----------
#. B. H. Toby and T. Egami, *Accuracy of Pair Distribution Functions Analysis Appliced to Crystalline and Non-Crystalline Materials*, Acta Cryst. (1992) A**48**, 336-346
`doi: 10.1107/S0108767391011327 <http://dx.doi.org/10.1107/S0108767391011327>`_
#. B.H. Toby and S. Billinge, *Determination of Standard uncertainities in fits to pair distribution functions* Acta Cryst. (2004) A**60**, 315-317]
`doi: 10.1107/S0108767304011754 <http://dx.doi.org/10.1107/S0108767304011754>`_
.. The algorithm itself is able to identify the unit. -- not any more. TODO: should be investigated why this has been disabled
Output Options:
###############
Output Options
--------------
**G(r)**
'''''''''
......
......@@ -47,6 +47,10 @@ Graphical user interface:
now view the plot in `dSpacing` instead `ToF`, which enables you to
rerun the fitting process after selecting peaks from the interface.
Powder Diffraction
------------------
- :ref:`PDFFourierTransform <algm-PDFFourierTransform>` has been corrected in its calculation of errors.
Imaging
-------
......
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