Working with resonant anomalous surface diffraction (RASD) data
This is a brief description how to use the functions implemented in PDS to work with RASD data. At the moment there are three modules for integrating and analyzing RASD data.
- modules/xray/ana/rasd_data.py
- modules/xray/ana/rasd_ana.py
- pds/modules/menu/rasd_menu.py
Integrating RASD data
For the first step you use the "ana.rasd_data.rasd_data()" function. This function is especially designed to for data measured with the "raxr" spec command as it is used at GSECARS. It takes four arguments:
- spec_path (string containing the path to your spec file e.g. spec_path = 'D:/Data/APS/RASD')
- spec_file (string containing the name of the spec file e.g. spec_file = 'caco3_mar10d.spc')
- first_scan (integer number of the first scan in the spec file that belongs to your raxr scan)
- last_scan (integer number of the last scan in the spec file that belongs to your raxr scan)
To create an instance called "A" that has your data available for integration, you type in the PDS command line e.g.:
A = ana.rasd_data.rasd_data('D:/Data/APS/RASD','caco3_mar10d.spc', 24, 102)For the integration of image data in "A" you simply use the PDS "CTR Data" application, you find at: PDS --> Applications --> CTR Data
In the CTR Data GUI's "CTR Data Name" scroll bar you select "A" and you can start the integration analogous to the integration of CTR Data (for a description of how to do that see the section about "Working with CTR Data") (some of the GUI functionalities, like selecting a point or a list of points from the plot or appending a scan, do not work for RASD Data)
Once you are happy with your data integration you can quit the CTR Data GUI. To go on with data analyses it is so far still necessary that you dump the results of the data integration to an Ascii file. For the instance "A" you can do that by calling:
A.write_RSD()
If you do not like the default file names created ('rasdHK_L.rsd') you may define your own file name:
A.write_RSD('yourfilename')
Analyzing RASD Data
After you have integrated all your RASD scans you still need to prepare some files containing additional information, before you can start the actual analyses of the RASD Data.
Non-resonant interface model
Along with your RASD data you need a valid interface model to calculate non-resonant structure factors. Therefore you need a bulk_file and a surface_file.
You'll have measured a full set of CTRs of your RASD sample, these should cover all the HK positions at which you have RASD data. Integrate (see "Working with CTR Data") and analyze (e.g. using ROD (so far not implemented in PDS)) the CTR data. After the CTR modeling you can produce files in ROD which are similar to the necessary bulk_file and surface_file using the:
ROD --> List --> Bulk
and the
ROD --> List --> Surface
commands.
The bulk_file must contain no comments or cell definitions but all atoms in the bulk unit cell, one line for each atom:
element_symbol x y z DW
x, y, and z are in fractional coordinates, DW is the isotropic Debye-Waller-Factor in Angstroem**2.
The surface_file must contain no comments or cell definitions but all atoms in the surface unit cell, one line for each atom:
element_symbol x y z occ DW
x, y, and z are in fractional coordinates, occ is the occupancy of the site, DW is the isotropic Debye-Waller-Factor in Angstroem**2.
Make sure the surface model is defined in a way that the z-position of the actual crystal surface is at z = 0. As in ROD, the bulk unit cell must be defined so that it's z-coordinates are adjacent to the surface model.
f1f2 data
f1f2 data or f' and f" data is necessary to calculate the resonant structure factors.
Cromer Liberman (CL) f1f2
The easiest way to get CL f1f2 data is to use the "Hephaestus" program from Ifeffit: select f' & f" at the left side, type in the energy range of your RASD scans, select the smallest energy steps used in your RASD scans as energy grid (so far this is restricted to 1 eV), select plot both f' and f" and klick at your resonant element in the Periodic Table. Klick save data for ..., give a file name, and that's it.
You can use this file as f1f2_file in your RASD analysis.
But you can also use this file together with a XANES scan of a reference sample of your resonant element to produce experimental f1f2 data. That is especially recommended if the absorption edge of the resonant element shows a big whiteline and the shape of the experimental XANES deviates strongly from the Cromer-Liberman calculated f" as it is generated by Hephaestus.
experimental f1f2
The ana.rasd_ana.py module holds a function "ana.rasd_ana.f1f2()" you can use to calculate experimental f1f2 data. It needs the CL f1f2 data from Hephaestus and a normalized XANES scan of a reference sample of your resonant element (same oxidation state, similar speciation ...). CL f1f2 and normalized XANES must be in the same Energy range and use the same regular (1eV) Energy grid otherwise this function will crash or produce quite spectacular results. Other information it needs is the theoretical edge energy, e0 in eV (integer), an energy shift between the CL data and the experimental data, e0shift (also eV, also integer), a file name for the output file (default is 'exp.f1f2'), and a number n (default is 30) which marks the number of points used at each end of the scan to match your normalized XANES to the CL f", and the range of points around e0, which are not used to match the spectra . You can run the function like this:
ana.rasd_ana.f1f2(datafile = 'CL.f1f2' , expfile = 'XANES.nor' , e0 = 12658 , e0shift = 5 , output ='Se_exp.f1f2', n=50)
It seems to work best when the start of the absorption edges of the CL and the experimental f" match as exactly as possible, you may have to play around with e0shift (and in case with the Hephaestus option to convolute your CL f1f2 with a certain energy interval).
You can then use the output of this function, 'exp.f1f2' as f1f2_file in your RASD analysis.
The RASD analysis menu
The function rasd_menu() that creates the Rasd analysis menu is in pds/modules/menu/rasd_menu.py. When you call menu it is imported as rasd(). To start it you need to give it at least one argument, a list of strings with all the names of the files in which the results of your rasd data integration have been saved. This list might e.g. be called rasddata and be defined like this:
rasddata = ['rasd00_0.9.rsd','rasd00_1.1.rsd','rasd00_1.3.rsd',...,'rasd20_0.7.rsd',...,'rasd01_3.5.rsd']
The menu could then be started like this:
menu.rasd(rasddata)
It will interactively ask you for additional information:
cell: is a unit cell definition, a list of eight floats [a,b,c,alpha,beta,gamma,delta1,delta2]. a, b, c, alpha, beta, and gamma are the lengths of your basis vectors and the angles between them in Angstroem and degrees. delta1 and delta2 are used for surfaces where there is no integer real space vector perpendicular to the surface. (If you don't know you may have a look into: Trainor et al. (2002) Journal of Applied Crystallography, 35, 696-701, but if you've never heard of it, it is most probably both zero in your case.)
bulk_file: string containing the name of the bulk file explained above.
surface_file: string containing the name of the surface file explained above.
f1f2_file: string containing the name of the f1f2 file explained above, either CL or experimental.
E0: absorption edge energy in eV.
If you don't want to go through all these steps every time you start the menu you may predefine all these variables and start the menu directly like this:
menu.rasd(rasddata, cell, bulk_file, surface_file, f1f2_file, 12663)
Then rasd_menu will jump over all these first steps and you get directly to the menu.
That means a "Figure 1" showing your first RASD scan and a fit to it should appear and something like this should be written to your PDS shell:
########################################## Number of rasd scans = 9 Current scan = 0 Current scan AR = 0.0966330298591 Current scan PR = 0.465473173313 Current scan E0shift = 0.0 ( 1) PLot_norm : Plot scan with (default) or without normalization ( 2) SETE0shift : Set E0 shift for this scan ( 3) SETPRstart : set a starting value for the resonant Phase (PR) ( 4) USEINFourier : use AR and PR of this scan in Fourier synthesis (True/False) ( 5) USEINRefine : use this scan in the structure refinement (True/False) ( 6) FourierParams : Set Fourier synthesis parameters ( 7) RUNFourier : Run Fourier synthesis ( 8) RefinementParams: Set simulated annealing parameters ( 9) RUNRefine : Run simulated annealing structure refinement (10) SELect : Select scan (11) Next : Select next scan (12) PRevious : Select previous scan (13) Done : All Done (14) Help : Show menu options
The header information tells you:
- how many scans you have loaded (e.g. 9),
- which of these scans you are currently working on (if you have 9 scans this goes from 0 to 8)
- resonant amplitude, AR, of the fit to this scan
- resonant phase, PR, of the fit to this scan
- e0shift you applied to this scan.
Some more information is in the title of "Figure1".
You can choose the menu options just by typing the numbers before each option, or by typing the part of the option name written in capital letters, or by typing the whole option name.
Let's go quickly through the options.
(1) sets a boolean flag. If it is true your scans are plotted normalized if it is false they are plotted just the way they are.
(2) you may apply an individual e0shift to every scan (eV, integer). (If these deviate for different scans by more than 1-2 eV it should make you suspicious.)
(3) This sets a starting value for the fit of the resonant phase. It should always be possible to find a starting value for PR such that the fitted values for AR and PR are between 0 and 1, but that's just cosmetics. Negative or higher values do the same.
(4) HKL, AR, and PR of each RASD scan may be used as a Fourier component, to synthesize the electron density of your resonant element at the surface. Here you can decide whether you wish to consider this scan in a Fourier synthesis or not.
(5) Here you can switch on/off Rasd scans you want to be considered in structure refinement.
(6) A couple of parameters can be modified to customize the Fourier synthesis for your needs. There are default values for all parameters so you don't have to do this.
- atomic number of the resonant element
- number of unit cells along a. If e.g. your rasd scans are measured at reciprocal space coordinates HKL, at a regular interval dH (e.g. H = -2,0,2... dH = 2) it makes sense to use only 1/dH unit cells along a. That's what you can adjust here.
- number of unit cells along b. The same for K, dK, and b.
number of unit cells along c. If you measured your rasd scans at a regular interval dL this value should be 1/dL or smaller. As for rasd scans usually dL < 1, 1/dL > 1 that's one of the big advantages of RASD compared to x-ray standing waves.
- The Fourier synthesis calculates a 3D Matrix. The next three parameters allow you to define the size of this Matrix (x*y*z).
- The last parameters defines if electron density is calculated in the L-range (Z) from 0 to Z (default) or from -Z/2 to +Z/2.
(7) This runs the Fourier synthesis. It will produce two plots. One showing 9 y-z slices of the e-density at different x positions and the other showing a sum over z plotted as x-y image, a sum over x plotted as y-z image, a sum over y plotted as x-z image, and a sum over x and y plotted as graph rho_e- --> z. First experiences indicate that you need extremely good and many data for the Fourier synthesis to yield a really good result. But you can play around with it, use different sets of rasd scans as Fourier components, and it may help you find an estimate for how many atoms you need to model your data and good position limitations for the data refinement (and anyway it produces very nice pictures).
(8) A simulated annealing algorithm is used to model the rasd scans you specified. Here you can adjust the necessary parameters.
- First you need to tell how many atoms you want to have in your model.
- Then you give min and max values for the position of all the atoms. Attention: first min values for all atoms then max values for all atoms. Positions are in Angstroem not in fractional coordinates.
- Next you specify min and max values for the site occupancy (0-1)
- Next min and max for an isotropic Debye Waller Factor (Angstroem**2)
- Then you can modify the simulated annealing parameters, to speed up the fit or to make it more accurate. Please refer to the source code (modules/xray/ana/rasd_ana.py - simulated_annealing()) if you want to know what exactly these parameters stand for.
(9) This runs the structure refinement. As result you get the final positions, occupancies and DW-factors of all atoms and a plot showing your rasd scans with corresponding model curves.
(10) Here you can select a certain scan number
(11) Here you can switch to the next scan
(12) Here you can switch to the previous scan
(13) Use this to quit the menu
(14) The help option just shows you the menu options.
So far that's it. This is just a first version of functions that can be used to integrate and analyze RASD data, but there's of course still a lot of space for improvement. So feel free to contribute any changes you want make or to report any bugs you discover.
Shortcuts
On my page I pasted some short scripts that proved to be handy to speed up the work with CTR and RASD data in PDS.