Skip to content

Commit

Permalink
adding RRP89 average
Browse files Browse the repository at this point in the history
  • Loading branch information
karllark committed Feb 19, 2021
1 parent bfafc54 commit 644c18b
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 1 deletion.
3 changes: 3 additions & 0 deletions docs/dust_extinction/choose_model.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Simple Average Curves
These are straightforward averages of observed extinction curves. They are the
simplest models and include models for the MW
(:class:`~dust_extinction.averages.RL85_MWGC`,
:class:`~dust_extinction.averages.RRP89_MWGC`,
:class:`~dust_extinction.averages.B92_MWAvg`,
:class:`~dust_extinction.averages.I05_MWAvg`,
:class:`~dust_extinction.averages.CT06_MWLoc`,
Expand Down Expand Up @@ -44,6 +45,8 @@ Way, the usual average used is R(V) = 3.1.
+--------------+-------------+------------------+--------------+
| RL85_MWGC | 0.08 - 0.8 | 1.25 - 13.0 | MW (GCenter) |
+--------------+-------------+------------------+--------------+
| RRP89_MWGC | 0.08 - 1.25 | 0.8 - 13.0 | MW (GCenter) |
+--------------+-------------+------------------+--------------+
| CT06_MWGC | 0.037 - 0.8 | 1.24 - 27.0 | MW (GCenter) |
+--------------+-------------+------------------+--------------+
| F11_MWGC | 0.05 - 0.8 | 1.28 - 19.1 | MW (GCenter) |
Expand Down
3 changes: 2 additions & 1 deletion docs/dust_extinction/model_flavors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ Average models
import astropy.units as u

from dust_extinction.averages import (RL85_MWGC,
RRP89_MWGC,
I05_MWAvg,
CT06_MWLoc,
CT06_MWGC,
Expand All @@ -73,7 +74,7 @@ Average models
# generate the curves and plot them
x = 1.0 / (np.arange(1.0, 40.0 ,0.1) * u.micron)

models = [RL85_MWGC, I05_MWAvg, CT06_MWLoc, CT06_MWGC,
models = [RL85_MWGC, RRP89_MWGC, I05_MWAvg, CT06_MWLoc, CT06_MWGC,
F11_MWGC]

for cmodel in models:
Expand Down
100 changes: 100 additions & 0 deletions dust_extinction/averages.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

__all__ = [
"RL85_MWGC",
"RRP89_MWGC",
"B92_MWAvg",
"G03_SMCBar",
"G03_LMCAvg",
Expand Down Expand Up @@ -122,6 +123,105 @@ def evaluate(self, in_x):
return f(x)


class RRP89_MWGC(BaseExtModel):
r"""
Reike, Rieke, & Paul (1989) MW Average Extinction Curve
Parameters
----------
None
Raises
------
None
Notes
-----
From Rieke, Rieke, & Paul (1989, ApJ, 336, 752)
Example showing the average curve
.. plot::
:include-source:
import numpy as np
import matplotlib.pyplot as plt
import astropy.units as u
from dust_extinction.averages import RRP89_MWGC
fig, ax = plt.subplots()
# define the extinction model
ext_model = RRP89_MWGC()
# generate the curves and plot them
x = np.arange(1.0/ext_model.x_range[1], 1.0/ext_model.x_range[0], 0.1) * u.micron
ax.plot(x,ext_model(x),label='RRP89_MWGC')
ax.plot(1.0/ext_model.obsdata_x, ext_model.obsdata_axav, 'ko',
label='obsdata')
ax.set_xlabel(r'$\lambda$ [$\mu m$]')
ax.set_ylabel(r'$A(x)/A(V)$')
ax.legend(loc='best')
plt.show()
"""

x_range = [1.0 / 13.0, 1.0 / 0.90]

Rv = 3.09

# fmt: off
obsdata_x = 1.0 / np.array(
[0.90, 1.25, 1.6, 2.2, 3.5, 4.8, 8.0,
9.5, 10.6, 11.0, 13.0]
)
obsdata_elvebv = np.array(
[-1.60, -2.22, -2.55, -2.744, -2.88, -2.99, -3.01,
-2.73, -2.87, -2.84, -2.98]
)
# fmt: on
obsdata_axav = obsdata_elvebv / Rv + 1.0

# accuracy of the observed data based on published table
obsdata_tolerance = 1e-6

def evaluate(self, in_x):
r"""
RRP89 MWGC function
Parameters
----------
in_x: float
expects either x in units of wavelengths or frequency
or assumes wavelengths in wavenumbers [1/micron]
internally wavenumbers are used
Returns
-------
axav: np array (float)
A(x)/A(V) extinction curve [mag]
Raises
------
ValueError
Input x values outside of defined range
"""
x = _get_x_in_wavenumbers(in_x)

# check that the wavenumbers are within the defined range
_test_valid_x_range(x, self.x_range, self.__class__.__name__)

# define the function using simple linear interpolation
# avoids negative values of alav that happens with cubic splines
f = interp1d(self.obsdata_x, self.obsdata_axav)

return f(x)


class B92_MWAvg(BaseExtModel):
r"""
Bastiaansen (1992) Optical Extinction Curve
Expand Down
2 changes: 2 additions & 0 deletions dust_extinction/tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from dust_extinction.shapes import FM90, P92
from dust_extinction.averages import (
RL85_MWGC,
RRP89_MWGC,
B92_MWAvg,
G03_SMCBar,
G03_LMCAvg,
Expand All @@ -32,6 +33,7 @@
shape_models = [FM90, P92]
ave_models = [
RL85_MWGC,
RRP89_MWGC,
B92_MWAvg,
G03_SMCBar,
G03_LMCAvg,
Expand Down

0 comments on commit 644c18b

Please sign in to comment.