\(\renewcommand\AA{\unicode{x212B}}\)
Table of Contents
Scales the X-axis of an input workspace by the given factor, which can be either multiplicative or additive.
Name | Direction | Type | Default | Description |
---|---|---|---|---|
InputWorkspace | Input | MatrixWorkspace | Mandatory | Name of the input workspace |
OutputWorkspace | Output | MatrixWorkspace | Mandatory | Name of the output workspace |
Factor | Input | number | 1 | The value by which to scale the X-axis of the input workspace. Default is 1.0 |
Operation | Input | string | Multiply | Whether to multiply by, or add factor. Allowed values: [‘Multiply’, ‘Add’] |
IndexMin | Input | number | 0 | The workspace index of the first spectrum to scale. Only used if IndexMax is set. |
IndexMax | Input | number | Optional | The workspace index of the last spectrum to scale. Only used if explicitly set. |
InstrumentParameter | Input | string | The name of an instrument parameter whose value is used to scale as the input factor | |
Combine | Input | boolean | False | If true, combine the value given in the Factor property with the value obtained from the instrument parameter. The factors are combined using the operation specified in the Operation parameter |
Scales the X axis, the X-coordinate of histograms in a histogram workspace, and the X-coordinate of events in an event workspace by the requested amount.
Example - Modify the mean and standard deviation of a Gaussian via rescaling of the X-axis:
import numpy as np
# A Gaussian in the [-1, 1] range
DataX=np.arange(-1,1,0.01)
mean=0.3
sigma=0.2
DataY=np.exp( -(DataX-mean)**2/(2*sigma**2) )
ws = CreateWorkspace(DataX,DataY)
# Center the Gaussian by shifting the X-axis, then find its average
ws2 = ScaleX(ws, Factor=-mean, Operation='Add')
print('mean={:.2f}'.format(abs(np.sum( ws2.dataX(0) *ws2.dataY(0) ) / np.sum( ws2.dataY(0) ))))
# Decrease the standard deviation of the Gaussian by half via shrinkage of the X-axis,
# then find its standard deviation
ws3 = ScaleX(ws2, Factor=0.5, Operation='Multiply')
print('sigma={:.2f}'.format(np.sqrt( np.sum( ws3.dataX(0)**2 *ws3.dataY(0) ) / np.sum( ws3.dataY(0) ) )))
Output:
mean=0.00
sigma=0.10
Categories: AlgorithmIndex | Arithmetic | CorrectionFunctions