lfkit.corrections.color_anchors module#
Color-anchor utilities for kcorrect.
- Core concept:
An “anchor” is defined by a single two-band color constraint:
color = (band_a - band_b) = color_value
where band_a and band_b are kcorrect response names (e.g. “sdss_g0”).
This module is intentionally agnostic: - no galaxy “types” - no “red/blue” naming - no survey assumptions beyond optional filter mapping wrappers
- What this module does:
The goal is simply to obtain a set of kcorrect template coefficients that reproduce a specified two-band color at a given redshift. Since a color only fixes a flux ratio, the overall normalization of the SED is arbitrary. To make the problem well defined we choose an arbitrary reference magnitude (“anchor”) and construct a minimal synthetic photometry vector consistent with the requested color. Those fluxes are then passed to kcorrect to solve for the template mixture.
- Important limitations:
The resulting coefficients are not a unique physical SED fit. A single color constraint leaves large degeneracies in template space. The anchor normalization is purely a gauge choice, and no attempt is made to infer galaxy type, stellar population parameters, dust, or luminosity evolution. The coefficients are therefore best interpreted as a convenient internal representation for evaluating K(z) curves consistent with the specified color constraint.
- lfkit.corrections.color_anchors.fit_coeffs_from_bandcolor(*, color, color_value, z_phot=0.0, anchor_band=None, anchor_mag=22.0, responses=None, ivar_level=10000000000.0, response_dir=None, redshift_range=(0.0, 2.0), nredshift=4000, rescale_maggies=True)[source]#
Fit kcorrect coefficients from a single two-band color constraint.
This routine constructs the minimal synthetic photometry required to reproduce a given color. Because a color only fixes a flux ratio, the overall normalization is arbitrary; we therefore choose an internal anchor magnitude to define a concrete flux scale. The resulting fluxes are passed to kcorrect to solve for a template mixture whose predicted photometry matches the requested color at the specified redshift.
- Parameters:
color (tuple[str, str]) – Tuple (band_a, band_b) meaning color = m_a - m_b. These must be kcorrect response names (file stems).
color_value (float) – Target color value in magnitudes.
z_phot (float) – Redshift at which to fit the coefficients.
anchor_band (str | None) – Band used to set the arbitrary flux normalization. If None, defaults to band_b.
anchor_mag (float) – Magnitude used to set the arbitrary flux normalization.
responses (list[str] | None) – Optional explicit list of responses to use in the fit. If None, uses the minimal set {band_a, band_b, anchor_band}.
ivar_level (float) – Inverse-variance weight for constrained bands.
response_dir (str | Path | None) – Optional directory containing custom response .dat files.
redshift_range (tuple[float, float]) – Internal kcorrect lookup redshift range.
nredshift (int) – Internal kcorrect lookup grid size.
rescale_maggies (bool) – If True, rescale synthetic maggies to O(1) to reduce numerical issues; adjusts ivar accordingly.
- Returns:
(coeffs, fit_responses) - coeffs: array (n_templates,) - fit_responses: list of responses actually used in the fit
- Return type:
tuple[ndarray, list[str]]