sheap.Profiles.profiles_templates module
Template-Based Profiles
This module provides template-driven spectral components used in sheap:
- Fe II templates (UV, optical, combined) read from ASCII files and broadened
via FFT convolution.
Balmer high-order blends represented as fixed templates.
- Host galaxy templates based on E-MILES SSP cubes, sub-selected in metallicity,
age, and wavelength, and combined with free weights.
Functions
make_feii_template_function:Factory for Fe II template models by name. Supports optional wavelength cuts and returns a JAX-ready profile function plus template metadata.
make_host_function:Factory for host galaxy models from a precomputed SSP cube. Uses efficient memory mapping and a single FFT-based convolution of the weighted template sum.
Constants
TEMPLATES_PATH: Path to the bundled template data directory.FEII_TEMPLATES: Registry of available Fe II template definitions.
Notes
All returned models are decorated with
@with_param_namesand are JAX-compatible.- FFT-based Gaussian broadening quadratically subtracts the intrinsic template
resolution before applying user-defined FWHM.
- Host models build parameter names dynamically as
weight_Z{Z}_age{age} for each included SSP grid point.
- Host models build parameter names dynamically as
- make_host_function(filename=PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/sheap/checkouts/latest/sheap/SuportData/templates/miles_cube_log.npz'), z_include=[-0.7, 0.22], age_include=[0.1, 10.0], xmin=None, xmax=None, verbose=None, **kwargs)[source]
Factory for host-galaxy SSP models stored on a log-sampled wavelength grid.
The returned model builds a weighted sum of SSP templates, then applies a single FFT-based Gaussian broadening in velocity space (LOSVD-like), and finally interpolates to the user grid
x.- Parameters:
filename (str | Path) – Either
"miles","xsl", a path to a*_cube_log.npzfile, orNone(defaults to MILES).z_include (tuple[float, float] | list[float] | None) – Metallicity selection; either (min,max) or list/array.
age_include (tuple[float, float] | list[float] | None) – Age selection; either (min,max) or list/array.
xmin (float | None) – Optional wavelength window in Angstrom. A ±50 Å guard band is applied.
xmax (float | None) – Optional wavelength window in Angstrom. A ±50 Å guard band is applied.
verbose (bool | None) – Print selected grid size.
- Returns:
{"model": callable, "host_info": dict}- Return type:
dict
Notes
Important: The template wavelength axis in the NPZ file must be sampled approximately uniformly in \(\ln(\lambda)\) (i.e. log-spaced in wavelength). The convolution kernel is constructed in \(\ln(\lambda)\), so the model assumes a constant velocity step per pixel.
The input
xpassed tomodel(x, params)is in Angstrom, but should be sampled on a grid that is also approximately uniform in \(\ln(\lambda)\) if you want the broadening to behave exactly like a Gaussian LOSVD on your evaluation grid. (Interpolation to arbitraryxis allowed, but the kernel is defined on the template log-grid.)Velocity shift is applied as \(\lambda \rightarrow \lambda \exp(v/c)\).
The parameter order is:
[logamp, logFWHM, vshift_kms, weight_0, weight_1, ...].