Skip to content
Snippets Groups Projects
Commit fe508fd0 authored by Dan Nixon's avatar Dan Nixon
Browse files

Added documentation and error handing when no peaks found

Refs #6971
parent d4c4f8ca
No related branches found
No related tags found
No related merge requests found
......@@ -16,7 +16,7 @@ class TOSCABankCorrection(DataProcessorAlgorithm):
def category(self):
return 'PythonAlgorithms;Inelastic'
return 'PythonAlgorithms;Inelastic;CorrectionFunctions'
def summary(self):
......@@ -28,7 +28,8 @@ class TOSCABankCorrection(DataProcessorAlgorithm):
direction=Direction.Input),
doc='Input reduced workspace')
self.declareProperty(FloatArrayProperty(name='SearchRange'),
self.declareProperty(FloatArrayProperty(name='SearchRange',
values=[200, 2000]),
doc='Range over which to find peaks')
self.declareProperty(name='ClosePeakTolerance', defaultValue=20.0,
......@@ -92,6 +93,11 @@ class TOSCABankCorrection(DataProcessorAlgorithm):
peaks = self._get_peaks('__search_ws')
DeleteWorkspace('__search_ws')
# Ensure there is at least one peak found
if len(peaks) < 1:
raise RuntimeError('Could not find any peaks. Try increasing \
width of SearchRange and/or ClosePeakTolerance')
delta = self._get_delta(peaks)
offset = delta / 2
......
.. algorithm::
.. summary::
.. alias::
.. properties::
Description
-----------
This algorithm attempts to automatically correct TOSCA data in which the
position of the sample has been moved and has affected the alignment of features
on the spectra from forward and backscattering detector banks.
The input workspace should be an energy transfer reduction, for the default
values of SearchRange and ClosePeakTolerance the X axis is assumed to be in
cm-1, however the X axis is not restricted to this unit.
The algorithm works by finding peaks of a given shape (using the :ref:`FindPeaks
<algm-FindPeaks>`) on both the forward and backscattering banks and attempting
to match them to what is believed to be the same feature on the other bank.
The choice can then be made to either take the difference in peak centre between
the tallest matched peaks or to average the difference of all matched peaks to
determine the mount that both spectra must be moved by to correct for the change
in sample position.
The data is then corrected by providing a shift in the X axis of each bank
spectra (using :ref:`ConvertAxisByFormula <algm-ConvertAxisByFormula>`) to bring
the two individual bank spectra back into alignment.
The corrected spectra are then rebinned to the input workspace (using
:ref:`RebinToWorkspace <algm-RebinToWorkspace>`) to preserve the X range and to
maintain bin alignment.
.. categories::
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment