Skip to content

torchsky.extinction

Stability: core. Names on this page follow the deprecation policy in contributing.

Milky Way and starburst dust laws on torch tensors.

Guides: extinction, spectral-axes


This reference is generated from the package source. Names are grouped by the module that defines them; import every name from the public namespace torchsky.extinction unless the group text says otherwise.

Top-level namespace

Milky Way and starburst dust laws on torch tensors.

Wavelengths are Angstrom-native internally. Pass wavelength_unit='nm' at the boundary. A(λ) is in magnitudes; transmission is 10**(-0.4 A).

The infrared power law is extrapolated below the CCM89 x=0.3 cutoff so broadband work stays defined into the far-IR. Optical and UV pieces follow Cardelli, Clayton & Mathis (1989); odonnell94 replaces the optical polynomials only.

g23 (Gordon et al. 2023), f19 (Fitzpatrick et al. 2019), and gcc09 (Gordon, Cartledge & Clayton 2009) use the published coefficients as implemented in dust_extinction (K. Gordon, BSD 3-Clause), and fail closed outside their calibrated wavelength and R_V ranges instead of extrapolating.

a_lambda

a_lambda(
    wave: Tensor,
    *,
    ebv: Tensor | float | None = None,
    a_v: Tensor | float | None = None,
    r_v: Tensor | float = 3.1,
    law: ExtinctionLaw = "ccm89",
    wavelength_unit: WavelengthUnit = "angstrom",
) -> Tensor

Extinction in magnitudes at wave.

Supply exactly one of ebv or a_v. A_V = R_V E(B-V).

apply_extinction

apply_extinction(
    flux: Tensor,
    wavelength: Tensor | None = None,
    ext_params: Tensor | None = None,
    extinction_law_name: str = "ccm89",
    r_v: float = 3.1,
    *,
    wavelength_unit: WavelengthUnit = "angstrom",
) -> Tensor

Apply a dust screen: ext_params is E(B-V) broadcast against flux.

Parameters:

Name Type Description Default
flux Tensor

Flux-density tensor with wavelength on the trailing axis.

required
wavelength Tensor | None

Wavelength samples in wavelength_unit.

None
ext_params Tensor | None

Color excess E(B-V), broadcastable against flux.

None
extinction_law_name str

Supported extinction-law name.

'ccm89'
r_v float

Total-to-selective extinction ratio A(V) / E(B-V).

3.1
wavelength_unit WavelengthUnit

"angstrom" or "nm".

'angstrom'

Returns:

Type Description
Tensor

Attenuated flux with the same shape, dtype, and device as flux.

Examples:

>>> import torch
>>> from torchsky.extinction import apply_extinction
>>> apply_extinction(torch.ones(1), torch.tensor([5500.0]), torch.tensor(0.0)).tolist()
[1.0]

calzetti

calzetti(
    wave_angstrom: Tensor,
    a_v: Tensor,
    r_v: Tensor | float | None = None,
    *,
    wavelength_unit: WavelengthUnit = "angstrom",
) -> Tensor

Calzetti (2000) starburst A(λ). Default R_V = 4.05.

calzetti_a_lambda

calzetti_a_lambda(
    wave_angstrom: Tensor, a_v: Tensor, r_v: Tensor
) -> Tensor

Calzetti (2000) A(λ). Default R_V for the law is 4.05.

calzetti_k_ebv

calzetti_k_ebv(
    wave_angstrom: Tensor, r_v: Tensor
) -> Tensor

Calzetti (2000) k(λ) = A(λ)/E(B-V). λ clamped to 0.12–2.20 μm.

ccm89

ccm89(
    wave_angstrom: Tensor,
    a_v: Tensor | float,
    r_v: Tensor | float | None = None,
    *,
    wavelength_unit: WavelengthUnit = "angstrom",
) -> Tensor

CCM89 A(λ) for A_V; wavelengths default to Angstrom.

ccm89_ab

ccm89_ab(x_um_inv: Tensor) -> tuple[Tensor, Tensor]

CCM89 a(x), b(x) for inverse-micron x = 1 / λ_μm.

Regions follow Cardelli, Clayton & Mathis (1989): IR x<1.1 (power law extrapolated below x=0.3), optical 1.1<=x<3.3, UV 3.3<=x<8, far-UV 8<=x<=10. Beyond x=10 the far-UV polynomials are evaluated at the x=10 boundary; the law is not defined there.

f19_a_lambda

f19_a_lambda(
    wave_angstrom: Tensor, a_v: Tensor, r_v: Tensor
) -> Tensor

Fitzpatrick et al. (2019) A(λ); 1150 Å to 3.3 μm, 2 <= R_V <= 6.

F19 is normalized at 5500 Å: a_v and r_v are A(55) and R(55), with k(λ-55) = k_3.02 + 0.990 Δk (R(55) - 3.10).

f99_a_lambda

f99_a_lambda(
    wave_angstrom: Tensor, a_v: Tensor, r_v: Tensor
) -> Tensor

Fitzpatrick (1999) A(λ); wavelengths in Angstrom.

fitzpatrick99

fitzpatrick99(
    wave_angstrom: Tensor,
    a_v: Tensor,
    r_v: Tensor | float | None = None,
    *,
    wavelength_unit: WavelengthUnit = "angstrom",
) -> Tensor

Fitzpatrick (1999) A(λ) for A_V; wavelengths default to Angstrom.

g23_a_lambda

g23_a_lambda(
    wave_angstrom: Tensor, a_v: Tensor, r_v: Tensor
) -> Tensor

Gordon et al. (2023) A(λ); 912 Å to 32 μm, 2.3 <= R_V <= 5.6.

gcc09_a_lambda

gcc09_a_lambda(
    wave_angstrom: Tensor, a_v: Tensor, r_v: Tensor
) -> Tensor

Gordon, Cartledge & Clayton (2009, with 2014 erratum) ultraviolet A(λ).

Defined only for 909-3030 Å (3.3 <= x <= 11) and 2 <= R_V <= 6; the law was not derived for the optical or infrared.

k_lambda

k_lambda(
    wave: Tensor,
    *,
    law: ExtinctionLaw = "ccm89",
    r_v: Tensor | float = 3.1,
    wavelength_unit: WavelengthUnit = "angstrom",
) -> Tensor

Named k(λ) = A(λ)/A_V so k(λ_V) ≈ 1. Host screens use this at λ_rest.

odonnell94

odonnell94(
    wave_angstrom: Tensor,
    a_v: Tensor,
    r_v: Tensor | float | None = None,
    *,
    wavelength_unit: WavelengthUnit = "angstrom",
) -> Tensor

O'Donnell (1994) A(λ) for A_V; wavelengths default to Angstrom.

odonnell94_ab

odonnell94_ab(x_um_inv: Tensor) -> tuple[Tensor, Tensor]

O'Donnell (1994) optical update; CCM89 in UV and IR.

transmission

transmission(
    wave: Tensor,
    ebv: Tensor | float,
    *,
    r_v: Tensor | float = 3.1,
    law: ExtinctionLaw = "ccm89",
    wavelength_unit: WavelengthUnit = "angstrom",
) -> Tensor

Multiplicative flux attenuation 10**(-0.4 A).

A is clamped at zero: a dust screen cannot emit.

Typing

ExtinctionLaw

typing.Literal['ccm89', 'odonnell94', 'odonnell', 'f99', 'fitzpatrick99', 'calzetti', 'g23', 'f19', 'gcc09']

WavelengthUnit

typing.Literal['angstrom', 'nm']