Skip to content
Snippets Groups Projects
Commit e22f3529 authored by Verena Reimund's avatar Verena Reimund
Browse files

Enable overlap region for point data

- and precise release notes
- and add a draft usage example

Refs #22197
parent 9d1a62e9
No related merge requests found
...@@ -564,22 +564,14 @@ void Stitch1D::exec() { ...@@ -564,22 +564,14 @@ void Stitch1D::exec() {
const double intersectionMin = intesectionXRegion.get<0>(); const double intersectionMin = intesectionXRegion.get<0>();
const double intersectionMax = intesectionXRegion.get<1>(); const double intersectionMax = intesectionXRegion.get<1>();
double startOverlap = getStartOverlap(intersectionMin, intersectionMax);
double startOverlap; double endOverlap = getEndOverlap(intersectionMin, intersectionMax);
double endOverlap; if (startOverlap > endOverlap) {
if (lhsWS->isHistogramData()) { std::string message = boost::str(
startOverlap = getStartOverlap(intersectionMin, intersectionMax); boost::format("Stitch1D cannot have a StartOverlap > EndOverlap. "
endOverlap = getEndOverlap(intersectionMin, intersectionMax); "StartOverlap: %0.9f, EndOverlap: %0.9f") %
if (startOverlap > endOverlap) { startOverlap % endOverlap);
std::string message = boost::str( throw std::runtime_error(message);
boost::format("Stitch1D cannot have a StartOverlap > EndOverlap. "
"StartOverlap: %0.9f, EndOverlap: %0.9f") %
startOverlap % endOverlap);
throw std::runtime_error(message);
}
} else {
startOverlap = intersectionMin;
endOverlap = intersectionMax;
} }
const bool scaleRHS = this->getProperty("ScaleRHSWorkspace"); const bool scaleRHS = this->getProperty("ScaleRHSWorkspace");
......
...@@ -75,7 +75,7 @@ workspace by this number takes into account its error. ...@@ -75,7 +75,7 @@ workspace by this number takes into account its error.
Usage Usage
----- -----
**Example - a basic example using stitch1D to stitch two workspaces together.** **Example - a basic example using stitch1D to stitch two histogram workspaces together.**
.. plot:: .. plot::
:include-source: :include-source:
...@@ -88,7 +88,7 @@ Usage ...@@ -88,7 +88,7 @@ Usage
"""Creates a Gaussian peak centered on mu and with width sigma.""" """Creates a Gaussian peak centered on mu and with width sigma."""
return (1/ sigma * np.sqrt(2 * np.pi)) * np.exp( - (x-mu)**2 / (2*sigma**2)) return (1/ sigma * np.sqrt(2 * np.pi)) * np.exp( - (x-mu)**2 / (2*sigma**2))
#create two histograms with a single peak in each one # create two histograms with a single peak in each one
x1 = np.arange(-1, 1, 0.02) x1 = np.arange(-1, 1, 0.02)
x2 = np.arange(0.4, 1.6, 0.02) x2 = np.arange(0.4, 1.6, 0.02)
ws1 = CreateWorkspace(UnitX="1/q", DataX=x1, DataY=gaussian(x1[:-1], 0, 0.1)+1) ws1 = CreateWorkspace(UnitX="1/q", DataX=x1, DataY=gaussian(x1[:-1], 0, 0.1)+1)
...@@ -109,6 +109,40 @@ Usage ...@@ -109,6 +109,40 @@ Usage
# uncomment the following line to show the plot window # uncomment the following line to show the plot window
#fig.show() #fig.show()
**Example - a basic example using stitch1D to stitch two point data workspaces together.**
.. plot::
:include-source:
from mantid.simpleapi import *
import matplotlib.pyplot as plt
import numpy as np
def gaussian(x, mu, sigma):
"""Creates a Gaussian peak centered on mu and with width sigma."""
return (1/ sigma * np.sqrt(2 * np.pi)) * np.exp( - (x-mu)**2 / (2*sigma**2))
# create two histograms with a single peak in each one
x1 = np.arange(-1, 1, 0.02)
x2 = np.arange(0.4, 1.6, 0.02)
ws1 = CreateWorkspace(UnitX="1/q", DataX=x1, DataY=gaussian(x1, 0, 0.1)+1)
ws2 = CreateWorkspace(UnitX="1/q", DataX=x2, DataY=gaussian(x2, 1, 0.05)+1)
#stitch the histograms together
stitched, scale = Stitch1D(LHSWorkspace=ws1, RHSWorkspace=ws2, StartOverlap=0.4, EndOverlap=0.6)
# plot the individual workspaces alongside the stitched one
fig, axs = plt.subplots(nrows=1, ncols=2, subplot_kw={'projection':'mantid'})
axs[0].plot(mtd['ws1'], wkspIndex=0, label='ws1')
axs[0].plot(mtd['ws2'], wkspIndex=0, label='ws2')
axs[0].legend()
axs[1].plot(mtd['stitched'], wkspIndex=0, color='k', label='stitched')
axs[1].legend()
# uncomment the following line to show the plot window
#fig.show()
**Example - a practical example using reflectometry data and a scale factor.** **Example - a practical example using reflectometry data and a scale factor.**
.. plot:: .. plot::
......
...@@ -27,7 +27,7 @@ Improved ...@@ -27,7 +27,7 @@ Improved
- :ref:`Maxent <algm-Maxent>` when outputting the results of the iterations, it no longer pads with zeroes but - :ref:`Maxent <algm-Maxent>` when outputting the results of the iterations, it no longer pads with zeroes but
returns as many items as iterations done for each spectrum, making the iterations easy to count. returns as many items as iterations done for each spectrum, making the iterations easy to count.
- XError values (Dx) can now be treated by the following algorithms: :ref:`ConjoinXRuns <algm-ConjoinXRuns>`, :ref:`ConvertToHistogram <algm-ConvertToHistogram>`, :ref:`ConvertToPointData <algm-ConvertToPointData>`, :ref:`CreateWorkspace <algm-CreateWorkspace>`, :ref:`SortXAxis <algm-SortXAxis>`, :ref:`algm-Stitch1D`. - XError values (Dx) can now be treated by the following algorithms: :ref:`ConjoinXRuns <algm-ConjoinXRuns>`, :ref:`ConvertToHistogram <algm-ConvertToHistogram>`, :ref:`ConvertToPointData <algm-ConvertToPointData>`, :ref:`CreateWorkspace <algm-CreateWorkspace>`, :ref:`SortXAxis <algm-SortXAxis>`, :ref:`algm-Stitch1D` (case point data).
- :ref:`Stitch1D <algm-Stitch1D>` can treat point data. - :ref:`Stitch1D <algm-Stitch1D>` can treat point data.
- The algorithm :ref:`SortXAxis <algm-SortXAxis>` has a new input option that allows ascending (default) and descending sorting. The documentation needed to be corrected in general. - The algorithm :ref:`SortXAxis <algm-SortXAxis>` has a new input option that allows ascending (default) and descending sorting. The documentation needed to be corrected in general.
......
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