Chapter 2: Diffraction


2.6. Analyzing Ring Diffraction Pattern#

Download

OpenInColab

part of

MSE672: Introduction to Transmission Electron Microscopy

Spring 2024

Gerd Duscher Khalid Hattar
Microscopy Facilities Tennessee Ion Beam Materials Laboratory
Materials Science & Engineering Nuclear Engineering
Institute of Advanced Materials & Manufacturing
The University of Tennessee, Knoxville

Background and methods to analysis and quantification of data acquired with transmission electron microscopes.

2.6.1. Load relevant python packages#

2.6.1.1. Check Installed Packages#

import sys
import importlib.metadata
def test_package(package_name):
    """Test if package exists and returns version or -1"""
    try:
        version = importlib.metadata.version(package_name)
    except importlib.metadata.PackageNotFoundError:
        version = '-1'
    return version

if test_package('pyTEMlib') < '0.2024.1.0':
    print('installing pyTEMlib')
    !{sys.executable} -m pip install git+https://github.com/pycroscopy/pyTEMlib.git@main -q --upgrade

if 'google.colab' in sys.modules:
    !{sys.executable} -m pip install numpy==1.24.4
print('done')
installing pyTEMlib
^C
done

2.6.1.2. Load the plotting and figure packages#

Import the python packages that we will use:

Beside the basic numerical (numpy) and plotting (pylab of matplotlib) libraries,

  • three dimensional plotting and some libraries from the book

  • kinematic scattering library.

%matplotlib  widget
import matplotlib.pyplot as plt
import numpy as np
import sys
if 'google.colab' in sys.modules:
    from google.colab import output
    from google.colab import drive
    output.enable_custom_widget_manager()
    
# 3D plotting package 
from mpl_toolkits.mplot3d import Axes3D # 3D plotting

# additional package 
import itertools 
import scipy.constants as const
import os

# Import libraries from the book
import pyTEMlib
import pyTEMlib.kinematic_scattering as ks         # Kinematic sCattering Library
                             # with Atomic form factors from Kirklands book
import pyTEMlib.file_tools as ft     
# it is a good idea to show the version numbers at this point for archiving reasons.
__notebook_version__ = '2024.01.10'
print('pyTEM version: ', pyTEMlib.__version__)
print('notebook version: ', __notebook_version__)
You don't have igor2 installed.     If you wish to open igor files, you will need to install it     (pip install igor2) before attempting.
You don't have gwyfile installed.     If you wish to open .gwy files, you will need to      install it (pip install gwyfile) before attempting.
Symmetry functions of spglib enabled
Qt dialogs are not available
Using kinematic_scattering library version {_version_ }  by G.Duscher
pyTEM version:  0.2024.01.1
notebook version:  2024.01.10

2.6.2. Load Ring-Diffraction Pattern#

2.6.2.1. First we select the diffraction pattern#

Load the GOLD-NP-DIFF.dm3 file as an example.

The dynamic range of diffraction patterns is too high for computer screens and so we take the logarithm of the intensity.

# ------Input -------------
load_your_own_data = False
# -------------------------
if 'google.colab' in sys.modules:
        drive.mount("/content/drive")

if load_your_own_data:
    fileWidget = ft.FileWidget()
if load_your_own_data:
    datasets = fileWidget.datasets
    main_dataset = fileWidget.selected_dataset
else:  # load example
    datasets = ft.open_file(os.path.join("../example_data", "GOLD-NP-DIFF.dm3"))
    main_dataset =  datasets['Channel_000']

view = main_dataset.plot(vmax=20000)
0 1
1 1
Channel_000 sidpy.Dataset of type IMAGE with:
 dask.array<array, shape=(2048, 2048), dtype=int32, chunksize=(2048, 2048), chunktype=numpy.ndarray>
 data contains: intensity (counts)
 and Dimensions: 
u:  reciprocal distance (1/nm) of size (2048,)
v:  reciprocal distance (1/nm) of size (2048,)
 with metadata: ['experiment']
Channel_000

2.6.3. Finding the center#

2.6.3.1. First try with cross correlation of rotated images#

2.6.3.2. Cross- and Auto- Correlation#

Cross correlation and auto correlation are based on a multiplication in Fourier space. In the case of a an auto-correlation it is the same data while in the cross correlation it is another data (here the transposed (rotated) diffraction pattern)”

## Access the data of the loaded image
    
diff_pattern = np.array(main_dataset)
diff_pattern = diff_pattern-diff_pattern.min()
correlation = 'auto'
dif_ft = np.fft.fft2(diff_pattern)
if correlation == 'auto':
    auto_correlation  = np.fft.fftshift(np.fft.ifft2(dif_ft*dif_ft))
    center = np.unravel_index(np.argmax(auto_correlation.real, axis=None), auto_correlation.real.shape)
    plt.figure()
    plt.title('Auto-Correlation')
    plt.imshow(auto_correlation.real);
else:   
    dif_ft2 = np.fft.fft2(diff_pattern.T)
    cross_correlation  = np.fft.fftshift(np.fft.ifft2(dif_ft*dif_ft2))
    center = np.unravel_index(np.argmax(cross_correlation.real, axis=None), cross_correlation.real.shape)
    plt.figure()
    plt.title('Cross-Correlation')
    plt.imshow(auto_correlation.real);

shift = np.array(center - np.array(dif_ft.shape)/2)
print(f'center = {center} which is a shift of {shift[0]} px in x and {shift[1]} px in y direction')
plt.scatter([center[1]],[center[0]]);
center = (1090, 1182) which is a shift of 66.0 px in x and 158.0 px in y direction

2.6.3.3. How well did we do?#

2.6.3.4. Select the center yourself#

The beam stop confuses the cross correlation sometimes and then we need to adjust the selection

from matplotlib.widgets import  EllipseSelector
from pylab import *

def onselect(eclick, erelease):
  'eclick and erelease are matplotlib events at press and release'
  print(' startposition : (%f, %f)' % (eclick.xdata, eclick.ydata))
  print(' endposition   : (%f, %f)' % (erelease.xdata, erelease.ydata))
  print(' used button   : ', eclick.button)

def toggle_selector(event):
    print(' Key pressed.')
    if event.key in ['Q', 'q'] and toggle_selector.ES.active:
        print(' EllipseSelector deactivated.')
        toggle_selector.RS.set_active(False)
    if event.key in ['A', 'a'] and not toggle_selector.ES.active:
        print(' EllipseSelector activated.')
        toggle_selector.ES.set_active(True)

x = arange(100)/(99.0)
y = sin(x)
fig = figure
ax = subplot(111)
ax.plot(x,y)

toggle_selector.ES = EllipseSelector(ax, onselect)
connect('key_press_event', toggle_selector)
show()
from matplotlib.widgets import  EllipseSelector
import pyTEMlib.image_tools    
import scipy
print(np.array(center)-2048)
center = np.array(center)

plt.figure(figsize=(8, 6))
plt.imshow(np.log(3.+diff_pattern).T, origin = 'upper')
selector = pyTEMlib.image_tools.LineSelector(plt.gca(), None,line_width=300)  # gca get current axis (plot)

selector.set_linewidth(300)
# selector.to_draw.set_visible(True)
radius = 559 
center = np.array(center)

selector.extents = (center[0]-radius,center[0]+radius,center[1]-radius,center[1]+radius)
[-958 -866]
x0 = int(selector.line_verts[3,0])
x1 = int(selector.line_verts[0,0])
y0 = int(selector.line_verts[3,1])
y1 = int(selector.line_verts[0,1])
self = selector
m = -(self.line_verts[0, 1]-self.line_verts[3, 1])/(self.line_verts[0, 0]-self.line_verts[3, 0])
c = 1/np.sqrt(1+m**2)
s = c*m

nx, ny = (3, 5)

x = np.linspace(0, nx)

y = np.linspace(0, ny)

xv, yv = np.meshgrid(x, y)
print(xv, yv)

#scipy.ndimage.map_coordinates(diff_pattern.T, xv.flatten(), yv.flatten())
[[0.         0.06122449 0.12244898 ... 2.87755102 2.93877551 3.        ]
 [0.         0.06122449 0.12244898 ... 2.87755102 2.93877551 3.        ]
 [0.         0.06122449 0.12244898 ... 2.87755102 2.93877551 3.        ]
 ...
 [0.         0.06122449 0.12244898 ... 2.87755102 2.93877551 3.        ]
 [0.         0.06122449 0.12244898 ... 2.87755102 2.93877551 3.        ]
 [0.         0.06122449 0.12244898 ... 2.87755102 2.93877551 3.        ]] [[0.         0.         0.         ... 0.         0.         0.        ]
 [0.10204082 0.10204082 0.10204082 ... 0.10204082 0.10204082 0.10204082]
 [0.20408163 0.20408163 0.20408163 ... 0.20408163 0.20408163 0.20408163]
 ...
 [4.79591837 4.79591837 4.79591837 ... 4.79591837 4.79591837 4.79591837]
 [4.89795918 4.89795918 4.89795918 ... 4.89795918 4.89795918 4.89795918]
 [5.         5.         5.         ... 5.         5.         5.        ]]
plt.figure(figsize=(8, 6))
plt.imshow(np.log(3.+diff_pattern).T, origin = 'upper')
plt.scatter(np.int64(line_verts[0,0,:]), np.int64(line_verts[1,1,:]))
<matplotlib.collections.PathCollection at 0x2d55d691760>
import scipy
x0 = selector.line_verts[3,0]
x1 = selector.line_verts[0,0]
y0 = selector.line_verts[3,1]
y1 = selector.line_verts[1,1]

length_plot = np.sqrt((x1-x0)**2+(y1-y0)**2)

num = int(length_plot)
x = np.linspace(x0, x1, num)
y = np.linspace(y0, y1, num)

# Extract the values along the line, using cubic interpolation
zi2 = scipy.ndimage.map_coordinates(diff_pattern.T, np.vstack((x, y)))
print(np.vstack((x, y)))

x_axis = np.linspace(0, length_plot, len(zi2))
x = x_axis
z = zi2

plt.figure()
plt.plot(z)
[[ 442.79004329  443.77146404  444.75288478 ... 1890.38564336
  1891.3670641  1892.34848485]
 [1418.02813853 1418.22584755 1418.42355657 ... 1709.6489412
  1709.84665022 1710.04435924]]
