hexrd.fitting.calibration package

Submodules

Module contents

class hexrd.fitting.calibration.GrainCalibrator(instr, material, grain_params, ome_period, index=0, default_refinements=None, calibration_picks=None, euler_convention=('zxz', False))[source]

Bases: AbstractGrainCalibrator

This is for HEDM grain calibration

autopick_points()[source]
model()[source]
property name
residual()[source]

Compute a residual using the calibration data.

Calibration data may have already been stored as an attribute on the calibration class instead, in which case, calibration_data can be None.

type = 'grain'
class hexrd.fitting.calibration.InstrumentCalibrator(*args, engineering_constraints=None, euler_convention=('zxz', False), relative_constraints_type=RelativeConstraintsType.none)[source]

Bases: object

property engineering_constraints
property instr
make_lmfit_params()[source]
minimize(method='least_squares', odict=None)[source]
minimizer_function(params)[source]
property relative_constraints: RelativeConstraints
property relative_constraints_type
reset_lmfit_params()[source]
reset_relative_constraint_params()[source]
residual()[source]
run_calibration(odict)[source]
property tth_distortion
update_all_from_params(params)[source]
class hexrd.fitting.calibration.LaueCalibrator(instr, material, grain_params, default_refinements=None, min_energy=5, max_energy=25, tth_distortion=None, calibration_picks=None, euler_convention=('zxz', False), xray_source: str | None = None)[source]

Bases: AbstractGrainCalibrator

A Laue calibrator “is-a” specific case for a grain calibrator.

Just like a grain calibrator, a Laue calibrator is calibrating grain parameters.

There are some unique properties for Laue, though, such as having a varying energy range rather than a constant energy value. Also, we do not utilize any omega periods.

autopick_points(raw_img_dict, tth_tol=5.0, eta_tol=5.0, npdiv=2, do_smoothing=True, smoothing_sigma=2, use_blob_detection=True, blob_threshold=0.25, fit_peaks=True, min_peak_int=1.0, fit_tth_tol=0.1)[source]

Parameters

raw_img_dictTYPE

DESCRIPTION.

tth_tolTYPE, optional

DESCRIPTION. The default is 5..

eta_tolTYPE, optional

DESCRIPTION. The default is 5..

npdivTYPE, optional

DESCRIPTION. The default is 2.

do_smoothingTYPE, optional

DESCRIPTION. The default is True.

smoothing_sigmaTYPE, optional

DESCRIPTION. The default is 2.

use_blob_detectionTYPE, optional

DESCRIPTION. The default is True.

blob_thresholdTYPE, optional

DESCRIPTION. The default is 0.25.

fit_peaksTYPE, optional

DESCRIPTION. The default is True.

Returns

None.

property energy_cutoffs
model()[source]
property name
residual()[source]

Compute a residual using the calibration data.

Calibration data may have already been stored as an attribute on the calibration class instead, in which case, calibration_data can be None.

property tth_distortion
type = 'laue'
class hexrd.fitting.calibration.PowderCalibrator(instr, material, img_dict, default_refinements=None, tth_tol=None, eta_tol=0.25, fwhm_estimate=None, min_pk_sep=0.001, min_ampl=0.0, pktype='pvoigt', bgtype='linear', tth_distortion=None, calibration_picks=None, xray_source: str | None = None)[source]

Bases: Calibrator

autopick_points(fit_tth_tol=5.0, int_cutoff=0.0001)[source]

return the RHS for the instrument DOF and image dict

The format is a dict over detectors, each containing

[index over ring sets]
[index over azimuthal patch]

[xy_meas, tth_meas, hkl, dsp_ref, eta_ref]

FIXME: can not yet handle tth ranges with multiple peaks!

property calibration_picks

A way to retrieve picks in calibration format

Often, the calibrators store the picks in a different format internally. But the calibrators must have a way to set/get from the calibration_picks format. The calibration_picks format looks like this:

{
“det_key1”: {

“hkl1”: picks1, “hkl2”: picks2, …

}, “det_key2”: …

}

Where “det_key” is the detector key. “hkl” is a space-delimited string of the hkl. And “picks” are either a list of points (powder) or a single point (laue). The picks are in cartesian coordinates.

create_lmfit_params(current_params)[source]

Create lmfit parameters that this class will use and return them

current_params is passed only so that this class can ensure that it does not produce any name conflicts with existing parameters.

It is recommended to save the names of the parameters created, for example, self.param_names, to remember them when updating in the future.

For example, the powder calibrator creates lmfit parameters for the lattice parameters. The Laue calibrator creates lmfit parameters for crystal parameters.

model()[source]
property plane_data
residual()[source]

Compute a residual using the calibration data.

Calibration data may have already been stored as an attribute on the calibration class instead, in which case, calibration_data can be None.

property spectrum_kwargs
property tth_distortion
property tth_tol
type = 'powder'
update_from_lmfit_params(params_dict)[source]

Update any needed properties based on the params_dict

The entries in the params_dict should have the same names as those that were created via create_lmfit_params(). Update any local parameters based upon the new contents of the params_dict.

For example, the powder calibrator will update the lattice parameters on the material. The Laue calibrator will update crystal parameters.

hexrd.fitting.calibration.StructureLessCalibrator

alias of StructurelessCalibrator

class hexrd.fitting.calibration.StructurelessCalibrator(instr, data, tth_distortion=None, engineering_constraints=None, relative_constraints_type=RelativeConstraintsType.none, euler_convention=('zxz', False))[source]

Bases: object

this class implements the equivalent of the powder calibrator but without constraining the optimization to a structure. in this implementation, the location of the constant two theta line that a set of points lie on is also an optimization parameter.

unlike the previous implementations, this routine is based on the lmfit module to implement the more complicated constraints for the TARDIS box

if TARDIS_constraints are set to True, then the following additional linear constraint is added to the calibration

22.83 mm <= |IMAGE-PLATE-2 tvec[1]| + |IMAGE-PLATE-2 tvec[1]| <= 23.43 mm

calc_residual(params)[source]
property data
property engineering_constraints
property instr
make_lmfit_params()[source]
property meas_angles: dict

this property will return a dictionary of angles based on current instrument parameters.

property relative_constraints: RelativeConstraints
property relative_constraints_type
property residual
run_calibration(method='least_squares', odict=None)[source]

odict is the options dictionary

set_minimizer()[source]
property tth_correction: dict
property tth_distortion
property two_XRS
hexrd.fitting.calibration.fix_detector_y(instr: HEDMInstrument, params: Parameters, relative_constraints: RelativeConstraints | None = None)[source]

Fix the y translation for all detectors