Plotting

Utilities for plotting setup and time-series post-processing used in analysis scripts, including figure sizing, tick formatting, and time-averaging helpers.

The API section below documents the functions exported in edlgt.tools.plotting.__all__.

Plotting and time-series post-processing helpers for analysis scripts.

This module combines small visualization utilities (figure sizing, tick formatters) with helpers for running time averages and windowed smoothing used in dynamics post-processing.

Only the functions listed in __all__ are considered the public API here.

edlgt.tools.plotting.get_tline(par)[source]

Build a uniform time grid from a parameter dictionary.

Parameters:

par (dict) – Dictionary containing at least "start", "stop", and "delta_n".

Returns:

Uniform time grid starting at par["start"] with step par["delta_n"] and stopping before par["stop"].

Return type:

numpy.ndarray

edlgt.tools.plotting.time_integral(time, observable_values)[source]

Compute a cumulative time average of an observable.

Parameters:
Returns:

Array where entry i is the time-averaged value accumulated up to time[i].

Return type:

numpy.ndarray

edlgt.tools.plotting.custom_average(arr, staggered=None, norm=None)[source]

Average rows of a 2D array with optional site selection or weighting.

Parameters:
  • arr (numpy.ndarray) – Two-dimensional array where each row is averaged over columns.

  • staggered ({"even", "odd"}, optional) – If provided, average only even or odd column indices.

  • norm (numpy.ndarray, optional) – Weight vector used for a dot-product average. If provided, this branch is used instead of the staggered selection.

Returns:

One-dimensional array containing one averaged value per row.

Return type:

numpy.ndarray

Raises:

ValueError – If norm is provided and its length does not match arr.shape[1].

edlgt.tools.plotting.moving_time_integral(time, observable_values, max_points=100)[source]

Compute a moving-window time average using trapezoidal integration.

Parameters:
  • time (numpy.ndarray) – One-dimensional time grid (can be non-uniform).

  • observable_values (numpy.ndarray) – Observable values sampled on time.

  • max_points (int, optional) – Maximum number of samples used in the averaging window.

Returns:

Running averaged observable with the same shape as observable_values.

Return type:

numpy.ndarray

Notes

At early times, when fewer than max_points samples are available, the window includes all samples from the start.

edlgt.tools.plotting.gaussian_time_integral(time, observable_values, sigma=None)[source]

Smooth a time series with a Gaussian-weighted local average.

Parameters:
  • time (numpy.ndarray) – One-dimensional time grid (can be non-uniform).

  • observable_values (numpy.ndarray) – Observable values sampled on time.

  • sigma (float, optional) – Width of the Gaussian window. If None, a default value equal to one-tenth of the total time range is used.

Returns:

Smoothed observable values with the same shape as observable_values.

Return type:

numpy.ndarray

edlgt.tools.plotting.set_size(width_pt, fraction=1, subplots=(1, 1), height_factor=1.0)[source]

Compute figure dimensions in inches from a document width.

Parameters:
  • width_pt (float) – Reference width in points.

  • fraction (float, optional) – Fraction of the width to occupy. Default is 1.

  • subplots (tuple, optional) – Number of subplot rows and columns. Default is (1, 1).

  • height_factor (float, optional) – Additional multiplier applied to the computed height.

Returns:

Figure dimensions (width_in, height_in) in inches.

Return type:

tuple

Notes

The height is based on a golden-ratio scaling, adjusted by the subplot layout and height_factor.