pyextal.jaxGeo.figures

Figures and tables of a refinement run, read back from the HDF5 file.

  • save_comparison_png – experiment, simulation, residuals and a line profile per reflection.

  • plot_history – loss, thickness and per-reflection trajectories of a run; also a command line (jaxgeo-history), since everything it draws is stored.

  • print_phase_table – amplitude and phase of each refined U_g (complex runs).

  • layer_report – per-layer thickness and structure factors (layered runs).

optimized_sf and history/structure_factor hold the layers one after another, each in the order of gvectors.

Attributes

Functions

_agg()

_run_key(f, run)

_draw_probe(axes, fig, probe)

Draws the refined probe kernel into the figure's top row.

save_comparison_png(sim, experimental, g_include, path)

Writes a per-reflection comparison of simulation, experiment and residual.

read_history(h5path[, run])

One run's minimisation history, out of the HDF5 file.

_thickness_A(t_norm, bounds, attrs)

Physical thickness in Angstrom (sum over layers) from the stored parameter.

_refined_components(hist)

Which of the four structure-factor components this run moved.

_free_corner(curves[, frac])

The axes corner the plotted curves stay out of, for a value box.

plot_history(h5path[, run, out, logy, show])

Draws loss, thickness and per-reflection structure-factor trajectories.

_read_layers(h5, run, nlayers)

(key, gvectors, sf (L, n, 4), start sf (L, n, 4) or None, steps, thickness (snap, L), sf history).

print_phase_table(h5[, run, nlayers])

Prints amplitude and phase of each refined U_g, per layer.

layer_report(h5, nlayers[, run])

Prints per-layer thickness and structure factors of a run, and draws them.

history_main([argv, h5])

Command line for plot_history (jaxgeo-history).

Module Contents

pyextal.jaxGeo.figures.SF_COMPONENTS = ('xfre', 'xfim', 'afre', 'afim')
pyextal.jaxGeo.figures.SF_LABELS
pyextal.jaxGeo.figures._agg()
pyextal.jaxGeo.figures._run_key(f, run)
pyextal.jaxGeo.figures._draw_probe(axes, fig, probe)

Draws the refined probe kernel into the figure’s top row.

Parameters:
  • axes (list) – The four axes of the row.

  • fig (Figure) – The figure, for the colourbar.

  • probe (dict) – sigma, gamma and radius as simulate uses them, and optionally pixel – a label for the pixel unit.

pyextal.jaxGeo.figures.save_comparison_png(sim, experimental, g_include, path, probe=None, profile_row=None)

Writes a per-reflection comparison of simulation, experiment and residual.

Five columns per reflection: the experiment, the simulation, the residual twice – once in intensity and once as a percentage of the experiment’s peak – and a horizontal line profile of experiment and simulation. The intensity difference is dominated by the strong reflections and tells you whether the fit is good where the counts are; the percentage weights every reflection equally, so it exposes a weak reflection fitted badly in relative terms. The profile row is marked with a dashed line on both images.

Parameters:
  • sim (np.ndarray) – (rows, cols, n) simulated intensities, scale and background applied.

  • experimental (np.ndarray) – (rows, cols, n) measured rocking curves.

  • g_include (array-like) – (n, 3) reflection labels, matching the last axis.

  • path (Path) – Where to write the PNG.

  • probe (dict, optional) – sigma, gamma, radius (and optionally pixel) of the refined Voigt probe; adds a top row showing it.

  • profile_row (int, optional) – Image row the line profile runs along, in the compared (possibly cropped) frame. Defaults to the centre row.

Returns:

path.

Return type:

Path

pyextal.jaxGeo.figures.read_history(h5path, run=None)

One run’s minimisation history, out of the HDF5 file.

Parameters:
  • h5path (Path) – The dataset file the refinement appended to.

  • run (str, optional) – Run key, e.g. ‘run_003’. The newest run when None.

Returns:

With keys run, notes, timestamp, attrs, loss, gvectors (n_refl, 3), final_sf (n_layers * n_refl, 4), final_thickness (Angstrom, all layers), and – only when the run carries a trajectory – steps, sf (n_snap, n_layers * n_refl, 4), thickness (n_snap,, total) plus whichever of intensity_scale, background, probe_sigma, probe_gamma and the over-subtraction arrays were stored.

Return type:

dict

pyextal.jaxGeo.figures._thickness_A(t_norm, bounds, attrs)

Physical thickness in Angstrom (sum over layers) from the stored parameter.

pyextal.jaxGeo.figures._refined_components(hist)

Which of the four structure-factor components this run moved.

pyextal.jaxGeo.figures._free_corner(curves, frac=(0.45, 0.34))

The axes corner the plotted curves stay out of, for a value box.

Parameters:
  • curves (list) – (axis, x, y) per plotted line.

  • frac (tuple) – Width and height of a corner region, as axes fractions.

Returns:

(x, y, ha, va) for Axes.text in axes coordinates.

Return type:

tuple

pyextal.jaxGeo.figures.plot_history(h5path, run=None, out=None, logy=False, show=False)

Draws loss, thickness and per-reflection structure-factor trajectories.

The structure-factor panels carry the elastic U_g on the left axis and, when it was refined too, the absorptive U’_g on the right one – they differ by two orders of magnitude. For a layered run the panels show layer 1 and the thickness is the total; layer_report draws every layer. A run with the over-subtraction model adds one panel per over-subtracted reflection.

Parameters:
  • h5path (Path) – The dataset file.

  • run (str, optional) – Run key; newest when None.

  • out (Path, optional) – Where to write the PNG; derived when None.

  • logy (bool) – Log scale on the loss axis.

  • show (bool) – Open a window as well as writing the file.

Returns:

The PNG written.

Return type:

Path

pyextal.jaxGeo.figures._read_layers(h5, run, nlayers)

(key, gvectors, sf (L, n, 4), start sf (L, n, 4) or None, steps, thickness (snap, L), sf history).

pyextal.jaxGeo.figures.print_phase_table(h5, run=None, nlayers=1)

Prints amplitude and phase of each refined U_g, per layer.

Parameters:
  • h5 (Path) – The dataset file.

  • run (str, optional) – Run key; newest when None.

  • nlayers (int) – Layers the run was refined with.

pyextal.jaxGeo.figures.layer_report(h5, nlayers, run=None)

Prints per-layer thickness and structure factors of a run, and draws them.

Parameters:
  • h5 (Path) – The dataset file.

  • nlayers (int) – Layers the run was refined with.

  • run (str, optional) – Run key; newest when None.

Returns:

<h5>_<run>_layers.png, written when the run has a trajectory.

Return type:

Path

pyextal.jaxGeo.figures.history_main(argv=None, h5=None)

Command line for plot_history (jaxgeo-history).

Parameters:
  • argv (list, optional) – Arguments; sys.argv[1:] when None.

  • h5 (Path, optional) – Default dataset file.