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

Logarithm v1

../_images/ImageNotFound.png

Enable screenshots using DOCS_SCREENSHOTS in CMake

Summary

Logarithm function calculates the logarithm of the data, held in a workspace. A user can choose between natural (default) or base 10 logarithm

See Also

Power, Exponential

Properties

Name

Direction

Type

Default

Description

InputWorkspace

Input

MatrixWorkspace

Mandatory

The name of the input workspace

OutputWorkspace

Output

MatrixWorkspace

Mandatory

The name to use for the output workspace (can be the same as the input one).

Filler

Input

number

0

The value that will be placed into the output workspace if an input value is equal or less than 0. Default value is 0

Natural

Input

boolean

True

Logical value which specifies if user wants to calculate natural or base 10 logarithm.

Description

Logarithm function calculates the logarithm of the data, held in a workspace and tries to estimate the errors of this data, by calculating logarithmic transformation of the errors. The errors are assumed to be small and Gaussian so they are calculated on the basis of Tailor decomposition e.g. if \(S\) and \(Err\) are the signal and errors for the initial signal, the logarithm would provide \(S_{ln}=ln(S)\) and \(Err_{ln}=Err/S\) accordingly. If the base 10 logarithm is used the errors are calculated as \(Err_{log10}=0.434Err/S\)

Some values in a workspace can normally be equal to zero. Logarithm is not calculated for values which are less or equal to 0, but the value of Filler is used instead. The errors for such cells set to zeros

When acting on an event workspace, the output will be a Workspace2D, with the default binning from the original workspace.

Usage

Example - logarithm of a histogram workspace:

dataX = list(range(0,10))*10 # define 10 x-spectra
dataY =([1]*10)*10     # with values 1
dataY[0]=-10           # make first value not suitable for logarithm
dataY[1]=10            # make second value different
dataE =([1]*10)*10     # define 10 error spectra with value 1
# create test workspace
ws = CreateWorkspace(dataX, dataY, dataE, NSpec=10)
# Calculate log10
ws = Logarithm(ws,Filler=-1,Natural='0')
#
# check results:

print('Log10 for spectra 0:  {}'.format(ws.readY(0)))
print('Log10 for Err spectra 0:  {}'.format(ws.readE(0)[0:4]))

Output:

Log10 for spectra 0:  [-1.  1.  0.  0.  0.  0.  0.  0.  0.  0.]
Log10 for Err spectra 0:  [ 0.      0.0434  0.434   0.434 ]

Categories: AlgorithmIndex | Arithmetic

Source

C++ header: Logarithm.h

C++ source: Logarithm.cpp