lfkit package#

Subpackages#

Module contents#

Top-level package for LFKit.

class lfkit.ConditionalLuminosityFunction[source]#

Bases: object

Factory namespace for conditional luminosity function models.

static double_schechter(*, phi_star, m_star, alpha, beta, m_transition, meta=None)[source]#

Create a conditional double-power-law Schechter luminosity function.

Parameters:
  • phi_star (float | Sequence[float] | ndarray[tuple[Any, ...], dtype[float64]] | Callable[[ndarray[tuple[Any, ...], dtype[float64]]], float | Sequence[float] | ndarray[tuple[Any, ...], dtype[float64]]])

  • m_star (float | Sequence[float] | ndarray[tuple[Any, ...], dtype[float64]] | Callable[[ndarray[tuple[Any, ...], dtype[float64]]], float | Sequence[float] | ndarray[tuple[Any, ...], dtype[float64]]])

  • alpha (float)

  • beta (float)

  • m_transition (float | Sequence[float] | ndarray[tuple[Any, ...], dtype[float64]] | Callable[[ndarray[tuple[Any, ...], dtype[float64]]], float | Sequence[float] | ndarray[tuple[Any, ...], dtype[float64]]])

  • meta (Mapping[str, object] | None)

Return type:

LuminosityFunction

static evolving_schechter(*, phi_model='linear_p', phi_kwargs=None, m_star_model='linear_q', m_star_kwargs=None, alpha_model='constant', alpha_kwargs=None, meta=None)[source]#

Create a conditional evolving Schechter luminosity function.

Parameters:
  • phi_model (str)

  • phi_kwargs (Mapping[str, float | Sequence[float] | ndarray[tuple[Any, ...], dtype[float64]]] | None)

  • m_star_model (str)

  • m_star_kwargs (Mapping[str, float | Sequence[float] | ndarray[tuple[Any, ...], dtype[float64]]] | None)

  • alpha_model (str)

  • alpha_kwargs (Mapping[str, float | Sequence[float] | ndarray[tuple[Any, ...], dtype[float64]]] | None)

  • meta (Mapping[str, object] | None)

Return type:

LuminosityFunction

static lognormal(*, mean_absolute_mag, sigma_log_luminosity, amplitude=1.0, meta=None)[source]#

Create a lognormal conditional luminosity function.

Parameters:
  • mean_absolute_mag (float | Sequence[float] | ndarray[tuple[Any, ...], dtype[float64]] | Callable[[ndarray[tuple[Any, ...], dtype[float64]]], float | Sequence[float] | ndarray[tuple[Any, ...], dtype[float64]]])

  • sigma_log_luminosity (float | Sequence[float] | ndarray[tuple[Any, ...], dtype[float64]] | Callable[[ndarray[tuple[Any, ...], dtype[float64]]], float | Sequence[float] | ndarray[tuple[Any, ...], dtype[float64]]])

  • amplitude (float | Sequence[float] | ndarray[tuple[Any, ...], dtype[float64]] | Callable[[ndarray[tuple[Any, ...], dtype[float64]]], float | Sequence[float] | ndarray[tuple[Any, ...], dtype[float64]]])

  • meta (Mapping[str, object] | None)

Return type:

LuminosityFunction

static modified_schechter(*, phi_star, m_star, alpha, meta=None)[source]#

Create a modified Schechter conditional luminosity function.

Parameters:
  • phi_star (float | Sequence[float] | ndarray[tuple[Any, ...], dtype[float64]] | Callable[[ndarray[tuple[Any, ...], dtype[float64]]], float | Sequence[float] | ndarray[tuple[Any, ...], dtype[float64]]])

  • m_star (float | Sequence[float] | ndarray[tuple[Any, ...], dtype[float64]] | Callable[[ndarray[tuple[Any, ...], dtype[float64]]], float | Sequence[float] | ndarray[tuple[Any, ...], dtype[float64]]])

  • alpha (float | Sequence[float] | ndarray[tuple[Any, ...], dtype[float64]] | Callable[[ndarray[tuple[Any, ...], dtype[float64]]], float | Sequence[float] | ndarray[tuple[Any, ...], dtype[float64]]])

  • meta (Mapping[str, object] | None)

Return type:

LuminosityFunction

static schechter(*, phi_star, m_star, alpha, meta=None)[source]#

Create a conditional Schechter luminosity function.