[<matplotlib.lines.Line2D at 0x2d53a7f1190>]
z[0] image[4]
inds = np.array([[0.5, 2], [0.5, 4]])
from matplotlib.widgets import  EllipseSelector
    
print(np.array(center)-2048)
center = np.array(center)

plt.figure(figsize=(8, 6))
plt.imshow(np.log(3.+diff_pattern).T, origin = 'upper')
selector = EllipseSelector(plt.gca(), None,interactive=True )  # gca get current axis (plot)

# selector.to_draw.set_visible(True)
radius = 559 
center = np.array(center)

selector.extents = (center[0]-radius,center[0]+radius,center[1]-radius,center[1]+radius)
[-958 -866]

Get center coordinates from selection

xmin, xmax, ymin, ymax = selector.extents
x_center, y_center = selector.center
x_shift = x_center - diff_pattern.shape[0]/2
y_shift = y_center - diff_pattern.shape[1]/2
print(f'radius = {(xmax-xmin)/2:.0f} pixels')

center = (x_center, y_center )
print(f'new center = {center} [pixels]')


out_tags ={}
out_tags['center'] = center
radius = 559 pixels
new center = (1054.5367965367968, 1093.3419913419912) [pixels]

2.6.4. Ploting Diffraction Pattern in Polar Coordinates\n”,#

2.6.4.1. The Transformation Routine#

from scipy.interpolate import interp1d
from scipy.ndimage import map_coordinates


def cartesian2polar(x, y, grid, r, t, order=3):

    R,T = np.meshgrid(r, t)

    new_x = R*np.cos(T)
    new_y = R*np.sin(T)

    ix = interp1d(x, np.arange(len(x)))
    iy = interp1d(y, np.arange(len(y)))

    new_ix = ix(new_x.ravel())
    new_iy = iy(new_y.ravel())

    
    return map_coordinates(grid, np.array([new_ix, new_iy]),
                            order=order).reshape(new_x.shape)

def warp(diff,center):
    # Define original polar grid
    nx = diff.shape[0]
    ny = diff.shape[1]

    x = np.linspace(1, nx, nx, endpoint = True)-center[0]
    y = np.linspace(1, ny, ny, endpoint = True)-center[1]
    z = diff

    # Define new polar grid
    nr = int(min([center[0], center[1], diff.shape[0]-center[0], diff.shape[1]-center[1]])-1)
    print(nr)
    nt = 360*3


    r = np.linspace(1, nr, nr)
    t = np.linspace(0., np.pi, nt, endpoint = False)
    return cartesian2polar(x,y, z, r, t, order=3).T

2.6.4.2. Now we transform#

If the center is correct a ring in carthesian coordinates is a line in polar coordinates

A simple sum over all angles gives us then the diffraction profile (intensity profile of diffraction pattern)

center = np.array(center)
out_tags={'center': center}
#center[1] = 1057
# center[0]= 1103
# center[1]=1055

polar_projection = warp(diff_pattern,center)
below_zero = polar_projection<0.
polar_projection[below_zero]=0.

out_tags['polar_projection'] = polar_projection

# Sum over all angles (axis 1)
profile = polar_projection.sum(axis=1)
profile_0 = polar_projection[:,0:20].sum(axis=1)
profile_360 = polar_projection[:,340:360].sum(axis=1)
profile_180 = polar_projection[:,190:210].sum(axis=1)

profile_90 = polar_projection[:,80:100].sum(axis=1)
profile_270 = polar_projection[:,260:280].sum(axis=1)


out_tags['radial_average'] = profile

scale = ft.get_slope(main_dataset.dim_0.values)

plt.figure()
plt.imshow(np.log2(1+polar_projection),extent=(0,360,polar_projection.shape[0]*scale,scale),cmap="gray", vmin=np.max(np.log2(1+diff_pattern))*0.5)
ax = plt.gca()
ax.set_aspect("auto");
plt.xlabel('angle [degree]');
plt.ylabel('distance [1/nm]')

plt.plot(profile/profile.max()*200,np.linspace(1,len(profile),len(profile))*scale,c='r');
#plt.plot(profile_0/profile_0.max()*200,np.linspace(1,len(profile),len(profile))*scale,c='orange');
#plt.plot(profile_360/profile_360.max()*200,np.linspace(1,len(profile),len(profile))*scale,c='orange');
#plt.plot(profile_180/profile_180.max()*200,np.linspace(1,len(profile),len(profile))*scale,c='b');
plt.plot(profile_90/profile_90.max()*200,np.linspace(1,len(profile),len(profile))*scale,c='orange');
plt.plot(profile_270/profile_270.max()*200,np.linspace(1,len(profile),len(profile))*scale,c='b');


plt.plot([0,360],[3.8,3.8])
plt.plot([0,360],[6.3,6.3])
953
[<matplotlib.lines.Line2D at 0x1f236774710>]

2.6.5. Determine Bragg Peaks#

Peak finding is actually not as simple as it looks

import scipy as sp
import scipy.signal as signal

scale = ft.get_slope(main_dataset.dim_0.values)*4.28/3.75901247*1.005
# find_Bragg peaks in profile
peaks, g= signal.find_peaks(profile,rel_height =0.7, width=7)  # np.std(second_deriv)*9)

print(peaks*scale)

out_tags['ring_radii_px'] = peaks


plt.figure()

plt.imshow(np.log2(1.+polar_projection),extent=(0,360,polar_projection.shape[0]*scale,scale),cmap='gray', vmin=np.max(np.log2(1+diff_pattern))*0.5)

ax = plt.gca()
ax.set_aspect("auto");
plt.xlabel('angle [degree]');
plt.ylabel('distance [1/nm]')

plt.plot(profile/profile.max()*200,np.linspace(1,len(profile),len(profile))*scale,c='r');

for i in peaks:
    if i*scale > 3.5:
        plt.plot((0,360),(i*scale,i*scale), linestyle='--', c = 'steelblue')
[ 0.21624743  0.68690359  1.17028019  1.46285024  2.56952825  4.52847552
  5.15177693  7.35241251  8.59901532 11.37207056]

2.6.6. Calculate Ring Pattern#

see Structure Factors notebook for details.

# Initialize the dictionary with all the input
atoms = ks.structure_by_name('gold')

main_dataset.structures['Structure_000'] = atoms


#Reciprocal Lattice 
# We use the linear algebra package of numpy to invert the unit_cell \"matrix\"
reciprocal_unit_cell = atoms.cell.reciprocal() # transposed of inverted unit_cell

#INPUT
hkl_max = 7#  maximum allowed Miller index

acceleration_voltage = 200.0 *1000.0 #V
wave_length  = ks.get_wavelength(acceleration_voltage)



h  = np.linspace(-hkl_max,hkl_max,2*hkl_max+1)   # all to be evaluated single Miller Index
hkl  = np.array(list(itertools.product(h,h,h) )) # all to be evaluated Miller indices
g_hkl = np.dot(hkl,reciprocal_unit_cell)  

# Calculate Structure Factors

structure_factors = []

base = atoms.positions # in Carthesian coordinates
for j  in range(len(g_hkl)):
    F = 0
    for b in range(len(base)):
        f = ks.feq(atoms[b].symbol,np.linalg.norm(g_hkl[j])) # Atomic form factor for element and momentum change (g vector)
        F += f * np.exp(-2*np.pi*1j*(g_hkl[j]*base[b]).sum())        
    structure_factors.append(F)
F = structure_factors = np.array(structure_factors)

# Allowed reflections have a non zero structure factor F (with a  bit of numerical error)
allowed = np.absolute(structure_factors) > 0.001

distances = np.linalg.norm(g_hkl, axis = 1)

print(f' Of the evaluated {hkl.shape[0]} Miller indices {allowed.sum()} are allowed. ')
# We select now all the 
zero = distances == 0.
allowed = np.logical_and(allowed,np.logical_not(zero))

F = F[allowed]
g_hkl = g_hkl[allowed]
hkl = hkl[allowed]
distances = distances[allowed]

sorted_allowed = np.argsort(distances)

distances = distances[sorted_allowed]
hkl = hkl[sorted_allowed]
F = F[sorted_allowed]

# How many have unique distances and what is their muliplicity

unique, indices  = np.unique(distances, return_index=True)

print(f' Of the {allowed.sum()} allowed Bragg reflections there are {len(unique)} families of reflections.')

intensity = np.absolute(F[indices]**2*(np.roll(indices,-1)-indices))
print('\n index \t  hkl \t      1/d [1/Ang]       d [pm]     F      multip.  intensity' )
family = []

reflection = 0
for j in range(len(unique)-1):
    i = indices[j]    
    i2 = indices[j+1]   
    family.append(hkl[i+np.argmax(hkl[i:i2].sum(axis=1))])
    index = '{'+f'{family[j][0]:.0f} {family[j][1]:.0f} {family[j][2]:.0f}'+'}'
    print(f'{i:3g}\t {index} \t  {distances[i]:.2f}  \t {1/distances[i]*100:.0f} \t {np.absolute(F[i]):4.2f} \t  {indices[j+1]-indices[j]:3g} \t {intensity[j]:.2f}') 
    #out_tags['reflections'+str(reflection)]={}
    out_tags['reflections-'+str(reflection)+'-index'] = index
    out_tags['reflections-'+str(reflection)+'-recip_distances'] = distances[i]
    out_tags['reflections-'+str(reflection)+'-structure_factor'] = np.absolute(F[i])
    out_tags['reflections-'+str(reflection)+'-multiplicity'] = indices[j+1]-indices[j]
    out_tags['reflections-'+str(reflection)+'-intensity'] = intensity[j]
    reflection +=1
 Of the evaluated 3375 Miller indices 855 are allowed. 
 Of the 854 allowed Bragg reflections there are 39 families of reflections.

 index 	  hkl 	      1/d [1/Ang]       d [pm]     F      multip.  intensity
  0	 {1 1 1} 	  0.42  	 235 	 27.00 	    8 	 5832.86
  8	 {0 0 2} 	  0.49  	 204 	 24.48 	    6 	 3596.79
 14	 {0 2 2} 	  0.69  	 144 	 18.27 	   12 	 4004.58
 26	 {1 1 3} 	  0.81  	 123 	 15.54 	    8 	 1930.91
 34	 {1 3 1} 	  0.81  	 123 	 15.54 	   16 	 3861.82
 50	 {2 2 2} 	  0.85  	 118 	 14.82 	    8 	 1756.96
 58	 {0 0 4} 	  0.98  	 102 	 12.57 	    6 	 948.09
 64	 {3 3 1} 	  1.07  	 94 	 11.33 	    8 	 1026.40
 72	 {3 1 3} 	  1.07  	 94 	 11.33 	   16 	 2052.80
 88	 {4 0 2} 	  1.10  	 91 	 10.97 	   24 	 2889.10
