Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feature/9572_documentation_check'
Browse files Browse the repository at this point in the history
  • Loading branch information
KarlPalmen committed Jun 26, 2014
2 parents ebeab29 + e13afe0 commit 35a7f5c
Show file tree
Hide file tree
Showing 35 changed files with 360 additions and 162 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,13 @@ class DLLExport ModeratorTzeroLinear : public API::Algorithm
/// Virtual destructor
virtual ~ModeratorTzeroLinear() {}
/// Algorithm's name
virtual const std::string name() const { return "ModeratorTzeroLinear"; }
///Summary of algorithms purpose
virtual const std::string summary() const {return " Corrects the time of flight of an indirect geometry instrument by a time offset that is linearly dependent on the wavelength of the neutron after passing through the moderator.";}

virtual const std::string name() const;
///Summary of algorithms purpose
virtual const std::string summary() const;
/// Algorithm's version
virtual int version() const { return (1); }
virtual int version() const;
/// Algorithm's category for identification
virtual const std::string category() const { return "CorrectionFunctions\\InstrumentCorrections"; }
virtual const std::string category() const;

private:
//conversion constants applicable to histogram and event workspaces
Expand Down
20 changes: 20 additions & 0 deletions Code/Mantid/Framework/Algorithms/src/ModeratorTzeroLinear.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,26 @@ using namespace Mantid::DataObjects;
// A reference to the logger is provided by the base class, it is called g_log.
// It is used to print out information, warning and error messages

const std::string ModeratorTzeroLinear::name() const
{
return "ModeratorTzeroLinear";
}

const std::string ModeratorTzeroLinear::summary() const
{
return "Corrects the time of flight of an indirect geometry instrument by a time offset that is linearly dependent on the wavelength of the neutron after passing through the moderator.";
}

int ModeratorTzeroLinear::version() const
{
return 1;
}

const std::string ModeratorTzeroLinear::category() const
{
return "CorrectionFunctions\\InstrumentCorrections";
}

