Continuum¶
Continuum Configuration¶
Continuum configuration for spectral fitting.
- class unite.continuum.config.Scale(name=None, *, prior=None)[source]¶
Bases:
ParameterTyped token for the
'scale'parameter slot.scaleis the continuum flux atnorm_wav. When the sameScaleinstance is placed in the'scale'slot of multipleContinuumRegionobjects, those regions share a single sampled amplitude in the model.Placing a
Scaletoken in any slot other than'scale'raises aValueErroratContinuumConfigurationconstruction time.
- class unite.continuum.config.NormWavelength(name=None, *, prior=None)[source]¶
Bases:
ParameterTyped token for the
'norm_wav'parameter slot.norm_wavis the rest-frame reference wavelength at which the continuum equalsscale. The model automatically applies the systemic redshift before evaluating the continuum form.Sharing the same
NormWavelengthinstance across multiple regions ties them to a single consistent reference wavelength — essential for globally-normalised forms such asPowerLawandBlackbody.Placing a
NormWavelengthtoken in any slot other than'norm_wav'raises aValueErroratContinuumConfigurationconstruction time.
- class unite.continuum.config.ContShape(name=None, *, prior=None)[source]¶
Bases:
ParameterTyped token for form-specific shape/parameter slots.
Used for continuum form parameters such as spectral indices (
beta), polynomial coefficients (c1,c2, etc.), and other dimensionless or form-specific parameters (e.g.angle,temperature,tau_v). The default prior isUniform(-10, 10); in practice the form’sdefault_priors()provides a more specific default when no token is supplied explicitly.
- class unite.continuum.config.ContinuumRegion(low, high, form=<factory>, params=<factory>, name=None)[source]¶
Bases:
objectA single continuum region with wavelength bounds and functional form.
- Parameters:
- lowastropy.units.Quantity
Lower wavelength bound (must have length units).
- highastropy.units.Quantity
Upper wavelength bound (must have length units).
- formContinuumForm
Functional form for the continuum in this region.
- paramsdict of str to Parameter, optional
Parameter tokens for the form’s parameters, keyed by
ContinuumForm.param_names(). Parameters not listed here receive auto-created tokens with the form’s default priors when the region is added to aContinuumConfiguration.- namestr, optional
Human-readable label for this region. When provided, auto-created parameter tokens use this as a suffix (e.g.
scale_blue,beta_blue). Region names must be unique within aContinuumConfiguration.Custom priors — supply a
Parameterwith the desired prior for any slot you want to override:from unite.prior import Parameter, TruncatedNormal region = ContinuumRegion( 1.0 * u.um, 1.5 * u.um, form=PowerLaw(), params={ 'scale': Parameter('my_scale', prior=TruncatedNormal(2.0, 0.5, 0, 10)), # 'beta' and 'norm_wav' get default priors }, )
Shared parameters — pass the same
Parameterinstance in theparamsdict of multiple regions. TheContinuumConfigurationdetects shared identity and creates a single numpyro site, coupling those regions to one sampled value:shared_scale = Parameter('global_scale', prior=Uniform(0, 10)) region1 = ContinuumRegion(1.0 * u.um, 1.5 * u.um, form=PowerLaw(), params={'scale': shared_scale}) region2 = ContinuumRegion(2.0 * u.um, 2.5 * u.um, form=PowerLaw(), params={'scale': shared_scale})
Use
ScaleandNormWavelengthtyped tokens for the'scale'and'norm_wav'slots respectively; they add a validation check that prevents accidentally assigning them to the wrong slot.
- Raises:
- TypeError
If
loworhighare not astropy Quantities with length units.- ValueError
If
low >= high.
- Parameters:
- form: ContinuumForm | str¶
- class unite.continuum.config.ContinuumConfiguration(regions=None, *, zorder=0)[source]¶
Bases:
objectCollection of continuum regions for spectral fitting.
Regions are sorted by wavelength at construction time and must not overlap. Parameters for each region are represented as
Parametertokens. Sharing the same token instance across multiple regions ties those parameters to a single sampled value in the model — analogous to howFWHMandFluxtokens work for emission lines.- Parameters:
- regionslist of ContinuumRegion, optional
Continuum regions. Will be sorted by
lowbound.
- Raises:
- ValueError
If any two regions overlap.
- Parameters:
regions (list[ContinuumRegion] | None)
zorder (int)
Examples
Auto-generate from line wavelengths (independent local continua):
>>> from astropy import units as u >>> from unite.continuum import ContinuumConfiguration >>> cont = ContinuumConfiguration.from_lines( ... [6564.61, 4862.68, 6585.27, 6549.86] * u.AA) >>> len(cont) 2
Manual construction with independent regions and custom priors:
>>> from astropy import units as u >>> from unite.continuum.config import ( ... ContinuumConfiguration, ContinuumRegion) >>> from unite.continuum.library import Linear >>> from unite.prior import Parameter, TruncatedNormal, Fixed >>> region = ContinuumRegion( ... 1.0 * u.um, 1.5 * u.um, form=Linear(), ... params={ ... 'scale': Parameter('my_scale', ... prior=TruncatedNormal(2.0, 0.5, 0.0, 10.0)), ... 'norm_wav': Parameter('my_nw', prior=Fixed(1.25)), ... # 'slope' receives the default Uniform(-10, 10) prior ... }, ... ) >>> cont = ContinuumConfiguration([region])
Global power-law with parameters shared across two spectral windows:
>>> from astropy import units as u >>> from unite.continuum.config import ( ... ContinuumConfiguration, ContinuumRegion, Scale, NormWavelength, ContShape) >>> from unite.continuum.library import PowerLaw >>> from unite.prior import Uniform, Fixed >>> pl = PowerLaw() >>> shared_scale = Scale('pl_scale', prior=Uniform(0, 10)) >>> shared_beta = ContShape('pl_beta', prior=Uniform(-5, 5)) >>> shared_nw = NormWavelength( ... 'pl_nw', prior=Fixed(1.0)) # single reference wavelength >>> cont = ContinuumConfiguration([ ... ContinuumRegion(0.9 * u.um, 1.4 * u.um, form=pl, ... params={'scale': shared_scale, 'beta': shared_beta, ... 'norm_wav': shared_nw}), ... ContinuumRegion(1.7 * u.um, 2.5 * u.um, form=pl, ... params={'scale': shared_scale, 'beta': shared_beta, ... 'norm_wav': shared_nw}), ... ]) >>> # → one 'pl_scale', one 'pl_beta', one 'pl_nw' site in the numpyro model
- property resolved_params: list[dict[str, Parameter]]¶
Resolved parameter tokens for each region (read-only copy).
Index i contains the full
{param_name: Parameter}mapping forself.regions[i], including auto-created tokens for any parameters the user did not explicitly provide.
- classmethod from_lines(wavelengths, width=<Quantity 15000. km / s>, form=None, *, zorder=0)[source]¶
Auto-generate continuum regions from line wavelengths.
Each line gets a region of total width width (i.e.
±width/2in velocity space around the line center). Overlapping regions are merged. All generated regions are independent: each receives its own auto-created parameter tokens.- Return type:
- Parameters:
- wavelengthsastropy.units.Quantity
Rest-frame wavelengths of spectral lines (must have length units).
- widthastropy.units.Quantity, optional
Total velocity width of each region (must have velocity units, e.g.
km/s). Each line is padded by±width/2. Defaults to3000 km/s.- formContinuumForm, optional
Functional form to assign to every region. Defaults to
Linear.
- Returns:
- ContinuumConfiguration
- Raises:
- TypeError
If wavelengths is not an astropy Quantity with length units, or if width is not a Quantity with velocity units.
- ValueError
If wavelengths is empty or width is not positive.
- Parameters:
wavelengths (Quantity)
width (Quantity)
form (ContinuumForm | None)
zorder (int)
- to_dict()[source]¶
Serialize to a YAML-safe dictionary.
Unique
ContinuumForminstances are collected into a'forms'section keyed by auto-generated names. UniqueParametertokens are collected into a'params'section keyed by their names. Each region references its form and params by name, so shared token objects round-trip correctly.- Return type:
- Returns:
- dict
Keys:
'params','forms','regions'.
- classmethod from_dict(d)[source]¶
Deserialize from a dictionary.
- classmethod from_yaml(text)[source]¶
Deserialize from a YAML string.
- classmethod load(path)[source]¶
Load from a YAML file.
- Return type:
- Parameters:
- pathstr or Path
Path to a YAML file written by
save().
- Returns:
- ContinuumConfiguration
- Parameters:
- property regions: list[ContinuumRegion]¶
List of continuum regions (read-only copy).
Continuum Forms¶
Continuum functional forms: abstract base and concrete implementations.
- class unite.continuum.library.ContinuumForm[source]¶
Bases:
ABCAbstract base class for continuum functional forms.
Each subclass defines a parameterised continuum model that can be evaluated at an array of wavelengths. Forms are stateless (or carry only static configuration like polynomial degree) and are fully serialisable for YAML round-trip.
All forms share a unified parameter interface:
scale— the continuum flux atnorm_wav.norm_wav— rest-frame reference wavelength where the continuum equalsscale. Default prior isFixed(region_center), pinning it to the region midpoint. Pass an explicitContinuumNormalizationWavelengthtoken withFixed(value)to share a consistent reference wavelength across multiple regions.
Subclasses must implement
param_names(),default_priors(),evaluate(),to_dict(), andfrom_dict().- abstractmethod default_priors(region_center=1.0)[source]¶
Return sensible default priors for each parameter.
The keys must match
param_names().
- abstractmethod evaluate(wavelength, center, params, obs_low, obs_high, lsf_fwhm=0.0, z_sys=0.0)[source]¶
Evaluate the (optionally LSF-convolved) continuum model.
All operations must use
jax.numpyso the function is compatible with JAX tracing / JIT compilation.- Return type:
- Parameters:
- wavelengthArrayLike
Wavelength array (observed frame).
- centerfloat
Region midpoint in observed frame (passed for convenience; forms use
params['norm_wav']instead).- paramsdict of str to ArrayLike
Parameter values keyed by
param_names().params['norm_wav']is already in observed frame (the model applies the systemic redshift before calling this method).- obs_lowfloat
Lower observed-frame wavelength bound of the region.
- obs_highfloat
Upper observed-frame wavelength bound of the region.
- lsf_fwhmArrayLike, optional
LSF FWHM at each wavelength point (same unit as wavelength). Default
0.0means no LSF convolution.- z_sysfloat, optional
Systemic redshift of the source. Forms that evaluate in rest-frame (e.g.
Template) use this to convert observed-frame wavelengths to rest-frame. Most forms ignore it. Default0.0.
- Returns:
- Array
Continuum flux at each wavelength.
- Parameters:
- integrate(edges, center, params, obs_low, obs_high, lsf_fwhm=0.0, z_sys=0.0)[source]¶
Cumulative continuum integral evaluated at edges.
jnp.diffover the returned array (then divided by pixel widths) gives the pixel-averaged continuum. The default implementation is a midpoint-rule cumulative sum viaevaluate(), which is exact for forms that vary linearly across a pixel (e.g.Linear) and a reasonable approximation otherwise. Polynomial-based forms override this method to use the exact antiderivative.- Return type:
- Parameters:
- edgesArrayLike, shape
(E,) Pixel edges (observed frame, canonical wavelength unit).
- centerfloat
Region midpoint in observed frame.
- paramsdict of str to ArrayLike
Parameter values keyed by
param_names().- obs_lowfloat
Lower observed-frame wavelength bound of the region.
- obs_highfloat
Upper observed-frame wavelength bound of the region.
- lsf_fwhmArrayLike, optional
LSF FWHM scalar for the region; polynomial-based forms apply it via the analytic Gaussian-moment convolution. Default
0.0means no LSF convolution.- z_sysfloat, optional
Systemic redshift; passed through to
evaluate(). Default0.0.
- edgesArrayLike, shape
- Returns:
- Array, shape
(E,) Cumulative continuum integral at the edges.
- Array, shape
- Parameters:
- property is_linear: bool¶
Whether the form is linear in its fitted parameters.
Linear forms can be solved exactly via weighted least squares. Nonlinear forms require iterative solvers (e.g. Gauss-Newton).
- Returns:
- bool
- abstractmethod param_units(flux_unit, wl_unit)[source]¶
Physical unit mapping for each parameter.
- Return type:
- Parameters:
- flux_unitastropy.units.UnitBase
Flux density unit of the spectrum (e.g.
u.Unit('erg s-1 cm-2 AA-1')).- wl_unitastropy.units.UnitBase
Canonical wavelength unit (e.g.
u.um).
- Returns:
- dict of str to (bool, unit)
For each parameter name:
(apply_continuum_scale, physical_unit). Ifapply_continuum_scaleisTrue, multiply the sampled value bycontinuum_scaleto recover the physical quantity.physical_unitis the resulting astropy unit, orNonefor dimensionless parameters.
- Parameters:
- unite.continuum.library.form_from_dict(d)[source]¶
Reconstruct a
ContinuumFormfrom a serialised dictionary.- Return type:
- Parameters:
- ddict
Must contain a
'type'key matching a registered form name.
- Returns:
- ContinuumForm
- Raises:
- ValueError
If the type is not recognised.
- Parameters:
d (dict)
- unite.continuum.library.get_form(name_or_form, **kwargs)[source]¶
Get a
ContinuumFormby name or pass through an existing instance.- Return type:
- Parameters:
- name_or_formstr or ContinuumForm
A registered form name (e.g.
'Linear','PowerLaw','Polynomial') or an existingContinuumForminstance.- **kwargs
Passed to the form constructor when name_or_form is a string (e.g.
get_form('Polynomial', degree=3)).
- Returns:
- ContinuumForm
- Raises:
- ValueError
If the name is not recognised.
- Parameters:
name_or_form (str | ContinuumForm)
Examples
>>> get_form('Linear') Linear() >>> get_form('Polynomial', degree=3) Polynomial(degree=3) >>> get_form(Linear()) # pass-through Linear()
- class unite.continuum.library.Linear[source]¶
Bases:
ContinuumFormLinear continuum:
scale + slope * (wavelength - norm_wav).This form has no constructor parameters.
Notes
Model parameters (sampled with priors, overridable via
ContinuumRegion(params={...})):scale— Continuum level atnorm_wav. Default prior:Uniform(0, 10).slope— Continuum slope in flux per wavelength unit. Default prior:Uniform(-10, 10).norm_wav— Reference wavelength where the continuum equalsscale. Default prior:Fixed(region_center).
- property is_linear: bool¶
Whether the form is linear in its fitted parameters.
Linear forms can be solved exactly via weighted least squares. Nonlinear forms require iterative solvers (e.g. Gauss-Newton).
- Returns:
- bool
- default_priors(region_center=1.0)[source]¶
Return sensible default priors for each parameter.
The keys must match
param_names().
- param_units(flux_unit, wl_unit)[source]¶
Physical unit mapping for each parameter.
- Return type:
- Parameters:
- flux_unitastropy.units.UnitBase
Flux density unit of the spectrum (e.g.
u.Unit('erg s-1 cm-2 AA-1')).- wl_unitastropy.units.UnitBase
Canonical wavelength unit (e.g.
u.um).
- Returns:
- dict of str to (bool, unit)
For each parameter name:
(apply_continuum_scale, physical_unit). Ifapply_continuum_scaleisTrue, multiply the sampled value bycontinuum_scaleto recover the physical quantity.physical_unitis the resulting astropy unit, orNonefor dimensionless parameters.
- Parameters:
- evaluate(wavelength, center, params, obs_low, obs_high, lsf_fwhm=0.0, z_sys=0.0)[source]¶
Evaluate the (optionally LSF-convolved) continuum model.
All operations must use
jax.numpyso the function is compatible with JAX tracing / JIT compilation.- Return type:
- Parameters:
- wavelengthArrayLike
Wavelength array (observed frame).
- centerfloat
Region midpoint in observed frame (passed for convenience; forms use
params['norm_wav']instead).- paramsdict of str to ArrayLike
Parameter values keyed by
param_names().params['norm_wav']is already in observed frame (the model applies the systemic redshift before calling this method).- obs_lowfloat
Lower observed-frame wavelength bound of the region.
- obs_highfloat
Upper observed-frame wavelength bound of the region.
- lsf_fwhmArrayLike, optional
LSF FWHM at each wavelength point (same unit as wavelength). Default
0.0means no LSF convolution.- z_sysfloat, optional
Systemic redshift of the source. Forms that evaluate in rest-frame (e.g.
Template) use this to convert observed-frame wavelengths to rest-frame. Most forms ignore it. Default0.0.
- Returns:
- Array
Continuum flux at each wavelength.
- Parameters:
- integrate(edges, center, params, obs_low, obs_high, lsf_fwhm=0.0, z_sys=0.0)[source]¶
Cumulative continuum integral evaluated at edges.
jnp.diffover the returned array (then divided by pixel widths) gives the pixel-averaged continuum. The default implementation is a midpoint-rule cumulative sum viaevaluate(), which is exact for forms that vary linearly across a pixel (e.g.Linear) and a reasonable approximation otherwise. Polynomial-based forms override this method to use the exact antiderivative.- Return type:
- Parameters:
- edgesArrayLike, shape
(E,) Pixel edges (observed frame, canonical wavelength unit).
- centerfloat
Region midpoint in observed frame.
- paramsdict of str to ArrayLike
Parameter values keyed by
param_names().- obs_lowfloat
Lower observed-frame wavelength bound of the region.
- obs_highfloat
Upper observed-frame wavelength bound of the region.
- lsf_fwhmArrayLike, optional
LSF FWHM scalar for the region; polynomial-based forms apply it via the analytic Gaussian-moment convolution. Default
0.0means no LSF convolution.- z_sysfloat, optional
Systemic redshift; passed through to
evaluate(). Default0.0.
- edgesArrayLike, shape
- Returns:
- Array, shape
(E,) Cumulative continuum integral at the edges.
- Array, shape
- Parameters:
- class unite.continuum.library.Polynomial(degree=1)[source]¶
Bases:
ContinuumFormPolynomial continuum of configurable degree.
Evaluates
scale + c1*x + c2*x**2 + ...wherex = wavelength - norm_wav.- Parameters:
- degreeint
Polynomial degree (default 1).
- Parameters:
degree (int)
Notes
Model parameters (sampled with priors, overridable via
ContinuumRegion(params={...})):scale— Continuum level atnorm_wav. Default prior:Uniform(0, 10).c1, c2, ...— Higher-order polynomial coefficients. Default prior:Uniform(-10, 10)each.norm_wav— Reference wavelength. Default prior:Fixed(region_center).
- property is_linear: bool¶
Whether the form is linear in its fitted parameters.
Linear forms can be solved exactly via weighted least squares. Nonlinear forms require iterative solvers (e.g. Gauss-Newton).
- Returns:
- bool
- default_priors(region_center=1.0)[source]¶
Return sensible default priors for each parameter.
The keys must match
param_names().
- param_units(flux_unit, wl_unit)[source]¶
Physical unit mapping for each parameter.
- Return type:
- Parameters:
- flux_unitastropy.units.UnitBase
Flux density unit of the spectrum (e.g.
u.Unit('erg s-1 cm-2 AA-1')).- wl_unitastropy.units.UnitBase
Canonical wavelength unit (e.g.
u.um).
- Returns:
- dict of str to (bool, unit)
For each parameter name:
(apply_continuum_scale, physical_unit). Ifapply_continuum_scaleisTrue, multiply the sampled value bycontinuum_scaleto recover the physical quantity.physical_unitis the resulting astropy unit, orNonefor dimensionless parameters.
- Parameters:
- evaluate(wavelength, center, params, obs_low, obs_high, lsf_fwhm=0.0, z_sys=0.0)[source]¶
Evaluate the (optionally LSF-convolved) continuum model.
All operations must use
jax.numpyso the function is compatible with JAX tracing / JIT compilation.- Return type:
- Parameters:
- wavelengthArrayLike
Wavelength array (observed frame).
- centerfloat
Region midpoint in observed frame (passed for convenience; forms use
params['norm_wav']instead).- paramsdict of str to ArrayLike
Parameter values keyed by
param_names().params['norm_wav']is already in observed frame (the model applies the systemic redshift before calling this method).- obs_lowfloat
Lower observed-frame wavelength bound of the region.
- obs_highfloat
Upper observed-frame wavelength bound of the region.
- lsf_fwhmArrayLike, optional
LSF FWHM at each wavelength point (same unit as wavelength). Default
0.0means no LSF convolution.- z_sysfloat, optional
Systemic redshift of the source. Forms that evaluate in rest-frame (e.g.
Template) use this to convert observed-frame wavelengths to rest-frame. Most forms ignore it. Default0.0.
- Returns:
- Array
Continuum flux at each wavelength.
- Parameters:
- integrate(edges, center, params, obs_low, obs_high, lsf_fwhm=0.0, z_sys=0.0)[source]¶
Cumulative continuum integral evaluated at edges.
jnp.diffover the returned array (then divided by pixel widths) gives the pixel-averaged continuum. The default implementation is a midpoint-rule cumulative sum viaevaluate(), which is exact for forms that vary linearly across a pixel (e.g.Linear) and a reasonable approximation otherwise. Polynomial-based forms override this method to use the exact antiderivative.- Return type:
- Parameters:
- edgesArrayLike, shape
(E,) Pixel edges (observed frame, canonical wavelength unit).
- centerfloat
Region midpoint in observed frame.
- paramsdict of str to ArrayLike
Parameter values keyed by
param_names().- obs_lowfloat
Lower observed-frame wavelength bound of the region.
- obs_highfloat
Upper observed-frame wavelength bound of the region.
- lsf_fwhmArrayLike, optional
LSF FWHM scalar for the region; polynomial-based forms apply it via the analytic Gaussian-moment convolution. Default
0.0means no LSF convolution.- z_sysfloat, optional
Systemic redshift; passed through to
evaluate(). Default0.0.
- edgesArrayLike, shape
- Returns:
- Array, shape
(E,) Cumulative continuum integral at the edges.
- Array, shape
- Parameters:
- class unite.continuum.library.Chebyshev(order=2, stretch=1.0)[source]¶
Bases:
ContinuumFormChebyshev polynomial continuum of configurable order.
Evaluates a Chebyshev series on coordinates normalized to
[-1, 1]within the continuum region, normalized so that the continuum equalsscaleatnorm_wav. Numerically more stable than a standard polynomial basis for higher orders.The x-coordinate is
(wavelength - center) / (half_width * stretch)wherehalf_widthis derived from the region bounds passed toevaluate(), andstretchis a form-specific scaling factor (default1.0for identity normalization).The continuum is parameterized as
scale * T(x) / T(x_nw)whereTis the Chebyshev series with constant term fixed at 1.0, andx_nwis the normalized coordinate atnorm_wav.- Parameters:
- orderint
Chebyshev order (default 2). Number of coefficients = order + 1.
- stretchfloat
Stretch factor to scale the region normalization (default 1.0).
- Parameters:
Notes
Model parameters (sampled with priors, overridable via
ContinuumRegion(params={...})):scale— Continuum level atnorm_wav. Default prior:Uniform(0, 10).c1, c2, ...— Higher-order Chebyshev coefficients (normalized to constant term 1.0). Default prior:Uniform(-10, 10)each.norm_wav— Reference wavelength. Default prior:Fixed(region_center).
- property is_linear: bool¶
Whether the form is linear in its fitted parameters.
Linear forms can be solved exactly via weighted least squares. Nonlinear forms require iterative solvers (e.g. Gauss-Newton).
- Returns:
- bool
- default_priors(region_center=1.0)[source]¶
Return sensible default priors for each parameter.
The keys must match
param_names().
- param_units(flux_unit, wl_unit)[source]¶
Physical unit mapping for each parameter.
- Return type:
- Parameters:
- flux_unitastropy.units.UnitBase
Flux density unit of the spectrum (e.g.
u.Unit('erg s-1 cm-2 AA-1')).- wl_unitastropy.units.UnitBase
Canonical wavelength unit (e.g.
u.um).
- Returns:
- dict of str to (bool, unit)
For each parameter name:
(apply_continuum_scale, physical_unit). Ifapply_continuum_scaleisTrue, multiply the sampled value bycontinuum_scaleto recover the physical quantity.physical_unitis the resulting astropy unit, orNonefor dimensionless parameters.
- Parameters:
- evaluate(wavelength, center, params, obs_low, obs_high, lsf_fwhm=0.0, z_sys=0.0)[source]¶
Evaluate the (optionally LSF-convolved) continuum model.
All operations must use
jax.numpyso the function is compatible with JAX tracing / JIT compilation.- Return type:
- Parameters:
- wavelengthArrayLike
Wavelength array (observed frame).
- centerfloat
Region midpoint in observed frame (passed for convenience; forms use
params['norm_wav']instead).- paramsdict of str to ArrayLike
Parameter values keyed by
param_names().params['norm_wav']is already in observed frame (the model applies the systemic redshift before calling this method).- obs_lowfloat
Lower observed-frame wavelength bound of the region.
- obs_highfloat
Upper observed-frame wavelength bound of the region.
- lsf_fwhmArrayLike, optional
LSF FWHM at each wavelength point (same unit as wavelength). Default
0.0means no LSF convolution.- z_sysfloat, optional
Systemic redshift of the source. Forms that evaluate in rest-frame (e.g.
Template) use this to convert observed-frame wavelengths to rest-frame. Most forms ignore it. Default0.0.
- Returns:
- Array
Continuum flux at each wavelength.
- Parameters:
- integrate(edges, center, params, obs_low, obs_high, lsf_fwhm=0.0, z_sys=0.0)[source]¶
Cumulative continuum integral evaluated at edges.
jnp.diffover the returned array (then divided by pixel widths) gives the pixel-averaged continuum. The default implementation is a midpoint-rule cumulative sum viaevaluate(), which is exact for forms that vary linearly across a pixel (e.g.Linear) and a reasonable approximation otherwise. Polynomial-based forms override this method to use the exact antiderivative.- Return type:
- Parameters:
- edgesArrayLike, shape
(E,) Pixel edges (observed frame, canonical wavelength unit).
- centerfloat
Region midpoint in observed frame.
- paramsdict of str to ArrayLike
Parameter values keyed by
param_names().- obs_lowfloat
Lower observed-frame wavelength bound of the region.
- obs_highfloat
Upper observed-frame wavelength bound of the region.
- lsf_fwhmArrayLike, optional
LSF FWHM scalar for the region; polynomial-based forms apply it via the analytic Gaussian-moment convolution. Default
0.0means no LSF convolution.- z_sysfloat, optional
Systemic redshift; passed through to
evaluate(). Default0.0.
- edgesArrayLike, shape
- Returns:
- Array, shape
(E,) Cumulative continuum integral at the edges.
- Array, shape
- Parameters:
- class unite.continuum.library.BSpline(knots, degree=3)[source]¶
Bases:
ContinuumFormB-spline continuum with local knot control.
The knot vector must be set via knots at construction time (typically derived from the wavelength coverage of the spectrum). Knots should be in the same wavelength unit as the
ContinuumRegionbounds; they are converted to the canonical unit at region construction time via_prepare(). Knots must fall within the region bounds.The continuum is normalized so that it equals
scaleatnorm_wav, parameterized asscale * S(u) / S(u_nw)whereSis the B-spline series with first coefficient fixed at 1.0, andu_nwis the normalized coordinate atnorm_wav.- Parameters:
- knotsu.Quantity
Knot vector in wavelength units. It is automatically clamped at the region bounds.
- degreeint
Spline degree (default 3 for cubic).
- Parameters:
knots (u.Quantity)
degree (int)
Notes
Model parameters (sampled with priors, overridable via
ContinuumRegion(params={...})):scale— Continuum level atnorm_wav. Default prior:Uniform(0, 10).coeff_1, coeff_2, …— Remaining B-spline coefficients (normalized to first 1.0). Default prior:Uniform(-10, 10)each.norm_wav— Reference wavelength. Default prior:Fixed(region_center).
- property is_linear: bool¶
Whether the form is linear in its fitted parameters.
Linear forms can be solved exactly via weighted least squares. Nonlinear forms require iterative solvers (e.g. Gauss-Newton).
- Returns:
- bool
- default_priors(region_center=1.0)[source]¶
Return sensible default priors for each parameter.
The keys must match
param_names().
- param_units(flux_unit, wl_unit)[source]¶
Physical unit mapping for each parameter.
- Return type:
- Parameters:
- flux_unitastropy.units.UnitBase
Flux density unit of the spectrum (e.g.
u.Unit('erg s-1 cm-2 AA-1')).- wl_unitastropy.units.UnitBase
Canonical wavelength unit (e.g.
u.um).
- Returns:
- dict of str to (bool, unit)
For each parameter name:
(apply_continuum_scale, physical_unit). Ifapply_continuum_scaleisTrue, multiply the sampled value bycontinuum_scaleto recover the physical quantity.physical_unitis the resulting astropy unit, orNonefor dimensionless parameters.
- Parameters:
- evaluate(wavelength, center, params, obs_low, obs_high, lsf_fwhm=0.0, z_sys=0.0)[source]¶
Evaluate the (optionally LSF-convolved) continuum model.
All operations must use
jax.numpyso the function is compatible with JAX tracing / JIT compilation.- Return type:
- Parameters:
- wavelengthArrayLike
Wavelength array (observed frame).
- centerfloat
Region midpoint in observed frame (passed for convenience; forms use
params['norm_wav']instead).- paramsdict of str to ArrayLike
Parameter values keyed by
param_names().params['norm_wav']is already in observed frame (the model applies the systemic redshift before calling this method).- obs_lowfloat
Lower observed-frame wavelength bound of the region.
- obs_highfloat
Upper observed-frame wavelength bound of the region.
- lsf_fwhmArrayLike, optional
LSF FWHM at each wavelength point (same unit as wavelength). Default
0.0means no LSF convolution.- z_sysfloat, optional
Systemic redshift of the source. Forms that evaluate in rest-frame (e.g.
Template) use this to convert observed-frame wavelengths to rest-frame. Most forms ignore it. Default0.0.
- Returns:
- Array
Continuum flux at each wavelength.
- Parameters:
- class unite.continuum.library.Bernstein(degree=4, stretch=1.0)[source]¶
Bases:
ContinuumFormGlobal Bernstein polynomial continuum, normalized at a reference wavelength.
Evaluates a Bernstein series on coordinates normalized to
[0, 1]within the continuum region, normalized so that the continuum equalsscaleatnorm_wav.The wavelength range is derived from the region bounds passed to
evaluate(), normalized to[0, 1]for the Bernstein basis. Thestretchparameter optionally scales the region normalization.The continuum is parameterized as
scale * B(t) / B(t_nw)whereBis the Bernstein series with first term fixed at 1.0, andt_nwis the normalized coordinate atnorm_wav.- Parameters:
- degreeint
Polynomial degree (default 4). Number of coefficients = degree + 1.
- stretchfloat
Stretch factor to scale the region normalization (default 1.0).
- Parameters:
Notes
Model parameters (sampled with priors, overridable via
ContinuumRegion(params={...})):scale— Continuum level atnorm_wav. Default prior:Uniform(0, 10).coeff_1, coeff_2, …— Remaining Bernstein coefficients (normalized to first term 1.0). Default prior:Uniform(-10, 10)each.norm_wav— Reference wavelength. Default prior:Fixed(region_center).
- property is_linear: bool¶
Whether the form is linear in its fitted parameters.
Linear forms can be solved exactly via weighted least squares. Nonlinear forms require iterative solvers (e.g. Gauss-Newton).
- Returns:
- bool
- default_priors(region_center=1.0)[source]¶
Return sensible default priors for each parameter.
The keys must match
param_names().
- param_units(flux_unit, wl_unit)[source]¶
Physical unit mapping for each parameter.
- Return type:
- Parameters:
- flux_unitastropy.units.UnitBase
Flux density unit of the spectrum (e.g.
u.Unit('erg s-1 cm-2 AA-1')).- wl_unitastropy.units.UnitBase
Canonical wavelength unit (e.g.
u.um).
- Returns:
- dict of str to (bool, unit)
For each parameter name:
(apply_continuum_scale, physical_unit). Ifapply_continuum_scaleisTrue, multiply the sampled value bycontinuum_scaleto recover the physical quantity.physical_unitis the resulting astropy unit, orNonefor dimensionless parameters.
- Parameters:
- evaluate(wavelength, center, params, obs_low, obs_high, lsf_fwhm=0.0, z_sys=0.0)[source]¶
Evaluate the (optionally LSF-convolved) continuum model.
All operations must use
jax.numpyso the function is compatible with JAX tracing / JIT compilation.- Return type:
- Parameters:
- wavelengthArrayLike
Wavelength array (observed frame).
- centerfloat
Region midpoint in observed frame (passed for convenience; forms use
params['norm_wav']instead).- paramsdict of str to ArrayLike
Parameter values keyed by
param_names().params['norm_wav']is already in observed frame (the model applies the systemic redshift before calling this method).- obs_lowfloat
Lower observed-frame wavelength bound of the region.
- obs_highfloat
Upper observed-frame wavelength bound of the region.
- lsf_fwhmArrayLike, optional
LSF FWHM at each wavelength point (same unit as wavelength). Default
0.0means no LSF convolution.- z_sysfloat, optional
Systemic redshift of the source. Forms that evaluate in rest-frame (e.g.
Template) use this to convert observed-frame wavelengths to rest-frame. Most forms ignore it. Default0.0.
- Returns:
- Array
Continuum flux at each wavelength.
- Parameters:
- integrate(edges, center, params, obs_low, obs_high, lsf_fwhm=0.0, z_sys=0.0)[source]¶
Cumulative continuum integral evaluated at edges.
jnp.diffover the returned array (then divided by pixel widths) gives the pixel-averaged continuum. The default implementation is a midpoint-rule cumulative sum viaevaluate(), which is exact for forms that vary linearly across a pixel (e.g.Linear) and a reasonable approximation otherwise. Polynomial-based forms override this method to use the exact antiderivative.- Return type:
- Parameters:
- edgesArrayLike, shape
(E,) Pixel edges (observed frame, canonical wavelength unit).
- centerfloat
Region midpoint in observed frame.
- paramsdict of str to ArrayLike
Parameter values keyed by
param_names().- obs_lowfloat
Lower observed-frame wavelength bound of the region.
- obs_highfloat
Upper observed-frame wavelength bound of the region.
- lsf_fwhmArrayLike, optional
LSF FWHM scalar for the region; polynomial-based forms apply it via the analytic Gaussian-moment convolution. Default
0.0means no LSF convolution.- z_sysfloat, optional
Systemic redshift; passed through to
evaluate(). Default0.0.
- edgesArrayLike, shape
- Returns:
- Array, shape
(E,) Cumulative continuum integral at the edges.
- Array, shape
- Parameters:
- class unite.continuum.library.PowerLaw[source]¶
Bases:
ContinuumFormPower-law continuum:
scale * (wavelength / norm_wav) ** beta.This form has no constructor parameters.
To share a consistent reference wavelength across multiple regions (required for physically meaningful parameter sharing), pass a
ContinuumNormalizationWavelengthwithFixed(value)carrying your chosen reference wavelength.Notes
Model parameters (sampled with priors, overridable via
ContinuumRegion(params={...})):scale— Continuum level atnorm_wav. Default prior:Uniform(0, 10).beta— Power-law index (dimensionless). Default prior:Uniform(-5, 5).norm_wav— Reference wavelength. Default prior:Fixed(region_center).
- default_priors(region_center=1.0)[source]¶
Return sensible default priors for each parameter.
The keys must match
param_names().
- param_units(flux_unit, wl_unit)[source]¶
Physical unit mapping for each parameter.
- Return type:
- Parameters:
- flux_unitastropy.units.UnitBase
Flux density unit of the spectrum (e.g.
u.Unit('erg s-1 cm-2 AA-1')).- wl_unitastropy.units.UnitBase
Canonical wavelength unit (e.g.
u.um).
- Returns:
- dict of str to (bool, unit)
For each parameter name:
(apply_continuum_scale, physical_unit). Ifapply_continuum_scaleisTrue, multiply the sampled value bycontinuum_scaleto recover the physical quantity.physical_unitis the resulting astropy unit, orNonefor dimensionless parameters.
- Parameters:
- evaluate(wavelength, center, params, obs_low, obs_high, lsf_fwhm=0.0, z_sys=0.0)[source]¶
Evaluate the (optionally LSF-convolved) continuum model.
All operations must use
jax.numpyso the function is compatible with JAX tracing / JIT compilation.- Return type:
- Parameters:
- wavelengthArrayLike
Wavelength array (observed frame).
- centerfloat
Region midpoint in observed frame (passed for convenience; forms use
params['norm_wav']instead).- paramsdict of str to ArrayLike
Parameter values keyed by
param_names().params['norm_wav']is already in observed frame (the model applies the systemic redshift before calling this method).- obs_lowfloat
Lower observed-frame wavelength bound of the region.
- obs_highfloat
Upper observed-frame wavelength bound of the region.
- lsf_fwhmArrayLike, optional
LSF FWHM at each wavelength point (same unit as wavelength). Default
0.0means no LSF convolution.- z_sysfloat, optional
Systemic redshift of the source. Forms that evaluate in rest-frame (e.g.
Template) use this to convert observed-frame wavelengths to rest-frame. Most forms ignore it. Default0.0.
- Returns:
- Array
Continuum flux at each wavelength.
- Parameters:
- integrate(edges, center, params, obs_low, obs_high, lsf_fwhm=0.0, z_sys=0.0)[source]¶
Cumulative continuum integral evaluated at edges.
jnp.diffover the returned array (then divided by pixel widths) gives the pixel-averaged continuum. The default implementation is a midpoint-rule cumulative sum viaevaluate(), which is exact for forms that vary linearly across a pixel (e.g.Linear) and a reasonable approximation otherwise. Polynomial-based forms override this method to use the exact antiderivative.- Return type:
- Parameters:
- edgesArrayLike, shape
(E,) Pixel edges (observed frame, canonical wavelength unit).
- centerfloat
Region midpoint in observed frame.
- paramsdict of str to ArrayLike
Parameter values keyed by
param_names().- obs_lowfloat
Lower observed-frame wavelength bound of the region.
- obs_highfloat
Upper observed-frame wavelength bound of the region.
- lsf_fwhmArrayLike, optional
LSF FWHM scalar for the region; polynomial-based forms apply it via the analytic Gaussian-moment convolution. Default
0.0means no LSF convolution.- z_sysfloat, optional
Systemic redshift; passed through to
evaluate(). Default0.0.
- edgesArrayLike, shape
- Returns:
- Array, shape
(E,) Cumulative continuum integral at the edges.
- Array, shape
- Parameters:
- class unite.continuum.library.Blackbody[source]¶
Bases:
ContinuumFormPlanck blackbody continuum normalized at a reference wavelength.
Evaluates
scale * B_λ(T) / B_λ(norm_wav, T)so that scale directly represents the continuum flux atnorm_wav. Wavelength parameters may be in any unit; automatic unit conversion to microns is applied internally.norm_wavis a named parameter with a defaultFixed(region_center)prior. Pass an explicitContinuumNormalizationWavelengthwithFixed(value)to pin it to a specific wavelength across multiple regions — essential for physically consistent normalization when fitting a single blackbody across disjoint spectral windows.This form has no constructor parameters.
Notes
Model parameters (sampled with priors, overridable via
ContinuumRegion(params={...})):scale— Continuum flux atnorm_wav(in units ofcontinuum_scale). Default prior:Uniform(0, 10).temperature— Blackbody temperature in Kelvin. Default prior:Uniform(100, 50000).norm_wav— Reference wavelength. Default prior:Fixed(region_center).
- default_priors(region_center=1.0)[source]¶
Return sensible default priors for each parameter.
The keys must match
param_names().
- param_units(flux_unit, wl_unit)[source]¶
Physical unit mapping for each parameter.
- Return type:
- Parameters:
- flux_unitastropy.units.UnitBase
Flux density unit of the spectrum (e.g.
u.Unit('erg s-1 cm-2 AA-1')).- wl_unitastropy.units.UnitBase
Canonical wavelength unit (e.g.
u.um).
- Returns:
- dict of str to (bool, unit)
For each parameter name:
(apply_continuum_scale, physical_unit). Ifapply_continuum_scaleisTrue, multiply the sampled value bycontinuum_scaleto recover the physical quantity.physical_unitis the resulting astropy unit, orNonefor dimensionless parameters.
- Parameters:
- evaluate(wavelength, center, params, obs_low, obs_high, lsf_fwhm=0.0, z_sys=0.0)[source]¶
Evaluate the (optionally LSF-convolved) continuum model.
All operations must use
jax.numpyso the function is compatible with JAX tracing / JIT compilation.- Return type:
- Parameters:
- wavelengthArrayLike
Wavelength array (observed frame).
- centerfloat
Region midpoint in observed frame (passed for convenience; forms use
params['norm_wav']instead).- paramsdict of str to ArrayLike
Parameter values keyed by
param_names().params['norm_wav']is already in observed frame (the model applies the systemic redshift before calling this method).- obs_lowfloat
Lower observed-frame wavelength bound of the region.
- obs_highfloat
Upper observed-frame wavelength bound of the region.
- lsf_fwhmArrayLike, optional
LSF FWHM at each wavelength point (same unit as wavelength). Default
0.0means no LSF convolution.- z_sysfloat, optional
Systemic redshift of the source. Forms that evaluate in rest-frame (e.g.
Template) use this to convert observed-frame wavelengths to rest-frame. Most forms ignore it. Default0.0.
- Returns:
- Array
Continuum flux at each wavelength.
- Parameters:
- class unite.continuum.library.ModifiedBlackbody[source]¶
Bases:
ContinuumFormModified blackbody:
scale * B_λ(T) * (λ / norm_wav)^beta / B_λ(nw, T).The power-law modifier beta broadens (beta > 0) or narrows (beta < 0) the SED relative to a pure blackbody. beta = 0 recovers
Blackbody. Wavelength parameters may be in any unit; automatic unit conversion to microns is applied internally.norm_wavis a named parameter with a defaultFixed(region_center)prior. Share aContinuumNormalizationWavelengthtoken across regions to enforce a consistent reference wavelength.This form has no constructor parameters.
Notes
Model parameters (sampled with priors, overridable via
ContinuumRegion(params={...})):scale— Continuum flux atnorm_wav(in units ofcontinuum_scale). Default prior:Uniform(0, 10).temperature— Blackbody temperature in Kelvin. Default prior:Uniform(100, 50000).beta— Power-law modifier index (dimensionless). Default prior:Uniform(-4, 4).norm_wav— Reference wavelength. Default prior:Fixed(region_center).
- default_priors(region_center=1.0)[source]¶
Return sensible default priors for each parameter.
The keys must match
param_names().
- param_units(flux_unit, wl_unit)[source]¶
Physical unit mapping for each parameter.
- Return type:
- Parameters:
- flux_unitastropy.units.UnitBase
Flux density unit of the spectrum (e.g.
u.Unit('erg s-1 cm-2 AA-1')).- wl_unitastropy.units.UnitBase
Canonical wavelength unit (e.g.
u.um).
- Returns:
- dict of str to (bool, unit)
For each parameter name:
(apply_continuum_scale, physical_unit). Ifapply_continuum_scaleisTrue, multiply the sampled value bycontinuum_scaleto recover the physical quantity.physical_unitis the resulting astropy unit, orNonefor dimensionless parameters.
- Parameters:
- evaluate(wavelength, center, params, obs_low, obs_high, lsf_fwhm=0.0, z_sys=0.0)[source]¶
Evaluate the (optionally LSF-convolved) continuum model.
All operations must use
jax.numpyso the function is compatible with JAX tracing / JIT compilation.- Return type:
- Parameters:
- wavelengthArrayLike
Wavelength array (observed frame).
- centerfloat
Region midpoint in observed frame (passed for convenience; forms use
params['norm_wav']instead).- paramsdict of str to ArrayLike
Parameter values keyed by
param_names().params['norm_wav']is already in observed frame (the model applies the systemic redshift before calling this method).- obs_lowfloat
Lower observed-frame wavelength bound of the region.
- obs_highfloat
Upper observed-frame wavelength bound of the region.
- lsf_fwhmArrayLike, optional
LSF FWHM at each wavelength point (same unit as wavelength). Default
0.0means no LSF convolution.- z_sysfloat, optional
Systemic redshift of the source. Forms that evaluate in rest-frame (e.g.
Template) use this to convert observed-frame wavelengths to rest-frame. Most forms ignore it. Default0.0.
- Returns:
- Array
Continuum flux at each wavelength.
- Parameters:
- class unite.continuum.library.AttenuatedBlackbody(lambda_ext=<Quantity 5500. Angstrom>)[source]¶
Bases:
ContinuumFormDust-attenuated blackbody continuum.
Evaluates
scale * B_λ(T) / B_λ(nw,T) * exp(-tau_v * [(λ/lambda_ext)^alpha - (nw/lambda_ext)^alpha]).Extinction is normalized at
norm_wavso that scale represents the observed (attenuated) flux there. Negative alpha gives steeper extinction at short wavelengths (typical dust law). Wavelength parameters may be in any unit; automatic unit conversion to microns is applied internally.- Parameters:
- lambda_extastropy.units.Quantity
Reference wavelength for the extinction law. Must be
Quantitywith any length unit — it will be converted automatically. Defaults to5500 * u.AA.
- Parameters:
lambda_ext (u.Quantity)
Notes
lambda_extis a static configuration parameter (not sampled). It is stored in microns internally and, along with evaluation wavelengths, automatically converted at model-build time via_prepare().Model parameters (sampled with priors, overridable via
ContinuumRegion(params={...})):scale— Observed continuum flux atnorm_wav(in units ofcontinuum_scale). Default prior:Uniform(0, 10).temperature— Blackbody temperature in Kelvin. Default prior:Uniform(100, 50000).tau_v— Optical depth atlambda_ext. Default prior:Uniform(0, 5).alpha— Dust extinction power-law index (negative = steeper at short λ). Default prior:Uniform(-2, 0).norm_wav— Reference wavelength. Default prior:Fixed(region_center).
- default_priors(region_center=1.0)[source]¶
Return sensible default priors for each parameter.
The keys must match
param_names().
- param_units(flux_unit, wl_unit)[source]¶
Physical unit mapping for each parameter.
- Return type:
- Parameters:
- flux_unitastropy.units.UnitBase
Flux density unit of the spectrum (e.g.
u.Unit('erg s-1 cm-2 AA-1')).- wl_unitastropy.units.UnitBase
Canonical wavelength unit (e.g.
u.um).
- Returns:
- dict of str to (bool, unit)
For each parameter name:
(apply_continuum_scale, physical_unit). Ifapply_continuum_scaleisTrue, multiply the sampled value bycontinuum_scaleto recover the physical quantity.physical_unitis the resulting astropy unit, orNonefor dimensionless parameters.
- Parameters:
- evaluate(wavelength, center, params, obs_low, obs_high, lsf_fwhm=0.0, z_sys=0.0)[source]¶
Evaluate the (optionally LSF-convolved) continuum model.
All operations must use
jax.numpyso the function is compatible with JAX tracing / JIT compilation.- Return type:
- Parameters:
- wavelengthArrayLike
Wavelength array (observed frame).
- centerfloat
Region midpoint in observed frame (passed for convenience; forms use
params['norm_wav']instead).- paramsdict of str to ArrayLike
Parameter values keyed by
param_names().params['norm_wav']is already in observed frame (the model applies the systemic redshift before calling this method).- obs_lowfloat
Lower observed-frame wavelength bound of the region.
- obs_highfloat
Upper observed-frame wavelength bound of the region.
- lsf_fwhmArrayLike, optional
LSF FWHM at each wavelength point (same unit as wavelength). Default
0.0means no LSF convolution.- z_sysfloat, optional
Systemic redshift of the source. Forms that evaluate in rest-frame (e.g.
Template) use this to convert observed-frame wavelengths to rest-frame. Most forms ignore it. Default0.0.
- Returns:
- Array
Continuum flux at each wavelength.
- Parameters:
- class unite.continuum.library.Template(path, *, wavelength_colname=None, usecols=None)[source]¶
Bases:
ContinuumFormInterpolated spectral template continuum.
Loads one or more template spectra from a file readable by
astropy.table.Table.read(). The file must contain a wavelength column (identified by its physical unit) and one or more flux columns. Each flux column becomes a separate scale parameter named{column}_scale.The template is evaluated by linearly interpolating each column in the rest frame and normalising so that
{col}_scaleequals the flux atnorm_wav:F(λ) = Σ_i {col_i}_scale * T_i(λ_rest) / T_i(norm_wav_rest)where
λ_rest = λ_obs / (1 + z_sys).- Parameters:
- pathstr or Path
Path to the template file. Any format supported by
read()is accepted (FITS, ECSV, …).- wavelength_colnamestr, optional
Name of the wavelength column. If omitted, the column whose unit has
physical_type == 'length'is used; raises if the result is ambiguous.- usecolslist or tuple of str, optional
Flux columns to load. Defaults to all non-wavelength columns. Raises if any requested column is absent.
- Parameters:
Notes
The wavelength column must carry an astropy unit with
physical_type == 'length'. Flux columns without units, or with units that are not spectral flux density (f_lambda), produce aUserWarningbut are still accepted.Model parameters (sampled with priors, overridable via
ContinuumRegion(params={...})):{col}_scale— Template amplitude atnorm_wav, one per column. Default prior:Uniform(0, 2).norm_wav— Rest-frame reference wavelength (shared across all columns). Default prior:Fixed(region_center_rest).
LSF convolution behaviour:
In analytic mode the
lsf_fwhmargument is ignored — the template returns raw interpolated values with no convolution applied. In convolution mode (integration_mode='convolution') the full numerical LSF kernel is applied externally by the model, but the kernel assumes the template is intrinsically unresolved. Templates that already carry native spectral resolution (e.g. stellar population models convolved to a library resolution) will be further broadened by the instrument LSF, producing an effective resolution equal to the convolution of both. Use a template whose native resolution is well below the instrument LSF, or deconvolve it beforehand, to avoid over-convolution.- default_priors(region_center=1.0)[source]¶
Return sensible default priors for each parameter.
The keys must match
param_names().
- param_units(flux_unit, wl_unit)[source]¶
Physical unit mapping for each parameter.
- Return type:
- Parameters:
- flux_unitastropy.units.UnitBase
Flux density unit of the spectrum (e.g.
u.Unit('erg s-1 cm-2 AA-1')).- wl_unitastropy.units.UnitBase
Canonical wavelength unit (e.g.
u.um).
- Returns:
- dict of str to (bool, unit)
For each parameter name:
(apply_continuum_scale, physical_unit). Ifapply_continuum_scaleisTrue, multiply the sampled value bycontinuum_scaleto recover the physical quantity.physical_unitis the resulting astropy unit, orNonefor dimensionless parameters.
- Parameters:
- evaluate(wavelength, center, params, obs_low, obs_high, lsf_fwhm=0.0, z_sys=0.0)[source]¶
Evaluate the (optionally LSF-convolved) continuum model.
All operations must use
jax.numpyso the function is compatible with JAX tracing / JIT compilation.- Return type:
- Parameters:
- wavelengthArrayLike
Wavelength array (observed frame).
- centerfloat
Region midpoint in observed frame (passed for convenience; forms use
params['norm_wav']instead).- paramsdict of str to ArrayLike
Parameter values keyed by
param_names().params['norm_wav']is already in observed frame (the model applies the systemic redshift before calling this method).- obs_lowfloat
Lower observed-frame wavelength bound of the region.
- obs_highfloat
Upper observed-frame wavelength bound of the region.
- lsf_fwhmArrayLike, optional
LSF FWHM at each wavelength point (same unit as wavelength). Default
0.0means no LSF convolution.- z_sysfloat, optional
Systemic redshift of the source. Forms that evaluate in rest-frame (e.g.
Template) use this to convert observed-frame wavelengths to rest-frame. Most forms ignore it. Default0.0.
- Returns:
- Array
Continuum flux at each wavelength.
- Parameters:
Continuum Functions¶
JAX-jitted continuum evaluation kernels.
All functions are pure JAX with no numpyro dependency and are designed to
be called from within jax.jit()-compiled model code.
- unite.continuum.functions.planck_function(wavelength_micron, temperature_k, pivot_micron)[source]¶
Return the normalized Planck function
B_λ(T) / B_λ(pivot, T).Returns the blackbody spectral radiance normalized to unity at pivot_micron, so the fitted amplitude directly represents the observed flux at the pivot wavelength.
- Return type:
- Parameters:
- wavelength_micronArrayLike
Rest-frame wavelengths in microns.
- temperature_kArrayLike
Temperature in Kelvin.
- pivot_micronfloat
Normalization wavelength in microns.
- Returns:
- Array
Normalized Planck function (= 1 at pivot_micron).
- Parameters:
Notes
Physical constants are pre-combined to avoid gradient overflow in JAX when differentiating
exp(hc / λkT)with respect to temperature.
- unite.continuum.functions.chebval(x, coeffs)[source]¶
Evaluate a Chebyshev series using the trigonometric identity.
- Return type:
- Parameters:
- xArrayLike
Evaluation points, normalized to
[-1, 1].- coeffslist of ArrayLike
Chebyshev coefficients
[c0, c1, ..., cN].
- Returns:
- Array
Series value at each point in x.
- Parameters:
- unite.continuum.functions.bernstein_eval(x, coeffs, binom_coeffs)[source]¶
Evaluate a Bernstein polynomial series using a vectorized basis matrix.
- Parameters:
- xArrayLike
Evaluation points, must be normalized to the range [0, 1]. Shape: (N,).
- coeffsArrayLike
Bernstein coefficients (control points). Shape: (n + 1,).
- binom_coeffsArrayLike
Pre-computed binomial coefficients for degree n, where binom_coeffs[i] = C(n, i). Shape: (n + 1,).
- Returns:
- Array
The evaluated polynomial values at each point in x. Shape: (N,).
- unite.continuum.functions.bspline_basis(t, knots, degree)[source]¶
Compute the B-spline basis matrix via iterative Cox-de Boor recursion.
The Python loop over degree is unrolled at JAX trace time because degree is a concrete
int, not a traced value.- Return type:
- Parameters:
- tArrayLike
Evaluation points, shape
(N,).- knotsArrayLike
Clamped knot vector, shape
(M,).- degreeint
Spline degree (e.g. 3 for cubic).
- Returns:
- Array
Basis matrix, shape
(N, n_basis)wheren_basis = M - degree - 1.
- Parameters:
- unite.continuum.functions.bspline_eval(wavelength, coeffs, knots, degree)[source]¶
Evaluate a B-spline continuum model.
- Return type:
- Parameters:
- wavelengthArrayLike
Wavelength values, shape
(N,).- coeffsArrayLike
B-spline coefficients, shape
(n_basis,).- knotsArrayLike
Clamped knot vector.
- degreeint
Spline degree (static for JIT).
- Returns:
- Array
Continuum flux, shape
(N,).
- Parameters: