hexrd.instrument.hedm_instrument module
Created on Fri Dec 9 13:05:27 2016
@author: bernier2
- class hexrd.instrument.hedm_instrument.GenerateEtaOmeMaps(image_series_dict, instrument, plane_data, active_hkls=None, eta_step=0.25, threshold=None, ome_period=(0, 360))[source]
Bases:
objecteta-ome map class derived from new image_series and YAML config
…for now…
must provide:
self.dataStore self.planeData self.iHKLList self.etaEdges # IN RADIANS self.omeEdges # IN RADIANS self.etas # IN RADIANS self.omegas # IN RADIANS
- property dataStore
- property etaEdges
- property etas
- property iHKLList
- property omeEdges
- property omegas
- property planeData
- class hexrd.instrument.hedm_instrument.GrainDataWriter(filename=None, array=None)[source]
Bases:
objectClass for dumping grain data.
- class hexrd.instrument.hedm_instrument.GrainDataWriter_h5(filename, instr_cfg, grain_params, use_attr=False)[source]
Bases:
objectClass for dumping grain results to an HDF5 archive.
TODO: add material spec
- class hexrd.instrument.hedm_instrument.HEDMInstrument(instrument_config=None, image_series=None, eta_vector=None, instrument_name=None, tilt_calibration_mapping=None, max_workers=1, physics_package=None, active_beam_name: str | None = None)[source]
Bases:
objectAbstraction of XRD instrument.
Distortion needs to be moved to a class with registry; tuple unworkable
where should reference eta be defined? currently set to default config
- property active_beam: dict
- property active_beam_name: str
- property beam_dict: dict
- property beam_energy: float
- property beam_names: list[str]
- property beam_vector: ndarray
- property beam_wavelength
- calc_transmission(rMat_s: ndarray = None) dict[str, numpy.ndarray][source]
calculate the transmission from the filter and polymer coating. the inverse of this number is the intensity correction that needs to be applied. actual computation is done inside the detector class
- property chi
- property detector_groups: list[str]
- property detector_parameters
- property detectors
- detectors_in_group(group: str) dict[str, hexrd.instrument.detector.Detector][source]
- property energy_correction: dict | None
Energy correction dict appears as follows:
- {
# The beam energy gradient center, along the specified # axis, in millimeters. ‘intercept’: 0.0,
# The slope of the beam energy gradient along the # specified axis, in eV/mm. ‘slope’: 0.0,
# The specified axis for the beam energy gradient, # either ‘x’ or ‘y’. ‘axis’: ‘y’,
}
- property eta_vector
- extract_line_positions(plane_data, imgser_dict, tth_tol=None, eta_tol=1.0, npdiv=2, eta_centers=None, collapse_eta=True, collapse_tth=False, do_interpolation=True, do_fitting=False, tth_distortion=None, fitting_kwargs=None)[source]
Perform annular interpolation on diffraction images.
Provides data for extracting the line positions from powder diffraction images, pole figure patches from imageseries, or Bragg peaks from Laue diffraction images.
Parameters
- plane_datahexrd.crystallography.PlaneData object or array_like
Object determining the 2theta positions for the integration sectors. If PlaneData, this will be all non-excluded reflections, subject to merging within PlaneData.tThWidth. If array_like, interpreted as a list of 2theta angles IN DEGREES.
- imgser_dictdict
Dictionary of powder diffraction images, one for each detector.
- tth_tolscalar, optional
The radial (i.e. 2theta) width of the integration sectors IN DEGREES. This arg is required if plane_data is array_like. The default is None.
- eta_tolscalar, optional
The azimuthal (i.e. eta) width of the integration sectors IN DEGREES. The default is 1.
- npdivint, optional
The number of oversampling pixel subdivision (see notes). The default is 2.
- eta_centersarray_like, optional
The desired azimuthal sector centers. The default is None. If None, then bins are distrubted sequentially from (-180, 180).
- collapse_etabool, optional
Flag for summing sectors in eta. The default is True.
- collapse_tthbool, optional
Flag for summing sectors in 2theta. The default is False.
- do_interpolationbool, optional
If True, perform bilinear interpolation. The default is True.
- do_fittingbool, optional
If True, then perform spectrum fitting, and append the results to the returned data. collapse_eta must also be True for this to have any effect. The default is False.
- tth_distortionspecial class, optional
for special case of pinhole camera distortions. See classes in hexrd.xrdutil.phutil
- fitting_kwargsdict, optional
kwargs passed to hexrd.fitting.utils.fit_ring if do_fitting is True
Raises
- RuntimeError
DESCRIPTION.
Returns
- panel_datadict
- Dictionary over the detctors with the following structure:
- [list over (merged) 2theta ranges]
- [list over valid eta sectors]
- [angle data <input dependent>,
bin intensities <input dependent>, fitting results <input dependent>]
Notes
TODO: May change the array_like input units to degrees. TODO: rename function.
- extract_polar_maps(plane_data, imgser_dict, active_hkls=None, threshold=None, tth_tol=None, eta_tol=0.25)[source]
Extract eta-omega maps from an imageseries.
Quick and dirty way to histogram angular patch data for make pole figures suitable for fiber generation
TODO: streamline projection code TODO: normalization !!!: images must be non-negative! !!!: plane_data is NOT a copy!
- property has_multi_beam: bool
- property id
- property mean_detector_center: ndarray
Return the mean center for all detectors
- mean_group_center(group: str) ndarray[source]
Return the mean center for detectors belonging to a group
- property num_panels
- pull_spots(plane_data, grain_params, imgser_dict, tth_tol=0.25, eta_tol=1.0, ome_tol=1.0, npdiv=2, threshold=10, eta_ranges=[(-3.141592653589793, 3.141592653589793)], ome_period=None, dirname='results', filename=None, output_format='text', return_spot_list=False, quiet=True, check_only=False, interp='nearest')[source]
Exctract reflection info from a rotation series.
Input must be encoded as an OmegaImageseries object.
Parameters
- plane_dataTYPE
DESCRIPTION.
- grain_paramsTYPE
DESCRIPTION.
- imgser_dictTYPE
DESCRIPTION.
- tth_tolTYPE, optional
DESCRIPTION. The default is 0.25.
- eta_tolTYPE, optional
DESCRIPTION. The default is 1..
- ome_tolTYPE, optional
DESCRIPTION. The default is 1..
- npdivTYPE, optional
DESCRIPTION. The default is 2.
- thresholdTYPE, optional
DESCRIPTION. The default is 10.
- eta_rangesTYPE, optional
DESCRIPTION. The default is [(-np.pi, np.pi), ].
- ome_periodTYPE, optional
DESCRIPTION. The default is (-np.pi, np.pi).
- dirnameTYPE, optional
DESCRIPTION. The default is ‘results’.
- filenameTYPE, optional
DESCRIPTION. The default is None.
- output_formatTYPE, optional
DESCRIPTION. The default is ‘text’.
- return_spot_listTYPE, optional
DESCRIPTION. The default is False.
- quietTYPE, optional
DESCRIPTION. The default is True.
- check_onlyTYPE, optional
DESCRIPTION. The default is False.
- interpTYPE, optional
DESCRIPTION. The default is ‘nearest’.
Returns
- complTYPE
DESCRIPTION.
- outputTYPE
DESCRIPTION.
- simulate_laue_pattern(crystal_data, minEnergy=5.0, maxEnergy=35.0, rmat_s=None, grain_params=None)[source]
Simulate Laue diffraction over the instrument.
Parameters
- crystal_dataTYPE
DESCRIPTION.
- minEnergyTYPE, optional
DESCRIPTION. The default is 5..
- maxEnergyTYPE, optional
DESCRIPTION. The default is 35..
- rmat_sTYPE, optional
DESCRIPTION. The default is None.
- grain_paramsTYPE, optional
DESCRIPTION. The default is None.
Returns
- resultsTYPE
DESCRIPTION.
xy_det, hkls_in, angles, dspacing, energy
TODO: revisit output; dict, or concatenated list?
- simulate_powder_pattern(mat_list, params=None, bkgmethod=None, origin=None, noise=None)[source]
Generate powder diffraction iamges from specified materials.
Parameters
- mat_listarray_like (n, )
List of Material classes.
- paramsdict, optional
Dictionary of LeBail parameters (see Notes). The default is None.
- bkgmethoddict, optional
Background function specification. The default is None.
- originarray_like (3,), optional
Vector describing the origin of the diffrction volume. The default is None, wiich is equivalent to [0, 0, 0].
- noisestr, optional
Flag describing type of noise to be applied. The default is None.
Returns
- img_dictdict
Dictionary of diffraciton images over the detectors.
Notes
TODO: add more controls for noise function. TODO: modify hooks to LeBail parameters. TODO: add optional volume fraction weights for phases in mat_list
- simulate_rotation_series(plane_data, grain_param_list, eta_ranges=[(-3.141592653589793, 3.141592653589793)], ome_ranges=[(-3.141592653589793, 3.141592653589793)], ome_period=(-3.141592653589793, 3.141592653589793), wavelength=None)[source]
Simulate a monochromatic rotation series over the instrument.
Parameters
- plane_dataTYPE
DESCRIPTION.
- grain_param_listTYPE
DESCRIPTION.
- eta_rangesTYPE, optional
DESCRIPTION. The default is [(-np.pi, np.pi), ].
- ome_rangesTYPE, optional
DESCRIPTION. The default is [(-np.pi, np.pi), ].
- ome_periodTYPE, optional
DESCRIPTION. The default is (-np.pi, np.pi).
- wavelengthTYPE, optional
DESCRIPTION. The default is None.
Returns
- resultsTYPE
DESCRIPTION.
TODO: revisit output; dict, or concatenated list?
- property source_distance
- property tvec
- class hexrd.instrument.hedm_instrument.PatchDataWriter(filename)[source]
Bases:
objectClass for dumping Bragg reflection data.
- hexrd.instrument.hedm_instrument.angle_in_range(angle, ranges, ccw=True, units='degrees')[source]
Return the index of the first wedge the angle is found in
WARNING: always clockwise; assumes wedges are not overlapping
- hexrd.instrument.hedm_instrument.calc_angles_from_beam_vec(bvec)[source]
Return the azimuth and polar angle from a beam vector
- hexrd.instrument.hedm_instrument.calc_beam_vec(azim, pola)[source]
Calculate unit beam propagation vector from spherical coordinate spec in DEGREES.
…MAY CHANGE; THIS IS ALSO LOCATED IN XRDUTIL!
- hexrd.instrument.hedm_instrument.chunk_instrument(instr, rects, labels, use_roi=False)[source]
Generate chunked config fro regularly tiled composite detectors.
Parameters
- instrTYPE
DESCRIPTION.
- rectsTYPE
DESCRIPTION.
- labelsTYPE
DESCRIPTION.
Returns
- new_icfg_dictTYPE
DESCRIPTION.
- hexrd.instrument.hedm_instrument.generate_chunks(nrows, ncols, base_nrows, base_ncols, row_gap=0, col_gap=0)[source]
Generate chunking data for regularly tiled composite detectors.
Parameters
- nrowsint
DESCRIPTION.
- ncolsint
DESCRIPTION.
- base_nrowsint
DESCRIPTION.
- base_ncolsint
DESCRIPTION.
- row_gapint, optional
DESCRIPTION. The default is 0.
- col_gapint, optional
DESCRIPTION. The default is 0.
Returns
- rectsarray_like
The (nrows*ncols, ) list of ROI specs (see Notes).
- labelsarray_like
The (nrows*ncols, ) list of ROI (i, j) matrix indexing labels ‘i_j’.
Notes
- ProcessedImageSeries needs a (2, 2) array for the ‘rect’ kwarg:
- [[row_start, row_stop],
[col_start, col_stop]]
- hexrd.instrument.hedm_instrument.histogram(x, bins, weights=None)
- hexrd.instrument.hedm_instrument.max_resolution(instr)[source]
Return the maximum angular resolution of the instrument.
Parameters
- instrHEDMInstrument instance
An instrument.
Returns
- max_tthfloat
Maximum tth resolution in radians.
- max_etaTYPE
maximum eta resolution in radians.
- hexrd.instrument.hedm_instrument.max_tth(instr)[source]
Return the maximum Bragg angle (in radians) subtended by the instrument.
Parameters
- instrhexrd.instrument.HEDMInstrument instance
the instrument class to evalutate.
Returns
- tth_maxfloat
The maximum observable Bragg angle by the instrument in radians.
- hexrd.instrument.hedm_instrument.migrate_instrument_config(instrument_config)[source]
utility function to generate old instrument config dictionary
- hexrd.instrument.hedm_instrument.pixel_resolution(instr)[source]
Return the minimum, median, and maximum angular resolution of the instrument.
Parameters
- instrHEDMInstrument instance
An instrument.
Returns
- tth_statsfloat
min/median/max tth resolution in radians.
- eta_statsTYPE
min/median/max eta resolution in radians.
- hexrd.instrument.hedm_instrument.switch_xray_source(instr: HEDMInstrument, xray_source: str | None)[source]