Spectral Energy Distribution Interpolation Module
This module provides fast interpolation of pre-computed SED templates for
stellar populations, AGN, dust emission, and nebular emission. It uses JAX
for GPU-accelerated interpolation and automatic differentiation support.
The module loads various SED libraries at import time and provides functions
to interpolate these templates for arbitrary physical parameters.
Templates are stored as .npz files with regular grids for fast interpolation.
All interpolators use RegularGridInterpolator from JAX for differentiability.
Notes
All luminosity values are in units of 10^38 erg/s unless otherwise noted.
This module is automatically imported and initialized when galfits is loaded.
Generate Balmer continuum emission from AGN broad-line region.
Computes BLR Balmer continuum using pre-computed templates that include
high-order Balmer recombination edges (Balmer jump at 3646 Å plus
higher-order series). Applies velocity broadening and Doppler shift.
Parameters:
x (array_like) – Rest-frame wavelength grid in Angstroms.
logL3600 (float) – Log10 of continuum luminosity at 3600 Å in 10^38 erg/s/Å.
Used for normalization.
logM (float) – Log10 of black hole mass in solar masses [5, 10].
logMdot (float) – Log10 of accretion rate in Eddington units [-4, 2].
spin (float) – Black hole spin parameter [0, 0.99].
dcen (float) – Velocity offset in km/s (positive = redshift).
fwhm (float) – Full-width at half-maximum velocity width in km/s.
Returns:
Balmer continuum flux in 10^38 erg/s/Å.
Return type:
array_like
Notes
The Balmer continuum arises from recombination of hydrogen in the
dense, ionized gas of the AGN broad-line region. Key features:
Balmer jump at 3646 Å (flux discontinuity)
Series of higher-order Balmer edges converging to Balmer limit
Contributes blue “pseudo-continuum” in optical spectra
Depends on BLR density, temperature, covering factor
Templates are computed from photoionization models and depend on
black hole parameters through the ionizing continuum shape.
The function normalizes to luminosity at 3600 Å (common AGN
reference point below Balmer jump).
Generate optical/UV FeII emission template for AGN.
Constructs iron emission spectrum using empirical templates with
independent UV and optical normalization. Applies velocity broadening
and Doppler shift.
Parameters:
x (array_like) – Rest-frame wavelength grid in Angstroms.
dcen (float) – Velocity offset in km/s (positive = redshift).
fwhm (float) – Full-width at half-maximum velocity width in km/s.
Intrinsic template FWHM = 900 km/s is deconvolved.
Returns:
FeII emission flux (arbitrary normalization).
Return type:
array_like
Notes
FeII emission arises from collisionally excited iron in the AGN
broad-line region. It creates broad pseudo-continuum with thousands
of blended transitions, especially prominent at:
UV: 2200-3200 Å (FeII multiplet 191)
Optical: 4400-5500 Å (FeII multiplets around Hβ)
Templates are empirical from composite quasar spectra. The UV and
optical components scale independently, reflecting different excitation
conditions.
Convolution is performed in log-wavelength space for uniform velocity
resolution. The 900 km/s intrinsic width is quadratically subtracted
before applying user-specified FWHM.
Generic SED table model with multi-parameter interpolation.
Loads pre-computed SED grids from .npz files and provides fast
interpolation for arbitrary parameter values. Supports optional
normalization parameter for flexible scaling.
Parameters:
table_path (str) – Path to .npz file containing SED table.
Must contain ‘sed’ (log10 L_λ), ‘wave’, and parameter grids.
param_names (list of str) – Parameter names to interpolate (must match keys in .npz file).
If ‘logNorm’ is included, it will be used for normalization.
prefix (str) – Prefix to add to parameter names for external interface
(e.g., ‘AGN’ → ‘AGN_spin’, ‘AGN_logM’).
Interpolate SED at given parameters and wavelengths.
Parameters:
pardict (dict) – Dictionary mapping parameter names (with prefix) to values.
Must include all parameters in self.param_names.
If self.norm=True, must also include normalization parameter.
x (array_like) – Wavelength grid in Angstroms for interpolation.
Returns:
Interpolated SED normalized to L5100 = 1. Output in units of 10^38 erg/s/Å.
Given a wavelength grid, this function computes the selective attenuation
A(λ)/E(B-V)∗ using the formula from Calzetti at al. (2000) and Leitherer et al. (2002). The formula
is given for wavelengths between 91.2 nm and 2200 nm, but this function
makes the computation outside.
Parameters:
wavelength (array of floats) – Wavelength grid in angstrom but converted to nm in the function.
Return type:
a numpy array of floats
galfits.sed_interp.cat3Dtorus(x, L38, a, h, N0, i)[source]
Interpolate AGN torus emission SED using CAT3D models.
Uses nearest-neighbor lookup in pre-computed grid of clumpy torus
radiative transfer models (Hoenig & Kishimoto 2017).
Parameters:
x (array_like) – Rest-frame wavelength in Angstroms.
L38 (float) – Normalization luminosity in units of 10^38 erg/s.
a (float) – Radial density power-law index. Typical range [0, -2].
ρ ∝ r^a where r is distance from center.
h (float) – Scale height (ratio of torus height to radius at inner edge).
Range [0.1, 1.0]. Larger h = more extended vertically.
N0 (float) – Average number of clouds along equatorial ray. Range [1, 15].
Controls optical depth (more clouds = higher τ).
i (float) – Inclination angle in degrees [0, 90].
i = 0: face-on (Type 1)
i = 90: edge-on (Type 2)
Returns:
Torus emission spectral luminosity density in 10^38 erg/s/Å.
Valid wavelength range: 1-100 μm (returns 0 outside).
Return type:
array_like
Notes
CAT3D models include clumpiness, 3D radiative transfer, anisotropy
Torus heated by central AGN UV/optical emission
Re-emits in near-to-far IR (peak around 10-30 μm)
Type 1/2 viewing angle dependence built into models
>>> logL_per_Msun=get_cold_dust_L(qpah=3.5,Umin=1.0,alpha=2.0,gamma=0.3)>>> # Total IR luminosity for 10^7 Msun of dust>>> logMdust=7.0>>> logL_IR=logL_per_Msun+logMdust
Interpolate dust emission SED using Draine & Li (2007) models.
Computes IR dust emission as combination of radiation fields with
constant intensity (U_min) and power-law distribution (dM/dU ∝ U^-α).
Parameters:
x (array_like) – Rest-frame wavelength in Angstroms.
logMdust (float) – Log10 of dust mass in solar masses.
qpah (float) – PAH abundance parameter (percentage of dust mass in PAH grains).
Range [0.47, 4.58]. Solar neighborhood: qpah ~ 3.5%.
Umin (float) – Minimum radiation field intensity (in units of Mathis field).
Range [0.1, 25]. ISRF: U = 1.
alpha (float) – Power-law index for radiation field distribution dM/dU ∝ U^-α.
Range [1.0, 3.0]. Typical: α ~ 2.
gamma (float) – Fraction of dust mass in power-law component. Range [0, 1].
gamma = 0: all dust at U_min (quiescent)
gamma = 1: all dust in power-law (PDR-dominated)
Returns:
Dust emission spectral luminosity density in 10^38 erg/s/Å.
Get the EAZY SEDs for a given set of wavelengths and normalizations.
Parameters:
wave (array-like) – The wavelengths at which to evaluate the SEDs.
lognorms (array-like) – Log10 normalizations for each template. (18,) array-like.
Returns:
sed – The SEDs evaluated at the given wavelengths and normalizations.
by simply linearly combining the EAZY templates with the provided normalizations.
Interpolate stellar population SED with composite star formation history.
Generates rest-frame SED by combining continuum star formation and
instantaneous burst components using BC03 templates. Supports multiple
SFH models (continuous, burst, or binned).
Parameters:
x (array_like) – Rest-frame wavelength grid in Angstroms [91, 1.6e6].
logM (float) – Log10 of total stellar mass in solar masses.
f_cont (float or array_like) – Fraction of mass in continuous star formation component.
For ‘bins’ SFH: array of log10(mass fraction) per bin.
For ‘conti’/’burst’: scalar in range [log10(1e-6), 0].
age (float or array_like) – For ‘conti’/’burst’: Age of burst component in Gyr [1e-5, 13.69].
For ‘bins’: Array of bin edges in Gyr.
Z (float) – Metallicity (mass fraction, not [Z/H]). Range [0.001, 0.04].
Z_solar = 0.02.
Av (float) – V-band attenuation in magnitudes.
C_unit (float) – Normalization constant (typically 10^38 for erg/s units).
SFH ({'conti', 'burst', 'bins'}, optional) –
Star formation history model (default: ‘conti’).
’conti’: Continuous SF + recent burst
’burst’: τ-model with exponential decline
’bins’: Custom binned SFH
present_age (float, optional) – Current age of universe in Gyr (default: 13.8).
Interpolate nebular emission SED (continuum + lines).
Uses pre-computed CLOUDY photoionization models normalized to H-α luminosity.
Includes both nebular continuum (free-free, free-bound, two-photon) and
emission lines.
Parameters:
x (array_like) – Rest-frame wavelength grid in Angstroms.
Lha (float) – H-α luminosity in units of 10^38 erg/s.
logU (float) – Log10 of ionization parameter (ratio of ionizing photon to hydrogen density).
Range typically [-4, -1].
Z (float) – Gas-phase metallicity (mass fraction). Range [0.001, 0.04].
Z_solar = 0.02.
Av (float) – V-band attenuation in magnitudes.
withline (bool, optional) – If True, include emission lines; if False, only continuum (default: True).
>>> wave=jnp.linspace(3000,10000,1000)>>> # Get full nebular SED with lines>>> neb_sed=get_nebular(wave,Lha=100,logU=-2.5,Z=0.02,Av=0.5)>>> # Get only nebular continuum>>> neb_cont=get_nebular(wave,Lha=100,logU=-2.5,Z=0.02,Av=0.5,withline=False)
Calculates wavelength-dependent IGM opacity from Lyman series absorption
and Lyman continuum blanketing by intervening neutral hydrogen along
the line of sight. Based on Meiksin (2006) prescriptions.
Parameters:
wavelength (array_like) – Observed-frame wavelength(s) in Angstroms.
redshift (float) – Source redshift. Must be strictly positive.
Returns:
IGM transmission factor T_IGM(λ) ∈ [0, 1].
Multiply SED by this to apply absorption: F_obs = F_int × T_IGM.
Return type:
array_like
Notes
Three opacity components contribute:
Lyman series (Lyα, Lyβ, …): Discrete absorption features
redshifted into spectrum. Each higher-order line has lower optical depth.
Lyman continuum (λ < 912 Å rest): Strong blanketing blueward of
Lyman limit. Creates sharp absorption edge at λ_obs = 912(1+z) Å.
Lyman limit systems (LLS): Additional opacity from dense clouds
with high HI column densities.
Total transmission: T = exp(-τ_Lyα - τ_Lyβ - … - τ_LC - τ_LLS)
At λ_obs < 912 Å (rest UV), transmission → 0 for z > 0.
IGM becomes transparent at λ_obs > Lyα(1+z) ≈ 1216(1+z) Å.
The function is JIT-compiled for performance with JAX.
Calzetti et al. (2000) attenuation curve with UV bump.
Implements the Calzetti+ (2000) and Leitherer+ (2002) starburst
attenuation law with optional UV bump feature (2175 Å bump).
Parameters:
wavelength (array_like) – Wavelength array in Angstroms.
amplitude (float) – Amplitude of the UV bump (2175 Å feature).
amplitude = 0: no bump (pure Calzetti curve)
amplitude = 3: typical value for Milky Way-like bump
Returns:
Attenuation curve k(λ) where A(λ) = k(λ) × E(B-V).
To apply: F_obs = F_int × 10^(-A(λ)/2.5).
Return type:
array_like
Notes
The Calzetti law applies to starburst galaxies where dust is mixed
with stars. It differs from Galactic extinction curves (CCM, RV=3.1):
Grayer (flatter) in UV/optical
No 2175 Å bump by default (added optionally here)
Normalized to E(B-V) of stellar continuum
Wavelength ranges:
λ < 180 nm: Leitherer+ (2002) extrapolation
180-630 nm: Calzetti+ (2000) law (optical/UV)
λ > 630 nm: Calzetti+ (2000) law (NIR)
The UV bump is parameterized as Drude profile centered at 2175 Å with
FWHM = 350 Å.
Galactic extinction curve (for Milky Way foreground)
Examples
>>> wave=jnp.linspace(1000,10000,1000)>>> # No UV bump (pure Calzetti)>>> k_cal=mycigale(wave,amplitude=0)>>> # With UV bump>>> k_bump=mycigale(wave,amplitude=3)>>> # Apply to SED with E(B-V) = 0.5>>> ebv=0.5>>> flux_atten=flux_int*10**(-k_bump*ebv/2.5)
galfits.sed_interp.sed_to_rest(x, y, z, ebv)[source]
Convert observed frame SED to restframe,
applying IGM and MW local extinction
x: wavelength in observed frame
y: L_38 in observed frame
z: redshift
ebv: Milky Way E(B-V)
Returns:
xnew: wavelength in restframe
ynew: L_38 in restframe
Interpolate stellar population SED with composite star formation history.
Generates rest-frame SED by combining continuum star formation and
instantaneous burst components using BC03 templates. Supports multiple
SFH models (continuous, burst, or binned).
Parameters:
x (array_like) – Rest-frame wavelength grid in Angstroms [91, 1.6e6].
logM (float) – Log10 of total stellar mass in solar masses.
f_cont (float or array_like) – Fraction of mass in continuous star formation component.
For ‘bins’ SFH: array of log10(mass fraction) per bin.
For ‘conti’/’burst’: scalar in range [log10(1e-6), 0].
age (float or array_like) – For ‘conti’/’burst’: Age of burst component in Gyr [1e-5, 13.69].
For ‘bins’: Array of bin edges in Gyr.
Z (float) – Metallicity (mass fraction, not [Z/H]). Range [0.001, 0.04].
Z_solar = 0.02.
Av (float) – V-band attenuation in magnitudes.
C_unit (float) – Normalization constant (typically 10^38 for erg/s units).
SFH ({'conti', 'burst', 'bins'}, optional) –
Star formation history model (default: ‘conti’).
’conti’: Continuous SF + recent burst
’burst’: τ-model with exponential decline
’bins’: Custom binned SFH
present_age (float, optional) – Current age of universe in Gyr (default: 13.8).
Generate optical/UV FeII emission template for AGN.
Constructs iron emission spectrum using empirical templates with
independent UV and optical normalization. Applies velocity broadening
and Doppler shift.
Parameters:
x (array_like) – Rest-frame wavelength grid in Angstroms.
dcen (float) – Velocity offset in km/s (positive = redshift).
fwhm (float) – Full-width at half-maximum velocity width in km/s.
Intrinsic template FWHM = 900 km/s is deconvolved.
Returns:
FeII emission flux (arbitrary normalization).
Return type:
array_like
Notes
FeII emission arises from collisionally excited iron in the AGN
broad-line region. It creates broad pseudo-continuum with thousands
of blended transitions, especially prominent at:
UV: 2200-3200 Å (FeII multiplet 191)
Optical: 4400-5500 Å (FeII multiplets around Hβ)
Templates are empirical from composite quasar spectra. The UV and
optical components scale independently, reflecting different excitation
conditions.
Convolution is performed in log-wavelength space for uniform velocity
resolution. The 900 km/s intrinsic width is quadratically subtracted
before applying user-specified FWHM.
Generate Balmer continuum emission from AGN broad-line region.
Computes BLR Balmer continuum using pre-computed templates that include
high-order Balmer recombination edges (Balmer jump at 3646 Å plus
higher-order series). Applies velocity broadening and Doppler shift.
Parameters:
x (array_like) – Rest-frame wavelength grid in Angstroms.
logL3600 (float) – Log10 of continuum luminosity at 3600 Å in 10^38 erg/s/Å.
Used for normalization.
logM (float) – Log10 of black hole mass in solar masses [5, 10].
logMdot (float) – Log10 of accretion rate in Eddington units [-4, 2].
spin (float) – Black hole spin parameter [0, 0.99].
dcen (float) – Velocity offset in km/s (positive = redshift).
fwhm (float) – Full-width at half-maximum velocity width in km/s.
Returns:
Balmer continuum flux in 10^38 erg/s/Å.
Return type:
array_like
Notes
The Balmer continuum arises from recombination of hydrogen in the
dense, ionized gas of the AGN broad-line region. Key features:
Balmer jump at 3646 Å (flux discontinuity)
Series of higher-order Balmer edges converging to Balmer limit
Contributes blue “pseudo-continuum” in optical spectra
Depends on BLR density, temperature, covering factor
Templates are computed from photoionization models and depend on
black hole parameters through the ionizing continuum shape.
The function normalizes to luminosity at 3600 Å (common AGN
reference point below Balmer jump).
Interpolate nebular emission SED (continuum + lines).
Uses pre-computed CLOUDY photoionization models normalized to H-α luminosity.
Includes both nebular continuum (free-free, free-bound, two-photon) and
emission lines.
Parameters:
x (array_like) – Rest-frame wavelength grid in Angstroms.
Lha (float) – H-α luminosity in units of 10^38 erg/s.
logU (float) – Log10 of ionization parameter (ratio of ionizing photon to hydrogen density).
Range typically [-4, -1].
Z (float) – Gas-phase metallicity (mass fraction). Range [0.001, 0.04].
Z_solar = 0.02.
Av (float) – V-band attenuation in magnitudes.
withline (bool, optional) – If True, include emission lines; if False, only continuum (default: True).
>>> wave=jnp.linspace(3000,10000,1000)>>> # Get full nebular SED with lines>>> neb_sed=get_nebular(wave,Lha=100,logU=-2.5,Z=0.02,Av=0.5)>>> # Get only nebular continuum>>> neb_cont=get_nebular(wave,Lha=100,logU=-2.5,Z=0.02,Av=0.5,withline=False)
Interpolate dust emission SED using Draine & Li (2007) models.
Computes IR dust emission as combination of radiation fields with
constant intensity (U_min) and power-law distribution (dM/dU ∝ U^-α).
Parameters:
x (array_like) – Rest-frame wavelength in Angstroms.
logMdust (float) – Log10 of dust mass in solar masses.
qpah (float) – PAH abundance parameter (percentage of dust mass in PAH grains).
Range [0.47, 4.58]. Solar neighborhood: qpah ~ 3.5%.
Umin (float) – Minimum radiation field intensity (in units of Mathis field).
Range [0.1, 25]. ISRF: U = 1.
alpha (float) – Power-law index for radiation field distribution dM/dU ∝ U^-α.
Range [1.0, 3.0]. Typical: α ~ 2.
gamma (float) – Fraction of dust mass in power-law component. Range [0, 1].
gamma = 0: all dust at U_min (quiescent)
gamma = 1: all dust in power-law (PDR-dominated)
Returns:
Dust emission spectral luminosity density in 10^38 erg/s/Å.
>>> logL_per_Msun=get_cold_dust_L(qpah=3.5,Umin=1.0,alpha=2.0,gamma=0.3)>>> # Total IR luminosity for 10^7 Msun of dust>>> logMdust=7.0>>> logL_IR=logL_per_Msun+logMdust
galfits.sed_interp.sed_to_rest(x, y, z, ebv)[source]
Convert observed frame SED to restframe,
applying IGM and MW local extinction
x: wavelength in observed frame
y: L_38 in observed frame
z: redshift
ebv: Milky Way E(B-V)
Returns:
xnew: wavelength in restframe
ynew: L_38 in restframe
Calzetti et al. (2000) attenuation curve with UV bump.
Implements the Calzetti+ (2000) and Leitherer+ (2002) starburst
attenuation law with optional UV bump feature (2175 Å bump).
Parameters:
wavelength (array_like) – Wavelength array in Angstroms.
amplitude (float) – Amplitude of the UV bump (2175 Å feature).
amplitude = 0: no bump (pure Calzetti curve)
amplitude = 3: typical value for Milky Way-like bump
Returns:
Attenuation curve k(λ) where A(λ) = k(λ) × E(B-V).
To apply: F_obs = F_int × 10^(-A(λ)/2.5).
Return type:
array_like
Notes
The Calzetti law applies to starburst galaxies where dust is mixed
with stars. It differs from Galactic extinction curves (CCM, RV=3.1):
Grayer (flatter) in UV/optical
No 2175 Å bump by default (added optionally here)
Normalized to E(B-V) of stellar continuum
Wavelength ranges:
λ < 180 nm: Leitherer+ (2002) extrapolation
180-630 nm: Calzetti+ (2000) law (optical/UV)
λ > 630 nm: Calzetti+ (2000) law (NIR)
The UV bump is parameterized as Drude profile centered at 2175 Å with
FWHM = 350 Å.
Galactic extinction curve (for Milky Way foreground)
Examples
>>> wave=jnp.linspace(1000,10000,1000)>>> # No UV bump (pure Calzetti)>>> k_cal=mycigale(wave,amplitude=0)>>> # With UV bump>>> k_bump=mycigale(wave,amplitude=3)>>> # Apply to SED with E(B-V) = 0.5>>> ebv=0.5>>> flux_atten=flux_int*10**(-k_bump*ebv/2.5)
Given a wavelength grid, this function computes the selective attenuation
A(λ)/E(B-V)∗ using the formula from Calzetti at al. (2000) and Leitherer et al. (2002). The formula
is given for wavelengths between 91.2 nm and 2200 nm, but this function
makes the computation outside.
Parameters:
wavelength (array of floats) – Wavelength grid in angstrom but converted to nm in the function.
Calculates wavelength-dependent IGM opacity from Lyman series absorption
and Lyman continuum blanketing by intervening neutral hydrogen along
the line of sight. Based on Meiksin (2006) prescriptions.
Parameters:
wavelength (array_like) – Observed-frame wavelength(s) in Angstroms.
redshift (float) – Source redshift. Must be strictly positive.
Returns:
IGM transmission factor T_IGM(λ) ∈ [0, 1].
Multiply SED by this to apply absorption: F_obs = F_int × T_IGM.
Return type:
array_like
Notes
Three opacity components contribute:
Lyman series (Lyα, Lyβ, …): Discrete absorption features
redshifted into spectrum. Each higher-order line has lower optical depth.
Lyman continuum (λ < 912 Å rest): Strong blanketing blueward of
Lyman limit. Creates sharp absorption edge at λ_obs = 912(1+z) Å.
Lyman limit systems (LLS): Additional opacity from dense clouds
with high HI column densities.
Total transmission: T = exp(-τ_Lyα - τ_Lyβ - … - τ_LC - τ_LLS)
At λ_obs < 912 Å (rest UV), transmission → 0 for z > 0.
IGM becomes transparent at λ_obs > Lyα(1+z) ≈ 1216(1+z) Å.
The function is JIT-compiled for performance with JAX.
Generic SED table model with multi-parameter interpolation.
Loads pre-computed SED grids from .npz files and provides fast
interpolation for arbitrary parameter values. Supports optional
normalization parameter for flexible scaling.
Parameters:
table_path (str) – Path to .npz file containing SED table.
Must contain ‘sed’ (log10 L_λ), ‘wave’, and parameter grids.
param_names (list of str) – Parameter names to interpolate (must match keys in .npz file).
If ‘logNorm’ is included, it will be used for normalization.
prefix (str) – Prefix to add to parameter names for external interface
(e.g., ‘AGN’ → ‘AGN_spin’, ‘AGN_logM’).
Interpolate SED at given parameters and wavelengths.
Parameters:
pardict (dict) – Dictionary mapping parameter names (with prefix) to values.
Must include all parameters in self.param_names.
If self.norm=True, must also include normalization parameter.
x (array_like) – Wavelength grid in Angstroms for interpolation.
Returns:
Interpolated SED normalized to L5100 = 1. Output in units of 10^38 erg/s/Å.