Skip to content

Commit

Permalink
docs: add docstring (#567)
Browse files Browse the repository at this point in the history
* docs: add docstring

* Update src/scippneutron/absorption/base.py

Co-authored-by: Jan-Lukas Wynen <[email protected]>

* docs: fix

---------

Co-authored-by: Jan-Lukas Wynen <[email protected]>
  • Loading branch information
jokasimr and jl-wynen authored Dec 9, 2024
1 parent 95eb1b4 commit bba8a88
Showing 1 changed file with 42 additions and 2 deletions.
44 changes: 42 additions & 2 deletions src/scippneutron/absorption/base.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from functools import partial
from typing import Any
from typing import Any, Literal

import scipp as sc

Expand All @@ -13,8 +13,48 @@ def compute_transmission_map(
beam_direction: sc.Variable,
wavelength: sc.Variable,
detector_position: sc.Variable,
quadrature_kind: Any = 'medium',
quadrature_kind: Literal['cheap', 'medium', 'expensive'] | Any = 'medium',
) -> sc.DataArray:
"""
Computes transmission probability of single-scattered neutrons.
Computes the probability that a neutron is transmitted to
``detector_position`` given that it travelled in ``beam_direction`` and
scattered incoherently a single time when passing through the sample.
.. math::
C(\\mathbf{p}, \\lambda) = \\int_{Sample} \\exp{(-\\mu(\\lambda)
L(\\mathbf{p}, \\mathbf{x}))} \\ d\\mathbf{x}
where :math:`L` is the length of the path through the sample,
:math:`\\mu` is the material dependent attenuation factor,
and :math:`\\mathbf{p}` is the ``detector_position``.
Parameters
----------
sample_shape:
The size and shape of the sample.
sample_material:
The sample material, this parameter determines the
absorption and scattering coefficients.
beam_direction:
The direction of the incoming beam.
wavelength:
An array of wavelengths for which to evaluate the transmission fraction.
detector_position:
An array of vectors representing the scattering directions
where the transmission fraction is evaluated.
quadrature_kind:
What kind of quadrature to use.
A denser quadrature makes the result more accurate but takes longer to compute.
What options exists depend on the sample shape.
Returns
-------
:
the transmission fraction as a function of detector_position and wavelength
"""
points, weights = sample_shape.quadrature(quadrature_kind)
transmission = _integrate_transmission_fraction(
partial(
Expand Down

0 comments on commit bba8a88

Please sign in to comment.