torchsky.redshift¶
Stability: core. Names on this page follow the deprecation policy in contributing.
Sample-wise redshift, velocity kinds, and named spectral dimming.
Guides: 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.redshift unless the group text says otherwise.
Top-level namespace¶
Sample-wise redshift, velocity kinds, and named spectral dimming.
Edge-based flux-conserving Doppler lives in :mod:torchsky.spectral
(relativistic_doppler_shift, metres per second). This module is the
sample-wise companion used by object SEDs and imaging renderers.
Dimming conventions are named because they are not interchangeable:
- :func:
dimming_f_lambda— 1DF_λdensities:F_obs = F_rest / (1+z) - :func:
dimming_tolman_sb— surface brightness: Tolman(1+z)**-4
apply_redshift ¶
apply_redshift(
flux_rest: Tensor,
lambda_rest: Tensor,
velocity_or_z: Tensor,
is_velocity: bool = True,
) -> tuple[Tensor, Tensor]
Shift a sampled rest-frame F_lambda spectrum by velocity or redshift.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
flux_rest
|
Tensor
|
Rest-frame flux density per unit wavelength. |
required |
lambda_rest
|
Tensor
|
Rest-frame wavelength samples. |
required |
velocity_or_z
|
Tensor
|
Radial velocity in km/s or redshift. |
required |
is_velocity
|
bool
|
Interpret |
True
|
Returns:
| Type | Description |
|---|---|
tuple[Tensor, Tensor]
|
Observed-frame flux density and wavelength tensors. |
Examples:
>>> import torch
>>> from torchsky.redshift import apply_redshift
>>> flux, wave = apply_redshift(torch.ones(1), torch.tensor([5000.0]), torch.tensor(0.0))
>>> wave.tolist()
[5000.0]
apply_redshift_f_lambda ¶
apply_redshift_f_lambda(
flux_rest: Tensor,
lambda_rest: Tensor,
one_plus_z: Tensor | float,
) -> tuple[Tensor, Tensor]
Shift a sampled F_λ spectrum: λ' = λ(1+z), F' = F / (1+z).
beta_from_redshift ¶
beta_from_redshift(
z: Tensor, relativistic: bool = True
) -> Tensor
Convert redshift to the dimensionless velocity ratio v / c.
compose_rapidities ¶
compose_rapidities(*zetas: Tensor | float) -> Tensor
Add rapidities. Equivalent to multiplying the (1+z) factors.
convert_velocity_kind ¶
convert_velocity_kind(
value: Tensor,
from_kind: Any,
to_kind: Any,
relativistic: bool = True,
) -> Tensor
Convert values among km/s, redshift, and dimensionless v / c.
dimming_f_lambda ¶
dimming_f_lambda(one_plus_z: Tensor | float) -> Tensor
F_λ density dimming 1 / (1+z).
dimming_tolman_sb ¶
dimming_tolman_sb(one_plus_z: Tensor | float) -> Tensor
Tolman surface-brightness dimming (1+z)**-4.
los_barycentric_beta ¶
los_barycentric_beta(
unit_xyz: Tensor, tt_mjd: Tensor
) -> Tensor
Earth barycentric LOS velocity as β = v/c.
unit_xyz is the ICRS unit vector toward the source. Positive β
means the observer is receding from the source (redshift). USPM uses the
same sign: v_BERV > 0 when the observer recedes. That is
β = -(v_earth · n̂) / c with v_earth from
:func:torchsky.wcs.iau2006.earth_barycentric_velocity_icrs.
one_plus_z_from_beta ¶
one_plus_z_from_beta(
beta: Tensor, relativistic: bool = True
) -> Tensor
1 + z = sqrt((1+b)/(1-b)); requires |b| < 1 when relativistic.
one_plus_z_from_codes ¶
one_plus_z_from_codes(
value: Tensor,
kind_codes: Tensor,
*,
default_kind: Any = V_KIND_KMS,
relativistic: bool = True,
) -> Tensor
Convert per-sample velocity kinds without device-synchronizing branches.
one_plus_z_from_kind ¶
one_plus_z_from_kind(
value: Tensor, kind: Any, relativistic: bool = True
) -> Tensor
Convert values of the specified velocity kind to 1 + z.
one_plus_z_from_redshift ¶
one_plus_z_from_redshift(z: Tensor) -> Tensor
Convert redshift to the wavelength factor 1 + z.
one_plus_z_from_velocity_kms ¶
one_plus_z_from_velocity_kms(
v_kms: Tensor, relativistic: bool = True
) -> Tensor
Convert radial velocity in km/s to the wavelength factor 1 + z.
redshift_from_velocity_kms ¶
redshift_from_velocity_kms(
v_kms: Tensor, relativistic: bool = True
) -> Tensor
Convert radial velocity in km/s to redshift.
shift_ln_wavelength ¶
shift_ln_wavelength(
ln_lambda: Tensor, zeta: Tensor | float
) -> Tensor
ln λ' = ln λ + ζ. Formulation Step 3 is ln λ_topo = ln λ_rest + ζ_sys + ζ_BERV.
shift_wavelength ¶
shift_wavelength(
lambda_rest: Tensor, one_plus_z: Tensor | float
) -> Tensor
λ_obs = λ_rest * (1+z).
velocity_kms_from_redshift ¶
velocity_kms_from_redshift(
z: Tensor, relativistic: bool = True
) -> Tensor
Convert redshift to radial velocity in km/s.
zeta_berv_from_sky ¶
zeta_berv_from_sky(
ra_deg: float, dec_deg: float, tt_mjd: float
) -> float
Approximate line-of-sight BERV rapidity for an explicitly TT epoch.
Convenience scalar wrapper: ICRS sky position plus TT MJD in, rapidity
ζ_BERV = atanh(v_BERV / c) out with the USPM sign convention
(v_BERV > 0: observer receding). A generic MJD without a time scale
is not enough to certify a topocentric correction, so callers must pass
an explicit TT epoch.
zeta_from_redshift ¶
zeta_from_redshift(z: Tensor | float) -> Tensor
Rapidity ζ = ln(1+z). z=0 is zero.
zeta_from_velocity_kms ¶
zeta_from_velocity_kms(v_kms: Tensor | float) -> Tensor
ζ_pec = atanh(v/c) for a line-of-sight velocity in km/s.
Iau2006¶
Sample-wise redshift, velocity kinds, and named spectral dimming.
Edge-based flux-conserving Doppler lives in :mod:torchsky.spectral
(relativistic_doppler_shift, metres per second). This module is the
sample-wise companion used by object SEDs and imaging renderers.
Dimming conventions are named because they are not interchangeable:
- :func:
dimming_f_lambda— 1DF_λdensities:F_obs = F_rest / (1+z) - :func:
dimming_tolman_sb— surface brightness: Tolman(1+z)**-4
earth_barycentric_velocity_icrs ¶
earth_barycentric_velocity_icrs(tt_mjd: Tensor) -> Tensor
Earth barycentric velocity in ICRS, metres per second (ERFA epv00 series).