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}_z &= b_1 / |b_1| \\ x_\perp &= -g \times \hat{e}_z \\ \hat{e}_x &= x_\perp / |x_\perp| \\ \hat{e}_y &= \hat{e}_z \times \hat{e}_x\end{split}\]

where \(b_1\) is the incident_beam and \(g\) is the gravity vector. The z-axis is along the incident beam and the x-axis is horizontal. The y-axis is antiparallel to gravity if and only if the incident beam is perpendicular to gravity. 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.