Convert between magnitude and spectral gradient.

SpectralGradient is a Quantity object with units of percent change per wavelength.

Spectral gradient is with respect to the flux density at a particular wavelength. By convention this is the mean flux between the two filters, assuming the reflectance spectrum is linear with wavelength. Eq. 1 of A’Hearn et al. [R4e2672b58685-ADT84]:

$S = \frac{R(λ1) - R(λ0)}{R(λ1) + R(λ0)} \frac{2}{Δλ}$

Δλ is typically measured in units of 100 nm.

Parameters
valuenumber, Quantity

The value(s).

unitstring, Unit, optional

The unit of the input value. Strings must be parseable by units package.

waveQuantity, optional

Effective wavelengths of the measurement for a solar spectral energy distribution. Required for conversion to other wavelengths.

wave0Quantity, optional

Normalization point. If None, the mean of wave will be assumed.

dtypedtype, optional

See Quantity.

copybool, optional

See Quantity.

References

A’Hearn, Dwek & Tokunaga 1984. Infrared Photometry of Comet Bowell and Other Comets. ApJ 282, 803-806.

Examples

>>> import astropy.units as u
>>> from sbpy.units import hundred_nm
>>> S = SpectralGradient(10 * u.percent / hundred_nm, wave0=5500 * u.AA)
>>> print(S)
10.0 % / 100 nm
>>> from sbpy.units import VEGAmag
>>> from sbpy.photometry import bandpass
>>> V = bandpass('Johnson V')
>>> R = bandpass('Cousins R')
>>> VmR = 15.8 * VEGAmag - 15.3 * VEGAmag
>>> VmR_sun = 0.37 * u.mag
>>> S = SpectralGradient.from_color((V, R), VmR - VmR_sun)
>>> print(S)    # doctest: +FLOAT_CMP
12.29185986266534 % / 100 nm

Methods Summary

 from_color(wfb, color) Initialize from observed color. renormalize(self, wave0) Re-normalize to another wavelength. to_color(self, wfb) Express as a color index.

Methods Documentation

classmethod from_color(wfb, color)[source]

Initialize from observed color.

Parameters
wfbtwo-element Quantity or tuple

Wavelengths, frequencies, or bandpasses of the measurement. If a bandpass, the effective wavelength of a solar spectrum will be used. Bandpasses may be a string (name) or SpectralElement (see filt()).

colorQuantity, optional

Observed color, blue - red for magnitudes, red / blue for linear units. Must be dimensionless and have the solar color removed.

Notes

Computes spectral gradient from color_index. wfb is the blue-ward of the two measurements

$\begin{split}S &= \frac{R(λ1) - R(λ0)}{R(λ1) + R(λ0)} \frac{2}{Δλ} \\ &= \frac{α - 1}{α + 1} \frac{2}{Δλ}\end{split}$

where R(λ) is the reflectivity, and:

\begin{align}\begin{aligned}α = R(λ1) / R(λ0) = 10^{0.4 color_index}\\color_index = Δm - C_{sun}\end{aligned}\end{align}

Δλ is typically expressed in units of 100 nm.

Examples

>>> import astropy.units as u
>>> w = [0.4719, 0.6185] * u.um
>>> S = SpectralGradient.from_color(w, 0.10 * u.mag)
>>> print(S)                            # doctest: +FLOAT_CMP
6.27819572 % / 100 nm
renormalize(self, wave0)[source]

Re-normalize to another wavelength.

The slope is linearly extrapolated to the new normalization point. Requires the wave0 attribute to be defined, see SpectralGradient.

Parameters
wave0Quantity

Wavelength.

Returns

Examples

>>> import astropy.units as u
>>> from sbpy.spectroscopy import SpectralGradient
>>> from sbpy.units import hundred_nm
>>> S1 = SpectralGradient(10 * u.percent / hundred_nm,
...                      wave0=0.55 * u.um)
>>> S2 = S1.renormalize(3.6 * u.um)
>>> print(S2.renormalize(3.6 * u.um))    # doctest: +FLOAT_CMP
2.469135802469136 % / 100 nm
>>> print(S2.wave0)
3.6 um
to_color(self, wfb)[source]

Express as a color index.

Parameters
wfbtwo-element Quantity or tuple

Wavelengths, frequencies, or bandpasses of the measurement. If a bandpass, the effective wavelength of a solar spectrum will be used. Bandpasses may be a string (name) or SpectralElement (see filt()).

Returns
colorQuantity

blue - red color in magnitudes, dimensionless and excludes the solar color.

Notes

Color index is computed from:

$α = \frac{1 + S Δλ / 2}{1 - S * Δλ / 2}$

where S is the spectral gradient at the mean of λ0 and λ1, and:

\begin{align}\begin{aligned}α = R(λ1) / R(λ0) = 10^{0.4 color_index}\\color_index = Δm - C_{sun}\end{aligned}\end{align}

Δλ is typically expressed in units of 100 nm.

Examples

>>> import astropy.units as u
>>> from sbpy.units import hundred_nm
>>> S = SpectralGradient(10 * u.percent / hundred_nm,
...                      wave0=0.55 * u.um)
>>> C = S.to_color((525, 575) * u.nm)
>>> print(C)    # doctest: +FLOAT_CMP
0.05429812423309064 mag