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.read_xrdml(filename)[source]

Load a Panalytical XRDML file.

Parameters:filename (str) – The filename of the xrdml file to be loaded.
Returns:A dictionary with all relevant data of the measurement.
Return type:dict

xrdtools.io module

xrdtools.io.read_xrdml(filename)[source]

Load a Panalytical XRDML file.

Parameters:filename (str) – The filename of the xrdml file to be loaded.
Returns:A dictionary with all relevant data of the measurement.
Return type:dict
xrdtools.io.validate_xrdml_schema(filename)[source]

Validate the xml schema of a given file.

Parameters:filename (str) – The Filename of the .xrdml file to test.
Returns:Returns the version number as float or None if the file was not matching any provided xml schema.
Return type:float or None

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:
  • hkl (dict) – A dictionary containing the hkl values.
  • lam (float) – The wavelength lambda in Angstrom. Defaults to 1.54.
  • lattice_param (tuple) – A tuple of three floats for the lattice parameter.
Returns:

  • tt (ndarray)
  • omega (ndarray)
  • delta (ndarray)

xrdtools.utils.get_qmap(data, omega_offset=0)[source]

Function to calculate kpar, kperp.

Parameters:
  • data (dict) – A xrdml data dictionary.
  • omega_offset (float) – Offset for the omega angle.
Returns:

  • kpar (ndarray)
  • kperp (ndarray)

xrdtools.utils.q2hkl_map(x, y, lattice_params=(3.905, 3.905, 3.905), hkl=None)[source]

Compute the hk coordinates for a given q vector.

Parameters:
  • x (ndarray) –
  • y (ndarray) –
  • lattice_params (tuple) – A tuple of three floats for the lattice parameter.
  • hkl (dict) – A dictionary containing the hkl values. Defaults to 001 if not given [Default: None].
Returns:

  • x (ndarray)
  • y (ndarray)

Subpackages

xrdtools.tools package
xrdtools.tools.clt module
xrdtools.tools.clt.xrdml()[source]

Command line tool to export measurement data from xrdml files.

-o, –output : str
Choices: ‘stdout’, ‘txt’ [default: ‘txt’]
–delimiter : str
Default: ‘ ‘
–fmt : str
Default: ‘%.18e’

Indices and tables