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

Scale v1

../_images/ImageNotFound.png

Enable screenshots using DOCS_SCREENSHOTS in CMake

Summary

Scales an input workspace by the given factor, which can be either multiplicative or additive.

See Also

ScaleX

Properties

Name

Direction

Type

Default

Description

InputWorkspace

Input

MatrixWorkspace

Mandatory

OutputWorkspace

Output

MatrixWorkspace

Mandatory

Factor

Input

number

1

The value by which to scale the input workspace

Operation

Input

string

Multiply

Whether to multiply by, or add factor. Allowed values: [‘Multiply’, ‘Add’]

Description

Uses the binary operation algorithms Multiply v1 or Plus v1 to scale the input workspace by the amount requested. This algorithm is provided as a simple, but less powerful, alternative to the python workspace algebra functionality.

Usage

Example: Adding an offset

ws = CreateSampleWorkspace(BankPixelWidth=1)
print("Every 10th bin value of " + ws.name())
print(ws.readY(0)[0:100:10])

# Add 2 using scale
wsOffset = Scale(ws,2,"Add")
print("Every 10th bin value of " + wsOffset.name())
print(wsOffset.readY(0)[0:100:10])

# Add 2 using the workspace operator overloads
wsOffset2 = ws + 2
print("Every 10th bin value of " + wsOffset2.name())
print(wsOffset2.readY(0)[0:100:10])

Output:

Every 10th bin value of ws
[  0.3   0.3   0.3   0.3   0.3  10.3   0.3   0.3   0.3   0.3]
Every 10th bin value of wsOffset
[  2.3   2.3   2.3   2.3   2.3  12.3   2.3   2.3   2.3   2.3]
Every 10th bin value of wsOffset2
[  2.3   2.3   2.3   2.3   2.3  12.3   2.3   2.3   2.3   2.3]

Example: Multiplying by a value

ws = CreateSampleWorkspace(BankPixelWidth=1)
print("Every 10th bin value of " + ws.name())
print(ws.readY(0)[0:100:10])

# Multiply by 10 using scale
wsScaled = Scale(ws,10,"Multiply")
print("Every 10th bin value of " + wsScaled.name())
print(wsScaled.readY(0)[0:100:10])

# Multiply by 10 using the workspace operator overloads
wsScaled2 = ws * 10
print("Every 10th bin value of " + wsScaled2.name())
print(wsScaled2.readY(0)[0:100:10])

Output:

Every 10th bin value of ws
[  0.3   0.3   0.3   0.3   0.3  10.3   0.3   0.3   0.3   0.3]
Every 10th bin value of wsScaled
[   3.    3.    3.    3.    3.  103.    3.    3.    3.    3.]
Every 10th bin value of wsScaled2
[   3.    3.    3.    3.    3.  103.    3.    3.    3.    3.]

Categories: AlgorithmIndex | Arithmetic | CorrectionFunctions

Source

C++ header: Scale.h

C++ source: Scale.cpp