In order to turn scattering patterns into meaningful information in reciprocal space, the detectors must be calibrated to set up the parameters for data processing. At LiX, beamline staff regularly collect scattering data from standard samples. These data should be used to update the geometric parameters and mask for each detector.
%matplotlib inline
import warnings
warnings.filterwarnings(action="ignore")
from py4xs.hdf import h5xs,h5exp
import pylab as plt
import numpy as np
In this example, recalibration is done using existing poni files produced by pyFAI. This function can also automatically generate masks for the detectors, based on the dark current (beam off) and scattering data from empty cell and amophous carbon. If the scattering path use mica windows (instead of Kapton), this function will automatically find the mica peaks as well.
dexp = h5exp("data/exp-2025Jun12.h5")
dexp.recalibrate("data/std-2025Jun12.h5",
use_existing_poni=['data/s.poni', 'data/w.poni'],
generate_mask=True, mica_window=False)
For verification, review the azimuthally averaged data from standard samples. There should not be any artifacts such as discontinuity between SAXS and WAXS data (due to incorrect scaling factor), high-intensity spikes (hot pixels), or split of peaks from silver behenate (incorrect beam center).
dt = h5xs("data/std-2025Jun12.h5")
dt.load_d1s()
plt.figure()
for sn in dt.samples:
dt.d1s[sn]['merged'][0].plot(ax=plt.gca())
Take a look at the mask more closely. Adjust if necessary. If you observe high-intensity spikes in the 1D data. It can be helpful to track down the hot pixels following the ring corresponding to the \(q\) value where the spike appears.
plt.figure(figsize=(6,6))
dt.show_data(sn="empty-2025Jun12", det_ext="_WAXS2",
showMask=True, mask_alpha=0.5, showRef=[[2.1], "b--"])
This will show the essential parameters saved in the detector configurations:
dexp.report()