hexrd.fitting.calibration package

Submodules

Module contents

class hexrd.fitting.calibration.InstrumentCalibrator(*args, engineering_constraints=None, set_refinements_from_instrument_flags=True, euler_convention=('zxz', False))[source]

Bases: object

property engineering_constraints
property instr
make_lmfit_params()[source]
minimize(method='least_squares', odict=None)[source]
minimizer_function(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))[source]

Bases: Calibrator

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 bmatx
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.

property energy_cutoffs
property grain_params_euler
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.

type = 'laue'
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.

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)[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_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, 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

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

property nrings

return dictionary over panels with number of DS rings on each panel

property residual
run_calibration(method='least_squares', odict=None)[source]

odict is the options dictionary

set_minimizer()[source]
property tth_correction
property tth_distortion
property two_XRS
hexrd.fitting.calibration.calibrate_instrument_from_sx(instr, grain_params, bmat, xyo_det, hkls_idx, param_flags=None, grain_flags=None, ome_period=None, xtol=1.4901161193847656e-08, ftol=1.4901161193847656e-08, factor=10.0, sim_only=False, use_robust_lsq=False)[source]

arguments xyo_det, hkls_idx are DICTs over panels

hexrd.fitting.calibration.generate_parameter_names(instr, grain_params)[source]