Table of Contents
Extracts the specified spectrum from a workspace and places it in a new single-spectrum workspace.
Name | Direction | Type | Default | Description |
---|---|---|---|---|
InputWorkspace | Input | MatrixWorkspace | Mandatory | The name of the input workspace. |
OutputWorkspace | Output | MatrixWorkspace | Mandatory | The name under which to store the output workspace. |
WorkspaceIndex | Input | number | Mandatory | The workspace index number of the spectrum to extract. |
Extracts a single spectrum from a Workspace2D and stores it in a new workspace.
Example
ws = CreateSampleWorkspace()
print("Workspace %s contains %i spectra" % (ws, ws.getNumberHistograms()))
print("Counts for every 10th bin for workspace index 5")
print(", ".join(["{:.1f}".format(y) for y in ws.readY(5)[0:100:10]]))
wsOut = ExtractSingleSpectrum(ws,WorkspaceIndex=5)
print("After extracting one spectra at workspace index 5")
print("Workspace %s contains %i spectra" % (wsOut, wsOut.getNumberHistograms()))
print("Counts for every 10th bin for workspace index 0 (now it's 0 as wsOut only contains 1 spectra)")
print(", ".join(["{:.1f}".format(y) for y in wsOut.readY(0)[0:100:10]]))
Output:
Workspace ws contains 200 spectra
Counts for every 10th bin for workspace index 5
0.3, 0.3, 0.3, 0.3, 0.3, 10.3, 0.3, 0.3, 0.3, 0.3
After extracting one spectra at workspace index 5
Workspace wsOut contains 1 spectra
Counts for every 10th bin for workspace index 0 (now it's 0 as wsOut only contains 1 spectra)
0.3, 0.3, 0.3, 0.3, 0.3, 10.3, 0.3, 0.3, 0.3, 0.3
Categories: Algorithm Index | Transforms\Splitting
C++ source: ExtractSingleSpectrum.cpp (last modified: 2018-10-05)
C++ header: ExtractSingleSpectrum.h (last modified: 2018-10-05)