112	 {2 2 4} 	  1.20  	 83 	 9.77 	   24 	 2291.50
136	 {5 1 1} 	  1.27  	 78 	 9.05 	   16 	 1310.07
152	 {3 3 3} 	  1.27  	 78 	 9.05 	   16 	 1310.07
168	 {0 4 4} 	  1.39  	 72 	 8.08 	   12 	 783.51
180	 {1 5 3} 	  1.45  	 69 	 7.60 	   48 	 2775.70
228	 {4 4 2} 	  1.47  	 68 	 7.46 	   30 	 1669.40
258	 {6 2 0} 	  1.55  	 64 	 6.94 	   24 	 1155.47
282	 {3 3 5} 	  1.61  	 62 	 6.60 	   24 	 1045.13
306	 {2 2 6} 	  1.63  	 61 	 6.49 	    8 	 337.38
314	 {2 6 2} 	  1.63  	 61 	 6.49 	   16 	 674.76
330	 {4 4 4} 	  1.70  	 59 	 6.11 	    8 	 298.61
338	 {5 1 5} 	  1.75  	 57 	 5.85 	   24 	 822.23
362	 {5 5 1} 	  1.75  	 57 	 5.85 	   24 	 822.23
386	 {0 4 6} 	  1.77  	 57 	 5.77 	   24 	 799.86
410	 {2 4 6} 	  1.83  	 54 	 5.48 	   48 	 1439.07
458	 {3 5 5} 	  1.88  	 53 	 5.27 	   72 	 2002.47
530	 {3 7 3} 	  2.01  	 50 	 4.81 	   24 	 554.73
554	 {6 4 4} 	  2.02  	 49 	 4.76 	   24 	 542.78
578	 {0 6 6} 	  2.08  	 48 	 4.56 	   12 	 249.42
590	 {5 5 5} 	  2.12  	 47 	 4.42 	   56 	 1095.37
646	 {6 6 2} 	  2.14  	 47 	 4.38 	    8 	 153.42
654	 {6 2 6} 	  2.14  	 47 	 4.38 	   16 	 306.83
670	 {5 7 3} 	  2.23  	 45 	 4.10 	   48 	 806.10
718	 {4 6 6} 	  2.30  	 43 	 3.92 	   24 	 368.66
742	 {7 5 5} 	  2.44  	 41 	 3.58 	   48 	 614.38
790	 {7 7 3} 	  2.54  	 39 	 3.37 	   24 	 271.77
814	 {6 6 6} 	  2.55  	 39 	 3.34 	    8 	 89.26
822	 {7 7 5} 	  2.72  	 37 	 3.01 	   24 	 217.16

We can have a look what we saved in the file

