ImageD11.transform module#
- class ImageD11.transform.Ctransform(pars)#
Bases:
object- pnames = ('y_center', 'z_center', 'y_size', 'z_size', 'distance', 'wavelength', 'omegasign', 'tilt_x', 'tilt_y', 'tilt_z', 'o11', 'o12', 'o21', 'o22', 'wedge', 'chi')#
- reset()#
- sf2gv(sc, fc, omega, tx=0, ty=0, tz=0, out=None)#
computes g vectors in the sample frame input sc, fc, omega = spot coordinates, shape(n) tx, ty, tz = scalar grain centre of mass returns: gve shape(n,3)
- sf2gvlocal(sc, fc, omega, xpos, out=None)#
computes local g vectors in the sample frame for scanning 3DXRD data emulating a moving scattering origin along the beam direction (xpos). input sc, fc, omega = spot coordinates, shape(n,) xpos = lab-coordinate of the target point/pixel along the beam direction for each omega, shape=(n,) returns: gve shape(n,3)
- sf2xyz(sc, fc, out=None)#
computes the xlab, ylab, zlab co-ordinates of spots on the detector input: sc, fc = corrected spot positions, shape(n) output: xlylzl array shape (n,3)
- xyz2geometry(xyz, omega, tx=0, ty=0, tz=0, out=None)#
Takes x,y,z laborator spot positions. Computes everything else needed for updateGeometry in columnfile
- xyz2gv(xyz, omega, tx=0, ty=0, tz=0, out=None)#
computes g vectors from xlylzl co-ordinates on the detector input: xlylzl array shape (n,3) output: gve shape (n,3)
- class ImageD11.transform.PixelLUT(pars)#
Bases:
objectA look up table for a 2D image to store pixel-by-pixel values
- pnames = ('y_center', 'z_center', 'y_size', 'z_size', 'distance', 'wavelength', 'omegasign', 'tilt_x', 'tilt_y', 'tilt_z', 'o11', 'o12', 'o21', 'o22', 'wedge', 'chi', 'dxfile', 'dyfile', 'spline', 'shape')#
- spatial(sraw, fraw)#
applies a spatial distortion to sraw, fraw (for peak centroids)
- ImageD11.transform.compute_g_from_k(k, omega, wedge=0, chi=0)#
Compute g-vectors with cached k-vectors
- ImageD11.transform.compute_g_vectors(tth, eta, omega, wvln, wedge=0.0, chi=0.0)#
- Generates spot positions in reciprocal space from
twotheta, wavelength, omega and eta
Assumes single axis vertical … unless a wedge angle is specified
- ImageD11.transform.compute_grain_origins(omega, wedge=0.0, chi=0.0, t_x=0.0, t_y=0.0, t_z=0.0)#
# print “Using translations t_x %f t_y %f t_z %f”%(t_x,t_y,t_z) # Compute positions of grains # expecting tx, ty, tz for each diffraction spot # # g = R . W . k # g - is g-vector w.r.t crystal # k is scattering vector in lab # so we want displacement in lab from displacement in sample # shift = W-1 R-1 crystal_translation # # R = ( cos(omega) , sin(omega), 0 ) # (-sin(omega) , cos(omega), 0 ) # ( 0 , 0 , 1 ) # # W = ( cos(wedge) , 0 , sin(wedge) ) # ( 0 , 1 , 0 ) # (-sin(wedge) , 0 , cos(wedge) ) # # C = ( 1 , 0 , 0 ) ??? Use eta0 instead # ( 0 , cos(chi) , sin(chi) ) ??? Use eta0 instead # ( 0 , -sin(chi) , cos(chi) ) ??? Use eta0 instead
- ImageD11.transform.compute_k_vectors(tth, eta, wvln)#
generate k vectors - scattering vectors in laboratory frame
- ImageD11.transform.compute_lorentz_factors(tth, eta, omega, wavelength, wedge=0.0, chi=0.0)#
From Kabsch 1988 J. Appl. Cryst. 21 619
Multiply the intensities by: Lorentz = | S.(u x So)| / |S|.|So| S = scattered vector So = incident vector u = unit vector along rotation axis
- ImageD11.transform.compute_polarisation_factors(args)#
From Kabsch 1988 J. Appl. Cryst. 21 619
DIVIDE the intensities by: <sin2 psi> = (1 - 2p) [ 1 - (n.S/|S|^2) ] + p { 1 + [S.S_0/(|S||S_0|)^2]^2}
- p = degree of polarisation (sync = 1, tube = 0.5 , mono + tube in between)
- or “probability of finding electric field vector in plane having
normal, n”
S = scattered vector S_0 = incident vector n = normal to polarisation plane, typically perpendicular to S_0
In ImageD11 we normally expect to find: x axis along the beam z axis being up, and parallel to the normal n mentioned above
- ImageD11.transform.compute_sinsqth_from_xyz(xyz)#
Computes sin(theta)**2 x,y,z = co-ordinates of the pixel in cartesian space
if you need grain translations then use func(peaks_xyz - compute_grain_origins(…) )
seems to be competitive with arctan2 (docs/sintheta_squared_geometry.ipynb)
returns sin(theta)**2
- ImageD11.transform.compute_tth_eta(peaks, y_center=0.0, y_size=0.0, tilt_y=0.0, z_center=0.0, z_size=0.0, tilt_z=0.0, tilt_x=0.0, distance=0.0, o11=1.0, o12=0.0, o21=0.0, o22=-1.0, t_x=0.0, t_y=0.0, t_z=0.0, omega=None, wedge=0.0, chi=0.0, **kwds)#
Finds x,y,z co-ordinates of peaks in the laboratory frame Computes tth/eta from these (in degrees)
kwds are not used (left for convenience if you have a parameter dict)
- ImageD11.transform.compute_tth_eta_from_xyz(peaks_xyz, omega, t_x=0.0, t_y=0.0, t_z=0.0, wedge=0.0, chi=0.0, **kwds)#
Peaks is a 3 d array of x,y,z peak co-ordinates crystal_translation is the position of the grain giving rise to a diffraction spot in x,y,z ImageD11 co-ordinates
x,y is with respect to the axis of rotation (usually also beam centre). z with respect to beam height, z centre
omega data are needed if crystal translations are used
computed via the arctan recipe.
returns tth/eta in degrees
- ImageD11.transform.compute_tth_histo(tth, no_bins=100, weight=False, weights=None, **kwds)#
Compute a histogram of tth values Uses numpy’s histogram rather that doing it by hand as above New feature: weight by something (peak intensity for instance), send true for weight and weights values
Returns a normalised histogram (should make this a probability and
For each datapoint, the corresponding histogram weight
Updated and modernized 2021-02-11 S. Merkel
- ImageD11.transform.compute_xyz_from_tth_eta(tth, eta, omega, t_x=0.0, t_y=0.0, t_z=0.0, wedge=0.0, chi=0.0, **kwds)#
Given the tth, eta and omega, compute the xyz on the detector
crystal_translation is the position of the grain giving rise to a diffraction spot
in x,y,z ImageD11 co-ordinates x,y with respect to axis of rotation and or beam centre ?? z with respect to beam height, z centre
omega data needed if crystal translations used
- ImageD11.transform.compute_xyz_lab(peaks, y_center=0.0, y_size=0.0, tilt_y=0.0, z_center=0.0, z_size=0.0, tilt_z=0.0, tilt_x=0.0, distance=0.0, o11=1.0, o12=0.0, o21=0.0, o22=-1.0, **kwds)#
Peaks is a 2 d array of x,y yc is the centre in y ys is the y pixel size ty is the tilt around y zc is the centre in z zs is the z pixel size tz is the tilt around z dist is the sample - detector distance detector_orientation is a matrix to apply to peaks arg to get ImageD11 convention
(( 0, 1),( 1, 0)) for ( y, x) ((-1, 0),( 0, 1)) for (-x, y) (( 0,-1),(-1, 0)) for (-y,-x)
etc…
kwds are not used (but lets you pass in a dict with other things in it)
- ImageD11.transform.cross_product_2x2(a, b)#
returns axb for two len(3) vectors a,b
- ImageD11.transform.detector_rotation_matrix(tilt_x, tilt_y, tilt_z)#
Return the tilt matrix to apply to peaks tilts are in radians typically applied to peaks rotating around beam center
- ImageD11.transform.sinth2_sqrt_deriv(xyz)#
sin(theta)**2 from xyz, and derivatives w.r.t x,y,z
- ImageD11.transform.uncompute_g_vectors(g, wavelength, wedge=0.0, chi=0.0)#
Given g-vectors compute tth,eta,omega assert uncompute_g_vectors(compute_g_vector(tth,eta,omega))==tth,eta,omega
- ImageD11.transform.uncompute_one_g_vector(gv, wavelength, wedge=0.0)#
Given g-vectors compute tth,eta,omega assert uncompute_g_vectors(compute_g_vector(tth,eta,omega))==tth,eta,omega