hexrd.xrdutil.utils module

class hexrd.xrdutil.utils.EtaOmeMaps(ome_eta_archive)[source]

Bases: object

find-orientations loads pickled eta-ome data, but CollapseOmeEta is not pickleable, because it holds a list of ReadGE, each of which holds a reference to an open file object, which is not pickleable.

save(filename)[source]
static save_eta_ome_maps(eta_ome, filename)[source]

eta_ome.dataStore eta_ome.planeData eta_ome.iHKLList eta_ome.etaEdges eta_ome.omeEdges eta_ome.etas eta_ome.omegas

hexrd.xrdutil.utils.angularPixelSize(xy_det, xy_pixelPitch, rMat_d, rMat_s, tVec_d, tVec_s, tVec_c, distortion=None, beamVec=None, etaVec=None)[source]

Calculate angular pixel sizes on a detector.

  • choices to beam vector and eta vector specs have been supressed

  • assumes xy_det in UNWARPED configuration

hexrd.xrdutil.utils.extract_detector_transformation(detector_params)[source]

Construct arrays from detector parameters.

goes from 10 vector of detector parames OR instrument config dictionary (from YAML spec) to affine transformation arrays

Parameters

detector_paramsTYPE

DESCRIPTION.

Returns

rMat_dTYPE

DESCRIPTION.

tVec_dTYPE

DESCRIPTION.

chiTYPE

DESCRIPTION.

tVec_sTYPE

DESCRIPTION.

hexrd.xrdutil.utils.make_polar_net(ndiv=24, projection='stereographic', max_angle=120.0)[source]

TODO: options for generating net boundaries; fixed to Z proj.

hexrd.xrdutil.utils.make_reflection_patches(instr_cfg, tth_eta, ang_pixel_size, omega=None, tth_tol=0.2, eta_tol=1.0, rmat_c=array([[1., 0., 0.],        [0., 1., 0.],        [0., 0., 1.]]), tvec_c=array([[0.],        [0.],        [0.]]), npdiv=1, quiet=False, compute_areas_func=CPUDispatcher(<function compute_areas>))[source]

Make angular patches on a detector.

panel_dims are [(xmin, ymin), (xmax, ymax)] in mm

pixel_pitch is [row_size, column_size] in mm

FIXME: DISTORTION HANDING IS STILL A KLUDGE!!!

patches are:

delta tth

d ————- … ————- e | x | x | x | … | x | x | x | l ————- … ————- t . a .

.

e ————- … ————- t | x | x | x | … | x | x | x | a ————- … ————-

outputs are:

(tth_vtx, eta_vtx), (x_vtx, y_vtx), connectivity, subpixel_areas, (x_center, y_center), (i_row, j_col)

hexrd.xrdutil.utils.simulateGVecs(pd, detector_params, grain_params, ome_range=[(-3.141592653589793, 3.141592653589793)], ome_period=(-3.141592653589793, 3.141592653589793), eta_range=[(-3.141592653589793, 3.141592653589793)], panel_dims=[(-204.8, -204.8), (204.8, 204.8)], pixel_pitch=(0.2, 0.2), distortion=None)[source]

returns valid_ids, valid_hkl, valid_ang, valid_xy, ang_ps

panel_dims are [(xmin, ymin), (xmax, ymax)] in mm

pixel_pitch is [row_size, column_size] in mm

simulate the monochormatic scattering for a specified

  • space group

  • wavelength

  • orientation

  • strain

  • position

  • detector parameters

  • oscillation axis tilt (chi)

subject to

  • omega (oscillation) ranges (list of (min, max) tuples)

  • eta (azimuth) ranges

pd…………….a hexrd.crystallography.PlaneData instance detector_params…a (10,) ndarray containing the tilt angles (3),

translation (3), chi (1), and sample frame translation (3) parameters

grain_params……a (12,) ndarray containing the exponential map (3),

