CosmoFit.define_model

CosmoFit.define_model(name, E, *, extra_params=None, label=None, w=None, dEdz=None, Omega_de=None, mu=None)[source]

Build a new Cosmology subclass from a plain E(z) function.

Parameters:
  • name (str) – Model name (model.MODEL_NAME and the generated class’s __name__).

  • E (callable(params: dict, z: ndarray) -> ndarray) – Dimensionless Hubble parameter. Required – this alone is enough to fit the model against every CosmoFit dataset and produce every plot except w_of_z() / deceleration().

  • extra_params (dict[str, dict], optional) – New parameters this model needs beyond the standard set (H0, Omega_m, Omega_k, w0, wa, rd, MB, Omega_b, A_s, alpha). Maps name -> spec dict with keys "default" (float, default 0.0), "bounds" ((lower, upper), needed only if the parameter will be fit rather than fixed, unless bounds are instead passed to Fitter(bounds=...)), and "label" (str, optional, LaTeX label for corner plots). Names must not collide with the standard set.

  • label (str, optional) – How the model’s name should appear in figure legends and titles (model.MODEL_LABEL), when name is really a set of symbols spelled out as an identifier – e.g. name="MyQuintessence", label=r"$\phi$CDM". Matplotlib renders the $...$ spans with mathtext. Defaults to name used verbatim, which is right for an acronym.

  • w (callable(params, z) -> ndarray, optional) – Dark-energy equation of state, for w_of_z(). Not required for fitting.

  • dEdz (callable(params, z) -> ndarray, optional) – Derivative of E(z), for deceleration() / background.q(). Defaults to a numerical (central finite-difference) approximation of E if omitted.

  • Omega_de (callable(params, z) -> ndarray, optional) – Dark-energy density parameter, for background.Omega_de().

  • mu (callable(params: dict, a: ndarray, k: float or None) -> ndarray, optional) – Effective-to-Newtonian gravitational coupling G_eff(a,k)/G_N, for growth-of-structure predictions (background.{growth_rate,sigma8,fsigma8}, the "fsigma8"/"s8" datasets) – see mu(). a is the scale factor (an ndarray, evaluated on a whole grid at once, same convention as E); k is a single wavenumber [h/Mpc] (or None, for a scale-independent mu that never reads it). Defaults to 1 everywhere (standard GR growth) if omitted – correct for any model that reparametrizes dark energy without touching gravity itself; only give this for a genuinely modified-gravity model, exactly as FQExponential/FRTLinear/ FRHuSawicki do internally.

Returns:

type – A new Cosmology subclass, usable directly as Fitter(model=..., ...).

Return type:

type