Creation of a new calibrant

In this tutorial we will see how to create a new calibrant. For this example we will use one of the calibrant sold by the NIST: Chromium oxide.

The cell parameter are definied in this document: http://www.cristallografia.org/uploaded/614.pdf

The first step is to record the cell parameters and provide them to pyFAI to define the cell.

[1]:
import pyFAI
print("pyFAI version",pyFAI.version)
pyFAI version 2023.9.0-dev0
[2]:
from pyFAI.calibrant import Cell
crox = Cell.hexagonal(4.958979, 13.59592)

Chromium oxide has a crystal structure de Corrundom which is R-3c (space group 167). The selection rules are rather complicated and are available in: http://img.chem.ucl.ac.uk/sgp/large/167bz2.gif

We will setup a function corresponding to the selection rules. It returns True if the reflection is active and False otherwise.

[3]:
def reflection_condition_167(h,k,l):
    """from http://img.chem.ucl.ac.uk/sgp/large/167bz2.htm"""
    if h == 0 and k == 0:
        # 00l: 6n
        return l%6 == 0
    elif h == 0 and l == 0:
        # 0k0: k=3n
        return k%3 == 0
    elif k == 0 and l == 0:
        # h00: h=3n
        return h%3 == 0
    elif h == k:
        # hhl: l=3n
        return l%3 == 0
    elif l == 0:
        # hk0: h-k = 3n
        return (h-3)%3 == 0
    elif k == 0:
        # h0l: l=2n h-l = 3n
        return (l%2 == 0) and ((h - l)%3 == 0)
    elif h == 0:
        # 0kl: l=2n h+l = 3n
        return (l%2 == 0) and ((k + l)%3 == 0)
    else:
        # -h + k + l = 3n
        return (-h + k + l) % 3 == 0
[4]:
# Use the actual selection rule, not the short version:
#cro.selection_rules.append(lambda h, k, l: ((-h + k + l) % 3 == 0))
crox.selection_rules.append(reflection_condition_167)
[5]:
for reflex in crox.d_spacing(1).values():
    print(reflex[0], reflex[1])
1.0237895129603751 (-4, 0, -4)
1.06050521932356 (-4, 0, 2)
1.091026544381222 (-4, 1, -5)
1.1732349299369376 (-4, 1, -2)
1.1865634227509676 (-4, 1, 1)
1.1240862807166163 (-4, 1, 4)
1.0153814717019545 (-4, 1, 7)
1.0876084918690192 (-4, 2, -6)
1.1958092169288077 (-4, 2, -3)
1.07031836243183 (-4, 4, 1)
1.191108228042296 (-3, -1, 0)
1.210253337060561 (-3, 0, -6)
1.431533930277851 (-3, 0, 0)
1.042279063895563 (-3, 1, -10)
1.245515918797666 (-3, 1, -7)
1.464751514565614 (-3, 1, -4)
1.6117606917001979 (-3, 1, -1)
1.623206902656887 (-3, 1, 0)
1.5788223557618772 (-3, 1, 2)
1.3937626066300757 (-3, 1, 5)
1.173822262746344 (-3, 1, 8)
1.0390938597733972 (-3, 3, -9)
1.3650526839471662 (-3, 3, -3)
1.2397447500000003 (-2, -2, 0)
1.3326159122281918 (-2, 0, -8)
2.0475790259207503 (-2, 0, -2)
1.8153800055908411 (-2, 0, 4)
1.1486975649382964 (-2, 0, 10)
1.0305051285304707 (-2, 1, -12)
1.2900773006845312 (-2, 1, -9)
1.6726910204294987 (-2, 1, -6)
2.1752169837380384 (-2, 1, -3)
1.4404399928990794 (-2, 2, -7)
2.1210104386471196 (-2, 2, -1)
1.6852056306951424 (-2, 2, 5)
1.0712106709595173 (-2, 2, 11)
2.4794895000000006 (-1, -1, 0)
1.2961881850329564 (-1, 0, -10)
2.6652318244563835 (-1, 0, -4)
3.6307600111816822 (-1, 0, 2)
1.5802545229021043 (-1, 0, 8)
1.187779534309575 (-1, 1, -11)
2.297395129876593 (-1, 1, -5)
4.0951580518415 (-1, 1, 1)
1.7697022220402947 (-1, 1, 7)
1.0161432164799655 (-1, 1, 13)
1.1329933333333335 (0, 0, -12)
2.265986666666667 (0, 0, -6)
[6]:
crox.save("Cr2O3", "Eskolaite (R-3c)", dmin=0.1, doi="NIST reference compound SRM 674b")

Conclusion

This is an advanced tutorial, most user won’t have to define their own calibrant. You can also contact the developers to get your own calibrant integrated into pyFAI which makes things easier for you and other users.