Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if not HAS_SCIPY:
raise ImportError('To use this function scipy needs to be installed')
from scipy.interpolate import spleval
wave_shape = wave.shape
wave = _process_wave(wave)
_check_wave(wave, 909.091* u.angstrom, 6. * u.micron)
res = np.empty_like(wave.__array__(), dtype=np.float64)
# Analytic function in the UV.
uvmask = wave < (2700. * u.angstrom)
if np.any(uvmask):
res[uvmask] = cextinction.f99uv(wave[uvmask].value, self.a_v, self.r_v) * wave.unit
# Spline in the Optical/IR
oirmask = ~uvmask
if np.any(oirmask):
k = spleval(self._spline, 1. / wave[oirmask].to('micron'))
res[oirmask] = self.a_v / self.r_v * (k + self.r_v)
return res.reshape(wave_shape)
not connect smoothly with longer and shorter wavelengths, it is
not included here.
References
----------
.. [1] Cardelli, J. A., Clayton, G. C., & Mathis, J. S. 1989, ApJ, 345, 245
.. [2] O'Donnell, J. E. 1994, ApJ, 422, 158O
.. [3] Savage & Mathis 1979, ARA&A, 17, 73
.. [4] Longo et al. 1989, ApJ, 339,474
.. [5] Valencic et al. 2004, ApJ, 616, 912
"""
_check_wave(wave, 909.091 * u.angstrom, 33333.333 * u.angstrom)
res = cextinction.od94(_process_wave(wave).value, a_v, r_v) * wave.unit
return res.reshape(wave.shape)
References
----------
.. [1] Fitzpatrick, E. L. 1999, PASP, 111, 63
.. [2] Fitzpatrick, E. L. & Massa, D. 1990, ApJS, 72, 163
"""
f = ExtinctionF99(a_v, r_v)
return f(wave)
# fm07 knots for spline
_fm07_r_v = 3.1
_fm07_xknots = np.array([0., 0.25, 0.50, 0.75, 1., 1.e4/5530., 1.e4/4000.,
1.e4/3300., 1.e4/2700., 1.e4/2600.])
_fm07_kknots = cextinction.fm07kknots(_fm07_xknots)
try:
from scipy.interpolate import splmake
_fm07_spline = splmake(_fm07_xknots, _fm07_kknots, order=3)
except ImportError:
pass
def extinction_fm07(wave, a_v):
"""Fitzpatrick & Massa (2007) extinction model for R_V = 3.1.
The Fitzpatrick & Massa (2007) [1]_ model, which has a slightly
different functional form from that of Fitzpatrick (1999) [3]_
(`extinction_f99`). Fitzpatrick & Massa (2007) claim it is
preferable, although it is unclear if signficantly so (Gordon et
al. 2009 [2]_). Defined from 910 A to 6 microns.
def __init__(self, a_v, r_v=3.1):
if not HAS_SCIPY:
raise ImportError('To use this function scipy needs to be installed')
from scipy.interpolate import splmake
self.a_v = a_v
self.r_v = r_v
kknots = cextinction.f99kknots(_f99_xknots, self.r_v)
self._spline = splmake(_f99_xknots, kknots, order=3)
.. math::
A(\lambda) = A_V (a(x) + b(x) / R_V)
where A_V can either be specified directly or via E(B-V)
(by defintion, A_V = R_V * E(B-V)).
References
----------
.. [1] Cardelli, J. A., Clayton, G. C., & Mathis, J. S. 1989, ApJ, 345, 245
"""
_check_wave(wave, 909.091 * u.angstrom, 33333.333 * u.angstrom)
res = cextinction.ccm89(_process_wave(wave).value, a_v, r_v) * wave.unit
return res.reshape(wave.shape)