translation (3), and inverse stretch tensor compnents in Mandel-Voigt notation (6).

  • currently only one panel is supported, but this will likely change soon

hexrd.xrdutil.utils.simulateLauePattern(hkls, bMat, rmat_d, tvec_d, panel_dims, panel_buffer=5, minEnergy=8, maxEnergy=24, rmat_s=array([[1., 0., 0.], [0., 1., 0.], [0., 0., 1.]]), grain_params=None, distortion=None, beamVec=None)[source]
hexrd.xrdutil.utils.simulateOmeEtaMaps(omeEdges, etaEdges, planeData, expMaps, chi=0.0, etaTol=None, omeTol=None, etaRanges=None, omeRanges=None, bVec=array([-0., -0., -1.]), eVec=array([1., 0., 0.]), vInv=array([1., 1., 1., 0., 0., 0.]))[source]

Simulate spherical maps.

Parameters

omeEdgesTYPE

DESCRIPTION.

etaEdgesTYPE

DESCRIPTION.

planeDataTYPE

DESCRIPTION.

expMaps(3, n) ndarray

DESCRIPTION.

chiTYPE, optional

DESCRIPTION. The default is 0..

etaTolTYPE, optional

DESCRIPTION. The default is None.

omeTolTYPE, optional

DESCRIPTION. The default is None.

etaRangesTYPE, optional

DESCRIPTION. The default is None.

omeRangesTYPE, optional

DESCRIPTION. The default is None.

bVecTYPE, optional

DESCRIPTION. The default is [0, 0, -1].

eVecTYPE, optional

DESCRIPTION. The default is [1, 0, 0].

vInvTYPE, optional

DESCRIPTION. The default is [1, 1, 1, 0, 0, 0].

Returns

eta_omeTYPE

DESCRIPTION.

Notes

all angular info is entered in degrees

??? might want to creat module-level angluar unit flag ??? might want to allow resvers delta omega

hexrd.xrdutil.utils.validateAngleRanges(angList, startAngs, stopAngs, ccw=True)[source]

Indetify angles that fall within specified ranges.

A better way to go. find out if an angle is in the range CCW or CW from start to stop

There is, of course an ambigutiy if the start and stop angle are the same; we treat them as implying 2*pi

hexrd.xrdutil.utils.zproject_sph_angles(invecs, chi=0.0, method='stereographic', source='d', use_mask=False, invert_z=False, rmat=None)[source]

Projects spherical angles to 2-d mapping.

Parameters

invecarray_like

The (n, 3) array of input points, interpreted via the ‘source’ kwarg.

chiscalar, optional

The inclination angle of the sample frame. The default is 0..

methodstr, optional

Mapping type spec, either ‘stereographic’ or ‘equal-area’. The default is ‘stereographic’.

sourcestr, optional
The type specifier of the input vectors, either ‘d’, ‘q’, or ‘g’.

‘d’ signifies unit diffraction vectors as (2theta, eta, omega), ‘q’ specifies unit scattering vectors as (2theta, eta, omega), ‘g’ specifies unit vectors in the sample frame as (x, y, z).

The default is ‘d’.

use_maskbool, optional

If True, trim points not on the +z hemishpere (polar angles > 90). The default is False.

invert_zbool, optional

If True, invert the Z-coordinates of the unit vectors calculated from the input angles. The default is False.

rmatnumpy.ndarry, shape=(3, 3), optional

Array representing a change of basis (rotation) to appy to the calculated unit vectors. The default is None.

Raises

RuntimeError

If method not in (‘stereographic’, ‘equal-area’).

Returns

numpy.ndarray or tuple

If use_mask = False, then the array of n mapped input points with shape (n, 2). If use_mask = True, then the first element is the ndarray of mapped points with shape (<=n, 2), and the second is a bool array with shape (n,) marking the point that fell on the upper hemishpere. .

Notes

CAVEAT: +Z axis projections only!!! TODO: check mask application.