Parameters:
  • phi_star (float | Sequence[float] | ndarray[tuple[Any, ...], dtype[float64]] | Callable[[ndarray[tuple[Any, ...], dtype[float64]]], float | Sequence[float] | ndarray[tuple[Any, ...], dtype[float64]]])

  • m_star (float | Sequence[float] | ndarray[tuple[Any, ...], dtype[float64]] | Callable[[ndarray[tuple[Any, ...], dtype[float64]]], float | Sequence[float] | ndarray[tuple[Any, ...], dtype[float64]]])

  • alpha (float | Sequence[float] | ndarray[tuple[Any, ...], dtype[float64]] | Callable[[ndarray[tuple[Any, ...], dtype[float64]]], float | Sequence[float] | ndarray[tuple[Any, ...], dtype[float64]]])

  • meta (Mapping[str, object] | None)

Return type:

LuminosityFunction

static two_component(*, lognormal_mean_absolute_mag, lognormal_sigma_log_luminosity, modified_phi_star, modified_alpha, lognormal_amplitude=1.0, modified_m_star=None, modified_luminosity_fraction=0.562, meta=None)[source]#

Create a two-component conditional luminosity function.

Parameters:
  • lognormal_mean_absolute_mag (float | Sequence[float] | ndarray[tuple[Any, ...], dtype[float64]] | Callable[[ndarray[tuple[Any, ...], dtype[float64]]], float | Sequence[float] | ndarray[tuple[Any, ...], dtype[float64]]])

  • lognormal_sigma_log_luminosity (float | Sequence[float] | ndarray[tuple[Any, ...], dtype[float64]] | Callable[[ndarray[tuple[Any, ...], dtype[float64]]], float | Sequence[float] | ndarray[tuple[Any, ...], dtype[float64]]])

  • modified_phi_star (float | Sequence[float] | ndarray[tuple[Any, ...], dtype[float64]] | Callable[[ndarray[tuple[Any, ...], dtype[float64]]], float | Sequence[float] | ndarray[tuple[Any, ...], dtype[float64]]])

  • modified_alpha (float | Sequence[float] | ndarray[tuple[Any, ...], dtype[float64]] | Callable[[ndarray[tuple[Any, ...], dtype[float64]]], float | Sequence[float] | ndarray[tuple[Any, ...], dtype[float64]]])

  • lognormal_amplitude (float | Sequence[float] | ndarray[tuple[Any, ...], dtype[float64]] | Callable[[ndarray[tuple[Any, ...], dtype[float64]]], float | Sequence[float] | ndarray[tuple[Any, ...], dtype[float64]]])

  • modified_m_star (float | Sequence[float] | ndarray[tuple[Any, ...], dtype[float64]] | Callable[[ndarray[tuple[Any, ...], dtype[float64]]], float | Sequence[float] | ndarray[tuple[Any, ...], dtype[float64]]] | None)

  • modified_luminosity_fraction (float | Sequence[float] | ndarray[tuple[Any, ...], dtype[float64]] | Callable[[ndarray[tuple[Any, ...], dtype[float64]]], float | Sequence[float] | ndarray[tuple[Any, ...], dtype[float64]]])

  • meta (Mapping[str, object] | None)

Return type:

LuminosityFunction

class lfkit.Corrections(k_func, e_func=None, *, meta=None)[source]#

Bases: object

Evaluator for k(z), e(z), and ke(z).

This object wraps callables representing the k-correction and the luminosity evolution correction and provides a consistent interface for evaluating:

k(z) e(z) ke(z) = k(z) + e(z)

Instances are typically created through the class constructors Corrections.poggianti or Corrections.kcorrect.

Parameters:
  • k_func (Callable[[ArrayLike], ArrayLike]) – Callable returning k(z).

  • e_func (Callable[[ArrayLike], ArrayLike] | None) – Optional callable returning e(z). If None, e(z)=0.

  • meta (dict[str, object] | None) – Optional metadata dictionary describing the backend configuration.

e(z)[source]#

Evaluate the luminosity evolution correction.

Parameters:

z (object) – Scalar or array-like redshift.

Returns:

NumPy array containing e(z). If no evolution model is attached, zeros are returned.

Return type:

ndarray

k(z)[source]#

Evaluate the k-correction.

Parameters:

z (object) – Scalar or array-like redshift.

Returns:

NumPy array containing k(z).

Return type:

ndarray

classmethod kcorrect(*, z_grid=None, response_out, color, color_value, z_phot=0.0, anchor_band=None, anchor_mag=22.0, band_shift=None, response_dir=None, redshift_range=(0.0, 2.0), nredshift=4000, ivar_level=10000000000.0, anchor_z0=True, method='pchip', extrapolate=True)[source]#

Construct k(z) using the kcorrect SED template model.

The spectral energy distribution (SED) is constrained by a two-band color. The color fixes a flux ratio between two bands, which determines a mixture of kcorrect templates consistent with that constraint. The resulting template mixture is then used to evaluate k(z) for the requested output response.

