AppendSpectra v1#
Summary#
Join two workspaces together by appending their spectra.
See Also#
Properties#
Name |
Direction |
Type |
Default |
Description |
|---|---|---|---|---|
InputWorkspace1 |
Input |
Mandatory |
The name of the first input workspace |
|
InputWorkspace2 |
Input |
Mandatory |
The name of the second input workspace |
|
ValidateInputs |
Input |
boolean |
True |
Perform a set of checks that the two input workspaces are compatible. |
Number |
Input |
number |
1 |
Append the spectra from InputWorkspace2 multiple times. |
OutputWorkspace |
Output |
Mandatory |
The name of the output workspace |
|
MergeLogs |
Input |
boolean |
False |
Whether to combine the logs of the two input workspaces |
AppendYAxisLabels |
Input |
boolean |
False |
Whether to append y axis labels; this is done automatically if there is spectra overlap |
RewriteSpectraMap |
Input |
boolean |
False |
Rewrites the detectorID associated with each spectrum, moving each detector to the position on the original workspace |
Description#
This algorithm appends the spectra of two workspaces together.
The output workspace from this algorithm will be a copy of the first input workspace, to which the data from the second input workspace will be appended.
Workspace data members other than the data (e.g. instrument etc.) will be copied from the first input workspace (but if they’re not identical anyway, then you probably shouldn’t be using this algorithm!).
Restrictions on the input workspace#
For an EventWorkspace, there are no restrictions on
the input workspaces if ValidateInputs=false.
For Workspace2D, the number of bins must be the same
in both inputs.
Mixing workspace types is not allowed.
Additionally, if ValidateInputs is selected, then the input workspaces are also required to:
Come from the same instrument
Have common units
Have common bin boundaries
Spectrum Numbers#
If there is an overlap in the spectrum numbers of both inputs, then the output workspace will have its spectrum numbers reset starting at 0 and increasing by 1 for each spectrum. In addition, the y-axis value will be copied from previous workspaces in order of the first workspace then the second workspace.
Note that when spectra numbers do not overlap, it doesn’t automatically imply that y-axis values are carried over from previous workspaces. To address this, use the ‘AppendYAxisLabels’ option. This will combine y-axis values from two input workspaces into the new output workspace, arranging them in the order of the first workspace followed by the second. In addition, the axes should have the same type.
Rewrite Spectra Map#
Some instruments have moveable detector banks and a frequently used workflow is to make two measurements with the detector banks at slightly offset positions
such that gaps between the detector tubes are covered. AppendSpectra combines the two runs only using the detector map from the first run.
Thus spectra from the second run, although having the correct detector IDs, have the incorrect position.
Setting RewriteSpectraMap to True will rewrite the detector ID per spectrum map by resetting the detector ID associated
with each spectrum on the output workspace to single available detectors on the instrument, and moving the repeated detector positions
in the appended workspace to available single detectors. This is only compatible with workspaces with common instruments and sufficient
available detectors. Also, monitor spectra are skipped.
See also
ConjoinWorkspaces v1 for joining parts of the same workspace.
Usage#
Example: Appending two workspaces
ws = CreateSampleWorkspace(BankPixelWidth=1)
ws2 = CreateSampleWorkspace(BankPixelWidth=2)
for wsLoop in [ws,ws2]:
print("Workspace '{}' has {} spectra beforehand".format(wsLoop, wsLoop.getNumberHistograms()))
wsOut = AppendSpectra(ws, ws2)
print("Workspace '{}' has {} spectra after AppendSpectra".format(wsOut, wsOut.getNumberHistograms()))
Output:
Workspace 'ws' has 2 spectra beforehand
Workspace 'ws2' has 8 spectra beforehand
Workspace 'wsOut' has 10 spectra after AppendSpectra
Example: Appending two workspaces
ws = CreateSampleWorkspace(BankPixelWidth=1)
ws2 = CreateSampleWorkspace(BankPixelWidth=1)
for wsLoop in [ws,ws2]:
print("Workspace '{}' has {} spectra beforehand".format(wsLoop, wsLoop.getNumberHistograms()))
wsOut = AppendSpectra(ws, ws2, Number=4)
print("Workspace '{}' has {} spectra after AppendSpectra".format(wsOut, wsOut.getNumberHistograms()))
Output:
Workspace 'ws' has 2 spectra beforehand
Workspace 'ws2' has 2 spectra beforehand
Workspace 'wsOut' has 10 spectra after AppendSpectra
Categories: AlgorithmIndex | Transforms\Merging
Source#
C++ header: AppendSpectra.h
C++ source: AppendSpectra.cpp