Welcome to xrdtools’s documentation!¶
The xrdtools is a package intended to load .xrdml files created by Panalytical XPert XRD machines. No full feature support is guaranteed at the current state.
Table of Content¶
Getting xrdtools¶
The simplest way to install the packages is via pip
:
$ pip install xrdtools
The most reasoned version can be cloned from git by running following commands in your command line:
$ git clone https://github.com/paruch-group/xrdtools.git
$ cd xrdtools
$ python setup.py install
In case you do not have git installed on your system, go to
and download the compressed package. Unpack the file in a directory of your choosing and run the following commands in the our terminal:
$ cd /path/to/the/extracted/zip/file
$ python setup.py install
Quick start tutorial¶
The main functionality of the xrdtools package is to read *.xrdml files. This can be easily achieved by running the following code, e.g. in a ipython prompt:
import xrdtools
data = xrdtools.read_xrdml('foo.xrdml')
The data returned from xrdtools.read_xrdml()
is stored in a dict
. In case of a simple line scan
(e.g. 2theta-omega scan) we can get the xy data as simple as:
x = data['x']
y = data['data']
And plot it for example with matplotlib.pyplot
:
from matplotlib import pyplot as plt
plt.plot(x, y)
plt.show()
Command line tool¶
Together with the xrdtools package a command line tool xrdml
is installed. It allows to extract
the recorded data from *.xrdml files into text files or the command prompt.
Export data into a text file:
$ xrdml my_xrdml_file.xrdml #another_file.xrdml ...
In case my_xrdml_file.xrdml is a simpe 2Theta-Omega scan, this will create a text file with two columns, one for the 2Theta angles and one for the Intensity.
Export data to the prompt:
$ xrdml my_xrdml_file.xrdml -o stdout
# 2Theta-Omega Intensity
1.500000000000000000e+01 9.000000000000000222e-01
1.501869158878504606e+01 5.999999999999999778e-01
...
The type of delimiter can be changed with the --delimiter
keyword argument:
$ xrdml my_xrdml_file.xrdml -o stdout --delimiter=','
# 2Theta-Omega,Intensity
1.500000000000000000e+01,9.000000000000000222e-01
1.501869158878504606e+01,5.999999999999999778e-01
...
The output format can be changed with the --fmt
keyword argument:
$ xrdml my_xrdml_file.xrdml -o stdout --fmt='%.2f'
# 2Theta-Omega Intensity
15.00 0.90
15.02 0.60
...
xrdtools package¶
xrdtools module¶
xrdtools.io module¶
xrdtools.utils module¶
-
xrdtools.utils.
angle2qvector
(tt, om, lam=1.54)[source]¶ Convert angles to q vector.
Calculate the q-vector from the 2theta tt and omega om angle and the x-ray wavelength lambda lam.
Parameters: - tt (array-like) – Array containing the 2Theta values.
- om (array-like) – Array containing the Omega values.
- lam (float) – The wavelength lambda in Angstrom [Default: 1.54].
Returns: - kpar (ndarray)
- kperp (ndarray)
-
xrdtools.utils.
angles
(hkl, lam=1.54, lattice_param=(3.905, 3.905, 3.905))[source]¶ Compute the angle for a given hkl position.
Compute the 2Theta, Omega and Delta angle for a given hkl point, wavelength lambda and unit cell lattice parameters.
Parameters: Returns: - tt (ndarray)
- omega (ndarray)
- delta (ndarray)
-
xrdtools.utils.
get_qmap
(data, omega_offset=0)[source]¶ Function to calculate kpar, kperp.
Parameters: Returns: - kpar (ndarray)
- kperp (ndarray)