Parameters:
  • z_grid (object | None) – Redshift grid used to compute the k(z) curve. If None, a default grid spanning redshift_range is used.

  • response_out (str) – kcorrect response name for which k(z) is evaluated.

  • color (tuple[str, str]) – Two-band color constraint (band_a, band_b).

  • color_value (float) – Target color value in magnitudes.

  • z_phot (float) – Redshift at which the color constraint is applied.

  • anchor_band (str | None) – Band used to set the arbitrary flux normalization.

  • anchor_mag (float) – Magnitude used to set the arbitrary flux normalization.

  • band_shift (float | None) – Optional kcorrect band shift parameter.

  • response_dir (str | Path | None) – Directory containing custom response curves.

  • redshift_range (tuple[float, float]) – Internal redshift range used by kcorrect.

  • nredshift (int) – Internal redshift grid size used by kcorrect.

  • ivar_level (float) – Weight assigned to constrained photometric bands.

  • anchor_z0 (bool) – Whether to normalize so that k(z=0)=0.

  • method (str) – Interpolation method used to construct k(z).

  • extrapolate (bool) – Whether to allow extrapolation outside the computed redshift range.

Returns:

Corrections instance evaluating k(z). In this configuration e(z) = 0.

Return type:

Corrections

ke(z)[source]#

Evaluate the combined correction ke(z).

Parameters:

z (object) – Scalar or array-like redshift.

Returns:

NumPy array containing ke(z) = k(z) + e(z).

Return type:

ndarray

classmethod poggianti(*, band, gal_type, cosmo=None, original_z_for_e=True, method='pchip', extrapolate=True, e_model='poggianti')[source]#

Construct corrections from Poggianti (1997) tabulated models.

Parameters:
  • band (str) – Poggianti band identifier (e.g. “V”, “B”).

  • gal_type (str) – Galaxy spectral type in the Poggianti tables (e.g. “E”, “Sc”).

  • cosmo – Optional cosmology object used for lookback-time calculations in the evolution correction.

  • original_z_for_e (bool) – Whether the evolution correction is evaluated on the original Poggianti redshift grid.

  • method (str) – Interpolation method for the tabulated curves.

  • extrapolate (bool) – Whether to allow extrapolation outside the tabulated redshift range.

  • e_model (str) – Evolution backend (“poggianti” or “none”).

Returns:

Corrections instance capable of evaluating k(z), e(z), and ke(z).

Raises:

ValueError – If an unsupported evolution model is requested.

Return type:

Corrections

class lfkit.LuminosityFunction(*, model, parameters, meta=None)[source]#

Bases: object

User-facing wrapper for luminosity function evaluation.

Parameters:
  • model (str) – Name of the luminosity function model.

  • parameters (Mapping[str, object]) – Model parameters passed to the underlying LF function.

  • meta (Mapping[str, object] | None) – Optional metadata describing the LF source or calibration.

static available_from_m_models()[source]#

Return models that support apparent magnitude evaluation.

Return type:

list[str]

static available_models()[source]#

Return luminosity function model names available through the API.

Return type:

list[str]

static available_parameter_models()[source]#

Return available LF parameter evolution models.

Return type:

dict[str, list[str]]

classmethod double_schechter(*, phi_star, m_star, alpha, beta, m_transition, meta=None)[source]#

Create a double-power-law Schechter luminosity function.

Parameters:
  • phi_star (float | Sequence[float] | ndarray[tuple[Any, ...], dtype[float64]]) – Normalization of the luminosity function.

  • m_star (float | Sequence[float] | ndarray[tuple[Any, ...], dtype[float64]]) – Characteristic absolute magnitude.

  • alpha (float) – Bright-end or main Schechter slope.

  • beta (float) – Additional slope controlling the second power-law component.

  • m_transition (float | Sequence[float] | ndarray[tuple[Any, ...], dtype[float64]]) – Transition magnitude for the second component.

  • meta (Mapping[str, object] | None) – Optional metadata describing the LF source or calibration.

Returns:

Luminosity-function API object using the double Schechter model.

Return type:

LuminosityFunction

classmethod evolving_schechter(*, phi_model='linear_p', phi_kwargs=None, m_star_model='linear_q', m_star_kwargs=None, alpha_model='constant', alpha_kwargs=None, meta=None)[source]#

Create a redshift-evolving Schechter luminosity function.

