Microscope and simulation controls#

Microscope and simulation controls.

This module defines two control classes: EMControl for the microscope, sample and detector, and SIMControl for the simulation. The simulation controls change less often, so an EMControl holds a SIMControl.

The main classes are also available from pyemaps as EMC and SIMC.

Simulation control defaults

pyemaps.emcontrols.DEF_EXCITATION = (0.3, 2.0)#
pyemaps.emcontrols.DEF_GMAX = 3.5#
pyemaps.emcontrols.DEF_BMIN = 0.1#
pyemaps.emcontrols.DEF_INTENSITY = (0.0, 5)#
pyemaps.emcontrols.DEF_GCTL = 6.0#
pyemaps.emcontrols.DEF_ZCTL = 5.0#
pyemaps.emcontrols.DEF_OMEGA = 10#
pyemaps.emcontrols.DEF_SAMPLING = 8#
pyemaps.emcontrols.DEF_THICKNESS = (200, 200, 100)#

Microscope control defaults

pyemaps.emcontrols.DEF_TILT = (0.0, 0.0)#
pyemaps.emcontrols.DEF_ZONE = (0, 0, 1)#
pyemaps.emcontrols.DEF_DEFL = (0.0, 0.0)#
pyemaps.emcontrols.DEF_KV = 200.0#
pyemaps.emcontrols.DEF_CL = 1000.0#
pyemaps.emcontrols.DEF_APERTURE = 1.0#
pyemaps.emcontrols.DEF_XAXIS = (0, 0, 0)#
pyemaps.emcontrols.DEF_PIXSIZE = 25#
pyemaps.emcontrols.DEF_DETSIZE = 512#
pyemaps.emcontrols.DEF_MODE = 1#
pyemaps.emcontrols.DEF_CBED_DSIZE = 0.16#
exception pyemaps.emcontrols.EMCError(message='')#

Bases: Exception

Raised when microscope or simulation controls are invalid.

__init__(message='')#
pyemaps.emcontrols.doc_dec_simc(k)#
class pyemaps.emcontrols.SIMControl(excitation=DEF_SIMC['excitation'], gmax=DEF_SIMC['gmax'], bmin=DEF_SIMC['bmin'], intensity=DEF_SIMC['intensity'], gctl=DEF_SIMC['gctl'], zctl=DEF_SIMC['zctl'])#

Bases: object

Simulation controls. An EMControl holds one as its simc; it’s also available from pyemaps as SIMC.

from pyemaps import EMC, SIMC

emc = EMC(zone=(1, 1, 0), simc=SIMC(gmax=1.0, excitation=(0.3, 1.0)))

The dynamic diffraction methods also record omega, sampling and sth (sample thickness, Å) here.

__init__(excitation=DEF_SIMC['excitation'], gmax=DEF_SIMC['gmax'], bmin=DEF_SIMC['bmin'], intensity=DEF_SIMC['intensity'], gctl=DEF_SIMC['gctl'], zctl=DEF_SIMC['zctl'])#
Parameters:
  • excitation (tuple of float, optional) – excitation error range (min, max). Defaults to (0.3, 2.0).

  • gmax (float, optional) – maximum reciprocal vector length, in 1/Å. Defaults to 3.5.

  • bmin (float, optional) – beta perturbation cutoff. Defaults to 0.1.

  • intensity (tuple of float, optional) – kinematic intensity cutoff level and scale, (level, scale). Defaults to (0.0, 5).

  • gctl (int, optional) – maximum index for the g-list. Defaults to 6.

  • zctl (int, optional) – maximum zone axis index. Defaults to 5.

Raises:

EMCError – if a value is invalid, or a range isn’t in ascending order.

property excitation#

Excitation error range (min, max)

property gmax#

Maximum reciprocal vector length (1/Å)

property bmin#

Beta perturbation cutoff

property intensity#

Kinematic diffraction intensity cutoff level and scale (level, scale)

property gctl#

Maximum index for the g-list

property zctl#

Maximum zone axis index

property omega#

Diagonalization cutoff

property sampling#

Number of sampling points

property sth#

Sample thickness (Å)

plot_format()#

Format the controls that aren’t at their defaults, for the captions of the built-in displays.

Returns:

the controls, as name=value pairs separated by semicolons.

Return type:

str

classmethod from_random()#

Create controls with random values. Kept for backward compatibility; for testing.

pyemaps.emcontrols.doc_dec(k)#
class pyemaps.emcontrols.EMControl(tilt=DEF_TILT, zone=DEF_ZONE, defl=DEF_DEFL, vt=DEF_KV, cl=DEF_CL, simc=None)#

Bases: object

Microscope, sample and detector controls for a simulation, holding the simulation controls too. Also available from pyemaps as EMC.

  • zone: starting zone axis

  • tilt: sample tilt in x and y, (x, y)

  • defl: shift in x and y, (x, y)

  • cl: camera length, in mm

  • vt: high voltage, in kV

  • simc: simulation controls, a SIMControl

The simulation methods also record these in it:

  • mode: 1 for normal diffraction, 2 for CBED

  • dsize: diffracted beam (disk) size, used in CBED mode

  • aperture: objective lens aperture

  • pix_size: detector pixel size, in µm

  • det_size: detector size, in pixels

  • xaxis: the crystal’s horizontal axis in reciprocal space

from pyemaps import Crystal, EMC

si = Crystal.from_builtin('Silicon')
emc, dp = si.generateDP(em_controls=EMC(zone=(1, 1, 0), cl=1500))
__init__(tilt=DEF_TILT, zone=DEF_ZONE, defl=DEF_DEFL, vt=DEF_KV, cl=DEF_CL, simc=None)#
Parameters:
  • tilt (tuple of float, optional) – sample tilt (x, y). Defaults to (0.0, 0.0).

  • zone (tuple of int, optional) – starting zone axis, three integers, not (0, 0, 0). Defaults to (0, 0, 1).

  • defl (tuple of float, optional) – shift (x, y). Defaults to (0.0, 0.0).

  • vt (float, optional) – high voltage, in kV. Defaults to 200.

  • cl (float, optional) – camera length, in mm. Defaults to 1000.

  • simc (SIMControl, optional) – simulation controls. Defaults to the default SIMControl.

Raises:

EMCError – if a value is invalid.

classmethod from_dict(emc_dict)#

Create controls from a dictionary.

Parameters:

emc_dict (dict, required) – the controls, with the keys tilt, zone, defl, vt and cl. Other keys are ignored, and the simulation controls are set to their defaults.

Returns:

the controls.

Return type:

EMControl

Raises:

EMCError – if emc_dict isn’t a dictionary, or a value is missing or invalid.

property zone#

Starting zone axis

property tilt#

Tilt in x and y directions (x, y)

property defl#

Shift in x and y directions (x, y)

property cl#

Camera length (mm)

property vt#

High voltage (kV)

property xaxis#

Crystal horizontal axis in reciprocal space

property simc#

Simulation controls

property aperture#

Objective lens aperture

property pix_size#

Detector pixel size (microns)

property det_size#

Detector size (pixels)

property mode#

Simulation mode

property dsize#

Diffracted beam size

plot_format()#

Format the controls, including the simulation controls, that aren’t at their defaults, for the captions of the built-in displays.

Returns:

the controls, as name=value pairs separated by semicolons.

Return type:

str

static def_dict()#

Return the default value of every microscope and simulation control.

Return type:

dict