Plotting and Data Loaders

halocat.plotting provides lightweight helpers for loading reformatted DEGRACE-pilot summary products and plotting them with matplotlib.

Data containers

The module returns structured dataclasses rather than bare arrays:

  • PkMmData for pk_mm.dat
  • HMFData for hmf.hdf5

These objects retain both the measurement arrays and the identifying metadata such as gravity, redshift, imodel, and ibox.

Load reformatted products

Load one matter power spectrum:

from halocat import load_degrace_pk_mm

pk = load_degrace_pk_mm(
    gravity="fRn1",
    redshift=0.25,
    imodel=1,
    ibox=1,
)

The returned PkMmData includes:

  • k
  • pk
  • nmodes
  • bin_index
  • the first three header lines from the source file

Load one halo mass function:

from halocat import load_degrace_hmf

hmf = load_degrace_hmf(
    gravity="fRn1",
    redshift=0.25,
    imodel=1,
    ibox=1,
)

The returned HMFData includes:

  • log10mass_edges
  • log10mass_centres
  • mass_edges
  • mass_centres
  • counts
  • dndlog10m
  • cumulative_number_density
  • volume

Plot helpers

plot_degrace_pk_mm_models(...) overlays several pk_mm.dat products for one (gravity, redshift, ibox) combination:

from halocat import plot_degrace_pk_mm_models

fig, ax = plot_degrace_pk_mm_models(
    gravity="fRn1",
    redshift=0.25,
    imodels=[0, 1, 2],
    ibox=1,
)

plot_degrace_hmf_models(...) does the same for HMF products:

from halocat import plot_degrace_hmf_models

fig, ax = plot_degrace_hmf_models(
    gravity="fRn1",
    redshift=0.25,
    imodels=[0, 1, 2],
    ibox=1,
    statistic="differential",
)

For HMF plots, statistic must be one of:

  • "differential"
  • "cumulative"

Both plotting helpers:

  • create a new matplotlib figure when ax=None
  • return (fig, ax)
  • accept label_template for legend formatting
  • accept output_root= to override the default DEGRACE output directory

Dependencies

  • load_degrace_hmf(...) requires h5py
  • the plotting helpers require matplotlib