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

ExtractSingleSpectrum v1

Summary

Extracts the specified spectrum from a workspace and places it in a new single-spectrum workspace.

See Also

CropWorkspace, ExtractSpectra, PerformIndexOperations

Properties

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.

Description

Extracts a single spectrum from a Workspace2D and stores it in a new workspace.

Usage

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: AlgorithmIndex | Transforms\Splitting

Source

C++ header: ExtractSingleSpectrum.h

C++ source: ExtractSingleSpectrum.cpp