Dans_Diffraction.tkgui.diffractometer
index
c:\users\grp66007\onedrive - diamond light source ltd\pythonprojects\dans_diffraction\dans_diffraction\tkgui\diffractometer.py

Dans-Diffraction
Diffractometer Simulator GUI
 
Simulate a generic detector situated around the crystal sample.
The sample and detector orientation are specified like a 6-axis diffractometer.
 
The angle conventions are those according to H. You, J. Appl. Cryst. (1999). 32, 614
 
On the top left, the reciprocal lattice is shown and any reflections incident on the detector are highlighted.
 
On the top right, the detector image is shown and incident reflections are highlighted.
 
On the bottom left, the lattice and detector orientation angles are controlled.
 
On the bottom right, the incident beam, intensity calculation options and detector size and shaper are specified.
 
Additional options can be found in the top menu. Any axis can be scanned to plot
the sum of the detector at each step
 
 Dr Daniel G Porter, dan.porter@diamond.ac.uk
 www.diamond.ac.uk
 Diamond Light Source, Chilton, Didcot, Oxon, OX11 0DE, U.K.

 
Modules
       
Dans_Diffraction.functions_crystallography
Dans_Diffraction.functions_general
Dans_Diffraction.functions_plotting
tkinter.messagebox
numpy
tkinter

 
Classes
       
builtins.object
Detector
DiffractometerGui
Lattice

 
class Detector(builtins.object)
    Detector(distance=1.0, normal_dir=(0, -1.0, 0), x_size=1.0, z_size=1.0, pixel_size=0.01, labmatrix=array([[1., 0., 0.],
       [0., 1., 0.],
       [0., 0., 1.]]))
 
Detector class
 
 distance: distance to detector in meters
 normal_dir: (dx, dy, dz) detector normal
 x_size: detector width along x-axis in meters
 z_size: detector height along z-axis in meters
 
assumes incident vector (0,1,0)
rotate delta (about z), gamma (about x)
 
  Methods defined here:
__init__(self, distance=1.0, normal_dir=(0, -1.0, 0), x_size=1.0, z_size=1.0, pixel_size=0.01, labmatrix=array([[1., 0., 0.], [0., 1., 0.], [0., 0., 1.]]))
Initialize self.  See help(type(self)) for accurate signature.
__repr__(self)
Return repr(self).
check_vector_incident(self, vectors)
Check a vector is in the direction of the detector
corners(self)
Returns coordinates of 4 corners
detector_image(self, iuvw, intensity, peak_width=0.01, background=0)
Generate detector image
:param iuvw: [nx3] array of relative positions on detector
:param intensity: [nx1] array of intensity values
:param peak_width: float or [nx1], peak FWHM, in m
:param background: float, background level
:return: xx, yy, mesh, peak_x[m], peak_y[m]
generate_detector = default_fun(*args, **kwargs)
height_lim(self)
incident_position(self, vectors)
Return position of vector incident on detector
kfkiq(self, wavelength_a)
Return lines traving kf, ki and Q
kfkiq_corners(self, wavelength_a)
Return lines to corners of kif, ki and Q
ki(self, wavelength_a)
peak_width_mm(self, delta_theta)
Calculate peak width on detector in mm
:param delta_theta: float or array, peak width in degrees
:return: FWHM in mm
q_shape(self, wavelength_a)
Return line in reciprocal space tracing the borders of the detector
reflection_position(self, qxqyqz, wavelength_a)
Return relative position of reflection on detector
:param qxqyqz: [nx3] array of reciprocal lattice vectors q = h.a* + k.b* + l.c*
:param wavelength_a: incident beam wavelength in Angstroms
:return ixyz: [nx3] array of positions on the detector
:return uvw: [nx3] array of positions on the detector, relative to detector centre, or NaN if not incident
:return diff: [nx1] array of wavevector difference in A-1, where 0 is the condition for diffraction.
relative_position(self, vectors)
Return a position coordinate relative to detector centre
rotate_to(self, delta=0.0, gamma=0.0)
Rotate detector position
:param delta: float angle in degrees in vertical direction (about diff-z)
:param gamma: float angle in degrees in horizontal direction (about diff-x)
:return: None
set_callbacks(self, generate_detector=None, update_widgets=None, update_plots=None)
set_detector(self, distance=1.0, normal_dir=(0, -1.0, 0), x_size=1.0, z_size=1.0, pixel_size=0.01)
set_labframe(self, labmatrix)
twotheta(self)
Return detector angle in degrees
update_plots = default_fun(*args, **kwargs)
update_widgets = default_fun(*args, **kwargs)
width_lim(self)

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

Data and other attributes defined here:
normal_dir = array([ 0., -1., 0.])
position = array([0., 0., 0.])
x_axis = array([1., 0., 0.])
z_axis = array([0., 0., 1.])

 
class DiffractometerGui(builtins.object)
    DiffractometerGui(xtl: Dans_Diffraction.classes_crystal.Crystal)
 
View and edit the symmetry operations
 
  Methods defined here:
