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

ExtractSpectra v1

../_images/ImageNotFound.png

Enable screenshots using DOCS_SCREENSHOTS in CMake

Summary

Extracts a list of spectra from a workspace and places them in a new workspace.

See Also

CropWorkspace, ExtractSingleSpectrum, ExtractUnmaskedSpectra, PerformIndexOperations

Properties

Name

Direction

Type

Default

Description

InputWorkspace

Input

MatrixWorkspace

Mandatory

The input workspace

OutputWorkspace

Output

MatrixWorkspace

Mandatory

Name of the output workspace

XMin

Input

number

Optional

An X value that is within the first (lowest X value) bin that will be retained (default: workspace min)

XMax

Input

number

Optional

An X value that is in the highest X value bin to be retained (default: max X)

StartWorkspaceIndex

Input

number

0

The index number of the first entry in the Workspace that will be loaded (default: first entry in the Workspace)

EndWorkspaceIndex

Input

number

Optional

The index number of the last entry in the Workspace to be loaded (default: last entry in the Workspace)

WorkspaceIndexList

Input

unsigned int list

A comma-separated list of individual workspace indices to read. Only used if explicitly set. The WorkspaceIndexList is only used if the DetectorList is empty.

DetectorList

Input

int list

A comma-separated list of individual detector IDs to read. Only used if explicitly set. When specifying the WorkspaceIndexList and DetectorList property, the latter is being selected.

Description

Extracts a number of spectra from a MatrixWorkspace and puts them into a new workspace. Optionally it can cut the number of bins (x values). See the CropWorkspace v1 algorithm for more details on how it works for ragged workspaces and workspaces with common bin boundaries.

Usage

Example - ExtractSpectra

# Create an input workspace
ws = CreateSampleWorkspace()
print('Input workspace has %s bins' % ws.blocksize())
print('Input workspace has %s spectra' % ws.getNumberHistograms())

# Extract spectra 1,3 and 5 and crop the x-vector to interval 200 <= x <= 1300
cropped = ExtractSpectra(ws,200,1300,WorkspaceIndexList=[1,3,5])
print('Output workspace has %s bins' % cropped.blocksize())
print('Output workspace has %s spectra' % cropped.getNumberHistograms())

Output:

Input workspace has 100 bins
Input workspace has 200 spectra
Output workspace has 5 bins
Output workspace has 3 spectra

Categories: AlgorithmIndex | Transforms\Splitting

Source

C++ header: ExtractSpectra.h

C++ source: ExtractSpectra.cpp