main_dataset.metadata['SAED'] = out_tags
main_dataset.metadata
{'experiment': {'exposure_time': 0.5,
  'microscope': 'Libra 200 MC',
  'acceleration_voltage': 199990.28125},
 'SAED': {'center': array([1054.53679654, 1093.34199134]),
  'polar_projection': array([[ 111,  111,  111, ...,  150,  150,  150],
         [  99,   99,   98, ...,  100,  100,  100],
         [ 113,  113,  112, ...,  118,  117,  117],
         ...,
         [1324, 1436, 1371, ...,  901,  872,  944],
         [1262, 1396, 1354, ...,  895,  880,  832],
         [1284, 1297, 1361, ...,  915,  922,  777]]),
  'radial_average': array([  148836,    93699,   129753,   140513,   130784,   122593,
           124406,   130814,   123720,   136909,   122484,   122371,
           126946,   129407,   129853,   127250,   126809,   132294,
           129702,   125705,   126971,   123653,   120413,   126933,
           128107,   128319,   127503,   124824,   125496,   130048,
           130221,   131443,   127203,   134670,   130296,   130245,
           127333,   130079,   126161,   129473,   125370,   125633,
           129478,   127914,   130516,   125466,   129849,   128702,
           130122,   126303,   130293,   131133,   128210,   130659,
           132280,   131648,   129528,   130468,   130740,   127451,
           127156,   129860,   125283,   129078,   130122,   132297,
           127062,   129022,   128874,   125346,   128930,   132911,
           130211,   131451,   129194,   126892,   130788,   128333,
           128494,   125555,   129732,   130341,   128384,   129396,
           128072,   126795,   128785,   127971,   132199,   128593,
           131210,   131936,   134398,   129940,   129292,   129674,
           129483,   130795,   129677,   126074,   130119,   129540,
           130301,   129215,   128710,   128643,   127218,   129000,
           131430,   129481,   131345,   131397,   130476,   131596,
           131704,   132178,   127474,   129318,   131728,   130791,
           130233,   128175,   129438,   128674,   130462,   131641,
           129854,   134404,   130260,   128525,   127800,   130779,
           130943,   130461,   130884,   131620,   133024,   131292,
           131536,   133754,   129650,   131994,   133698,   134255,
           133371,   131882,   134009,   133162,   136103,   135491,
           137004,   134363,   135006,   134699,   135886,   133936,
           135976,   135219,   138826,   140043,   141838,   141588,
           141166,   141929,   143598,   143221,   142486,   145354,
           147035,   145423,   148862,   150948,   154823,   156447,
           158146,   160519,   162610,   168979,   173819,   182459,
           192391,   207713,   231356,   276453,   348587,   473167,
           682771,  1028173,  1580939,  2428895,  3631850,  5268806,
          7478480,  9989837, 12193141, 14322888, 16581099, 18337784,
         19325882, 19843714, 20110152, 20210750, 20216976, 20141863,
         20007864, 19863257, 19705531, 19518682, 19325076, 19143719,
         18977206, 18841691, 18685124, 18505014, 18351225, 18236622,
         18115449, 17963948, 17812798, 17704171, 17580492, 17452893,
         17305703, 17165844, 17064240, 16912286, 16778923, 16638920,
         16526270, 16419981, 16287758, 16141729, 16014248, 15893959,
         15778295, 15649434, 15511739, 15416931, 15329911, 15207932,
         15067119, 14913803, 14809956, 14691725, 14570015, 14458580,
         14355514, 14248493, 14128715, 14038433, 13952920, 13845841,
         13745729, 13655682, 13557584, 13443175, 13336075, 13232258,
         13152315, 13063128, 12972737, 12890658, 12814785, 12691991,
         12603528, 12524974, 12454952, 12397200, 12304401, 12204739,
         12120085, 12058887, 11970268, 11881655, 11813396, 11755659,
         11655135, 11576108, 11500837, 11432660, 11368109, 11314437,
         11260168, 11204182, 11165460, 11116228, 11062633, 10998704,
         10933135, 10873178, 10836398, 10793843, 10743835, 10698922,
         10658657, 10635407, 10593561, 10565971, 10517749, 10472820,
         10451836, 10419777, 10384497, 10357935, 10329603, 10309833,
         10299449, 10305832, 10299513, 10293107, 10278831, 10273828,
         10275534, 10285767, 10305583, 10316656, 10349749, 10378363,
         10421072, 10444904, 10480940, 10542802, 10596994, 10667971,
         10747060, 10858815, 10963919, 11085579, 11226953, 11375330,
         11532723, 11723970, 11961701, 12219608, 12496173, 12827501,
         13191230, 13604791, 14046318, 14547532, 15103225, 15729216,
         16399333, 17117819, 17896079, 18715293, 19528184, 20352554,
         21193357, 22030784, 22852124, 23610235, 24271166, 24813957,
         25200521, 25454047, 25524487, 25414625, 25099704, 24591569,
         23997176, 23339573, 22581911, 21764201, 20940008, 20099867,
         19264938, 18448685, 17708213, 16999882, 16336421, 15737983,
         15207286, 14746010, 14309244, 13924400, 13593208, 13299168,
         13052215, 12847873, 12658994, 12480048, 12342003, 12232309,
         12127737, 12052540, 11996346, 11948709, 11918711, 11915864,
         11931377, 11944285, 11976667, 12030604, 12066590, 12137411,
         12209697, 12264938, 12331101, 12388284, 12463173, 12521361,
         12563833, 12624516, 12649328, 12656002, 12616294, 12577549,
         12505009, 12420026, 12292861, 12122982, 11945034, 11714699,
         11484374, 11238565, 10969573, 10682606, 10404871, 10123549,
          9848824,  9572080,  9305427,  9060430,  8832035,  8611888,
          8404602,  8199889,  8015294,  7836777,  7670341,  7506809,
          7357160,  7221108,  7091989,  6969976,  6856641,  6743190,
          6631924,  6525859,  6442756,  6351056,  6265557,  6179077,
          6101606,  6040513,  5978314,  5899082,  5831836,  5768172,
          5709359,  5662070,  5601081,  5538635,  5487873,  5432811,
          5375282,  5340270,  5300145,  5247612,  5197322,  5152006,
          5110636,  5073711,  5032732,  4997952,  4961998,  4924893,
          4883250,  4833217,  4803370,  4777437,  4756838,  4726871,
          4687867,  4657346,  4622504,  4602088,  4584254,  4545255,
          4513341,  4483283,  4462494,  4449413,  4422413,  4391789,
          4372245,  4348814,  4322876,  4296276,  4269580,  4242045,
          4221903,  4203451,  4178293,  4160355,  4146645,  4126679,
          4106602,  4088161,  4070126,  4053066,  4042538,  4025165,
          4006372,  3986450,  3967480,  3958055,  3943593,  3937931,
          3925083,  3901406,  3886987,  3883765,  3870621,  3852119,
          3834008,  3829746,  3830284,  3829036,  3817503,  3802664,
          3795163,  3785974,  3781680,  3776238,  3771565,  3760447,
          3748967,  3748748,  3747786,  3736273,  3740437,  3741262,
          3735026,  3741970,  3746215,  3752626,  3756563,  3756057,
          3763171,  3771579,  3785959,  3792395,  3798819,  3811080,
          3832088,  3853447,  3875269,  3901433,  3928435,  3961311,
          3994542,  4026750,  4072801,  4124711,  4174146,  4215704,
          4272546,  4338839,  4410011,  4489824,  4578343,  4673475,
          4774091,  4874817,  4989310,  5107257,  5229290,  5345969,
          5454130,  5560771,  5670467,  5773414,  5859455,  5936146,
          5987744,  6019707,  6035756,  6033968,  5998380,  5941165,
          5871105,  5790603,  5690670,  5583749,  5463228,  5344147,
          5217798,  5091870,  4964315,  4855815,  4746604,  4631003,
          4522883,  4423078,  4331524,  4248226,  4175123,  4105287,
          4045020,  3980723,  3922268,  3883451,  3841591,  3800155,
          3763336,  3734886,  3702249,  3672071,  3653752,  3629898,
          3608991,  3591905,  3571108,  3555839,  3547575,  3541660,
          3533978,  3528032,  3521190,  3518200,  3508448,  3502361,
          3501208,  3496513,  3491183,  3495870,  3497191,  3494097,
          3507473,  3514851,  3522068,  3525121,  3532452,  3552681,
          3560463,  3571300,  3576494,  3598155,  3617751,  3631264,
          3651309,  3673081,  3705602,  3736213,  3757061,  3784088,
          3817812,  3849433,  3890334,  3938266,  3983948,  4038068,
          4097735,  4156704,  4221996,  4304275,  4396699,  4480092,
          4570066,  4676586,  4781156,  4896488,  5011820,  5136948,
          5268043,  5381846,  5500309,  5610223,  5713814,  5805090,
          5883873,  5960916,  6031151,  6069495,  6091916,  6091487,
          6073735,  6048192,  5996681,  5919347,  5830642,  5740028,
          5630869,  5524323,  5405760,  5299411,  5198698,  5102878,
          5015570,  4930888,  4868876,  4804874,  4754488,  4711443,
          4670528,  4639930,  4619934,  4596919,  4568146,  4541680,
          4516007,  4488527,  4460812,  4423451,  4370928,  4322025,
          4278637,  4226855,  4159514,  4088129,  4023257,  3955468,
          3876833,  3801165,  3728269,  3659176,  3595420,  3537694,
          3480947,  3422062,  3366398,  3314679,  3267382,  3217396,
          3176215,  3137194,  3098684,  3063205,  3025651,  2987220,
          2955828,  2926592,  2897768,  2868428,  2835188,  2807794,
          2784332,  2755848,  2728101,  2704490,  2679288,  2652808,
          2626003,  2603465,  2583675,  2560301,  2540956,  2516748,
          2495568,  2468966,  2449040,  2430451,  2405977,  2386273,
          2364952,  2344290,  2332560,  2313011,  2294228,  2276686,
          2257885,  2240025,  2226637,  2208818,  2185082,  2168027,
          2152372,  2138428,  2128028,  2108579,  2090280,  2077533,
          2065035,  2053031,  2041526,  2028560,  2008635,  1993637,
          1986978,  1977354,  1962802,  1950682,  1941218,  1929873,
          1917571,  1911168,  1899924,  1892218,  1887048,  1879312,
          1871710,  1870042,  1864954,  1853605,  1844724,  1843453,
          1838313,  1836047,  1832173,  1826781,  1815544,  1808938,
          1807743,  1809215,  1808388,  1804737,  1805042,  1802339,
          1797692,  1803261,  1800126,  1792476,  1783954,  1779490,
          1769526,  1758994,  1750687,  1742654,  1730868,  1720459,
          1707189,  1695051,  1683829,  1672274,  1660398,  1645382,
          1633752,  1621741,  1611077,  1603041,  1593776,  1586940,
          1575997,  1562307,  1552670,  1544573,  1538144,  1533934,
          1523523,  1515352,  1514122,  1506306,  1501861,  1498098,
          1495586,  1494574,  1491984,  1486756,  1487000,  1485950,
          1487931,  1493965,  1495992,  1494769,  1496393,  1500697,
          1501389,  1507308,  1510483,  1517743,  1520534,  1529128,
          1537882,  1549987,  1561781,  1577338,  1595443,  1611872,
          1627939,  1648089,  1667320,  1689228,  1711297,  1734725,
          1761461,  1789961,  1822454,  1851715,  1882582,  1907427,
          1935941,  1965570,  1989031,  2012604,  2035065,  2055587,
          2072432,  2086297,  2091845,  2097736,  2103473,  2108654,
          2114612,  2110806,  2111365,  2113151,  2110832,  2109186,
          2109709,  2108758,  2104681,  2108993,  2107803,  2105732,
          2101465,  2092182,  2081869,  2067400,  2050098,  2031532,
          2008255,  1972068,  1940116,  1906370,  1865326,  1819064,
          1776905,  1735720,  1695577,  1656904,  1616652,  1577987,
          1538765,  1505285,  1472904,  1442556,  1416445,  1392365,
          1366456,  1345301,  1328313,  1308161,  1291580,  1274038,
          1259296,  1247606,  1234092,  1224435,  1214021,  1198810,
          1188811,  1180037,  1176347,  1168783,  1161649,  1156723,
          1151716,  1144028,  1139780,  1135992,  1131797]),
  'ring_radii_px': array([ 17,  54,  92, 115, 202, 356, 405, 578, 676, 894], dtype=int64),
  'reflections-0-index': '{1 1 1}',
  'reflections-0-recip_distances': 0.42470962865207135,
  'reflections-0-structure_factor': 27.001981488308132,
  'reflections-0-multiplicity': 8,
  'reflections-0-intensity': 5832.856034359481,
  'reflections-1-index': '{0 0 2}',
  'reflections-1-recip_distances': 0.4904124368593988,
  'reflections-1-structure_factor': 24.483978581619574,
  'reflections-1-multiplicity': 6,
  'reflections-1-intensity': 3596.7912431112363,
  'reflections-2-index': '{0 2 2}',
  'reflections-2-recip_distances': 0.6935479193630009,
  'reflections-2-structure_factor': 18.267861546028193,
  'reflections-2-multiplicity': 12,
  'reflections-2-intensity': 4004.577185578267,
  'reflections-3-index': '{1 1 3}',
  'reflections-3-recip_distances': 0.8132570227932421,
  'reflections-3-structure_factor': 15.535885121433875,
  'reflections-3-multiplicity': 8,
  'reflections-3-intensity': 1930.9098120511235,
  'reflections-4-index': '{1 3 1}',
  'reflections-4-recip_distances': 0.8132570227932422,
  'reflections-4-structure_factor': 15.535885121433877,
  'reflections-4-multiplicity': 16,
  'reflections-4-intensity': 3861.819624102248,
  'reflections-5-index': '{2 2 2}',
  'reflections-5-recip_distances': 0.8494192573041427,
  'reflections-5-structure_factor': 14.819583263744343,
  'reflections-5-multiplicity': 8,
  'reflections-5-intensity': 1756.9603848884115,
  'reflections-6-index': '{0 0 4}',
  'reflections-6-recip_distances': 0.9808248737187976,
  'reflections-6-structure_factor': 12.570414158304297,
  'reflections-6-multiplicity': 6,
  'reflections-6-intensity': 948.0918726677828,
  'reflections-7-index': '{3 3 1}',
  'reflections-7-recip_distances': 1.0688291264628202,
  'reflections-7-structure_factor': 11.326958231196201,
  'reflections-7-multiplicity': 8,
  'reflections-7-intensity': 1026.399862170107,
  'reflections-8-index': '{3 1 3}',
  'reflections-8-recip_distances': 1.0688291264628205,
  'reflections-8-structure_factor': 11.326958231196201,
  'reflections-8-multiplicity': 16,
  'reflections-8-intensity': 2052.799724340214,
  'reflections-9-index': '{4 0 2}',
  'reflections-9-recip_distances': 1.0965955458289391,
  'reflections-9-structure_factor': 10.971746279580813,
  'reflections-9-multiplicity': 24,
  'reflections-9-intensity': 2889.10119416389,
  'reflections-10-index': '{2 2 4}',
  'reflections-10-recip_distances': 1.2012602338204004,
  'reflections-10-structure_factor': 9.771334418145713,
  'reflections-10-multiplicity': 24,
  'reflections-10-intensity': 2291.4954314697366,
  'reflections-11-index': '{5 1 1}',
  'reflections-11-recip_distances': 1.2741288859562139,
  'reflections-11-structure_factor': 9.048739478365498,
  'reflections-11-multiplicity': 16,
  'reflections-11-intensity': 1310.0749783572849,
  'reflections-12-index': '{3 3 3}',
  'reflections-12-recip_distances': 1.274128885956214,
  'reflections-12-structure_factor': 9.048739478365498,
  'reflections-12-multiplicity': 16,
  'reflections-12-intensity': 1310.0749783572849,
  'reflections-13-index': '{0 4 4}',
  'reflections-13-recip_distances': 1.3870958387260017,
  'reflections-13-structure_factor': 8.080352576248991,
  'reflections-13-multiplicity': 12,
  'reflections-13-intensity': 783.5051730779244,
  'reflections-14-index': '{1 5 3}',
  'reflections-14-recip_distances': 1.450659551542253,
  'reflections-14-structure_factor': 7.604412728610221,
  'reflections-14-multiplicity': 48,
  'reflections-14-intensity': 2775.700461458359,
  'reflections-15-index': '{4 4 2}',
  'reflections-15-recip_distances': 1.4712373105781964,
  'reflections-15-structure_factor': 7.4596757183737825,
  'reflections-15-multiplicity': 30,
  'reflections-15-intensity': 1669.4028546988623,
  'reflections-16-index': '{6 2 0}',
  'reflections-16-recip_distances': 1.5508202933492128,
  'reflections-16-structure_factor': 6.938615373588864,
  'reflections-16-multiplicity': 24,
  'reflections-16-intensity': 1155.4651992624897,
  'reflections-17-index': '{3 3 5}',
  'reflections-17-recip_distances': 1.607924703129322,
  'reflections-17-structure_factor': 6.599014341582308,
  'reflections-17-multiplicity': 24,
  'reflections-17-intensity': 1045.1277667298154,
  'reflections-18-index': '{2 2 6}',
  'reflections-18-recip_distances': 1.6265140455864842,
  'reflections-18-structure_factor': 6.494057177048987,
  'reflections-18-multiplicity': 8,
  'reflections-18-intensity': 337.38222895025166,
  'reflections-19-index': '{2 6 2}',
  'reflections-19-recip_distances': 1.6265140455864844,
  'reflections-19-structure_factor': 6.494057177048987,
  'reflections-19-multiplicity': 16,
  'reflections-19-intensity': 674.7644579005033,
  'reflections-20-index': '{4 4 4}',
  'reflections-20-recip_distances': 1.6988385146082854,
  'reflections-20-structure_factor': 6.109532224675425,
  'reflections-20-multiplicity': 8,
  'reflections-20-intensity': 298.61107203477957,
  'reflections-21-index': '{5 1 5}',
  'reflections-21-recip_distances': 1.7511226591493427,
  'reflections-21-structure_factor': 5.8531681438729315,
  'reflections-21-multiplicity': 24,
  'reflections-21-intensity': 822.2298556907735,
  'reflections-22-index': '{5 5 1}',
  'reflections-22-recip_distances': 1.751122659149343,
  'reflections-22-structure_factor': 5.8531681438729315,
  'reflections-22-multiplicity': 24,
  'reflections-22-intensity': 822.2298556907735,
  'reflections-23-index': '{0 4 6}',
  'reflections-23-recip_distances': 1.7682071872218084,
  'reflections-23-structure_factor': 5.7730001082976115,
  'reflections-23-multiplicity': 24,
  'reflections-23-intensity': 799.8607260097015,
  'reflections-24-index': '{2 4 6}',
  'reflections-24-recip_distances': 1.8349553169407786,
  'reflections-24-structure_factor': 5.475463226438261,
  'reflections-24-multiplicity': 48,
  'reflections-24-intensity': 1439.0734821157293,
  'reflections-25-index': '{3 5 5}',
  'reflections-25-recip_distances': 1.8834647020422266,
  'reflections-25-structure_factor': 5.2737163509881615,
  'reflections-25-multiplicity': 72,
  'reflections-25-intensity': 2002.470058848952,
  'reflections-26-index': '{3 7 3}',
  'reflections-26-recip_distances': 2.0070993997039013,
  'reflections-26-structure_factor': 4.807655967320757,
  'reflections-26-multiplicity': 24,
  'reflections-26-intensity': 554.7253416027572,
  'reflections-27-index': '{6 4 4}',
  'reflections-27-recip_distances': 2.022022277287853,
  'reflections-27-structure_factor': 4.755611995620097,
  'reflections-27-multiplicity': 24,
  'reflections-27-intensity': 542.7802908692581,
  'reflections-28-index': '{0 6 6}',
  'reflections-28-recip_distances': 2.080643758089003,
  'reflections-28-structure_factor': 4.559050974930633,
  'reflections-28-multiplicity': 12,
  'reflections-28-intensity': 249.41934950419147,
  'reflections-29-index': '{5 5 5}',
  'reflections-29-recip_distances': 2.1235481432603565,
  'reflections-29-structure_factor': 4.422685732877285,
  'reflections-29-multiplicity': 56,
  'reflections-29-intensity': 1095.3683491405918,
  'reflections-30-index': '{6 6 2}',
  'reflections-30-recip_distances': 2.1376582529256405,
  'reflections-30-structure_factor': 4.37914286212942,
  'reflections-30-multiplicity': 8,
  'reflections-30-intensity': 153.4151376555124,
  'reflections-31-index': '{6 2 6}',
  'reflections-31-recip_distances': 2.137658252925641,
  'reflections-31-structure_factor': 4.379142862129421,
  'reflections-31-multiplicity': 16,
  'reflections-31-intensity': 306.83027531102493,
  'reflections-32-index': '{5 7 3}',
  'reflections-32-recip_distances': 2.2339349661969248,
  'reflections-32-structure_factor': 4.098006979092962,
  'reflections-32-multiplicity': 48,
  'reflections-32-intensity': 806.095737633342,
  'reflections-33-index': '{4 6 6}',
  'reflections-33-recip_distances': 2.3002382226587366,
  'reflections-33-structure_factor': 3.9192757947321013,
  'reflections-33-multiplicity': 24,
  'reflections-33-intensity': 368.65734612415065,
  'reflections-34-index': '{7 5 5}',
  'reflections-34-recip_distances': 2.4397710683797262,
  'reflections-34-structure_factor': 3.577655721287873,
  'reflections-34-multiplicity': 48,
  'reflections-34-intensity': 614.3817820830649,
  'reflections-35-index': '{7 7 3}',
  'reflections-35-recip_distances': 2.536432846056741,
  'reflections-35-structure_factor': 3.3650622751716925,
  'reflections-35-multiplicity': 24,
  'reflections-35-intensity': 271.76745877880853,
  'reflections-36-index': '{6 6 6}',
  'reflections-36-recip_distances': 2.548257771912428,
  'reflections-36-structure_factor': 3.340273246671722,
  'reflections-36-multiplicity': 8,
  'reflections-36-intensity': 89.25940289944677,
  'reflections-37-index': '{7 7 5}',
  'reflections-37-recip_distances': 2.7194685170931825,
  'reflections-37-structure_factor': 3.008047711514111,
  'reflections-37-multiplicity': 24,
  'reflections-37-intensity': 217.16042483388674}}

2.6.7. Comparison#

Comparison between experimental profile and kinematic theory

The grain size will have an influence on the width of the diffraction rings”

# -------Input of grain size ----
resolution  = 0 # 1/nm
thickness = 100 # Ang
# -------------------------------

from scipy import signal

width = (1/thickness + resolution) / scale
scale = ft.get_slope(main_dataset.dim_0.values)  *1.085*1.0/10*1.01

intensity2 = intensity/intensity.max()*10

gauss = signal.gaussian(len(profile), std=width)
simulated_profile = np.zeros(len(profile))
rec_dist = np.linspace(1,len(profile),len(profile))*scale

x  =[]
yAu = []
yC  = []
for i in rec_dist:
    yAu.append(ks.feq('Au', i))
    yC.append(ks.feq('C', i))
        
plt.figure()
plt.plot(rec_dist,profile/profile.max()*150, color='blue', label='experiment');
for j in range(len(unique)-1):
    if unique[j] < len(profile)*scale:
        # plot lines
        plt.plot([unique[j],unique[j]], [0, intensity2[j]],c='r')
        # plot indices
        index = '{'+f'{family[j][0]:.0f} {family[j][1]:.0f} {family[j][2]:.0f}'+'}' # pretty index string
        plt.text(unique[j],-3, index, horizontalalignment='center',
              verticalalignment='top', rotation = 'vertical', fontsize=8, color = 'red')
        
        # place Gaussian with appropriate width in profile
        g = np.roll(gauss,int(-len(profile)/2+unique[j]/scale))* intensity2[j]*np.array(yAu)*1.3#rec_dist**2*10
        simulated_profile = simulated_profile + g
plt.plot(np.linspace(1,len(profile),len(profile))*scale,simulated_profile, label='simulated');
plt.plot(rec_dist,np.array(yAu)**2, label='form_factor')
plt.xlabel('angle (1/$\AA$)')
plt.legend()
plt.ylim(-35,210);
<>:40: SyntaxWarning: invalid escape sequence '\A'
<>:40: SyntaxWarning: invalid escape sequence '\A'
C:\Users\gduscher\AppData\Local\Temp\ipykernel_25848\3589635777.py:40: SyntaxWarning: invalid escape sequence '\A'
  plt.xlabel('angle (1/$\AA$)')
C:\Users\gduscher\AppData\Local\Temp\ipykernel_25848\3589635777.py:13: DeprecationWarning: Importing gaussian from 'scipy.signal' is deprecated and will raise an error in SciPy 1.13.0. Please use 'scipy.signal.windows.gaussian' or the convenience function 'scipy.signal.get_window' instead.
  gauss = signal.gaussian(len(profile), std=width)

2.6.8. Publication Quality Output#

Now we have all the ingredients to make a publication quality plot of the data.

from matplotlib import patches
fig = plt.figure(figsize=(9, 6)) 

extent= np.array([-center[0], diff_pattern.shape[0]-center[0],-diff_pattern.shape[1]+center[1], center[1]])*scale*1.005

plt.imshow(np.log2(1+diff_pattern).T,cmap='gray', extent=(extent*1.0), vmin=np.max(np.log2(1+diff_pattern))*0.5)
plt.xlabel(r'reciprocal distance [nm$^{-1}$]')
ax = fig.gca()
#ax.add_artist(circle1);
plt.plot(np.linspace(1,len(profile),len(profile))*scale,profile/profile.max(), color='y');
plt.plot((0,len(profile)*scale),(0,0),c='r')

for j in range(len(unique)-1):
    i = indices[j]   
    if distances[i] < len(profile)*scale:
        plt.plot([distances[i],distances[i]], [0, intensity2[j]/20],c='r')
        arc = patches.Arc((0,0), distances[i]*2, distances[i]*2, angle=90.0, theta1=0.0, theta2=270.0, color='r', fill= False, alpha = 0.5)#, **kwargs)
        ax.add_artist(arc);
plt.scatter(0,0);

for i in range(6):
    index = '{'+f'{family[i][0]:.0f} {family[i][1]:.0f} {family[i][2]:.0f}'+'}' # pretty index string
    plt.text(unique[i],-0.05, index, horizontalalignment='center',
             verticalalignment='top', rotation = 'vertical', fontsize=8, color = 'white')
C:\Users\gduscher\AppData\Local\Temp\ipykernel_25848\1750695307.py:2: RuntimeWarning: More than 20 figures have been opened. Figures created through the pyplot interface (`matplotlib.pyplot.figure`) are retained until explicitly closed and may consume too much memory. (To control this warning, see the rcParam `figure.max_open_warning`). Consider using `matplotlib.pyplot.close()`.
  fig = plt.figure(figsize=(9, 6))