__init__(self, xtl: Dans_Diffraction.classes_crystal.Crystal)
"Initialise
fun_i16(self)
"Add I16 parameters
fun_supernova(self)
Add SuperNova parameters
fun_wish(self)
"Add Wish parameters
menu_new(self)
Create a new instance
menu_options(self)
Set plot options
menu_orientation(self)
Set lattice orientation
update(self, event=None)
Update plot

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
class Lattice(builtins.object)
    Lattice(crystal: Dans_Diffraction.classes_crystal.Crystal)
 
Reciprocal Lattice
 
  Methods defined here:
__init__(self, crystal: Dans_Diffraction.classes_crystal.Crystal)
Initialize self.  See help(type(self)) for accurate signature.
generate_hkl(self, wavelength_a, max_q=4)
Generate reflection list
generate_intensities(self, calculate_index=())
Generate list of structure factors
generate_refs = default_fun(*args, **kwargs)
get_wavelength = default_fun(*args, **kwargs)
latt_str(self)
Generate list of reflections
rotate_to(self, phi=0.0, chi=0.0, eta=0.0, mu=0.0)
set_callbacks(self, generate_refs=None, update_widgets=None, update_plots=None, get_wavelength=None)
set_orientation(self, umatrix=None, labmatrix=None)
update_plots = default_fun(*args, **kwargs)
update_widgets = default_fun(*args, **kwargs)

Data descriptors defined here:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

 
Functions
       
default_fun(*args, **kwargs)
generate_reflections(latt: Dans_Diffraction.tkgui.diffractometer.Lattice, det: Dans_Diffraction.tkgui.diffractometer.Detector, minimum_gaussian_intensity=0.01)
Calulate reflections on detector
reflist_str()
Generate string from REFLIST
tk_angle_element(name, parent, callback, help_message='', val_range=(-180, 180), initial=0)
Slider element
tk_beam(parent, xtl, callback)
radiation tkinter widgets, returns Latt
tk_detector(parent, callback)
Create detector options widget
tk_help()
Display help
tk_hkl(parent, latt: Dans_Diffraction.tkgui.diffractometer.Lattice, tth_axis: tkinter.DoubleVar, th_axis: tkinter.DoubleVar, callback)
reflection frame
tk_orientation(parent, latt: Dans_Diffraction.tkgui.diffractometer.Lattice, det: Dans_Diffraction.tkgui.diffractometer.Detector, callback)
Orientation options window
tk_plot_options(parent, callback)
Plot options window
tk_scan(parent, angle_dict, latt, det)
update_3d(array, line_obj)
Update 3D line object

 
Data
        BF = ['Palatino', 14]
DEFAULT_DET_DISTANCE = 1000
DEFAULT_DET_HEIGHT = 200
DEFAULT_DET_PIXEL = 0.2
DEFAULT_DET_WIDTH = 200
DEFAULT_ENERGY = 8
DEFAULT_MAXQ = 4
DEFAULT_PEAKWIDTH = 0.2
DEFAULT_RESOLUTION = 200
FIGURE_3D_SIZE = [8, 4]
FIGURE_DET_SIZE = [7, 4]
FIGURE_DPI = 80
HF = ['Courier', 12]
LF = ['Palatino', 14]
MSG_CHI = "2nd rotation, right handed rotation about y''-axis."
MSG_DEL = 'Detector rotation, left handed rotation about diffractometer z-axis'
MSG_ETA = "3rd rotation, left handed rotation about z'-axis"
MSG_GAM = 'Detector rotation, right handed rotation about diffractometer x-axis'
MSG_MU = '4th rotation, right handed rotation about diffractometer x-axis'
MSG_PHI = "1st rotation, left handed roation about z'''-axis (crystal axis)"
OPTIONS = {'3d_basis': False, '3d_detector_corners': False, '3d_lattice': True, '3d_ref_arrows': False, 'det_clim': [0.0, 1.0], 'det_cmap': 'viridis', 'det_labels': True, 'det_log': False, 'fig_dpi': 80, 'maxq': 4.0, ...}
REFLIST = {'color': [], 'detx': array([], dtype=float64), 'dety': array([], dtype=float64), 'fwhm': array([], dtype=float64), 'hkl': array([], shape=(0, 3), dtype=int32), 'hkl_str': [], 'intensity': array([], dtype=float64), 'qxqyqz': array([], shape=(0, 3), dtype=float64), 'scaled': array([], dtype=float64)}
SF = ['Palatino', 14]
TABLEAU_COLORS = {'tab:blue': '#1f77b4', 'tab:brown': '#8c564b', 'tab:cyan': '#17becf', 'tab:gray': '#7f7f7f', 'tab:green': '#2ca02c', 'tab:olive': '#bcbd22', 'tab:orange': '#ff7f0e', 'tab:pink': '#e377c2', 'tab:purple': '#9467bd', 'tab:red': '#d62728'}
TF = ['Palatino', 12]
TTF = ('Helvetica', 10, 'bold italic')
bkg = 'snow'
btn = 'azure'
btn2 = 'gold'
btn_active = 'grey'
btn_txt = 'black'
col_cycle = <itertools.cycle object>
ety = 'white'
ety_txt = 'black'
opt = 'azure'
opt_active = 'grey'
opt_txt = 'black'
txtcol = 'black'