SphericalDetector

For SAS and GISAS simulations, the two-dimensional area detector is modelled by the SphericalDetector class.

Geometry

A SphericalDetector is a flat 2D detector perpendicular to the x axis, defined in angular coordinates. All pixels have equal size.

In BornAgain, detector images are shown as seen from the back of the detector. In this way we ensure that the $\varphi$ or $q_y$ axis has the same orientation as the real-space $y$ axis.

Axes

The axes of a simulation result hold the angles of the pixel edges. With $D$ the distance from the sample to the detector plane:

  • The horizontal axis holds the azimuth $\varphi_\text{f}=\arctan(y/D)$ of each column edge. It is exact in every row.
  • The vertical axis holds the grazing angle $\alpha_\text{f}=\arctan(z/D)$ of each row edge at $\varphi_\text{f}=0$. It is exact in the column at zero azimuth, and on the horizon. At other azimuths, a row is seen under the smaller grazing angle given by $\tan\alpha_\text{f}=(z/D)\cos\varphi_\text{f}$.

Since all pixels have the same size on the plane, the angular bins are not equidistant: they get narrower towards large angles. Plots draw each pixel between its edge angles. The edges are available from the axes:

phi_edges = result.xAxis().binEdges()    # n_phi + 1 values in rad
alpha_edges = result.yAxis().binEdges()  # n_alpha + 1 values in rad

To attach these axes to measured pixel data, use detector.frame().

For the actual scattering computation, BornAgain uses the true direction and solid angle of each pixel.

Further distortions arise if the detector is not perpendicular to the x axis. This is not unlikely in GISAS where it makes sense to position the detector perpendicular to the reflected or transmitted beam. Corrections for these and other distortions will be implemented when requested by users.

Constructor

The constructor has the signature

detector = ba.SphericalDetector(n_phi, phi_min, phi_max, n_alpha, alpha_min, alpha_max)

The arguments phi_min, phi_max, alpha_min, alpha_max define the range of the detector in direction $\varphi_\text{f},\alpha_\text{f}$. The limits of $\alpha_\text{f}$ refer to $\varphi_\text{f}=0$.

The arguments n_phi, n_alpha are the number of bins per direction; their product is the number of pixels of the detector.

Masks

When fitting theoretical models to measured diffraction images, it can be helpful to mask part of the detector area. SphericalDetector.setMask(mask) accepts a Python boolean array with shape (n_alpha, n_phi), matching Datafield.intensities(). True marks an excluded pixel. In ScatteringSimulation, masked pixels are not computed and are stored as NaN in the result.

import numpy as np

mask = np.zeros((n_alpha, n_phi), dtype=bool)
mask[0, :] = True  # Exclude the row at the lowest grazing angle.
detector.setMask(mask)

Set the mask before constructing ScatteringSimulation, which stores its own detector copy. Editing the original detector afterwards does not change that simulation.

setMask replaces any existing mask. detector.clearMask() removes it. detector.hasMask() reports whether a mask has been assigned, even when all its entries are False.

Resolution

For modeling the detector resolution, see Detector resolution.

Examples

History

Until BornAgain 21, we had a RectangularDetector and a SphericalDetector. In BornAgain 22, they were merged into SphericalDetector class.

Up to BornAgain 25.0, the result axes were equidistant between the angular limits of the detector. On a wide detector, they showed features away from their exit angles. Since BornAgain 25.1, the axes hold the pixel edge angles.