void ModeratorTzeroLinear::init()
{
declareProperty(new WorkspaceProperty<MatrixWorkspace>("InputWorkspace","",Direction::Input,boost::make_shared<WorkspaceUnitValidator>("TOF")),
Expand Down
26 changes: 1 addition & 25 deletions Code/Mantid/Framework/DataHandling/src/SetSampleMaterial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,31 +52,7 @@ namespace Mantid
declareProperty(
new WorkspaceProperty<Workspace>("InputWorkspace","",Direction::InOut),
"The workspace with which to associate the sample ");
declareProperty("ChemicalFormula", "", "ChemicalFormula or AtomicNumber must be given. "
"Enter a composition as a molecular formula of \n"
"elements or isotopes. For example, basic "
"elements might be \"H\", \"Fe\" or \"Si\", etc. \n"
"A molecular formula of elements might be "
"\"H4-N2-C3\", which corresponds to a molecule \n"
"with 4 Hydrogen atoms, 2 Nitrogen atoms and "
"3 Carbon atoms. Each element in a molecular \n"
"formula is followed by the number of the atoms "
"for that element, specified _without a hyphen_, \n"
"because each element is separated from other "
"elements using a hyphen. The number of atoms \n"
"can be integer or float, but must start with "
"a digit, e.g. 0.6 is fine but .6 is not. \n"
"Isotopes may also be included in a material "
"composition, and can be specified alone \n"
"(as in \"Li7\"), or in a molecular formula "
"(as in \"(Li7)2-C-H4-N-Cl6\"). Note, however, \n"
"that No Spaces or Hyphens are allowed in an "
"isotope symbol specification. Also Note \n"
"that for isotopes specified in a molecular "
"expression, the isotope must be enclosed \n"
"by parenthesis, except for two special "
"cases, D and T, which stand for H2 and H3, \n"
"respectively.");
declareProperty("ChemicalFormula", "", "ChemicalFormula or AtomicNumber must be given.");
declareProperty("AtomicNumber", 0, "ChemicalFormula or AtomicNumber must be given");
declareProperty("MassNumber", 0, "Mass number if ion (default is 0)");
auto mustBePositive = boost::make_shared<BoundedValidator<double> >();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
Description
-----------

The transmission can be given as a MatrixWorkspace or given directly as
The transmission can be given as a `MatrixWorkspace <http://www.mantidproject.org/MatrixWorkspace>`__ or given directly as
numbers. One or the other method must be used.

See `SANS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,21 @@ Description
Here are examples of input and output from PG3 and SNAP:

.. figure:: /images/PG3_Calibrate.png
:alt: PG3_Calibrate.png

PG3\_Calibrate.png
.. figure:: /images/SNAP_Calibrate.png
:alt: SNAP_Calibrate.png

SNAP\_Calibrate.png
-The purpose of this algorithm is to calibrate the detector pixels and
The purpose of this algorithm is to calibrate the detector pixels and
write a calibration file. The calibration file name contains the
instrument, run number, and date of calibration. A binary Dspacemap file
that converts from TOF to d-space including the calculated offsets is
also an output option. For CrossCorrelation option: If one peak is not
also an output option. For ``CrossCorrelation`` option: If one peak is not
in the spectra of all the detectors, you can specify the first n
detectors to be calibrated with one peak and the next n detectors to be
calibrated with the second peak. If a color fill plot of the calibrated
workspace does not look good, do a color fill plot of the workspace that
ends in cc to see if the CrossCorrelationPoints and/or PeakHalfWidth
should be increased or decreased. Also plot the reference spectra from
the cc workspace.
ends in cc (cross correlation) to see if the ``CrossCorrelationPoints``
and/or ``PeakHalfWidth`` should be increased or decreased. Also plot the
reference spectra from the cc workspace.

Features to improve performance of peak finding
-----------------------------------------------
Expand All @@ -40,18 +36,17 @@ Define peak fit-window

There are two exclusive approaches to define peak's fit-window.

1. *PeakWindowMax*: All peaks will use this value to define their
fitting range.

2. *FitwindowTableWorkspace*: This is a table workspace by which each
peak will have its individual fit window defined.
- ``PeakWindowMax`` All peaks will use this value to define their fitting
range.
- ``FitwindowTableWorkspace`` This is a table workspace by which each peak
will have its individual fit window defined.

Define accepted range of peak's width
#####################################

Optional input property *DetectorResolutionWorkspace* is a matrix
Optional input property ``DetectorResolutionWorkspace`` is a matrix
workspace containing the detector resolution :math:`\Delta(d)/d` for
each spectrum. Combining with property *AllowedResRange*, it defines the
each spectrum. Combining with property ``AllowedResRange``, it defines the
lower and upper limit for accepted fitted peak width.

Let :math:`c_l = AllowedResRange[0]`, :math:`c_h = AllowedResRange[1]`
Expand Down
6 changes: 3 additions & 3 deletions Code/Mantid/docs/source/algorithms/ChangePulsetime-v1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
Description
-----------

Modifies the pulse time (wall-clock time) of all the events in the
specified spectra of an EventWorkspace, by adding the given number of
seconds.
Modifies the pulse time (wall-clock time) of all the events in the specified
spectra of an `EventWorkspace <http://www.mantidproject.org/EventWorkspace>`__, by adding the given number
of seconds as specified with ``TimeOffset``.

.. categories::
3 changes: 2 additions & 1 deletion Code/Mantid/docs/source/algorithms/ClearMaskFlag-v1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Description
-----------

This algorithm clears the mask flag/bit on all spectra of a workspace.
It does not restore masked data.

.. note:: It does not restore masked data.

.. categories::
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,23 @@
Description
-----------

This algorithm takes a Workspace2D with any binning or units as its
input. An event is created for each bin of each histogram, except if the
bin count is 0.0 (unless *GenerateZeros* is true). Infinity and NAN
(not-a-number) values are always skipped.
This algorithm takes a `Workspace2D <http://www.mantidproject.org/Workspace2D>`__
with any binning or units as its input. An event is created for each
bin of each histogram, except if the bin count is 0.0 (unless
``GenerateZeros`` is true). Infinity and NAN (not-a-number) values
are always skipped.

Each event is created with an X position (typically time-of-flight)
equal to the \*\*center\*\* of the bin. The weight and error of the
equal to the **center** of the bin. The weight and error of the
event are taken from the histogram value.

If the *GenerateMultipleEvents* option is set, then instead of a single
If the ``GenerateMultipleEvents`` option is set, then instead of a single
event per bin, a certain number of events evenly distributed along the X
bin are generated. The number of events generated in each bin is
calculated by N = (Y/E)^2. However, it is limited to a max of
*MaxEventsPerBin* and a minimum of 1 event per bin.
``MaxEventsPerBin`` and a minimum of 1 event per bin.

Note that using *GenerateZeros* or *GenerateMultipleEvents* may use a
Note that using ``GenerateZeros`` or ``GenerateMultipleEvents`` may use a
lot of memory!

.. categories::
4 changes: 2 additions & 2 deletions Code/Mantid/docs/source/algorithms/ConvertToHistogram-v1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
Description
-----------

The input workspace must contain point data.
The ``InputWorkspace`` must contain point data.

Once executed, the OutputWorkspace will contain histogram data where the
Once executed, the ``OutputWorkspace`` will contain histogram data where the
bin width is guessed from the spacing between the input X points.

.. categories::
4 changes: 2 additions & 2 deletions Code/Mantid/docs/source/algorithms/ConvertToPointData-v1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
Description
-----------

The input workspace must contain histogram data. Once executed the
OutputWorkspace will contain point data, where the X values are simply
The ``InputWorkspace`` must contain histogram data. Once executed the
``OutputWorkspace`` will contain point data, where the X values are simply
the centre points of the input bins.

.. categories::
38 changes: 22 additions & 16 deletions Code/Mantid/docs/source/algorithms/FindPeakBackground-v1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,27 @@
Description
-----------

Algorithm written using this paper: J. Appl. Cryst. (2013). 46, 663-671

Objective algorithm to separate signal from noise in a
Poisson-distributed pixel data set

T. Straaso/, D. Mueter, H. O. So/rensen and J. Als-Nielsen

Synopsis: A method is described for the estimation of background level
and separation of background pixels from signal pixels in a
Poisson-distributed data set by statistical analysis. For each
iteration, the pixel with the highest intensity value is eliminated from
the data set and the sample mean and the unbiased variance estimator are
calculated. Convergence is reached when the absolute difference between
the sample mean and the sample variance of the data set is within k
standard deviations of the variance, the default value of k being 1. The
k value is called SigmaConstant in the algorithm input.
Algorithm written using the paper referenced below which has a very good
description.

This algorithm estimates the background level and separates the background
from signal data in a Poisson-distributed data set by statistical analysis.
For each iteration, the bins/points with the highest intensity value are
eliminated from the data set and the sample mean and the unbiased variance
estimator are calculated. Convergence is reached when the absolute
difference between the sample mean and the sample variance of the data set
is within k standard deviations of the variance, the default value of k
being 1. The k value is called ``SigmaConstant`` in the algorithm input.

References
----------
**Objective algorithm to separate signal from noise in a Poisson-distributed pixel data set**
by T. |Straaso|, D. Mueter, H. O. |Sorensen| and J. Als-Nielsen Strass
`J. Appl. Cryst. (2013). 46, 663-671 <http://dx.doi.org/10.1107/S0021889813006511>`__

.. |Straaso| unicode:: Straas U+00F8 ..
:ltrim:
.. |Sorensen| unicode:: S U+00F8 rensen ..
:trim:

.. categories::
2 changes: 1 addition & 1 deletion Code/Mantid/docs/source/algorithms/MaskDetectorsIf-v1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ Description
Iterates over the input workspace evaluating the test for each single
value spectrum. If the detectors should be masked it deselects all of
the contributing detectors in the output calfile. All other aspects of
the InputCalFile are copied over to the OutputCalFile.
the ``InputCalFile`` are copied over to the ``OutputCalFile``.

.. categories::
86 changes: 46 additions & 40 deletions Code/Mantid/docs/source/algorithms/ModeratorTzero-v1.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,64 +9,70 @@
Description
-----------

| Corrects the time of flight (TOF) by a time offset that is dependent
Corrects the time of flight (TOF) by a time offset that is dependent
on the energy of the neutron after passing through the moderator. A
heuristic formula for the correction is stored in the instrument
definition file. Below is shown the entry in the instrument file for the
VISION beamline:
| <!-- formula for t0 calculation. See
http://muparser.sourceforge.net/mup\_features.html#idDef2 for available
operators-->

| `` <parameter name="t0_formula" type="string">``
| ``  <value val="(incidentEnergy < 34.7332) ? 37.011296*incidentEnergy^(-0.052874) : (incidentEnergy < 88.7556) ? 124.267307*incidentEnergy^(-0.394282) : (incidentEnergy < 252.471) ? 963.775145*incidentEnergy^(-0.850919) : (incidentEnergy < 420.145) ? 33.225834*incidentEnergy^(-0.242105) : (incidentEnergy < 100000.0) ? 120.569231*incidentEnergy^(-0.455477) : 0.0" />``
| ``</parameter>``
| The recorded :math:`TOF = t_0 + t_i + t_f` with
| :math:`t_0`: emission time from the moderator
| :math:`t_1`: time from moderator to sample or monitor
| :math:`t_2`: time from sample to detector
| This algorithm will replace :math:`TOF` with
:math:`TOF^* = TOF-t_0 = t_i+t_f`

| For a direct geometry instrument, the incident energy :math:`E_1` is

.. code-block:: xml
<!-- formula for t0 calculation. See http://muparser.sourceforge.net/mup_features.html#idDef2 for available operators-->
<parameter name="t0_formula" type="string">
<value val="(incidentEnergy < 34.7332) ? 37.011296*incidentEnergy^(-0.052874) : (incidentEnergy < 88.7556) ? 124.267307*incidentEnergy^(-0.394282) : (incidentEnergy < 252.471) ? 963.775145*incidentEnergy^(-0.850919) : (incidentEnergy < 420.145) ? 33.225834*incidentEnergy^(-0.242105) : (incidentEnergy < 100000.0) ? 120.569231*incidentEnergy^(-0.455477) : 0.0" />
</parameter>
The recorded :math:`TOF = t_0 + t_i + t_f` with

- :math:`t_0`: emission time from the moderator
- :math:`t_1`: time from moderator to sample or monitor
- :math:`t_2`: time from sample to detector

This algorithm will replace :math:`TOF` with :math:`TOF^* = TOF-t_0 = t_i+t_f`

For a direct geometry instrument, the incident energy :math:`E_1` is
the same for all neutrons. Hence, the moderator emission time is the
same for all neutrons. For an indirect geometry instrument, :math:`E_1`
is different for each neutron and is not known. However, the final
energy :math:`E_2` selected by the analyzers is known.
| :math:`t_0 = func(E_1)` , a function of the incident energy
| :math:`t_1 = L_1/v_1` with :math:`L_1` the distance from moderator to
sample, and :math:`v_1` the initial unknown velocity (
:math:`E_1=1/2*m*v_1^2`)
| :math:`t_2 = L_2/v_2` with :math:`L_2` the distance from sample to
detector, and :math:`v_2` is the final fixed velocity (
:math:`E_2=1/2*m*v_2^2`)

| **Note:** We obtain :math:`TOF^*` as an iterative process, taking into
account the fact that the correction :math:`t_0` is much smaller than
:math:`t_i+t_f`. Thus
| :math:`TOF-t_0^{(n)} = L_1/v_1^{(n)} + L_2/v_2` , n=0, 1, 2,..
| Set :math:`t_0^{(0)}=0` and obtain :math:`v_1^{(0)}` from the previous
formula. From :math:`v_1^{(0)}` we obtain :math:`E_1^{(0)}`
| Set :math:`t_0^{(1)}=func( E_1^{(0)} )` and repeat the steps until
:math:`|t_0^{(n+1)} - t_0^{(n+1)}| < tolTOF`. With
tolTOF=0.1microsecond, only one iteration is needed for convergence.

- :math:`t_0 = func(E_1)` , a function of the incident energy
- :math:`t_1 = L_1/v_1` with :math:`L_1` the distance from moderator to
sample, and :math:`v_1` the initial unknown velocity (:math:`E_1=1/2*m*v_1^2`)
- :math:`t_2 = L_2/v_2` with :math:`L_2` the distance from sample to
detector, and :math:`v_2` is the final fixed velocity (:math:`E_2=1/2*m*v_2^2`)

.. note:: We obtain :math:`TOF^*` as an iterative process,
taking into account the fact that the correction :math:`t_0` is much
smaller than :math:`t_i+t_f`. Thus
:math:`TOF-t_0^{(n)} = L_1/v_1^{(n)} + L_2/v_2` , :math:`n=0, 1, 2,..`
Set :math:`t_0^{(0)}=0` and obtain :math:`v_1^{(0)}` from the previous
formula. From :math:`v_1^{(0)}` we obtain :math:`E_1^{(0)}`
Set :math:`t_0^{(1)}=func( E_1^{(0)} )` and repeat the steps until
:math:`|t_0^{(n+1)} - t_0^{(n+1)}| < tolTOF`. With
:math:`tolTOF=0.1 microsecond`, only one iteration is needed for convergence.

Here's the result of applying ModeratorTzero to both the event list and
the histogrammed data of a run in the VISION beamline. The
transformation of either events or histograms shifts the curve to
smaller TOF's. The transformed curves are not supposed to be identical,
but similar and differenciated from the original curve.

+---------------------------------------------------------------------------------------+----------------+---------------------------------------------------------------------------------------+--------------+---------------------------------------------------------------------------------------+--------------+
| Sumed Histogram | Elastic Line | Inelastic Peaks |
+=======================================================================================+================+=======================================================================================+==============+=======================================================================================+==============+
| [[`File:ModeratorTzero\_Fig.1.jpeg\|200px <File:ModeratorTzero_Fig.1.jpeg|200px>`__ | center\|]] | [[`File:ModeratorTzero\_Fig.2.jpeg\|200px <File:ModeratorTzero_Fig.2.jpeg|200px>`__ | center\|]] | [[`File:ModeratorTzero\_Fig.3.jpeg\|200px <File:ModeratorTzero_Fig.3.jpeg|200px>`__ | center\|]] |
+---------------------------------------------------------------------------------------+----------------+---------------------------------------------------------------------------------------+--------------+---------------------------------------------------------------------------------------+--------------+
.. figure:: /images/ModeratorTzero_Fig.1.jpeg
:width: 400px
:alt: Summed Histogram

.. figure:: /images/ModeratorTzero_Fig.2.jpeg
:width: 400px
:alt: Elastic Line

.. figure:: /images/ModeratorTzero_Fig.3.jpeg
:width: 400px
:alt: Inelastic Peaks

For indirect instruments featuring an incoming neutron flux having a
sufficiently narrow distribution of energies, a linear relationship
between t\_0 and the wavelength of the incoming neutron can be
between :math:`t_0` and the wavelength of the incoming neutron can be
established. This relation allows for coding of an algorithm with faster
execution times. For indirect instruments that comply with these
conditions, use of :ref:`algm-ModeratorTzeroLinear` is
Expand Down
Loading

0 comments on commit 35a7f5c

Please sign in to comment.