2.6.8.1. Quiz#

What would the figure caption for above figure be?

2.6.8.2. What does the above figure convey?#

  • center is determined accurately

  • relative distances are accurately described

  • scaling accurately for reference crystal - calibration?

2.6.8.3. What is the accuracy?#

Change the scale by 1% and see what happens

So we can determine the lattce parameter better than 1% if we use high scattering angles!

2.6.9. Logging the results#

out_tags['analysis'] = 'Indexing_Diffraction_Rings'
out_tags['scale'] = scale
main_dataset.metadata
{'experiment': {'exposure_time': 0.5,
  'microscope': 'Libra 200 MC',
  'acceleration_voltage': 199990.28125},
 'filename': '../example_data\\GOLD-NP-DIFF.dm3',
 'SAED': {'center': array([1050.1038961 , 1093.34199134]),
  'polar_projection': array([[ 128,  128,  128, ...,   83,   83,   83],
         [ 102,  102,  103, ...,  126,  126,  126],
         [ 119,  119,  119, ...,  112,  112,  113],
         ...,
         [1490, 1456, 1480, ...,  911,  907,  806],
         [1532, 1330, 1440, ...,  971,  876,  920],
         [1546, 1322, 1449, ..., 1055,  932,  940]]),
  'radial_average': array([  113917,   138535,   131136,   140874,   130527,   125258,
           124188,   107832,   124909,   129758,   123649,   132531,
           130458,   129159,   133556,   127874,   124721,   125452,
           124656,   124820,   129456,   127493,   129923,   123645,
           124923,   128064,   122533,   127398,   125151,   129337,
           132058,   130053,   129350,   131130,   130964,   133927,
           130435,   129989,   130159,   128313,   126845,   125979,
           129485,   128536,   127675,   127042,   125678,   125638,
           126532,   127697,   131957,   134705,   131328,   129462,
           131002,   126842,   130889,   130150,   127638,   126337,
           127288,   132128,   129738,   131041,   128685,   126849,
           128304,   126038,   129151,   135885,   128439,   126645,
           129765,   129524,   128958,   129755,   127193,   128735,
           129388,   125924,   130440,   128063,   127601,   127980,
           128217,   127315,   129050,   129238,   131687,   132710,
           130660,   131680,   131223,   130017,   128706,   130652,
           132960,   126002,   128225,   130161,   131781,   131852,
           128497,   128885,   129510,   128497,   131491,   130726,
           128289,   126527,   130819,   130084,   130287,   128925,
           131085,   129440,   130237,   133374,   131424,   131482,
           130147,   131397,   131092,   129077,   128293,   130322,
           127797,   129214,   131300,   130100,   130137,   133443,
           132074,   128605,   129098,   131110,   130063,   131887,
           133161,   133099,   133888,   132151,   134541,   132247,
           134386,   134232,   136458,   135108,   133843,   134733,
           131723,   137989,   133253,   135306,   134854,   136871,
           136386,   138390,   138521,   141204,   139794,   139911,
           142055,   146112,   143255,   144021,   146727,   150404,
           150335,   150131,   152624,   155887,   157625,   163678,
           166860,   173964,   185240,   199369,   224434,   267003,
           336618,   458525,   649856,   953199,  1401122,  2014608,
          2768380,  3665263,  4726294,  5910515,  7153489,  8372856,
          9506817, 10467947, 11328794, 12286432, 13298524, 14336402,
         15475904, 16811094, 18037581, 18846535, 19312128, 19567083,
         19652311, 19626427, 19540490, 19459562, 19315759, 19159122,
         18999891, 18864496, 18697000, 18530538, 18353311, 18198252,
         18057327, 17935852, 17794315, 17653301, 17521141, 17411450,
         17273093, 17143253, 17036377, 16916324, 16770591, 16651723,
         16536898, 16390227, 16237761, 16110543, 15994693, 15888998,
         15788700, 15676427, 15542619, 15395890, 15273603, 15157109,
         15022711, 14898780, 14787409, 14668898, 14548739, 14435068,
         14351582, 14258226, 14166938, 14061999, 13950563, 13844390,
         13751750, 13644857, 13552329, 13454850, 13346370, 13254481,
         13166429, 13064978, 12964587, 12902192, 12821676, 12724030,
         12624860, 12531399, 12457983, 12381355, 12291984, 12211704,
         12129305, 12070667, 11966800, 11872676, 11795939, 11729950,
         11671806, 11608984, 11538793, 11465951, 11403923, 11346151,
         11293723, 11235003, 11183952, 11121111, 11072923, 11016993,
         10956099, 10899682, 10856222, 10817033, 10774570, 10750228,
         10701601, 10639481, 10617926, 10590718, 10562224, 10528706,
         10483224, 10438541, 10430016, 10413098, 10377845, 10357378,
         10355458, 10356144, 10356516, 10368733, 10370592, 10373434,
         10388756, 10408232, 10421442, 10428509, 10448801, 10467089,
         10509177, 10559202, 10627602, 10712766, 10796159, 10861440,
         10958296, 11059980, 11204568, 11362333, 11537494, 11730596,
         11933442, 12161905, 12450503, 12756711, 13098227, 13462574,
         13848264, 14271980, 14767191, 15276596, 15802405, 16350481,
         16938284, 17562252, 18207730, 18876454, 19552689, 20295008,
         21047122, 21755491, 22374519, 22950121, 23418792, 23788072,
         24057967, 24126977, 24054840, 23835083, 23521813, 23133427,
         22680519, 22163411, 21557529, 20948239, 20335410, 19683677,
         19060500, 18443345, 17839307, 17237712, 16650306, 16117023,
         15634312, 15165460, 14723228, 14325350, 13972334, 13651725,
         13363242, 13145923, 12933520, 12744031, 12576431, 12456610,
         12350054, 12256689, 12187491, 12130339, 12094540, 12065131,
         12044552, 12050563, 12055025, 12054987, 12076934, 12096889,
         12121531, 12148363, 12183945, 12222940, 12255191, 12301251,
         12339300, 12370744, 12395274, 12380501, 12352621, 12311646,
         12270375, 12186735, 12073818, 11952618, 11796624, 11622767,
         11412716, 11193449, 10946377, 10665791, 10392323, 10129214,
          9874146,  9594522,  9347026,  9109403,  8894990,  8676998,
          8459813,  8254699,  8071230,  7904326,  7740562,  7570680,
          7422909,  7279992,  7141855,  7020343,  6911792,  6796500,
          6688399,  6583116,  6468507,  6371623,  6289589,  6208419,
          6130542,  6061406,  5995775,  5918798,  5847963,  5783516,
          5724705,  5665726,  5604506,  5555806,  5502192,  5447134,
          5395835,  5342838,  5293794,  5247316,  5209035,  5174323,
          5127928,  5084875,  5035165,  4995870,  4962683,  4924655,
          4889373,  4866649,  4826996,  4793715,  4758923,  4730403,
          4691405,  4665580,  4641704,  4609181,  4578677,  4551551,
          4520166,  4495444,  4476563,  4449558,  4424235,  4397018,
          4365163,  4338361,  4315609,  4296526,  4274528,  4255384,
          4236123,  4214520,  4196142,  4172940,  4146701,  4127052,
          4117207,  4099094,  4082280,  4069214,  4044636,  4016949,
          3997492,  3987469,  3968926,  3964132,  3950595,  3936264,
          3930234,  3911039,  3896935,  3888191,  3878224,  3865339,
          3852584,  3845745,  3835734,  3829355,  3815199,  3809993,
          3805085,  3795858,  3793827,  3791449,  3781658,  3768671,
          3768566,  3764416,  3761279,  3761764,  3766748,  3767484,
          3763124,  3760334,  3765081,  3774261,  3776979,  3776850,
          3778107,  3785201,  3797889,  3809828,  3826069,  3843028,
          3859973,  3887793,  3916166,  3935286,  3972908,  4007815,
          4036982,  4071954,  4116217,  4161910,  4205538,  4258063,
          4314991,  4383924,  4446777,  4518991,  4595440,  4690227,
          4785467,  4876683,  4977127,  5084024,  5188215,  5285449,
          5380955,  5480310,  5564915,  5646089,  5723904,  5786371,
          5838531,  5870776,  5885349,  5883349,  5866654,  5838356,
          5784534,  5715828,  5637109,  5548028,  5443853,  5334825,
          5222278,  5116113,  5003738,  4893054,  4776403,  4672786,
          4578563,  4477634,  4385604,  4293256,  4212644,  4143740,
          4083003,  4017538,  3963545,  3921139,  3869664,  3821988,
          3785862,  3749786,  3724554,  3693965,  3667585,  3648091,
          3628912,  3614183,  3598570,  3588252,  3573864,  3554374,
          3546471,  3536943,  3527562,  3527916,  3523069,  3511355,
          3508733,  3505141,  3503287,  3507271,  3519116,  3520360,
          3523889,  3529117,  3535497,  3548303,  3558836,  3569412,
          3580472,  3590390,  3598786,  3619070,  3648456,  3661422,
          3676996,  3701644,  3722291,  3751843,  3789563,  3824273,
          3864966,  3906220,  3949910,  3991670,  4037497,  4082591,
          4141436,  4208422,  4284456,  4362981,  4441335,  4525794,
          4622637,  4728945,  4828241,  4923600,  5020349,  5114575,
          5209590,  5312976,  5408342,  5500787,  5597229,  5692160,
          5762967,  5829846,  5889081,  5920529,  5946354,  5952919,
          5942679,  5921014,  5886784,  5831993,  5763512,  5685944,
          5601743,  5514880,  5418199,  5333090,  5237572,  5142386,
          5059544,  4989269,  4919755,  4856075,  4805815,  4755107,
          4702227,  4664552,  4634263,  4600032,  4574774,  4549626,
          4516483,  4476731,  4436713,  4393249,  4345698,  4294435,
          4238865,  4172336,  4106290,  4043398,  3981231,  3918913,
          3847963,  3784675,  3720440,  3659650,  3603020,  3550373,
          3494810,  3433253,  3376333,  3323218,  3275411,  3237301,
          3193063,  3153637,  3113457,  3077797,  3037653,  3004393,
          2969601,  2933937,  2907164,  2875716,  2844991,  2816365,
          2788260,  2762132,  2735955,  2710229,  2683487,  2657871,
          2632383,  2608648,  2585188,  2558852,  2541322,  2518423,
          2494130,  2471581,  2450985,  2430956,  2407371,  2386202,
          2369540,  2350689,  2329256,  2311288,  2296935,  2278077,
          2260678,  2244313,  2225290,  2206215,  2196297,  2177539,
          2153726,  2137747,  2126674,  2110214,  2097310,  2085650,
          2070928,  2057192,  2040913,  2027600,  2013627,  1995513,
          1987805,  1979892,  1965363,  1949007,  1942923,  1935182,
          1925383,  1915101,  1904065,  1898390,  1895842,  1886088,
          1875257,  1865311,  1861711,  1858726,  1853497,  1843833,
          1834549,  1830164,  1825741,  1823330,  1821531,  1817439,
          1811668,  1808190,  1807024,  1803174,  1802309,  1799664,
          1796693,  1794808,  1794116,  1791540,  1783891,  1774006,
          1762083,  1756412,  1752606,  1740174,  1728050,  1717563,
          1704482,  1694902,  1680763,  1670177,  1658882,  1647181,
          1640550,  1630512,  1620244,  1611154,  1598863,  1587672,
          1578927,  1569715,  1564439,  1552691,  1545065,  1535574,
          1527685,  1524351,  1518721,  1514009,  1513708,  1507393,
          1504877,  1504411,  1499575,  1492475,  1488891,  1491886,
          1493645,  1497210,  1498429,  1497727,  1499623,  1506621,
          1513644,  1519276,  1523166,  1531474,  1539221,  1550356,
          1560029,  1565344,  1574077,  1590827,  1605905,  1620625,
          1641935,  1663004,  1682377,  1705689,  1729344,  1752751,
          1774811,  1797771,  1819812,  1847260,  1874182,  1898951,
          1926245,  1954136,  1976108,  1996723,  2015789,  2033945,
          2051202,  2061411,  2069353,  2077311,  2084304,  2094206,
          2097433,  2099232,  2100385,  2101515,  2099046,  2098528,
          2098830,  2102682,  2101290,  2089808,  2077378,  2075202,
          2074150,  2067241,  2054646,  2043767,  2022506,  2002426,
          1982364,  1953978,  1920573,  1887717,  1852764,  1811689,
          1775993,  1739504,  1698547,  1662085,  1623523,  1586164,
          1553224,  1519748,  1489776,  1457950,  1428826,  1405716,
          1381033,  1358207,  1338200,  1317031,  1297790,  1280064,
          1265636,  1253515,  1238679,  1227611,  1219560,  1208467,
          1198673,  1189185,  1184241,  1177339,  1168926,  1160560,
          1155479,  1149835,  1146021,  1138701,  1131540]),
  'analysis': 'Indexing_Diffraction_Rings',
  'scale': 0.001206134390551597}}
