scippneutron.conversion.beamline.beam_aligned_unit_vectors#

scippneutron.conversion.beamline.beam_aligned_unit_vectors(incident_beam, gravity)[source]#

Return unit vectors for a coordinate system aligned with the incident beam.

The unit vectors are

\[\begin{split}\hat{e}_y &= -g / |g| \\ z_{\text{proj}} &= b_1 - (b_1 \cdot \hat{e}_y) \hat{e}_y \\ \hat{e}_z &= z_{\text{proj}} / |z_{\text{proj}}| \\ \hat{e}_x &= \hat{e}_y \times \hat{e}_z\end{split}\]

where \(b_1\) is the incident_beam and \(g\) is the gravity vector. See the module-level docs of scippneutron.conversion.beamline for details.

Parameters:
  • incident_beam (Variable) – Beam from source to sample. Expects dtype=vector3.

  • gravity (Variable) – Gravity vector. Expects dtype=vector3.

Returns:

BeamAlignedUnitVectors – A dict containing the unit vectors with keys 'ex', 'ey', and 'ez'

Raises:

ValueError – If the incident beam is parallel to gravity. The rotation of the x-z plane is ill-define din this case.

See also

straight_incident_beam

Compute the incident beam for a straight beamline.