Plotting#

Note

Now that we have computed spatial quantities, possibly for multiple redshifts, it is often useful to visualize them. Grids can easily be represented as 2D slices or projected along an axis.

It is however more involved to visualize statistical quantities and their evolution with redshift. The functions in this module help with that, providing easy ways to plot power spectra and signals as a function of redshift.

These functions can be used in scripts or in Jupyter notebooks and aim to provide an easy way to compare results from different simulation runs.

Plotting module for Beorn. Provides functions to visualize various derived quantities.

beorn.plotting.draw_Temp_signal(ax: matplotlib.pyplot.Axes, grid: TemporalCube, label=None, color=None, **kwargs)[source]#

Plot the mean kinetic temperature history T_k(z).

Parameters:
  • ax (matplotlib.axes.Axes) – Axis to draw on.

  • grid (TemporalCube) – Temporal cube providing Grid_Temp and z arrays.

  • label (str, optional) – Legend label.

  • color (str|tuple, optional) – Line color.

  • **kwargs – Additional keyword arguments forwarded to ax.semilogy.

beorn.plotting.draw_dTb_power_spectrum_of_k(ax: matplotlib.pyplot.Axes, grid: TemporalCube, parameters: Parameters, z_index=1, z_value=None, label=None, color=None)[source]#

Plot the dTb power spectrum as a function of k at a given z.

Parameters:
  • ax (matplotlib.axes.Axes) – Axis to draw on.

  • grid (TemporalCube) – Temporal cube providing Grid_dTb and z.

  • parameters (Parameters) – Simulation parameters containing kbins and box size.

  • z_index (int) – Index of the redshift slice to analyse.

  • label (str, optional) – Legend label.

  • color (str|tuple, optional) – Line color.

beorn.plotting.draw_dTb_power_spectrum_of_z(ax: matplotlib.pyplot.Axes, grid: TemporalCube, parameters: Parameters, label=None, color=None, k_index=1, k_value=None, **kwargs)[source]#

Plot the evolution of the dTb power spectrum at a fixed k.

Computes the power spectrum for each snapshot and plots the dimensionless power at the requested wavenumber index as a function of redshift.

Parameters:
  • ax (matplotlib.axes.Axes) – Axis to draw on.

  • grid (TemporalCube) – Temporal cube providing Grid_dTb and z.

  • parameters (Parameters) – Simulation parameters passed to the cube’s power spectrum routine.

  • label (str, optional) – Legend label.

  • color (str|tuple, optional) – Line color.

  • k_index (int, optional) – Index of the k-bin to plot.

  • **kwargs – Additional keyword arguments forwarded to ax.semilogy.

beorn.plotting.draw_dTb_signal(ax: matplotlib.pyplot.Axes, grid: TemporalCube, label=None, color=None, **kwargs)[source]#

Plot the global mean differential brightness temperature dTb(z).

Parameters:
  • ax (matplotlib.axes.Axes) – Axis to draw on.

  • grid (TemporalCube) – Temporal cube providing Grid_dTb and z arrays.

  • label (str, optional) – Legend label.

  • color (str|tuple, optional) – Line color.

  • **kwargs – Additional keyword arguments forwarded to ax.plot.

beorn.plotting.draw_f_esc(ax: matplotlib.pyplot.Axes, parameters: Parameters, label=None, color=None)[source]#

Draw the escape fraction as a function of halo mass.

The escape fraction f_esc is computed by beorn.astro.f_esc() on the simulation halo-mass grid and the result is plotted over the configured source mass range.

Parameters:
  • ax (matplotlib.axes.Axes) – Axis to draw the curve onto.

  • parameters (Parameters) – Simulation parameters used to obtain the halo mass grid and source mass limits.

  • label (str, optional) – Optional legend label.

  • color (str|tuple, optional) – Color for the plotted line.

beorn.plotting.draw_star_formation_rate(ax: matplotlib.pyplot.Axes, parameters: Parameters, label=None, color=None)[source]#

Draw the star-formation efficiency as a function of halo mass.

The function queries the halo-mass grid from parameters and computes the star-formation fraction f_* using beorn.astro.f_star_Halo(), restricting the plotted range to the configured source mass limits.

Parameters:
  • ax (matplotlib.axes.Axes) – Axis to draw the curve onto.

  • parameters (Parameters) – Simulation parameters used to obtain the halo mass grid and source mass limits.

  • label (str, optional) – Optional legend label.

  • color (str|tuple, optional) – Color for the plotted line.

beorn.plotting.draw_xHII_signal(ax: matplotlib.pyplot.Axes, grid: TemporalCube, label=None, color=None, **kwargs)[source]#

Plot the mean ionized fraction x_HII(z).

Parameters:
  • ax (matplotlib.axes.Axes) – Axis to draw on.

  • grid (TemporalCube) – Temporal cube providing Grid_xHII and z arrays.

  • label (str, optional) – Legend label.

  • color (str|tuple, optional) – Line color.

  • **kwargs – Additional keyword arguments forwarded to ax.plot.

