pyFAI
pyFAI copied to clipboard
Tutorial of generation of calibrant using `xrayutilities`
The library allow and easy way to generate a list of allowed reflections.
import xrayutilities as xu
import numpy as np
cif_file = r'SRM660s-LaB6.cif'
crystal = xu.materials.cif.CIFFile(cif_file)
sg = crystal.SGLattice()
print('Content of the .cif file:')
print(crystal)
# Lattice parameters
print('a, b, c, alpha, beta, gamma:', sg.a, sg.b, sg.c, sg.alpha, sg.beta, sg.gamma)
# Space group number
sg_number = sg.space_group_nr
print('space group:', sg_number)
# List of allowed hkl
Qmax = 5 # in Angstrom^-1
hkls = sg.get_allowed_hkl(Qmax)
print(f'hkl list (Qmax={Qmax}Angst): {list(hkls)}')
# List of equivalent reflections hkl
ehkl = sg.equivalent_hkls((1,1,1))
print('equiv hkl:', ehkl)
# Check whether a reflection is allowed
hkl=(28,0,0)
check = sg.hkl_allowed(hkl)
print(hkl, 'allowed:', check)
# Reflection conditions (rules)
print(sg.reflection_conditions())
# Check whether 2 reflections are equivalent
hkl1 = (1,1,1)
hkl2 = (1,2,-1)
print(f'{hkl1} and {hkl2} are equivalent: {sg.isequivalent(hkl1, hkl2)}')
# Sorted list of hkl reflections for powder diffraction
sortedhkls = sorted(hkls, reverse=True) # sort by decreasing h, then k, then l.
print(f'Sorted hkl list: {sortedhkls}')
phkl = []
for hkl1 in sortedhkls:
alreadyIncluded = False
for hkl2 in phkl:
if sg.isequivalent(hkl1, hkl2):
alreadyIncluded = True
if not alreadyIncluded:
phkl.append(hkl1)
phkl = sorted(phkl) # finally by increasing hkl values
print(f'phkl = {phkl}')