14.5. XAFS: Fourier Transforms for XAFS¶
Fourier transforms are central to understanding and using
XAFS. Consequently, many of the XAFS functions in Larch use XAFS Fourier
transforms as part of their processing, and many of the functions
parameters and arguments described here have names and meanings used
throughout the XAFS functionality of Larch. For example, both
autobk()
and feffit()
rely on XAFS Fourier transforms, and use
the XAFS Fourier transform function described here.
14.5.1. Overview of XAFS Fourier transforms¶
The standard Fourier transform of a signal
where the symmetric normalization is one of the more common choices of
conventions. This gives conjugate variables of
the conjugate variables in XAFS are generally taken to be
But there are two more important issues to mention. First, an XAFS Fourier
transform multiplies
The second important issue is that the continuous Fourier transform
described above is replaced by a discrete transform. This better matches
the discrete sampling of energy and autobk()
)
is
For the discrete Fourier transforms with samples of
These normalizations preserve the symmetry properties of the Fourier
Transforms with conjugate variables
A final complication in using Fourier transforms for XAFS is that the
measured
14.5.2. Forward XAFS Fourier transforms ( )¶
The forward Fourier transform converts xftf()
function.
- xftf(k, chi=None, group=None, ...)¶
perform a forward XAFS Fourier transform, from
to , using common XAFS conventions.- Parameters:
k – 1-d array of photo-electron wavenumber in
chi – 1-d array of
group – output Group
rmax_out – highest R for output data (10
)kweight – exponent for weighting spectra by
kmin – starting k for FT Window
kmax – ending k for FT Window
dk – tapering parameter for FT Window
dk2 – second tapering parameter for FT Window
window – name of window type
nfft – value to use for
(2048).kstep – value to use for
(0.05).
- Returns:
None
– outputs are written to supplied group.
Follows the First Argument Group convention, using group members named
k
andchi
. The following data is put into the output group:array name
meaning
kwin
window
(length of input chi(k)).r
uniform array of
, out tormax_out
.chir
complex array of
.chir_mag
magnitude of
.chir_pha
phase of
.chir_re
real part of
.chir_im
imaginary part of
.It is expected that the input
k
be a uniformly spaced array of values with spacingkstep
, starting a 0. If it is not, thek
andchi
data will be linearly interpolated onto the proper grid.The FT window parameters are explained in more detail in the discussion of
ftwindow()
.
- xftf_fast(chi, nfft=2048, kstep=0.05)¶
perform a forward XAFS Fourier transform, from
to , using common XAFS conventions. This version demandschi
to include any weighting and windowing, and so to represent on a uniform grid. It returns the complex array of .- Parameters:
chi – 1-d array of
to be transformednfft – value to use for
(2048).kstep – value to use for
(0.05).
- Returns:
complex
.
14.5.3. Reverse XAFS Fourier transforms ( )¶
Reverse Fourier transforms convert
- xftr(r, chir, group=None, ...)¶
perform a reverse XAFS Fourier transform, from
to .- Parameters:
r – 1-d array of distance.
chir – 1-d array of
group – output Group
qmax_out – highest k for output data (30
)rweight – exponent for weighting spectra by
(0)rmin – starting R for FT Window
rmax – ending R for FT Window
dr – tapering parameter for FT Window
dr2 – second tapering parameter for FT Window
window – name of window type
nfft – value to use for
(2048).kstep – value to use for
(0.05).
- Returns:
None
– outputs are written to supplied group.
Follows the First Argument Group convention, using group members named
r
andchir
. The following data is put into the output group:array name
meaning
rwin
window
(length of input chi(R)).q
uniform array of
, out toqmax_out
.chiq
complex array of
.chiq_mag
magnitude of
.chiq_pha
phase of
.chiq_re
real part of
.chiq_im
imaginary part of
.In analogy with
xftf()
, it is expected that the inputr
be a uniformly spaced array of values starting a 0.The input
chir
array can be either the complex array as output toGroup.chir
fromxftf()
, or one of the real or imaginary parts of the as output toGroup.chir_re
orGroup.chir_im
.The FT window parameters are explained in more detail in the discussion of
ftwindow()
.
- xftr_fast(chir, nfft=2048, kstep=0.05)¶
perform a reverse XAFS Fourier transform, from
to , using common XAFS conventions. This version demandschir
be the complex as created fromxftf()
. It returns the complex array of without putting any values into a group.- Parameters:
chir – 1-d array of
to be transformednfft – value to use for
(2048).kstep – value to use for
(0.05).
- Returns:
complex
.
14.5.4. ftwindow()
: Generating Fourier transform windows¶
As mentioned above, a Fourier transform window will smooth the resulting Fourier transformed spectrum, removing ripple and ringing in it that would result from a sudden truncation data at the end of it range. There is an extensive literature on such windows, and a lot of choices and parameters available for constructing windows. A sampling of windows is shown below.
- ftwindow(x, xmin=0, xmax=None, dk=1, ...)¶
create a Fourier transform window array.
- Parameters:
x – 1-d array array to build window on.
xmin – starting x for FT Window
xmax – ending x for FT Window
dx – tapering parameter for FT Window
dx2 – second tapering parameter for FT Window (=dx)
window – name of window type
- Returns:
1-d window array.
Note that if
dx
is specified butdx2
is not,dx2
will generally take the same value asdx
.The window type must be one of those listed in the Table of Fourier Transform Window Types.
Table of Fourier Transform Window Types.
window name
description
hanning
cosine-squared taper
parzen
linear taper
welch
quadratic taper
gaussian
Gaussian (normal) function window
sine
sine function window
kaiser
Kaiser-Bessel function-derived window
In general, the window arrays have a value that gradually increases from 0
up to 1 at the low-k end, may stay with a value 1 over some central
portion, and then tapers down to 0 at the high-k end. The meaning of the
dx
and dx2
, and even xmin
, and xmax
varies a bit for the
different window types. The Hanning, Parzen, and Welch windows share a
convention that the windows taper up from 0 to 1 between xmin-dx/2
and
xmin+dx/2
, and then taper down from 1 to 0 between xmax-dx2/2
and
xmax+dx2/2
.
The conventions for the Kaiser, Gaussian, and Sine window types is a bit
more complicated, and is best given explicitly. In the formulas below,
dx
written as dx2
as
The form for the Sine window is
between
where
14.5.5. Catalog of Fourier transform window¶
Here, we give a series of example windows, to illustrate the different
window types and the effect of the various parameters. The meanings of
xmin
, xmax
, dx
and dx2
are identical for the Hanning, Parzen and
Welch windows, and illustrated in the two following figures.


