\(\renewcommand\AA{\unicode{x212B}}\)
Table of Contents
Name | Direction | Type | Default | Description |
---|---|---|---|---|
InputWorkspaces | Input | str list | Mandatory | List or group of MatrixWorkspaces |
OutputWorkspace | Output | Workspace | Mandatory | Stitched workspace. |
Params | Input | dbl list | Rebinning Parameters, see Rebin algorithm for format. | |
StartOverlaps | Input | dbl list | Start overlaps for stitched workspaces (number of input workspaces minus one). | |
EndOverlaps | Input | dbl list | End overlaps for stitched workspaces (number of input workspaces minus one). | |
ScaleRHSWorkspace | Input | boolean | True | Scaling either with respect to first (first hand side, LHS) or second (right hand side, RHS) workspace. |
UseManualScaleFactors | Input | boolean | False | True to use provided values for the scale factor. |
ManualScaleFactors | Input | dbl list | Either a single scale factor which will be applied to all input workspaces or individual scale factors (number of input workspaces minus one) | |
OutScaleFactors | Output | dbl list | The actual used values for the scaling factors at each stitch step. | |
ScaleFactorFromPeriod | Input | number | 1 | Provided index of period to obtain scale factor from; periods are indexed from 1 and used only if stitching group workspaces, UseManualScaleFactors is true and ManualScaleFactors is set to default. |
IndexOfReference | Input | number | 0 | Index of the workspace to be used as reference for scaling. |
Stitches Matrix Workspaces together outputting a stitched Matrix Workspace. This algorithm is a wrapper over Stitch1D v3.
Please note the different behavior for histogram and point data described in Stitch1D v3. You may consider to run ConvertToHistogram v1 on workspaces prior to passing them to this algorithm.
The algorithm expects pairs of StartOverlaps
and
EndOverlaps
values. The order in which these are provided determines
the pairing. There should be N entries in each of these lists, where N = 1 -
(No. of workspaces to stitch). StartOverlaps and EndOverlaps are in the same
units as the X-axis for the workspace and are optional. For each pair of these
values, the StartOverlaps
value cannot exceed its corresponding
EndOverlaps
value. Furthermore, if either the start or end value is
outside the range of X-axis intersection, they will be forcibly changed to the
intersection min and max respectively.
This algorithm is also capable of stitching together matrix workspaces from multiple workspace groups. In this case, each group must contain the same number of workspaces. The algorithm will stitch together the workspaces in the first group before stitching workspaces from the next group on top of the previous ones.
When stitching the workspaces, either the RHS or LHS workspaces can be scaled.
We can specify manual scale factors to use by setting
UseManualScaleFactors
true and passing values to
ManualScaleFactors
. For group workspaces, we can also use
ScaleFactorFromPeriod
to select a period which will obtain a vector
of scale factors from the selected period. These scale factors are then applied
to all other periods when stitching.
The workspace that provides the scale for stitching output can be chosen by
specifying the desired index through IndexOfReference
property.
The reference workspace will not be scaled, and the other workspaces will be scaled
to match the reference.
The algorithm workflow is as follows:
Stitch1D
algorithm. This stitches each RHS
workspace to the LHS workspace to form a single stitched workspace (LHS to
RHS if ScaleRHSWorkspace is set to false). The resultant workspace and its
scale factor are outputted.ScaleFactorFromPeriod
). This is done only if
UseManualScaleFactors
is true and ManualScaleFactors
is
set to its default value (empty).ScaleFactorFromPeriod
, the algorithm collects the
workspaces belonging to each period across all groups and calls
Stitch1DMany
for each period. As a selection of non-group
workspaces are passed to it, this essential repeats step 2 for each period.
Each of the resultant stitched workspaces stored in a vector while each list
of out scale factors are appended to each other and outputted.GroupWorkspaces
, which groups the workspaces into a single
workspace, which is then outputted.ScaleFactorFromPeriod
, the algorithm calls
Stitch1DMany
for a period specified by
ScaleFactorFromPeriod
and passes the same input workspaces. This
returns a vector of period scale factors obtained by stitching workspaces
from a specific period.Stitch1D
, passing the scale factor from period scale
factors for each period index. Like in step 4, the stitched workspaces are
stored in a vector while the out scale factors are appended and outputted.
Finally step 5 is performed, grouping the workspaces into a single one that
is outputted.In the diagram below, all input parameters other than
InputWorkspaces
, UseManualScaleFactors
,
ManualScaleFactors
and ScaleFactorFromPeriod
have been
omitted as they do not serve any purpose other than to be passed to the
Stitch1DMany
algorithm.
Example - a basic example using Stitch1DMany to stitch three workspaces together.
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 three histograms with a single peak in each one
x1 = np.arange(-1, 1, 0.02)
x2 = np.arange(0.4, 1.6, 0.02)
x3 = np.arange(1.3, 3, 0.02)
ws1 = CreateWorkspace(UnitX="1/q", DataX=x1, DataY=gaussian(x1[:-1], 0, 0.1)+1)
ws2 = CreateWorkspace(UnitX="1/q", DataX=x2, DataY=gaussian(x2[:-1], 1, 0.05)+1)
ws3 = CreateWorkspace(UnitX="1/q", DataX=x3, DataY=gaussian(x3[:-1], 2, 0.08)+1)
# Stitch the histograms together
workspaces = ws1.name() + "," + ws2.name() + "," + ws3.name()
stitched, scale = Stitch1DMany(InputWorkspaces=workspaces, StartOverlaps=[0.4, 1.2], EndOverlaps=[0.6, 1.4], Params=[0.02])
Output:
Example - another example using three group workspaces of two workspaces each.
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 six histograms with a single peak in each one
x1 = np.arange(-1, 1, 0.02)
x3 = np.arange(0.3, 1.8, 0.02)
x5 = np.arange(1.4, 2.8, 0.02)
x2 = np.arange(2.4, 3.5, 0.02)
x4 = np.arange(3.2, 4.9, 0.02)
x6 = np.arange(4.5, 5.2, 0.02)
ws1 = CreateWorkspace(UnitX="1/q", DataX=x1, DataY=gaussian(x1[:-1], 0, 0.1)+1)
ws3 = CreateWorkspace(UnitX="1/q", DataX=x3, DataY=gaussian(x3[:-1], 1, 0.05)+1)
ws5 = CreateWorkspace(UnitX="1/q", DataX=x5, DataY=gaussian(x5[:-1], 2, 0.12)+1)
ws2 = CreateWorkspace(UnitX="1/q", DataX=x2, DataY=gaussian(x2[:-1], 3, 0.08)+1)
ws4 = CreateWorkspace(UnitX="1/q", DataX=x4, DataY=gaussian(x4[:-1], 4, 0.06)+1)
ws6 = CreateWorkspace(UnitX="1/q", DataX=x6, DataY=gaussian(x6[:-1], 5, 0.04)+1)
# Group first, second and third pairs of workspaces
groupWSNames1 = ws1.name() + "," + ws2.name()
gws1 = GroupWorkspaces(InputWorkspaces=groupWSNames1)
groupWSNames2 = ws3.name() + "," + ws4.name()
gws2 = GroupWorkspaces(InputWorkspaces=groupWSNames2)
groupWSNames3 = ws5.name() + "," + ws6.name()
gws3 = GroupWorkspaces(InputWorkspaces=groupWSNames3)
# Stitch together workspaces from each group
workspaceNames = gws1.name() + "," + gws2.name() + "," + gws3.name()
stitched, scale = Stitch1DMany(InputWorkspaces=workspaceNames, StartOverlaps=[0.3, 1.4], EndOverlaps=[3.3, 4.6], Params=[0.02])
Output:
Categories: AlgorithmIndex | Reflectometry
C++ header: Stitch1DMany.h (last modified: 2021-04-07)
C++ source: Stitch1DMany.cpp (last modified: 2021-04-07)