beorn.plotting.draw_x_alpha_signal(ax: matplotlib.pyplot.Axes, grid: TemporalCube, label=None, color=None, **kwargs)[source]#

Plot the mean Lyman-alpha coupling history x_alpha(z).

Parameters:
  • ax (matplotlib.axes.Axes) – Axis to draw on.

  • grid (TemporalCube) – Temporal cube providing Grid_xal and z arrays.

  • label (str, optional) – Legend label.

  • color (str|tuple, optional) – Line color.

  • **kwargs – Additional keyword arguments forwarded to ax.semilogy.

beorn.plotting.full_diff_plot(fig: matplotlib.pyplot.Figure, grid: TemporalCube, baseline_grid: TemporalCube = None, label: str = None, color: str = None)[source]#

Create a multi-panel comparison plot of global quantities.

If baseline_grid is provided the routine also plots fractional deviations between grid and baseline_grid for the set of global quantities.

Parameters:
  • fig (matplotlib.figure.Figure) – Figure to draw on; axes will be created if the figure is empty.

  • grid (TemporalCube) – Primary temporal cube to visualise.

  • baseline_grid (TemporalCube, optional) – Reference temporal cube for fractional deviation plots.

  • label (str, optional) – Label applied to plotted lines.

  • color (str, optional) – Color used for plotted lines.

beorn.plotting.plot_1D_profiles(parameters: Parameters, profiles: RadiationProfiles, mass_index: int, redshifts: list, alphas: list, label: str = None, figsize: tuple = (14, 9), fontsize: int = None, labelsize: int = None, cmap: str = 'plasma', **gridspec_kw) None[source]#

Plot 1D radiation profiles for selected masses, redshifts and alphas.

The figure has two rows: - Top row: halo mass accretion history (left) and legend (right). - Bottom row: Lyman-alpha flux, kinetic temperature, and ionisation fraction profiles.

In the profile panels colour encodes redshift (blue → red, high z → low z) and linestyle encodes alpha (solid / dashed / dotted / dash-dot).

In the MAR panel the Behroozi+20 simulation tracks are solid black curves; the analytical exponential MAR model is shown as dashed curves, one per alpha value, using the same colour palette as the profile panels’ alpha linestyle legend (tab10).

Parameters:
  • parameters (Parameters) – Simulation parameters used for axis labels and lookups.

  • profiles (RadiationProfiles) – Radiation profiles to plot.

  • mass_index (int) – Index selecting the mass bin to visualize.

  • redshifts (list) – Sequence of redshifts to plot (closest match is used).

  • alphas (list) – Sequence of alpha values to plot (closest match is used).

  • label (str, optional) – Optional suptitle for the figure.

  • figsize (tuple, optional) – Figure size as (width, height) in inches. Default is (14, 9).

  • fontsize (int, optional) – Font size for axis labels and legends. When None (default) the current rcParams values are used.

  • labelsize (int, optional) – Font size for tick labels. When None (default) the current rcParams values are used.

  • cmap (str, optional) – Colormap name used to colour redshift curves in the profile panels and scatter points in the MAR panel. Default is 'plasma'.

  • **gridspec_kw – Extra keyword arguments forwarded to matplotlib.gridspec.GridSpec (e.g. hspace=0.4, wspace=0.3). When hspace or wspace is supplied, constrained_layout is automatically disabled so the manual spacing takes effect.

beorn.plotting.plot_halo_mass_evolution(profiles: RadiationProfiles, mass_bin: int = None)[source]#

Plot halo mass evolution and its derivative for a mass bin.

Parameters:
  • profiles (RadiationProfiles) – RadiationProfiles which also contains halo mass evolution arrays and parameters.

  • mass_bin (int, optional) – Index of the mass bin to plot. If None, the central mass bin is used.

beorn.plotting.plot_halo_mass_function(ax: matplotlib.pyplot.Axes, halo_catalog: HaloCatalog, bin_count: int = None, label: str = None, color: str = None, analytical: bool = True, analytical_model: str = 'Tinker08') None[source]#

Plot the halo mass function from a HaloCatalog.

Optionally overlays an analytical reference curve computed with the hmf package (Tinker et al. 2008 by default).

Parameters:
  • ax (matplotlib.axes.Axes) – Axis to draw the HMF on.

  • halo_catalog (HaloCatalog) – Halo catalog providing halo_mass_function.

  • bin_count (int, optional) – Number of bins to use; if None the catalog default is used.

  • label (str, optional) – Legend label for the simulation data points.

  • color (str, optional) – Line/marker color for the simulation data points.

  • analytical (bool) – If True (default), overlay an analytical HMF curve. Requires the hmf package (pip install hmf).

  • analytical_model (str) – hmf model name passed to hmf.MassFunction. Default is 'Tinker08'.