How to retrieve and handle x-ray data

A bit wonky, but here’s where you can get x-ray data, how to use it in python, and some common conversion.

Here are two important database to know:

CXRO database

NIST database

And here’s how to get all the K-edge for heavy elements:

(feel free to edit the URL to get different energy ranges)

To import fundamental constants in python, you can user scipy.constants

import scipy.constants as constant
eV = constant.eV
h = constant.h
c = constant.c
hBar = constant.hbar
me = constant m_e #mass of an electron
NA = constant.N_A

(and here are many other constants:

Besides, instead of using CXRO website, you can use xrt (developed by K Klementiev at Max IV) to pull out some data.

For example, if you need to get the absorption coefficient for gold (‘Au’) between 10eV and 20keV, you can do this:

pip install xrt
pip install

Then here’s how to retrieve the absorbtion coefficient for gold:

import xrt.backends.raycing.materials as rm
import matplotlib.pyplot as plt
import numpy as np
import periodictable
# see
mat = rm.Material('Au',table='Henke',rho=periodictable.Au.density)
E = np.logspace(1, 4 + np.log10(2), 501) #1e1 to 2e4
mu = mat.get_absorption_coefficient(E)
plt.loglog(E, mu)
plt.xlabel('Energy [EV]')
plt.xlabel('linear absorption coefficient [cm-1]')
plt.gca().set_xlim(E[0], E[-1])

Here are some conversions useful for back of the envelope calculations:

angle[deg] = 180/pi angle[rad] ~ 57*angle[rad]
E[eV] = hc/e * 1/ λ[m] ~ 1239/λ[nm]
FWHM = 2.35 * stdev