Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
rhklss = np.rint(hklss)
ehklss = np.abs(hklss - rhklss)
return ehklss
ai, aj, ak = mat2euler(solution.rotation_matrix)
params = lmfit.Parameters()
params.add("center_x", value=solution.center_x, vary=vary_center)
params.add("center_y", value=solution.center_y, vary=vary_center)
params.add("ai", value=ai, vary=vary_angles)
params.add("aj", value=aj, vary=vary_angles)
params.add("ak", value=ak, vary=vary_angles)
params.add("scale", value=solution.scale, vary=vary_scale, min=0.8, max=1.2)
wavelength = get_electron_wavelength(accelarating_voltage)
camera_length = camera_length * 1e10
args = k_xy, lattice_recip, wavelength, camera_length
res = lmfit.minimize(objfunc, params, args=args, method=method)
if verbose: # pragma: no cover
lmfit.report_fit(res)
p = res.params
ai, aj, ak = p["ai"].value, p["aj"].value, p["ak"].value
scale = p["scale"].value
center_x = params["center_x"].value
center_y = params["center_y"].value
rotation_matrix = euler2mat(ai, aj, ak)
def calculate_cartesian_coordinates(self, accelerating_voltage, camera_length,
*args, **kwargs):
"""Get cartesian coordinates of the diffraction vectors.
Parameters
----------
accelerating_voltage : float
The acceleration voltage with which the data was acquired.
camera_length : float
The camera length in meters.
"""
# Imported here to avoid circular dependency
from diffsims.utils.sim_utils import get_electron_wavelength
wavelength = get_electron_wavelength(accelerating_voltage)
self.cartesian = self.map(detector_to_fourier,
wavelength=wavelength,
camera_length=camera_length * 1e10,
inplace=False,
parallel=False, # TODO: For testing
*args, **kwargs)
transfer_navigation_axes(self.cartesian, self)