Scale v1

../_images/Scale-v1_dlg.png

Scale dialog.

Summary

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

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.getName()
print ws.readY(0)[0:100:10]

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

# Add 2 using the workspace operator overloads
wsOffset2 = ws + 2
print "Every 10th bin value of " + wsOffset2.getName()
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.getName()
print ws.readY(0)[0:100:10]

# Multiply by 10 using scale
wsScaled = Scale(ws,10,"Multiply")
print "Every 10th bin value of " + wsScaled.getName()
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.getName()
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: Algorithms | Arithmetic | CorrectionFunctions

Source

C++ source: Scale.cpp

C++ header: Scale.h