pyextal.jaxGeo.figures ====================== .. py:module:: pyextal.jaxGeo.figures .. autoapi-nested-parse:: 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 ---------- .. autoapisummary:: pyextal.jaxGeo.figures.SF_COMPONENTS pyextal.jaxGeo.figures.SF_LABELS Functions --------- .. autoapisummary:: pyextal.jaxGeo.figures._agg pyextal.jaxGeo.figures._run_key pyextal.jaxGeo.figures._draw_probe pyextal.jaxGeo.figures.save_comparison_png pyextal.jaxGeo.figures.read_history pyextal.jaxGeo.figures._thickness_A pyextal.jaxGeo.figures._refined_components pyextal.jaxGeo.figures._free_corner pyextal.jaxGeo.figures.plot_history pyextal.jaxGeo.figures._read_layers pyextal.jaxGeo.figures.print_phase_table pyextal.jaxGeo.figures.layer_report pyextal.jaxGeo.figures.history_main Module Contents --------------- .. py:data:: SF_COMPONENTS :value: ('xfre', 'xfim', 'afre', 'afim') .. py:data:: SF_LABELS .. py:function:: _agg() .. py:function:: _run_key(f, run) .. py:function:: _draw_probe(axes, fig, probe) Draws the refined probe kernel into the figure's top row. :param axes: The four axes of the row. :type axes: list :param fig: The figure, for the colourbar. :type fig: Figure :param probe: ``sigma``, ``gamma`` and ``radius`` as `simulate` uses them, and optionally ``pixel`` -- a label for the pixel unit. :type probe: dict .. py:function:: 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. :param sim: (rows, cols, n) simulated intensities, scale and background applied. :type sim: np.ndarray :param experimental: (rows, cols, n) measured rocking curves. :type experimental: np.ndarray :param g_include: (n, 3) reflection labels, matching the last axis. :type g_include: array-like :param path: Where to write the PNG. :type path: Path :param probe: ``sigma``, ``gamma``, ``radius`` (and optionally ``pixel``) of the refined Voigt probe; adds a top row showing it. :type probe: dict, optional :param profile_row: Image row the line profile runs along, in the compared (possibly cropped) frame. Defaults to the centre row. :type profile_row: int, optional :returns: ``path``. :rtype: Path .. py:function:: read_history(h5path, run=None) One run's minimisation history, out of the HDF5 file. :param h5path: The dataset file the refinement appended to. :type h5path: Path :param run: Run key, e.g. 'run_003'. The newest run when None. :type run: str, optional :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. :rtype: dict .. py:function:: _thickness_A(t_norm, bounds, attrs) Physical thickness in Angstrom (sum over layers) from the stored parameter. .. py:function:: _refined_components(hist) Which of the four structure-factor components this run moved. .. py:function:: _free_corner(curves, frac=(0.45, 0.34)) The axes corner the plotted curves stay out of, for a value box. :param curves: ``(axis, x, y)`` per plotted line. :type curves: list :param frac: Width and height of a corner region, as axes fractions. :type frac: tuple :returns: ``(x, y, ha, va)`` for ``Axes.text`` in axes coordinates. :rtype: tuple .. py:function:: 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. :param h5path: The dataset file. :type h5path: Path :param run: Run key; newest when None. :type run: str, optional :param out: Where to write the PNG; derived when None. :type out: Path, optional :param logy: Log scale on the loss axis. :type logy: bool :param show: Open a window as well as writing the file. :type show: bool :returns: The PNG written. :rtype: Path .. py:function:: _read_layers(h5, run, nlayers) ``(key, gvectors, sf (L, n, 4), start sf (L, n, 4) or None, steps, thickness (snap, L), sf history)``. .. py:function:: print_phase_table(h5, run=None, nlayers=1) Prints amplitude and phase of each refined U_g, per layer. :param h5: The dataset file. :type h5: Path :param run: Run key; newest when None. :type run: str, optional :param nlayers: Layers the run was refined with. :type nlayers: int .. py:function:: layer_report(h5, nlayers, run=None) Prints per-layer thickness and structure factors of a run, and draws them. :param h5: The dataset file. :type h5: Path :param nlayers: Layers the run was refined with. :type nlayers: int :param run: Run key; newest when None. :type run: str, optional :returns: ``
__layers.png``, written when the run has a trajectory. :rtype: Path .. py:function:: history_main(argv=None, h5=None) Command line for `plot_history` (``jaxgeo-history``). :param argv: Arguments; ``sys.argv[1:]`` when None. :type argv: list, optional :param h5: Default dataset file. :type h5: Path, optional