def detector2sample( sample_tilt: float, detector_tilt: float, convention: Optional[str] = None, ) -> Rotation: """Rotation U_S to align detector frame D with sample frame S. Parameters ---------- sample_tilt Sample tilt in degrees. detector_tilt Detector tilt in degrees. convention Which sample reference frame to use, either the one used by EDAX TSL (default), "tsl", or the one used by Bruker, "bruker". Returns ------- Rotation """ # Rotation about sample (microscope) X axis tilt = -np.deg2rad((sample_tilt - 90) - detector_tilt) ax_angle = neo_euler.AxAngle.from_axes_angles(Vector3d.xvector(), tilt) r = Rotation.from_neo_euler(ax_angle) if convention != "bruker": # Followed by a 90 degree rotation about the sample Z axis, # if the TSL sample reference frame is used ax_angle_bruker2tsl = neo_euler.AxAngle.from_axes_angles( Vector3d.zvector(), np.pi / 2) r = Rotation.from_neo_euler(ax_angle_bruker2tsl) * r return r.to_matrix()[0]
def detector2sample(sample_tilt: float, detector_tilt: float) -> Rotation: """Rotation U_S to align detector frame D with sample frame S. Parameters ---------- sample_tilt Sample tilt in degrees. detector_tilt Detector tilt in degrees. Returns ------- Rotation """ x_axis = Vector3d.xvector() tilt = -np.deg2rad((sample_tilt - 90) - detector_tilt) ax_angle = neo_euler.AxAngle.from_axes_angles(x_axis, tilt) return Rotation.from_neo_euler(ax_angle).to_matrix()[0]
def test_mean_xyz(): x = Vector3d.xvector() y = Vector3d.yvector() z = Vector3d.zvector() t = Vector3d([3 * x.data, 3 * y.data, 3 * z.data]) np.allclose(t.mean().data, 1)