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

PaddingAndApodization v1

Summary

This algorithm applies apodization and/or padding to input data.

Properties

Name

Direction

Type

Default

Description

InputWorkspace

Input

MatrixWorkspace

Mandatory

The name of the input 2D workspace.

OutputWorkspace

Output

MatrixWorkspace

Mandatory

The name of the output 2D workspace.

ApodizationFunction

Input

string

None

The apodization function to apply to the data. Allowed values: [‘None’, ‘Lorentz’, ‘Gaussian’]

DecayConstant

Input

number

1.5

The decay constant for the apodization function.

Padding

Input

number

0

The amount of padding to add to the data,it is the number of multiples of the data set.i.e 0 means no padding and 1 will double the number of data points.

NegativePadding

Input

boolean

False

If true padding is added to both sides of the original data. Both sides share the padding

Description

This algorithm can prepare data for

FFT by applying padding and/or applying an apodization function.

Padding is when the input data is extended by adding extra measurments of zero at regular intervals. For real data this is only done after the end of the input data. However, for complex data the padding should be shared between the start and end of the input data.

Apodization functions can be used to remove data with large errors. These are usually found at large time scales. These take a decay constant (\(\tau\) ) that determines the rate at which the data goes to zero. The time the function is evaluated at is denoted by \(t\). The current implementation includes the following functions:

  • None.

  • Lorentz \(\exp\left(-\frac{t}{\tau}\right)\).

  • Gaussian \(\exp\left(-\frac{t^2}{2\tau^2}\right)\).

Usage

Example - Apply apodization function:

import math
import numpy as np
y = [100, 150, 50, 10, 5]
x = [1,2,3,4,5,6]
input = CreateWorkspace(x,y)
output=PaddingAndApodization(InputWorkspace=input,ApodizationFunction="Gaussian",DecayConstant=2.44,Padding=0,)
print("output:  {}".format(['{0:.2f}'.format(value) for value in output.readY(0)]))

Output:

output:  ['91.94', '107.20', '23.48', '2.61', '0.61']

Example - Add padding:

import math
import numpy as np
y = [100, 150, 50, 10, 5]
x = [1,2,3,4,5,6]
input = CreateWorkspace(x,y)
output=PaddingAndApodization(InputWorkspace=input,Padding=2,)
print("output:  {}".format(['{0:.2f}'.format(value)  for value in output.readY(0)]))

Output:

output:  ['100.00', '150.00', '50.00', '10.00', '5.00', '0.00', '0.00', '0.00', '0.00', '0.00', '0.00', '0.00', '0.00', '0.00', '0.00']

Example - Add padding and apodization function:

import math
import numpy as np
y = [100, 150, 50, 10, 5]
x = [1,2,3,4,5,6]
input = CreateWorkspace(x,y)
output=PaddingAndApodization(InputWorkspace=input,ApodizationFunction="Gaussian",DecayConstant=2.44,Padding=2,)
print("output:  {}".format(['{0:.2f}'.format(value)  for value in output.readY(0)]))

Output:

output:  ['91.94', '107.20', '23.48', '2.61', '0.61', '0.00', '0.00', '0.00', '0.00', '0.00', '0.00', '0.00', '0.00', '0.00', '0.00']

Categories: AlgorithmIndex | Arithmetic\FFT

Source

C++ header: PaddingAndApodization.h

C++ source: PaddingAndApodization.cpp