uvex_transients.dust.log_attenuation#
- uvex_transients.dust.log_attenuation(nu: Quantity, Ebv: float | Quantity | NDArray[float64], dust_law: str | None = None) NDArray[float64][source]#
Natural log of the Milky Way foreground attenuation, \(\ln(10^{-0.4\,A(\nu)})\), at
nu.Takes an already-resolved E(B-V) – resolving one from a dust map and a sky position is a separate, prior step (resolve_ebv), deliberately kept out of this function: fixing
Ebv’s shape once, up front, is what lets this stay a single, fully vectorized computation (no per-position or per-frequency Python loop, and, unlike building a ~synphot.SpectralElement per position, no repeated ~astropy.modeling.Model construction either) – the reddening law’s dimensionless shape \(A(\nu)/A(V)\) is evaluated once at everynusample (shape(K,)), and combined withEbv(shapeS) by plain numpy broadcasting into a result of shapeS + (K,).Add this directly to a ~uvex_transients.models.core.base.SpectralModel flux calculation’s log flux (its
log_attenuationkeyword) – e.g., having already calledebv = resolve_ebv(dust_map(), coord)once,model.flux_log(nu, t, ..., log_attenuation=log_attenuation(nu, ebv))– rather than multiplying a linear transmission fraction in, since everything on that side is already computed in log space.SpectralModel.as_source_spectrum/as_astropy_model take the same shape one level removed, as a callable (their wavelength grid isn’t known until the resulting ~synphot.SourceSpectrum is actually called): use attenuation_callable rather than binding this function yourself, e.g.
model.as_source_spectrum(t, ..., log_attenuation=attenuation_callable(ebv)).- Parameters:
nu (
Quantity) – Frequency(ies) (or frequency-equivalent, e.g. wavelength) to evaluate the reddening law at, any shape(K,)(or scalar, in which case the trailing frequency axis below is squeezed away).Ebv (
float,Quantity, ornumpy.ndarray) – Already-resolved, dimensionless \(E(B-V)\), any shapeS– see resolve_ebv for turning a dust map + sky position into this.dust_law (
str, optional) – Passed through to get_dust_law;None(the default) uses the configured default reddening law.
- Returns:
Natural log of the dimensionless attenuation,
NaNwherevernufalls outside the reddening law’s native range (roughly 900 Angstrom to 32 microns for the default, dust_extinction.parameter_averages.G23). ShapeS + (K,), or plainSifnuwas scalar.- Return type: