ReplaceSpecialValues v1

../_images/ReplaceSpecialValues-v1_dlg.png

ReplaceSpecialValues dialog.

Summary

Replaces instances of NaN and infinity in the workspace with user defined numbers. If a replacement value is not provided the check will not occur. This algorithm can also be used to replace numbers whose absolute value is larger than a user-defined threshold.

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).
NaNValue Input number Optional The value used to replace occurrances of NaN (default: do not check).
NaNError Input number 0 The error value used when replacing a value of NaN
InfinityValue Input number Optional The value used to replace occurrances of positive or negative infinity (default: do not check).
InfinityError Input number 0 The error value used when replacing a value of infinity
BigNumberThreshold Input number Optional The threshold above which a number (positive or negative) should be replaced. (default: do not check)
BigNumberValue Input number 0 The value with which to replace occurrances of ‘big’ numbers.
BigNumberError Input number 0 The error value used when replacing a ‘big’ number

Description

The algorithm searches over all of the values in a workspace and if it finds a value set to NaN (not a number), infinity or larger than the ‘big’ threshold given then that value and the associated error is replaced by the user provided values.

If no value is provided for either NaNValue, InfinityValue or BigValueThreshold then the algorithm will exit with an error, as in this case it would not be checking anything.

Algorithm is now event aware.

Usage

Example

import numpy as np
ws = CreateSampleWorkspace(BankPixelWidth=1)

yArray = np.array(ws.readY(0))
yArray[0] = 8e80
yArray[1] = float("inf")
yArray[2] = float("-inf")
yArray[3] = float("NaN")
ws.setY(0,yArray)

ws = ReplaceSpecialValues(ws,NaNValue=0,InfinityValue=1000,
 BigNumberThreshold=1000, BigNumberValue=1000)

print "i\tBefore\tAfter"
print "-\t------\t-----"
for i in range(4):
    print "%i\t%s\t%s" % (i, yArray[i],ws.readY(0)[i])

Output:

i       Before  After
-       ------  -----
0       8e+80   1000.0
1       inf     1000.0
2       -inf    1000.0
3       nan     0.0

Categories: Algorithms | CorrectionFunctions\SpecialCorrections