source — X-ray sources#

This module contains all the facilities for the description of simple X-ray sources, for both the morphological and spectral part. At the very basic level, a Source object is the datum of an energy spectrum and a beam description, and has the primary purpose of generating lists of X-ray basic properties (time, energy and position in the horizontal plane) than can be folded into an actual detector simulation.

spectrum = LineForest('Cu', 'K')
beam = GaussianBeam(sigma=0.1)
source = Source(spectrum, beam, rate=10.)
timestamp, energy, x, y = source.rvs()

Note

At this point a Source is a very simple object describing a parallel beam of photons traveling along the z axis, that is, orthogonally to the detector plane—the latter will be always assumed to lie in the x-y plane—with no concept, e.g., of beam divergence. This is an area where we might want to add functionalities in the future.

Morphology#

The morphological part of the source description is encapsulated in a series of subclasses of the (purely virtual) BeamBase class. More specifically:

Spectrum#

Likewise, the source spectrum is encapsulated in subclasses of the (virtual) SpectrumBase class and, particularly, LineForest.

Module documentation#

X-ray source description.

class hexsample.source.Line(energy: float = 6000.0)[source]#

Class describing a monochromatic emission line at a given energy.

Arguments#

energyfloat

The line energy in eV.

energy: float = 6000.0#
rvs(size: int = 1) ndarray[source]#

Overloaded method.

render(axes: Axes, **kwargs) None[source]#

Overloaded method.

_abc_impl = <_abc._abc_data object>#
class hexsample.source.LineForest(element: str | int = 'Cu', initial_level: str = 'K')[source]#

Class describing a set of X-ray emission lines for a given element and initial level or excitation energy.

The underlying implementation relies on the XrayDB package. See https://xraypy.github.io/XrayDB/python.html#x-ray-emission-lines for more information.

Arguments#

elementint or str

atomic number or atomic symbol for the given element (default: “Cu”).

initial_levelstr, optional

IUPAC symbol of the initial level (default: “K”). Note that the Python interface to XrayDB allows specifying either the initial level or the excitation energy (in eV), with the latter superseding the former, as it means “all initial levels with below this energy”. In this initial implementation we only support specifying the initial level, and support for excitation energy may be added in the future, if truly needed.

element: str | int = 'Cu'#
initial_level: str = 'K'#
rvs(size: int = 1) ndarray[source]#

Overloaded method.

render(axes: Axes, **kwargs) None[source]#

Overloaded method.

_abc_impl = <_abc._abc_data object>#
class hexsample.source.PointBeam(x0: float = 0.0, y0: float = 0.0)[source]#

Point-like X-ray beam.

Arguments#

x0float

The x-coordinate of the beam centroid in cm.

y0float

The y-coordinate of the beam centroid in cm.

rvs(size: int = 1) Tuple[ndarray, ndarray][source]#

Overloaded method.

_abc_impl = <_abc._abc_data object>#
class hexsample.source.DiskBeam(x0: float = 0.0, y0: float = 0.0, radius: float = 0.1)[source]#

Uniform disk X-ray beam.

Arguments#

x0float

The x-coordinate of the beam centroid in cm.

y0float

The y-coordinate of the beam centroid in cm.

radiusfloat

The disk radius in cm.

radius: float = 0.1#
rvs(size: int = 1) Tuple[ndarray, ndarray][source]#

Overloaded method.

_abc_impl = <_abc._abc_data object>#
class hexsample.source.GaussianBeam(x0: float = 0.0, y0: float = 0.0, sigma: float = 0.1)[source]#

Azimuthally-simmetric gaussian beam.

Arguments#

x0float

The x-coordinate of the beam centroid in cm.

y0float

The y-coordinate of the beam centroid in cm.

sigmafloat

The beam sigma in cm.

sigma: float = 0.1#
rvs(size: int = 1) Tuple[ndarray, ndarray][source]#

Overloaded method.

_abc_impl = <_abc._abc_data object>#
class hexsample.source.TriangularBeam(x0: float = 0.0, y0: float = 0.0, v1: Tuple[float, float] = (1.0, 0.0), v2: Tuple[float, float] = (0.0, 1.0))[source]#

Triangular uniform X-ray beam.

Arguments#

x0float

The x-coordinate of the first vertex of the triangle in cm.

y0float

The y-coordinate of the first vertex of the triangle in cm.

v1Tuple[float, float]

The (x, y) coordinates of the second vertex of the triangle in cm.

v2Tuple[float, float]

The (x, y) coordinates of the third vertex of the triangle in cm.

v1: Tuple[float, float] = (1.0, 0.0)#
v2: Tuple[float, float] = (0.0, 1.0)#
rvs(size: int = 1) Tuple[ndarray, ndarray][source]#

Overloaded method.

_abc_impl = <_abc._abc_data object>#
class hexsample.source.HexagonalBeam(x0: float = 0.0, y0: float = 0.0, v0: Tuple[float, float] = (1.0, 0.0), v1: Tuple[float, float] = (0.5, np.float64(0.8660254037844386)))[source]#

Hexagonal uniform X-ray beam.

Arguments#

x0float

The x-coordinate of the center of the hexagon in cm.

y0float

The y-coordinate of the center of the hexagon in cm.

v0Tuple[float, float]

The (x, y) coordinates of the first vertex of the hexagon in cm.

v1Tuple[float, float]

The (x, y) coordinates of the second vertex of the hexagon in cm.

v0: Tuple[float, float] = (1.0, 0.0)#
v1: Tuple[float, float] = (0.5, np.float64(0.8660254037844386))#
rvs(size: int = 1) Tuple[ndarray, ndarray][source]#

Overloaded method.

_abc_impl = <_abc._abc_data object>#
class hexsample.source.Source(spectrum: AbstractSpectrum = <factory>, beam: AbstractBeam = <factory>, rate: float = 100.0)[source]#

Class describing a fully-fledged X-ray source.

Arguments#

spectrumAbstractSpectrum

The source spectrum.

beamAbstractBeam

The source morphology.

ratefloat

The photon rate in Hz.

spectrum: AbstractSpectrum#
beam: AbstractBeam#
rate: float = 100.0#
classmethod from_filtered_kwargs(**kwargs) Source[source]#

Alternative constructor to create source objects from specifications.

Arguments#

kwargsdict

The keyword arguments containing the source specifications.

Returns#

Source

The source object.

rvs(size: int = 1) Tuple[ndarray, ndarray, ndarray, ndarray][source]#

Extract random X-ray initial properties.

Arguments#

sizeint

The number of X-rays to be generated.

Returns#

t, energy, x, y4-element tuple of np.ndarray of shape size

The X-ray properties.