pylbo.ivp_solution

Classes

IVPSolution

Container for IVP snapshot data returned by Legolas.

Functions

_fmt(x, pos)

Module Contents

pylbo.ivp_solution._fmt(x, pos)
class pylbo.ivp_solution.IVPSolution(times, data, component_names=None, x_domain=None, units=None)

Container for IVP snapshot data returned by Legolas.

Parameters:
  • times (np.ndarray) – Physical times at each snapshot, shape (n_snap,).

  • data (np.ndarray) – Snapshot data, shape (n_snap, n_comp, n_points).

  • component_names (dict, optional) – Map from integer index to component name, e.g. {0: "rho", 1: "v1"}.

  • x_domain (np.ndarray, optional) – Spatial coordinates, shape (n_points,).

  • units (dict, optional) – Unit normalisations from the Legolas datfile header.

times
data
component_names
x_domain = None
units = None
_scale_component_array(component, comp_array)

Returns comp_array scaled to physical (cgs) units.

_scale_time_array(times)
_scale_x_domain(x_vals)
_get_component_index(component)
get_component(component)

Returns the (n_snap, n_points) array for the requested component.

Parameters:

component (int or str) – Component index or name (e.g. "rho").

plot_space_time_heatmap(component, ax=None, cmap='plasma', time_range=None, **imshow_kwargs)

Plot a space-time heatmap for the given component.

Parameters:
  • component (int or str) – Which component to plot.

  • ax (Axes, optional) – Axes to plot on; created if not provided.

  • cmap (str) – Colormap passed to imshow.

  • time_range (tuple, optional) – (t_min, t_max) to restrict the plotted time window.

plot_spatial_slices(component, snap_indices, ax=None, **plot_kwargs)

Plot the spatial profile of a component at selected snapshot indices.

Parameters:
  • component (int or str) – Which component to plot.

  • snap_indices (list of int) – Snapshot indices to plot, in [0, n_snap-1].

  • ax (Axes, optional) – Axes to plot on; created if not provided.

plot_growth_vs_time(component, mode='centre', centre_idx=None, region=None, logy=True, tau=None, ax=None, data_kw=None, fit_kw=None)

Plot perturbation amplitude vs. time, with an optional analytic exp(t/tau) overlay for comparison against eigenvalue growth rates.

Parameters:
  • component (str or int) – Which component to track.

  • mode ({"centre", "max", "integral"}) – How to reduce the spatial data to a scalar amplitude.

  • centre_idx (int, optional) – Spatial index for mode="centre"; defaults to the midpoint.

  • region (tuple (i_min, i_max), optional) – Spatial slice for mode="max" or "integral".

  • logy (bool) – Use a semilog-y axis.

  • tau (float, optional) – Analytic e-folding time [s]. Positive => growth, negative => decay.

  • ax (Axes, optional) – Axes to plot on; created if not provided.

  • data_kw (dict, optional) – Extra kwargs forwarded to the data and fit plot calls.

  • fit_kw (dict, optional) – Extra kwargs forwarded to the data and fit plot calls.