lfkit.corrections.kcorrect_grids module#
kcorrect k(z) grid generation and interpolation utilities.
This module builds tables of k(z) values for one or more anchors on a specified redshift grid and provides helpers to interpolate those tables.
An anchor is simply a label associated with a vector of kcorrect template coefficients. Each coefficient vector represents a particular template mixture and therefore defines a specific spectral energy distribution. Evaluating kcorrect with those coefficients produces the corresponding k(z) curve for a given set of filter responses.
The main purpose of this module is to turn a small set of anchors into reusable k(z) grids that can be cached and quickly interpolated during analysis. The resulting tables store k(z) as a function of redshift for each anchor and response band, allowing fast lookup without repeatedly calling the kcorrect solver.
Anchors intentionally carry no semantic meaning here. They are not interpreted as galaxy types or populations; they are simply convenient labels for different template mixtures used to generate k(z) curves.
- lfkit.corrections.kcorrect_grids.build_kcorr_grid_package(*, responses_in, responses_out, responses_map, coeffs_by_anchor, z_grid, band_shift=0.1, response_dir=None, redshift_range=(0.0, 3.5), nredshift=4000)[source]#
Build a packaged k(z) grid for a set of anchors.
This function generates a self-contained data package holding k(z) tables evaluated on a common redshift grid for multiple anchors. Each anchor corresponds to a template mixture that defines a specific spectral energy distribution and therefore a specific k(z) curve.
The resulting package contains the redshift grid, the computed k(z) tables, the filter responses used, and basic metadata describing the setup. It is intended to serve as a reusable object that can be saved, cached, or passed to interpolation routines without recomputing the k-corrections.
- Parameters:
responses_in (list[str])
responses_out (list[str] | None)
responses_map (list[str] | None)
coeffs_by_anchor (dict[str, ndarray])
z_grid (ndarray)
band_shift (float | None)
response_dir (str | None)
redshift_range (tuple[float, float])
nredshift (int)
- Return type:
dict[str, Any]
- lfkit.corrections.kcorrect_grids.compute_k_table(*, kc, z_grid, coeffs_by_anchor, band_shift=None, anchor_z0=True)[source]#
Compute k(z) values on a redshift grid for each anchor.
This function evaluates k-corrections on a fixed redshift grid using a set of precomputed template coefficient vectors (“anchors”). Each anchor represents a particular SED mixture and therefore defines a specific k(z) curve. The output is a table of k(z) values for every anchor across the provided grid, which can later be used for interpolation or lookup.
By default the table is normalized so that k(z=0)=0 for each band. This convention is commonly used when working with k-corrections because it removes arbitrary offsets and ensures that all curves are anchored to the same reference point.
- Parameters:
z_grid (ndarray)
coeffs_by_anchor (dict[str, ndarray])
band_shift (float | None)
anchor_z0 (bool)
- Return type:
dict[str, ndarray]
- lfkit.corrections.kcorrect_grids.kcorr_interpolators(pkg, *, method='pchip', extrapolate=True)[source]#
Create interpolation functions for k(z).
This function converts a precomputed k(z) grid package into a set of interpolators that return k(z) for any redshift within the grid range. An interpolator is produced for each combination of anchor and output response band.
The resulting structure allows k-corrections to be evaluated quickly without recomputing the underlying tables, making it convenient to integrate precomputed grids into analysis workflows that repeatedly query k(z) values.
- Parameters:
pkg (dict[str, Any])
method (str)
extrapolate (bool)
- Return type:
dict[str, dict[str, PchipInterpolator | Akima1DInterpolator | Callable[[ndarray], ndarray] | None]]