vibe-sketcherDocumentation

vibesketcher.render.diffraction

Publication figures of powder patterns: measured against calculated (#207).

The figure is drawn from the calculated result of vibesketcher.document.diffraction and, optionally, a measured pattern read by vibesketcher.document.measured_patterns: the measured curve, the calculated profile (or sticks when no profile was asked for), a row of reflection tick marks under the curves, and provenance lines naming both sources by their SHA-256 digests, the wavelengths and the instrument fields as given. The calculated curve is scaled to the measured maximum for display; the factor is printed and nothing is fitted.

The x axis is 2theta (degrees), d (angstrom) or Q = 2 pi / d (1/angstrom). A measured 2theta axis is compared in 2theta only at the calculated wavelength, and converted to d or Q only with its stated wavelength; other combinations are refused rather than shifted. Styling follows the periodic figures: white background, Arial/Helvetica, SVG with PDF/PNG through the publication extra.

Functions

overlay_figure(calculated[, measured, ...])

SVG, or PDF/PNG through the publication extra.

overlay_svg(calculated[, measured, options])

The overlay as standalone SVG (UTF-8).

Classes

OverlayOptions(*[, axis, x_range, ticks, ...])

What the overlay shows; every choice is stated.

Exceptions

OverlayRefused

The two patterns cannot be put on one axis faithfully.

class vibesketcher.render.diffraction.OverlayOptions(*, axis='two_theta_deg', x_range=None, ticks=True, label_reflections=0, width=640, height=400, title=None, provenance=True)[source]

Bases: BaseModel

What the overlay shows; every choice is stated.

Parameters:
model_config = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

axis: PlotAxis
x_range: tuple[float, float] | None
ticks: bool
label_reflections: int

Label the hkl of the n strongest reflections above their ticks.

width: float
height: float
title: str | None
provenance: bool
exception vibesketcher.render.diffraction.OverlayRefused[source]

Bases: ValueError

The two patterns cannot be put on one axis faithfully.

vibesketcher.render.diffraction.overlay_svg(calculated, measured=None, options=None)[source]

The overlay as standalone SVG (UTF-8).

Parameters:
Return type:

bytes

vibesketcher.render.diffraction.overlay_figure(calculated, measured=None, options=None, fmt='svg', *, dpi=300)[source]

SVG, or PDF/PNG through the publication extra.

Parameters:
Return type:

bytes