Skip to content

Commit

Permalink
Merge d7a1b7a into dd752c8
Browse files Browse the repository at this point in the history
  • Loading branch information
karllark committed Mar 15, 2017
2 parents dd752c8 + d7a1b7a commit c9625d1
Showing 1 changed file with 43 additions and 4 deletions.
47 changes: 43 additions & 4 deletions dust_extinction/dust_extinction.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class CCM89(Model):
Returns
-------
elvebv: float
elvebv: np.array(dtype=float)
E(x-V)/E(B-V) extinction curve [mag]
Raises
Expand All @@ -50,8 +50,6 @@ class CCM89(Model):
F99 should be used instead as it is based on 10x more observations
and a better treatment of the optical/NIR photometry based portion
of the curves.
CCM89 is mainly for historical puposes
"""
inputs = ('x',)
outputs = ('elvebv',)
Expand Down Expand Up @@ -146,6 +144,47 @@ def evaluate(in_x, Rv):
a[fuv_indxs] = np.polyval((-.070, .137, -.628, -1.073), y)
b[fuv_indxs] = np.polyval((.374, -.42, 4.257, 13.67), y)

# return Al/Av
# return E(lambda-V)/E(B-V)
return a + b/Rv

def extinguish(self, x, Av=None, Ebv=None):
"""
Calculate the extinction as a fraction
Parameters
----------
x: float
expects either x in units of wavelengths or frequency
or assumes wavelengths in wavenumbers [1/micron]
internally wavenumbers are used
Av: float
A(V) value of dust column
Av or Ebv must be set
Ebv: float
E(B-V) value of dust column
Av or Ebv must be set
Returns
-------
frac_ext: np.array(dtype=float)
extinction as a function of x
"""
# get the extinction curve
elvebv = self(x)

# check that av or ebv is set
if (Av is None) and (Ebv is None):
raise ValueError('neither Av or Ebv passed, one is required')

# if Av is not set and Ebv set, convert to Av
if Av is None:
Av = self.Rv*Ebv

# convert to A(lambda)/A(V)
alav = elvebv/self.Rv + 1

# return fractional extinction
return np.power(10.0,-0.4*alav*Av)

0 comments on commit c9625d1

Please sign in to comment.