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

CreateSingleValuedWorkspace v1

../_images/CreateSingleValuedWorkspace-v1_dlg.png

CreateSingleValuedWorkspace dialog.

Summary

Creates a 2D workspace containing a single X, Y & E value.

Properties

Name Direction Type Default Description
OutputWorkspace Output MatrixWorkspace Mandatory Name to use for the output workspace
DataValue Input number 0 The value to place in the workspace
ErrorValue Input number 0 The error value to place in the workspace (default 0.0)

Description

Creates a 2D workspace that contains a single value and an optional error value. This was traditionally used for doing binary operations between a workspace and a single value. However, now that the Python access allows the standard binary operations with workspaces & single numbers, the requirement for this algorithm is almost gone.

One use case for which it will be required is when performing operations using only the MantidPlot GUI point-and-click approach.

Usage

Workspace with single y value and zero error:

five = CreateSingleValuedWorkspace(5)

print("Number of histograms: {}".format(five.getNumberHistograms()))
print("Length of y array: {}".format(len(five.readY(0))))
print("Length of e array: {}".format(len(five.readE(0))))
print("Length of x array: {}".format(len(five.readX(0))))

print("y value: {}".format(five.readY(0)))
print("e value: {}".format(five.readE(0)))

Output:

Number of histograms: 1
Length of y array: 1
Length of e array: 1
Length of x array: 1
y value: [ 5.]
e value: [ 0.]

Workspace with single y and e value:

five = CreateSingleValuedWorkspace(5, 0.1)

print("Number of histograms: {}".format(five.getNumberHistograms()))
print("Length of y array: {}".format(len(five.readY(0))))
print("Length of e array: {}".format(len(five.readE(0))))
print("Length of x array: {}".format(len(five.readX(0))))

print("y value: {}".format(five.readY(0)))
print("e value: {}".format(five.readE(0)))

Output:

Number of histograms: 1
Length of y array: 1
Length of e array: 1
Length of x array: 1
y value: [ 5.]
e value: [ 0.1]

Categories: AlgorithmIndex | Utility\Workspaces

Source

C++ header: CreateSingleValuedWorkspace.h (last modified: 2020-03-20)

C++ source: CreateSingleValuedWorkspace.cpp (last modified: 2020-04-07)