## 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: https://physics.nist.gov/cgi-bin/XrayTrans/search.pl?download=column&element=All&trans=Kedge&lower=100&upper=10000&units=eV

(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: https://docs.scipy.org/doc/scipy/reference/constants.html)

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 https://xrt.readthedocs.io/raycing.html#module-xrt.backends.raycing.materials 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, E[-1]) plt.show() ```
Here are some conversions useful for back of the envelope calculations: