#!/usr/bin/env python # this script requires Python3, numpy, scipy, matplotlib, and xraydb modules. Use: # pip install xraydb scipy matplotlib import numpy as np import matplotlib.pyplot as plt import xraydb # X-ray monochromator Darwin Width calculations # inputs from web form xtal = 'Si' h, k, l = (1, 1, 1) polarization = 's' energy = 10000 dw = xraydb.darwin_width(energy, xtal, (h, k, l), polarization=polarization) print('Mono Angle: %.5f deg' % (dw.theta*180/np.pi)) print('Angular width : %.5f microrad' % (dw.theta_width*1.e6)) print('Energy width : %.5f eV' % (dw.energy_width)) plt.plot(dw.denergy, dw.intensity) plt.xlabel('Energy (eV)') plt.ylabel('reflectivity') plt.title(f'{xtal} {(h, k, l)}, "{polarization}" polar, E={energy} eV') plt.show() plt.plot(dw.dtheta*1e6, dw.intensity) plt.xlabel('Angle (microrad)') plt.ylabel('reflectivity') plt.title(f'{xtal} {(h, k, l)}, "{polarization}" polar, E={energy} eV') plt.show()