h5_group = ft.save_dataset(datasets, filename='Gold_SAED.hf5')
h5_group.file.close()
Cannot overwrite file. Using:  Gold_SAED-1.hf5
C:\Users\gduscher\Anaconda3\lib\site-packages\pyNSID\io\hdf_io.py:111: UserWarning: main_data_name should not contain the "-" character. Reformatted name from:GOLD-NP-DIFF to GOLD_NP_DIFF
  warn('main_data_name should not contain the "-" character. Reformatted'
C:\Users\gduscher\Anaconda3\lib\site-packages\pyNSID\io\hdf_utils.py:376: FutureWarning: validate_h5_dimension may be removed in a future version
  warn('validate_h5_dimension may be removed in a future version',

2.6.10. Conclusion#

We only need the scatterng factors to calculate the ring pattern.

A comparison between simulation and experiment can be very precise.

Normally one would do a fit of the most prominent peaks to establish the scale.

2.6.12. Appendix#

Opening the hdf5 file and plot the data again

2.6.12.1. Open hf5 file#

new_dataset = ft.open_file(current_filename)
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_40988/3060170363.py in <module>
----> 1 new_dataset = ft.open_file(current_filename)

NameError: name 'current_filename' is not defined

2.6.12.2. And Plot#

Because we saved all the results in all steps, it is straight forward to retrieve the publication quality plot again.

## Access the data of the loaded image


diff_pattern = np.array(new_dataset)
diff_pattern = diff_pattern-diff_pattern.min()
current_channel = new_dataset.h5_dataset.parent.parent
result_group = current_channel['Log_000']

center = result_group['center'][()]
scale = result_group['scale'][()]

from matplotlib import patches
fig = plt.figure(figsize=(9, 6)) 
ax = plt.gca()
extent= np.array([-center[0], diff_pattern.shape[0]-center[0],-diff_pattern.shape[1]+center[1], center[1]])*scale

plt.imshow(np.log2(1+diff_pattern).T, cmap="gray", extent=(extent), vmin=np.max(np.log2(1+diff_pattern))*0.5)
plt.xlabel(r'reciprocal distance [nm$^{-1}$]')

profile = result_group['radial_average'][()]
plt.plot(np.linspace(1,len(profile),len(profile))*scale,profile/profile.max()*10, color='y');#
plt.plot((0,len(profile)*scale),(0,0),c='r')
reflections = {}
for key in result_group:
    if 'reflection' in key:
        keys = key.split('-')
        
        if keys[1] not in reflections:
            reflections[keys[1]]={}
        reflections[keys[1]][keys[2]] =  result_group[key][()]
        #print( reflections[keys[1]][keys[2]] )
for key in reflections:
    distance = reflections[key]['recip_distances']
    if distance < len(profile)*scale:
        
        plt.plot([distance,distance], [0, reflections[key]['intensity']/1000],c='r')
        arc = patches.Arc((0,0), distance*2, distance*2, angle=90.0, theta1=0.0, theta2=270.0, color='r', fill= False, alpha = 0.5)#, **kwargs)
        ax.add_artist(arc);
plt.scatter(0,0);
for i in range(7):
    index = reflections[str(i)]['index'] # pretty index string
    plt.text(unique[i],-0.5, index, horizontalalignment='center',
          verticalalignment='top', rotation = 'vertical', fontsize=8, color = 'white')
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_40988/1639223971.py in <module>
      2 
      3 
----> 4 diff_pattern = np.array(new_dataset)
      5 diff_pattern = diff_pattern-diff_pattern.min()
      6 current_channel = new_dataset.h5_dataset.parent.parent

NameError: name 'new_dataset' is not defined

2.6.12.3. 3D Plot of Miller Indices#

hkl_max = 4
h  = np.linspace(-hkl_max,hkl_max,2*hkl_max+1)  # all evaluated single Miller Indices
hkl  = np.array(list(itertools.product(h,h,h) )) # all evaluated Miller indices

# Plot 2D
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.scatter(hkl[:,0], hkl[:,2], hkl[:,1], c='red', s=10)
plt.xlabel('h')
plt.ylabel('l')
fig.gca().set_zlabel('k')
#ax.set_aspect('equal')
Text(0.5, 0, 'k')

2.6.13. Reciprocal Space and Miller Indices#

For a reciprocal cubic unit cell with lattice parameter \(b = \frac{1}{a}\):

\[\begin{split} \vec{g}_{hkl} = \begin{pmatrix}h\\k\\l\end{pmatrix} \cdot \begin{pmatrix}b&0&0\\0&b&0\\0&0&b\end{pmatrix} \end{split}\]

Or more general

\[\begin{split} \vec{g}_{hkl} = \begin{pmatrix}h\\k\\l\end{pmatrix} \cdot \begin{pmatrix}b_{1,1}&b_{1,2}&b_{1,3}\\b_{2,1}&b_{2,2}&b_{2,3}\\b_{3,1}&b_{3,2}&b_{3,3}\end{pmatrix} \end{split}\]

The matrix is of course the reciprocal unit cell or the inverse of the structure matrix.

Therefore, we get any reciprocal lattice vector with the dot product of its Miller indices and the reciprocal lattice matrix.

Spacing of planes with Miller Indices \(hkl\) $\( \begin{align*} |\vec{g}_{hkl}|& = \frac{1}{d}\\ d &= \frac{1}{|\vec{g}_{hkl}|} \end{align*}\)$

The length of a vector is called its norm.

Be careful there are two different notations for the reciprocal lattice vectors:

  • materials science

  • physics

The notations are different in a factor \(2\pi\). The introduction of \(2\pi\) in physics allows to take care of the \(n\) more naturally.

In the materials science notation the reciprocal lattice points are directly associated with the Bragg reflections in your diffraction pattern.
(OK,s we are too lacy to keep track of \(2\pi\))

2.6.13.1. All Possible Reflections#

Are then given by the all permutations of the Miller indices and the reiprocal unit cell matrix.

All considered Miller indices are then produced with the itertool package of python.

hkl_max = 9#  maximum allowed Miller index

h  = np.linspace(-hkl_max,hkl_max,2*hkl_max+1)   # all evaluated single Miller Indices
hkl  = np.array(list(itertools.product(h,h,h) )) # all evaluated Miller indices
g_hkl = np.dot(hkl,reciprocal_unit_cell)         # all evaluated reciprocal lattice points

print(f'Evaluation of {g_hkl.shape} reflections of {hkl.shape} Miller indices')

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.scatter(g_hkl[:,0], g_hkl[:,2], g_hkl[:,1], c='red', s=10)
plt.xlabel('u')
plt.ylabel('v')
fig.gca().set_zlabel('w')
Evaluation of (6859, 3) reflections of (6859, 3) Miller indices
Text(0.5, 0, 'w')

2.6.13.2. Atomic form factor#

If we look at the scattering power of a single atom that deflects an electron:

Single atom scattering

See Atomic Form Factor for details

2.6.14. Calculate Structure Factors#

To extend the single atom view of the atomic form factor \(f(\theta\)) to a crystal, we change to the structure factor \(F(\theta)\). The structure factor \(F(\theta)\) is a measure of the amplitude scattered by a unit cell of a crystal structure.

Because \(F(\theta)\) is an amplitude like \(f(\theta)\), it also has dimensions of length.We can define \(F(\theta)\) as: $\( F_{hkl}(\theta) = \sum_{j=1}^{\inf} f_i(\theta) \mathrm{e}^{[-2 \pi i (h x_j+k y_j + l z_j)]} \)$

The sum is over all the \(i\) atoms in the unit cell (with atomic coordinates \(x_i, y_i, z_i\)

The structure factors \(f_i(\theta)\) are multiplied by a phase factor (the exponential function). The phase factor takes account of the difference in phase between waves scattered from atoms on different but parallel atomic planes with the same Miller indices\( (hkl)\).

The scattering angle \(\theta\) is the angle between the angle between the incident and scattered electron beams.

Please identify all the variables in line 10 below. Please note that we only do a finite number of hkl

# Calculate Structure Factors

structure_factors = []

base = np.dot(tags['base'],tags['unit_cell'])  # transformation from relative to Carthesian coordinates
for j  in range(len(g_hkl)):
    F = 0
    for b in range(len(base)):
        f = ks.feq(tags['elements'][b],np.linalg.norm(np.dot(g_hkl[j], reciprocal_lattice))) # Atomic form factor for element and momentum change (g vector)
        F += f * np.exp(-2*np.pi*1j*(g_hkl[j]*base[b]).sum())        
    structure_factors.append(F)
F = structure_factors = np.array(structure_factors)

2.6.14.1. All Allowed Reflections#

The structure factor determines whether a reflection is allowed or not.

If the structure factor is zero, the reflection is called forbidden.

# Allowed reflections have a non zero structure factor F (with a  bit of numerical error)
allowed = np.absolute(structure_factors) > 0.001

print(f' Of the evaluated {hkl.shape[0]} Miller indices {allowed.sum()} are allowed. ')

distances = np.linalg.norm(g_hkl, axis = 1)
# We select now all the 
zero = distances == 0.
allowed = np.logical_and(allowed,np.logical_not(zero))

F = F[allowed]
g_hkl = g_hkl[allowed]
hkl = hkl[allowed]
distances = distances[allowed]
 Of the evaluated 6859 Miller indices 1365 are allowed. 

2.6.14.2. Families of reflections#

reflections with the same length of reciprocal lattice vector are called families

sorted_allowed = np.argsort(distances)

distances = distances[sorted_allowed]
hkl = hkl[sorted_allowed]
F = F[sorted_allowed]

# How many have unique distances and what is their muliplicity

unique, indices  = np.unique(distances, return_index=True)

print(f' Of the {allowed.sum()} allowed Bragg reflections there are {len(unique)} families of reflections.')
 Of the 1364 allowed Bragg reflections there are 47 families of reflections.

2.6.14.3. Intensities and Multiplicities#

multiplicitity = np.roll(indices,-1)-indices
intensity = np.absolute(F[indices]**2*multiplicitity)
print('\n index \t     hkl \t 1/d [1/nm]     d [pm] \t  F \t multip. intensity' )
family = []
for j in range(len(unique)-1):
    i = indices[j]    
    i2 = indices[j+1]   
    family.append(hkl[i+np.argmax(hkl[i:i2].sum(axis=1))])
    print(f'{i:3g}\t {family[j]} \t  {distances[i]:.2f}  \t {1/distances[i]*1000:.0f} \t {np.absolute(F[i]):.2f}, \t  {indices[j+1]-indices[j]:3g} \t {intensity[j]:.2f}') 
    
 index 	     hkl 	 1/d [1/nm]     d [pm] 	  F 	 multip. intensity
  0	 [1. 1. 1.] 	  3.06  	 327 	 10.05, 	    8 	 808.52
  8	 [0. 2. 2.] 	  4.99  	 200 	 7.10, 	   12 	 605.58
 20	 [3. 1. 1.] 	  5.85  	 171 	 4.02, 	   24 	 387.33
 44	 [0. 0. 4.] 	  7.06  	 142 	 4.39, 	    6 	 115.65
 50	 [3. 1. 3.] 	  7.69  	 130 	 2.75, 	   24 	 182.13
 74	 [2. 2. 4.] 	  8.64  	 116 	 3.30, 	   24 	 260.59
 98	 [1. 5. 1.] 	  9.17  	 109 	 2.14, 	   24 	 109.40
122	 [3. 3. 3.] 	  9.17  	 109 	 2.14, 	    8 	 36.47
130	 [0. 4. 4.] 	  9.98  	 100 	 2.65, 	   12 	 84.35
142	 [3. 5. 1.] 	  10.44  	 96 	 1.75, 	   48 	 146.49
190	 [0. 2. 6.] 	  11.16  	 90 	 2.22, 	   24 	 118.13
214	 [3. 5. 3.] 	  11.57  	 86 	 1.48, 	   24 	 52.43
238	 [4. 4. 4.] 	  12.22  	 82 	 1.91, 	    8 	 29.07
246	 [5. 5. 1.] 	  12.60  	 79 	 1.28, 	   48 	 78.66
294	 [6. 2. 4.] 	  13.20  	 76 	 1.67, 	   48 	 133.86
342	 [5. 5. 3.] 	  13.55  	 74 	 1.13, 	   72 	 91.64
414	 [0. 8. 0.] 	  14.11  	 71 	 1.48, 	    6 	 13.23
420	 [3. 7. 3.] 	  14.44  	 69 	 1.01, 	   24 	 24.37
444	 [2. 2. 8.] 	  14.97  	 67 	 1.34, 	    8 	 14.27
452	 [8. 2. 2.] 	  14.97  	 67 	 1.34, 	   28 	 49.95
480	 [5. 5. 5.] 	  15.28  	 65 	 0.91, 	   56 	 46.38
536	 [0. 8. 4.] 	  15.78  	 63 	 1.21, 	   24 	 35.32
560	 [7. 5. 3.] 	  16.07  	 62 	 0.83, 	   72 	 49.50
632	 [6. 6. 4.] 	  16.55  	 60 	 1.11, 	   24 	 29.61
656	 [3. 9. 1.] 	  16.83  	 59 	 0.76, 	   48 	 27.82
704	 [4. 8. 4.] 	  17.29  	 58 	 1.02, 	   24 	 25.16
728	 [7. 5. 5.] 	  17.55  	 57 	 0.70, 	   72 	 35.62
800	 [2. 8. 6.] 	  17.99  	 56 	 0.95, 	   48 	 43.28
848	 [3. 7. 7.] 	  18.25  	 55 	 0.65, 	   72 	 30.75
920	 [5. 3. 9.] 	  18.92  	 53 	 0.61, 	   48 	 17.88
968	 [7. 7. 5.] 	  19.57  	 51 	 0.57, 	   24 	 7.86
992	 [0. 8. 8.] 	  19.96  	 50 	 0.78, 	   12 	 7.28
1004	 [5. 5. 9.] 	  20.19  	 50 	 0.54, 	   72 	 20.89
1076	 [8. 6. 6.] 	  20.57  	 49 	 0.73, 	   16 	 8.64
1092	 [6. 6. 8.] 	  20.57  	 49 	 0.73, 	    8 	 4.32
1100	 [9. 7. 3.] 	  20.80  	 48 	 0.51, 	   48 	 12.43
1148	 [8. 8. 4.] 	  21.17  	 47 	 0.70, 	   24 	 11.61
1172	 [7. 7. 7.] 	  21.39  	 47 	 0.48, 	    8 	 1.86
1180	 [7. 5. 9.] 	  21.96  	 46 	 0.46, 	   32 	 6.72
1212	 [7. 9. 5.] 	  21.96  	 46 	 0.46, 	   16 	 3.36
1228	 [9. 1. 9.] 	  22.52  	 44 	 0.44, 	   24 	 4.57
1252	 [9. 9. 3.] 	  23.07  	 43 	 0.42, 	   24 	 4.17
1276	 [7. 7. 9.] 	  23.60  	 42 	 0.40, 	   24 	 3.81
1300	 [5. 9. 9.] 	  24.13  	 41 	 0.38, 	   24 	 3.51
1324	 [8. 8. 8.] 	  24.45  	 41 	 0.53, 	    8 	 2.22
1332	 [9. 7. 9.] 	  25.63  	 39 	 0.34, 	   24 	 2.78

2.6.15. Allowed reflections for Silicon:#

\(\ \ |F_{hkl}|^2 = \begin{cases} ( h , k , l \ \ \mbox{ all odd} &\\ ( h ,| k , l \ \ \mbox{all even}& \mbox{and}\ \ h+k+l = 4n\end{cases}\)

Check above allowed reflections whether this condition is met for the zero order Laue zone.

Please note that the forbidden and alowed reflections are directly a property of the structure factor.

2.6.16. Diffraction with Parallel Illumination#

Polycrystalline Sample

Single Crystalline Sample

ring pattern

spot pattern

depends on \(F(\theta)\)

depends on \(F(\theta)\)

	| depends on excitation error $s$

2.6.17. Ring Pattern#

Bragg's Law Bragg's Law

Ring Pattern:

  • The profile of a ring diffraction pattern (of a polycrystalline sample) is very close to what a you are used from X-ray diffraction.

  • The x-axis is directly the magnitude of the \(|\vec{g}| = 1/d\) of a hkl plane set.

  • The intensity of a Bragg reflection is directly related to the square of the structure factor \(I = F^2(\theta)\)

  • The intensity of a ring is directly related to the multiplicity of the family of planes.

Ring Pattern Problem:

  • Where is the center of the ring pattern

  • Integration over all angles (spherical coordinates)

  • Indexing of pattern is analog to x-ray diffraction.

The Ring Diffraction Pattern are completely defined by the Structure Factor

from matplotlib import patches
fig, ax = plt.subplots()
plt.scatter(0,0);
img = np.zeros((1024,1024))
extent = np.array([-1,1,-1,1])*np.max(unique)
plt.imshow(img, extent = extent)

for radius in unique:   
    circle = patches.Circle((0,0), radius*2, color='r', fill= False, alpha = 0.3)#, **kwargs)
    ax.add_artist(circle);

2.6.18. Conclusion#

The scattering geometry provides all the tools to determine which reciprocal lattice points are possible and which of them are allowed.

Next we need to transfer out knowledge into a diffraction pattern.

2.6.19. Navigation#