\(\renewcommand\AA{\unicode{x212B}}\)

AppendSpectra v1

Summary

Join two workspaces together by appending their spectra.

See Also

ConjoinSpectra

Properties

Name

Direction

Type

Default

Description

InputWorkspace1

Input

MatrixWorkspace

Mandatory

The name of the first input workspace

InputWorkspace2

Input

MatrixWorkspace

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

MatrixWorkspace

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

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 EventWorkspaces, there are no restrictions on the input workspaces if ValidateInputs=false.

For Workspace2Ds, the number of bins must be the same in both inputs.

If ValidateInputs is selected, then the input workspaces must also:

  • 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.

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