Fourier Transform window examples and illustration of parameter meaning
for the Hanning, Parzen, and Welch windows. Note that
dx
is to control the taper over which the window
changes from 0 to 1. Here, xmin=5
and xmax=15
.
Some more window functions:


Fourier Transform window examples and illustration of parameter
meaning. On the left, a comparison of Welch, Parzen, and Hanning with
the same parameters is shown. On the right, the effect of dx2
is
shown as a different amount of taper on the high- and low-x
end of
the window. As before, xmin=5
and xmax=15
.
The Gaussian, Sine, and Kaiser-Bessel windows are illustrated next. These
go to 1 at the average of xmin
and xmax
, but do not stay at 1 over
a central portion of the window – they taper continuously. The Gaussian
window is a simple Gaussian function, and is not truncated according to
xmin
and xmax
, and the dx
parameter sets the width. The Sine
and Kaiser-Bessel windows both go to zero at xmin-dx/2
and xmax +
dx/2
. For very large values of dx
, the Kaiser-Bessel window
approaches a nearly Gaussian lineshape.
14.5.6. Examples: Forward XAFS Fourier transforms¶
Now we show some example Fourier transforms, illustrating the real and
imaginary parts of the
We start with a comparison of a small value of dk
and a larger value.
A script that runs xftf()
, changing on dk
would look like:
xftf(dat1.k, dat1.chi, kmin=3, kmax=13, dk=1, window='hanning',
kweight=kweight, group=dat1)
dat2 = group(k=dat1.k, chi=dat1.chi) # make a copy of the group
xftf(dat2.k, dat2.chi, kmin=3, kmax=13, dk=5, window='hanning',
kweight=kweight, group=dat2)
would result in the following results:


Comparison of the effect of different values of dk
on real XAFS
Fourier transforms. Increasing dk
reduces peak heights and tends
to broaden peaks, but the effects are rather small.
A script that runs xftf()
with consistent parameters, but different
window types:
xftf(dat1.k, dat1.chi, kmin=3, kmax=13, dk=4, window='hanning',
kweight=kweight, group=dat1)
dat2 = group(k=dat1.k, chi=dat1.chi) # make a copy of the group
xftf(dat2.k, dat2.chi, kmin=3, kmax=13, dk=4, window='parzen',
kweight=kweight, group=dat2)
dat3 = group(k=dat1.k, chi=dat1.chi) #
xftf(dat3.k, dat3.chi, kmin=3, kmax=13, dk=4, window='welch',
kweight=kweight, group=dat3)
dat4 = group(k=dat1.k, chi=dat1.chi) #
xftf(dat4.k, dat4.chi, kmin=3, kmax=13, dk=4, window='kaiser',
kweight=kweight, group=dat4)
dat5 = group(k=dat1.k, chi=dat1.chi) #
xftf(dat5.k, dat5.chi, kmin=3, kmax=13, dk=4, window='gaussian',
kweight=kweight, group=dat5)
would result in the following results:
We now turn our attention to the different components of the Fourier
transform. As above, it is most common to plot the magnitude of the
Fourier transform. But, as the transformed
newplot(dat1.r, dat1.chir_mag, xmax=8, label='chir_mag',
show_legend=True, legend_loc='ur', color='black',
xlabel=r'$R \rm\, (\AA)$', ylabel=r'$\chi(R)\rm\,(\AA^{-3})$' )
plot(dat1.r, dat1.chir_re, color='red', label='chir_re')
plot(dat1.r, dat1.chir_im, color='blue', label='chir_im')
which results in

Figure 14.5.6.1 The real and imaginary components of the XAFS Fourier transform.¶
In fact, in the analysis discussed with feffit()
, the real and
imaginary components are used, not simply the magnitude.
14.5.7. Examples: Reverse XAFS Fourier transforms, Fourier Filtering¶
A reverse Fourier transform will convert data from


Reverse XAFS Fourier transform, or Fourier filtering. Here, one can see the effect of different window sizes on the Fourier filtered spectrum. Including the first two peaks or shells reproduces most of the original spectrum, with only high-frequency components removed.
Note that it is chiq_re
that is compared to the k-weighted chi
array.