Kinematic diffraction#
Kinematic diffraction module is designed to handle kinematic simulation data. It is composed of Point, Line and Disk class objects.
- class pyemaps.kdiffs.Point(p=(0.0, 0.0))#
Bases:
objectA 2-D point
(x, y)in a kinematic diffraction pattern.- __init__(p=(0.0, 0.0))#
- Parameters:
p (tuple of float, optional) – the coordinates
(x, y).- Raises:
PointError – if a coordinate isn’t numeric.
- property x#
The x coordinate.
- property y#
The y coordinate.
- class pyemaps.kdiffs.Line(pt1=None, pt2=None, intensity=0, type=1)#
Bases:
objectA line in a kinematic diffraction pattern: a Kikuchi line or a HOLZ line.
- __init__(pt1=None, pt2=None, intensity=0, type=1)#
- Parameters:
- Raises:
LineError – if an end point isn’t a Point, or intensity or type is invalid.
- property type#
The line type: 1 for a Kikuchi line, 2 for a HOLZ line.
- property intensity#
The line’s intensity, as an integer.
- calOpacity(l, h)#
Calculate the opacity to draw the line with, scaled linearly by its intensity: 0.2 at the lowest intensity l and 0.35 at the highest h.
- Parameters:
l – lowest line intensity in the pattern.
h – highest line intensity in the pattern.
- Returns:
the opacity, from 0.2 to 0.35. If l equals h, 0.35.
- Return type:
float
- to_dict()#
Return the line as a dictionary:
{'pt1': (x1, y1), 'pt2': (x2, y2), 'int': intensity}.
- class pyemaps.kdiffs.Index(I0=(0, 0, 0))#
Bases:
objectThe Miller indices
(h, k, l)of a diffracted beam.- __init__(I0=(0, 0, 0))#
- Parameters:
I0 (tuple of int, optional) – the three indices.
- Raises:
PIndexError – if an index isn’t an integer.
- property I1#
The first Miller index, h.
- property I2#
The second Miller index, k.
- property I3#
The third Miller index, l.
- class pyemaps.kdiffs.Disk(c=None, r=0.0, i=None)#
Bases:
objectA diffracted beam in a kinematic diffraction pattern: its center, radius and Miller indices.
- __init__(c=None, r=0.0, i=None)#
- property r#
The radius of the diffracted beam.
- to_dict()#
Return the disk as a dictionary:
{'c': (x, y), 'idx': (h, k, l), 'r': radius}.
- class pyemaps.kdiffs.diffPattern(diff_dict)#
Bases:
objectA kinematic diffraction pattern: its Kikuchi lines, HOLZ lines and diffracted beams.
generateDP()returns one, andshowDif()displays it. Its coordinates are shifted byshift. For drawing it with other tools, see Using results in other tools.- __init__(diff_dict)#
- Parameters:
diff_dict (dict, required) – the raw pattern data from a kinematic simulation. Create diffraction patterns with
generateDP()rather than directly.- Raises:
DPError – if diff_dict is missing data or has invalid values.
- property name#
The crystal’s name.
- property nklines#
The number of Kikuchi lines.
- property nhlines#
The number of HOLZ lines.
- property ndisks#
The number of diffracted beams.
- to_dict()#
Return the pattern as a dictionary of lists:
{'klines': [...], 'hlines': [...], 'disks': [...]}. Each Kikuchi or HOLZ line is a dictionary fromLine.to_dict(), and each disk one fromDisk.to_dict().
- class pyemaps.kdiffs.Diffraction(name, mode=DEF_MODE)#
Bases:
objectA list of kinematic diffraction patterns (available as
DPList), each paired with the microscope controls it was simulated with.showDif()displays one.from pyemaps import Crystal, DPList si = Crystal.from_builtin('Silicon') dpl = DPList('Silicon') emc, dp = si.generateDP() dpl.add(emc, dp) for emc, dp in dpl: print(emc.zone, dp.ndisks)
- __init__(name, mode=DEF_MODE)#
- Parameters:
name (str, required) – the crystal’s name.
mode (int, optional) – 1 for normal patterns, 2 for CBED.
- Raises:
DPListError – if name is empty or mode isn’t 1 or 2.
- property name#
The crystal’s name.
- property mode#
The diffraction mode: 1 for normal, 2 for CBED.
- property diffList#
The patterns, as a list of
(controls, pattern)tuples.
- add(emc, diffP)#
Add a diffraction pattern, with the controls it was simulated with.
- Parameters:
emc (
EMControl, required) – the controls.diffP (
diffPattern, required) – the diffraction pattern.
- Raises:
DPListError – if diffP isn’t a diffPattern.
- sort()#
Sort the patterns by their controls.
- clear()#
Remove all patterns from the list.