Parameters:
  • phi_model (str) – Parameter model used for the normalization evolution.

  • phi_kwargs (Mapping[str, float | Sequence[float] | ndarray[tuple[Any, ...], dtype[float64]]] | None) – Keyword arguments for the normalization model.

  • m_star_model (str) – Parameter model used for characteristic-magnitude evolution.

  • m_star_kwargs (Mapping[str, float | Sequence[float] | ndarray[tuple[Any, ...], dtype[float64]]] | None) – Keyword arguments for the characteristic-magnitude model.

  • alpha_model (str) – Parameter model used for faint-end-slope evolution.

  • alpha_kwargs (Mapping[str, float | Sequence[float] | ndarray[tuple[Any, ...], dtype[float64]]] | None) – Keyword arguments for the faint-end-slope model.

  • meta (Mapping[str, object] | None) – Optional metadata describing the LF source or calibration.

Returns:

Luminosity-function API object using an evolving Schechter model.

Return type:

LuminosityFunction

parameters(z)[source]#

Evaluate evolving Schechter parameters at redshift.

Parameters:

z (float | Sequence[float] | ndarray[tuple[Any, ...], dtype[float64]]) – Redshift values where the evolving LF parameters are evaluated.

Returns:

Tuple containing phi_star(z), m_star(z), and alpha(z).

Return type:

tuple[ndarray[tuple[Any, …], dtype[float64]], ndarray[tuple[Any, …], dtype[float64]], ndarray[tuple[Any, …], dtype[float64]]]

phi(absolute_mag, z=None)[source]#

Evaluate the luminosity function in absolute magnitude space.

Parameters:
  • absolute_mag (float | Sequence[float] | ndarray[tuple[Any, ...], dtype[float64]]) – Absolute magnitude values where the LF is evaluated.

  • z (float | Sequence[float] | ndarray[tuple[Any, ...], dtype[float64]] | None) – Redshift or conditional-coordinate values. Required for evolving and conditional models.

Returns:

Luminosity-function values evaluated at the input magnitudes.

Return type:

ndarray[tuple[Any, …], dtype[float64]]

phi_from_m(cosmo_obj, z, apparent_mag, *, h=None, corrections=None)[source]#

Evaluate the luminosity function from apparent magnitudes.

Apparent magnitudes are converted to absolute magnitudes using the supplied cosmology, optional reduced Hubble parameter, and optional k- and e-correction model.

Parameters:
  • cosmo_obj (Any) – Cosmology object used for distance-modulus conversion.

  • z (float | Sequence[float] | ndarray[tuple[Any, ...], dtype[float64]]) – Redshift values.

  • apparent_mag (float | Sequence[float] | ndarray[tuple[Any, ...], dtype[float64]]) – Apparent magnitude values.

  • h (float | None) – Optional reduced Hubble parameter used in the magnitude conversion.

  • corrections (object | None) – Optional object providing k-correction and e-correction values.

Returns:

Luminosity-function values evaluated from apparent magnitudes.

Return type:

ndarray[tuple[Any, …], dtype[float64]]

static register_alpha_model(name, model, *, overwrite=False)[source]#

Register an alpha evolution model.

Parameters:
  • name (str) – Name used to identify the model.

  • model (Callable[[...], ndarray[tuple[Any, ...], dtype[float64]]]) – Callable evaluating alpha(z).

  • overwrite (bool) – If True, replace an existing model with the same name.

Return type:

None

static register_m_star_model(name, model, *, overwrite=False)[source]#

Register an M-star evolution model.

Parameters:
  • name (str) – Name used to identify the model.

  • model (Callable[[...], ndarray[tuple[Any, ...], dtype[float64]]]) – Callable evaluating M_star(z).

  • overwrite (bool) – If True, replace an existing model with the same name.

Return type:

None

static register_phi_star_model(name, model, *, overwrite=False)[source]#

Register a phi-star evolution model.

Parameters:
  • name (str) – Name used to identify the model.

  • model (Callable[[...], ndarray[tuple[Any, ...], dtype[float64]]]) – Callable evaluating phi_star(z).

  • overwrite (bool) – If True, replace an existing model with the same name.

Return type:

None

classmethod schechter(*, phi_star, m_star, alpha, meta=None)[source]#

Create a standard Schechter luminosity function.

Parameters:
  • phi_star (float | Sequence[float] | ndarray[tuple[Any, ...], dtype[float64]]) – Normalization of the luminosity function.

  • m_star (float | Sequence[float] | ndarray[tuple[Any, ...], dtype[float64]]) – Characteristic absolute magnitude.

  • alpha (float | Sequence[float] | ndarray[tuple[Any, ...], dtype[float64]]) – Faint-end slope.

  • meta (Mapping[str, object] | None) – Optional metadata describing the LF source or calibration.

Returns:

Luminosity-function API object using the standard Schechter model.

Return type:

LuminosityFunction