next up previous contents index
Next: 2.3 The show() and print() Up: 2 The Basics of IFEFFIT Previous: 2.1 Starting the program


2.2 A Sample Run

We start with a fairly complete example (see the tutorial for a more gentle introduction). We'll assume that we have some raw data from a beamline in a plain-text column format, and want to convert it to $ \mu$(E), do a background subtraction, Fourier Transform, and then see what the data looks like in R-space. Though a very practical request, it's a fair bit of data processing. Here's what the session might look like:

 Ifeffit> read_data(file=Cu.dat, type=raw, group= cu)
 Ifeffit> cu.energy  = cu.1 * 1000.0
 Ifeffit> cu.xmu     = ln(cu.2 / cu.3)
 Ifeffit> spline(energy = cu.energy, xmu = cu.xmu, 
 Ifeffit>        rbkg=1.1, kweight=1., kmin=0)
 Ifeffit> plot(cu.energy, cu.xmu)
 Ifeffit> plot(cu.energy, cu.bkg, xmin=8850, xmax=9300,
 Ifeffit>      color=red)
 Ifeffit> cu.chi_kw = cu.chi * cu.k^2
 Ifeffit> newplot(cu.k,  cu.chi_kw)
 Ifeffit> fftf(real = cu.chi, kmin = 2.0, kmax = 13.0, 
 Ifeffit>      dk = 1.0, kweight=2)
 Ifeffit> newplot(cu.r, cu.chir_mag, xmax=8)
 Ifeffit> $title1  = "Test: writing out  k, chi, chi*k"
 Ifeffit> $title2  = "   data from Cu.dat,   rbkg = 1.0"
 Ifeffit> write_data(file = Out.chi,  cu.k, cu.chi, 
 Ifeffit>            cu.chi_kw, $title1, $title2)

One important aspect of IFEFFIT is that you can save commands into a file and execute all commands in that file at one time. By saving the above commands into the file process.iff, we could simply type load process.iff at the IFEFFIT command line. These two methods of running these commands are completely equivalent.

We'll now go through each of these lines in detail. If there is too much detail here, please go through the The IFEFFIT Tutorial.

 Ifeffit> read_data(file=Cu.dat, type=raw, group= cu)
This command reads in data arrays from the ASCII column file Cu.dat. The arguments type=raw and group=cu help read_data()() name the arrays it reads in. Because arrays are often read in and processed together, it is convenient to give them names that are related. Arrays names always have two parts - a prefix and suffix, with a dot '.' in between. The prefix gives the group name, and the suffix explains what the data contains. Here, cu is used as the group name (prefix). The type raw is the simplest type, so the suffixes will just be the column index. To make a long story short, we just read in the arrays cu.1, cu.2, and cu.3.

 Ifeffit> cu.energy  = cu.1 * 1000.
 Ifeffit> cu.xmu     = ln(cu.2 / cu.3)
Presumably, we know what the contents of our data file. For this Cu.dat file, the column contained energy in keV, the second contained I0 and the third I, for absorption data measured in transmission. There might have been more columns in the file, but this is all we need at this point. IFEFFIT prefers to think about energy in eV not keV, so we make an array cu.energy that has energy in eV, and then we calculate $ \mu$(E) and call that cu.xmu. Note that the math here is done on all elements of the array.

 Ifeffit>  spline(energy = cu.energy, xmu = cu.xmu, 
 Ifeffit>         rbkg=1.1,kweight=1.,kmin=0)
This computes the background spline $ \mu_{0}^{}$(E) for our $ \mu$(E) using the AUTOBK algorithm. The argument energy = cu.energy names the array to use as the energy values, and xmu = cu.xmu names the $ \mu$(E) array. rbkg=1.1 sets the value of Rbkg, while kweight=1. sets the k-weighting, and kmin=0 sets the value of kmin.

Like many other commands, spline() uses, modifies, and (if necessary) creates several arrays and scalars. The complete list of what spline() uses is listed in section 9.42. For now a partial list will do: spline() sets the arrays cu.bkg to contain $ \mu_{0}^{}$(E), cu.k to contain the k values, and cu.chi to contain $ \chi$(k). Several scalar values (including rbkg, kweight, kmin, and e0) are also set by spline(). You can see the values of these variables with the show() command - try show(e0, kmax) for example.

 Ifeffit>  plot(cu.energy, cu.xmu)
This plots $ \mu$(E). That is a plot window should appear and a trace of $ \mu$(E) should be drawn on it. If this does not happen, please consult the installation instructions. The plot() command has many optional arguments, but here we're just giving the array names for the ordinate cu.energy and the abscissa cu.xmu.

 Ifeffit>  plot(cu.energy, cu.bkg, xmin= 8850, xmax= 9300, 
 Ifeffit>       color=red)
This adds a plot of $ \mu_{0}^{}$(E) to the previous plot. We specify the x range of the plot with xmin = 8850, xmax = 9300 to look at just the near-edge region, and explicitly give the color to use for $ \mu_{0}^{}$(E). Note that overplotting is the default behavior. See section 9.27 for all the plotting options, and chapter 5 for even more information about plotting with IFEFFIT.

 Ifeffit>  cu.chi_kw = cu.chi * cu.k^kweight
This creates the array cu.chi_kw which contains k2$ \chi$(k).

 Ifeffit>  newplot(cu.k,  cu.chi_kw)
This plots the k-weighted $ \chi$(k) that we just calculated. newplot() is a variation of plot() command that reinitializes the plot, so that it won't be plotted over the current window (which was still showing $ \mu$(E) and $ \mu_{0}^{}$(E)).

 Ifeffit>  fftf(real = cu.chi, kmin = 2.0, kmax = 13.0, 
 Ifeffit>        dk = 1.0, kweight=2)
This does the forward XAFS Fourier transform of $ \chi$(k). The argument real = cu.chi tells fftf() to use cu.chi (which is the un-k-weighted $ \chi$(k) from spline()) as the real part of the function to Fourier transform. We could have said imag = cu.chi to use $ \chi$(k) as the imaginary part. This is, to some extent, a matter of convention (see Appendix B for more details). The Fourier transform window was specified with the parameters kmin, kmax, dk, and kweight. fftf() creates arrays cu.r for R, and cu.chir_re, cu.chir_im, and cu.chir_mag for the real part, imaginary part, and magnitude of $ \tilde{\chi}$(R), among other things.

 Ifeffit>  newplot(cu.r, cu.chir_mag, xmax = 8)
Now we plot |$ \chi$(R)|, explicitly limiting the R-range to 8Å. By default, the R-based arrays from fftf() will extend to 10Å.

 Ifeffit>  $title1 = "Test: writing out  k, chi, chi*k"
 Ifeffit>  $title2 = "   data from Cu.dat,   rbkg = 1.1"
Here we define a pair of text string variables, which always have names starting with a dollar sign. These are useful for doing things like
 Ifeffit>  write_data(file = out.chi,  cu.k, cu.chi, 
 Ifeffit>             cu.chi_kw, $title1, $title2,e0,rbkg)
in which we save the $ \chi$(k) and k-weighted $ \chi$(k) data to the file out.chi. The rest of the arguments give the arrays, text strings, and scalars to write to the file. Text strings will be written first, then the scalars, and finally the data arrays will be written, in the order listed.


next up previous contents index
Next: 2.3 The show() and print() Up: 2 The Basics of IFEFFIT Previous: 2.1 Starting the program
Matt Newville
2004-02-09