Skip to content

Commit

Permalink
Merge pull request #184 from karllark/add_d22
Browse files Browse the repository at this point in the history
Add D22 models
  • Loading branch information
karllark committed Mar 30, 2022
2 parents c572658 + 4a6c7b5 commit 0ab9da9
Show file tree
Hide file tree
Showing 9 changed files with 356 additions and 24 deletions.
5 changes: 5 additions & 0 deletions docs/dust_extinction/choose_model.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ simplest models and include models for the MW
:class:`~dust_extinction.averages.GCC09_MWAvg`,
:class:`~dust_extinction.averages.F11_MWGC`,
:class:`~dust_extinction.averages.G21_MWAvg`;
:class:`~dust_extinction.averages.D22_MWAvg`;
Note the different valid wavelength ranges), the LMC
(:class:`~dust_extinction.averages.G03_LMCAvg`,
:class:`~dust_extinction.averages.G03_LMC2`) and the SMC
Expand All @@ -44,6 +45,8 @@ Way, the usual average used is R(V) = 3.1.
+--------------+-------------+------------------+--------------+
| G21_MWAvg | 0.3125 - 1 | 1 - 32 | MW |
+--------------+-------------+------------------+--------------+
| D22_MWAvg | 0.2 - 1.25 | 0.8 - 4 | MW |
+--------------+-------------+------------------+--------------+
| CT06_MWLoc | 0.037 - 0.8 | 1.24 - 27.0 | MW (Local) |
+--------------+-------------+------------------+--------------+
| RL85_MWGC | 0.08 - 0.8 | 1.25 - 13.0 | MW (GCenter) |
Expand Down Expand Up @@ -101,6 +104,8 @@ significantly more extinction curves than the
+----------+-------------+-------------+------------------+--------------+
| F19 | R(V) | 0.3 - 8.7 | 0.115 - 3.3 | MW |
+----------+-------------+-------------+------------------+--------------+
| D22 | R(V) | 0.2 - 1.25 | 0.8 - 5.0 | MW |
+----------+-------------+-------------+------------------+--------------+

Notes
-----
Expand Down
21 changes: 11 additions & 10 deletions docs/dust_extinction/model_flavors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,16 @@ Average models
CT06_MWLoc,
CT06_MWGC,
F11_MWGC,
G21_MWAvg)
G21_MWAvg,
D22_MWAvg)

fig, ax = plt.subplots()

# generate the curves and plot them
x = 1.0 / (np.arange(1.0, 40.0 ,0.1) * u.micron)

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

for cmodel in models:
ext_model = cmodel()
Expand Down Expand Up @@ -123,7 +124,7 @@ R(V) (+ other variables) dependent prediction models
import astropy.units as u

from dust_extinction.parameter_averages import (CCM89, O94, F99, F04,
VCG04, GCC09, M14, F19)
VCG04, GCC09, M14, F19, D22)

fig, ax = plt.subplots()

Expand All @@ -132,7 +133,7 @@ R(V) (+ other variables) dependent prediction models

Rv = 3.1

models = [CCM89, O94, F99, F04, VCG04, GCC09, M14, F19]
models = [CCM89, O94, F99, F04, VCG04, GCC09, M14, F19, D22]

for cmodel in models:
ext_model = cmodel(Rv=Rv)
Expand All @@ -159,16 +160,16 @@ R(V) (+ other variables) dependent prediction models
import astropy.units as u

from dust_extinction.parameter_averages import (CCM89, O94, F99, F04,
VCG04, GCC09, M14, F19)
VCG04, GCC09, M14, F19, D22)

fig, ax = plt.subplots()

# generate the curves and plot them
x = np.arange(0.5,11.0,0.1)/u.micron

Rv = 2.0
Rv = 2.5

models = [CCM89, O94, F99, F04, VCG04, GCC09, M14, F19]
models = [CCM89, O94, F99, F04, VCG04, GCC09, M14, F19, D22]

for cmodel in models:
ext_model = cmodel(Rv=Rv)
Expand All @@ -181,7 +182,7 @@ R(V) (+ other variables) dependent prediction models
ax.set_xlabel('$x$ [$\mu m^{-1}$]')
ax.set_ylabel('$A(x)/A(V)$')

ax.set_title('R(V) = 2.0')
ax.set_title('R(V) = 2.5')

ax.legend(loc='best')
plt.tight_layout()
Expand All @@ -195,7 +196,7 @@ R(V) (+ other variables) dependent prediction models
import astropy.units as u

from dust_extinction.parameter_averages import (CCM89, O94, F99, F04,
VCG04, GCC09, M14, F19)
VCG04, GCC09, M14, F19, D22)

fig, ax = plt.subplots()

Expand All @@ -204,7 +205,7 @@ R(V) (+ other variables) dependent prediction models

Rv = 5.5

models = [CCM89, O94, F99, F04, VCG04, GCC09, M14, F19]
models = [CCM89, O94, F99, F04, VCG04, GCC09, M14, F19, D22]

for cmodel in models:
ext_model = cmodel(Rv=Rv)
Expand Down
22 changes: 12 additions & 10 deletions docs/dust_extinction/references.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ References
##########

C11: `Compiegne et al. 2011, A&A, 525, 103
<https://ui.adsabs.harvard.edu/abs/2011A%26A...525A.103C/abstract>`_
<https://ui.adsabs.harvard.edu/abs/2011A%26A...525A.103C>`_

CCM89: `Cardelli, Clayton, & Mathis 1989, ApJ, 345, 245
<https://ui.adsabs.harvard.edu/abs/1989ApJ...345..245C>`_
Expand All @@ -12,12 +12,14 @@ CT06: `Chiar & Tielens 2006, ApJ, 637 774
<https://ui.adsabs.harvard.edu/abs/2006ApJ...637..774C>`_

D03: `Draine 2003, ARA&A, 41, 241
<https://ui.adsabs.harvard.edu/abs/2003ARA%26A..41..241D/abstract>`_;
<https://ui.adsabs.harvard.edu/abs/2003ARA%26A..41..241D>`_;
`Draine 2003, ApJ, 598, 1017
<https://ui.adsabs.harvard.edu/abs/2003ApJ...598.1017D/abstract>`_
<https://ui.adsabs.harvard.edu/abs/2003ApJ...598.1017D>`_

D22: Decleir et al. 2022, ApJ, in press

DBP90: `Desert, Boulanger, & Puget 1990, A&A, 237, 215
<https://ui.adsabs.harvard.edu/abs/1990A%26A...237..215D/abstract>`_
<https://ui.adsabs.harvard.edu/abs/1990A%26A...237..215D>`_

F99: `Fitzpatrick 1999, PASP, 111, 63
<https://ui.adsabs.harvard.edu/abs/1999PASP..111...63F>`_
Expand Down Expand Up @@ -46,17 +48,17 @@ GCC09: `Gordon, Cartledge, & Clayton 2009, ApJ, 705, 1320
G16: `Gordon et al. 2016, ApJ 826, 104
<https://ui.adsabs.harvard.edu/abs/2016ApJ...826..104G>`_

G21: `Gordon et al. 2021, ApJ, in press
<https://arxiv.org/abs/2105.05087>`_
G21: `Gordon et al. 2021, ApJ, 916, 33
<https://ui.adsabs.harvard.edu/abs/2021ApJ...916...33G>`_

I05: `Indebetouw et al. 2005, ApJ, 619, 931
<https://ui.adsabs.harvard.edu/abs/2005ApJ...619..931I>`_

J13: `Jones et al. 2013, A&A, 558, 62
<https://ui.adsabs.harvard.edu/abs/2013A%26A...558A..62J/abstract>`_
<https://ui.adsabs.harvard.edu/abs/2013A%26A...558A..62J>`_

KJY14: `Kohler, Jones, & Ysard 2014, A&A, 565, 9
<https://ui.adsabs.harvard.edu/abs/2014A%26A...565L...9K/abstract>`_
<https://ui.adsabs.harvard.edu/abs/2014A%26A...565L...9K>`_

M14: `Maiz Apell\’aniz et al. 2014, A&A, 564, 63
<https://ui.adsabs.harvard.edu/abs/2014A%26A...564A..63M>`_
Expand All @@ -74,10 +76,10 @@ VCG04: `Valencic, Clayton, & Gordon 2014, 616, 912
<https://ui.adsabs.harvard.edu/abs/2004ApJ...616..912V>`_

WG01: `Weingartner & Draine 2001, ApJ, 548, 296
<https://ui.adsabs.harvard.edu/abs/2001ApJ...548..296W/abstract>`_
<https://ui.adsabs.harvard.edu/abs/2001ApJ...548..296W>`_

ZDA04: `Zubko, Dwek, & Arendt 2004, ApJS, 152, 211
<https://ui.adsabs.harvard.edu/abs/2004ApJS..152..211Z/abstract>`_
<https://ui.adsabs.harvard.edu/abs/2004ApJS..152..211Z>`_

Naming Convention
=================
Expand Down
118 changes: 117 additions & 1 deletion dust_extinction/averages.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import numpy as np
from scipy.interpolate import interp1d
from astropy.table import Table
from astropy.modeling.models import PowerLaw1D

from .helpers import _get_x_in_wavenumbers, _test_valid_x_range
from .baseclasses import BaseExtModel
Expand All @@ -23,6 +24,7 @@
"GCC09_MWAvg",
"F11_MWGC",
"G21_MWAvg",
"D22_MWAvg",
]


Expand Down Expand Up @@ -1276,7 +1278,7 @@ class G21_MWAvg(BaseExtModel):
Notes
-----
From Gordon et al. (2021, ApJ, submitted)
From Gordon et al. (2021, ApJ, 916, 33)
Example showing the average curve
Expand Down Expand Up @@ -1398,4 +1400,118 @@ def evaluate(self, in_x):
)

# return A(x)/A(V)
# G21 a full dust_extinction model, hence send in x with units
return g21_fit(in_x)


class D22_MWAvg(BaseExtModel):
r"""
Decleir et al. (2022) Milky Way Average Extinction Curve
Parameters
----------
None
Raises
------
None
Notes
-----
From Decleir et al. (2022, ApJ, submitted)
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 D22_MWAvg
fig, ax = plt.subplots()
# generate the curves and plot them
lam = np.logspace(np.log10(0.8), np.log10(4.9), num=1000)
x = (1.0 / lam) / u.micron
# define the extinction model
ext_model = D22_MWAvg()
ax.plot(1.0 / x, ext_model(x), label="D22_MWAvg")
ax.errorbar(
1.0 / ext_model.obsdata_x,
ext_model.obsdata_axav,
yerr=ext_model.obsdata_axav_unc,
fmt="ko",
label="obsdata",
)
ax.set_xlabel(r"$\lambda$ [$\mu m$]")
ax.set_ylabel(r"$A(x)/A(V)$")
ax.set_xscale("log")
ax.set_yscale("log")
ax.legend(loc="best")
plt.show()
"""

x_range = [1.0 / 5.0, 1.0 / 0.8]

Rv = 3.12

def __init__(self, **kwargs):

# get the tabulated information
data_path = pkg_resources.resource_filename("dust_extinction", "data/")

# D22 sigma clipped average of 13 diffuse sightlines
a = Table.read(data_path + "D22.dat", format="ascii.commented_header")

# Spex data
self.obsdata_x = 1.0 / a["wavelength[micron]"].data
self.obsdata_axav = a["ave"].data
self.obsdata_axav_unc = a["ave_unc"].data

# accuracy of the observed data based on published table
self.obsdata_tolerance = 0.2 # check

super().__init__(**kwargs)

def evaluate(self, in_x):
"""
D22_MWAvg 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__)

# setup the model
d22_fit = PowerLaw1D(alpha=1.71, amplitude=0.386, x_0=1.0)

# return A(x)/A(V)
# Note that model in D22 was done versus wavelength in microns
return d22_fit(1.0 / x)
63 changes: 63 additions & 0 deletions dust_extinction/data/D22.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# wavelength[micron] ave ave_unc ave_fit intercept slope std
0.8500000000000001 0.5229116082191467 0.022688888013362885 0.5090679346458734 0.5043843287104457 -0.6293039288140487 0.05562848830036259
0.9000000000000001 0.45997095108032227 0.02032790146768093 0.46166625669933375 0.45549648735093856 -0.6174529410812017 0.050836719542353026
0.9500000000000002 0.42000287771224976 0.02005036734044552 0.42089729924118685 0.4136214060035163 -0.6385516873757641 0.0478619405952933
1.0000000000000002 0.3810850977897644 0.019589412957429886 0.38555305537535717 0.3774589648330171 -0.6469538603772321 0.04522852235644631
1.0500000000000003 0.34920358657836914 0.019196437671780586 0.35469172892455036 0.34599950638712346 -0.6512808886202338 0.043619971939746316
1.1000000000000003 0.32195335626602173 0.018980903550982475 0.3275698003772987 0.3184488876969109 -0.6583070646901519 0.0417168231073246
1.1500000000000004 0.30355149507522583 0.018601318821310997 0.30359359134808894 0.29417524356493724 -0.6680955040414542 0.03936325326515428
1.2000000000000004 0.28181931376457214 0.01777954027056694 0.28228416140059226 0.27267054082171815 -0.6345926051206287 0.03833801592606844
1.2500000000000004 0.2640969157218933 0.01732826977968216 0.2632514869766455 0.25352239430475715 -0.6211808201417144 0.03714196876173308
1.3000000000000005 0.24801427125930786 0.016910871490836143 0.24617520939060414 0.23639312104983637 -0.6322691076743284 0.03624935439391689
1.3500000000000005 0.23989495635032654 0.01684890314936638 0.23079010189928667 0.22100397773182737 -0.638483589495678 0.03559657117065511
1.4000000000000006 0.2204539030790329 0.020606864243745804 0.21687497364660085 0.20712316154029303 -0.6171752583533128 0.034496160362062656
1.4500000000000006 0.20975157618522644 0.018769754096865654 0.2042441084260786 0.1945565786103972 -0.5759689452024471 0.03344508246073979
1.5000000000000007 0.19530680775642395 0.014611581340432167 0.1927405948483919 0.18314067171798756 -0.5268239963976614 0.03310755967105022
1.5500000000000007 0.184793159365654 0.013940279372036457 0.18223108310987315 0.17273679698212466 -0.4834620236847841 0.033611979598619154
1.6000000000000008 0.1723860502243042 0.013286537490785122 0.1726016286036064 0.16322677758593934 -0.46130835240307666 0.03413885968415152
1.6500000000000008 0.16221222281455994 0.012996039353311062 0.16375437128263234 0.15450936031273937 -0.4551474878836529 0.03433255871616444
1.7000000000000008 0.15201103687286377 0.012922966852784157 0.15560486330775333 0.14649737068198002 -0.4477989120453107 0.034232487017141794
1.7500000000000009 0.1453346610069275 0.01250755600631237 0.14807990367215648 0.13911541312284362 -0.43856337330653 0.033805184503484506
1.800000000000001 0.14088815450668335 0.013930638320744038 0.14111577233296935 0.13229799966703115 -0.4310050977646393 0.03303487267830152
1.950000000000001 0.1248449832201004 0.012057552114129066 0.12306466161623147 0.11469642798848592 -0.40779614378003787 0.030031495507543138
2.000000000000001 0.12335485965013504 0.011307507753372192 0.11785053898808834 0.10963216488060923 -0.3946732749077495 0.029309921008456932
2.050000000000001 0.11623390018939972 0.010758263990283012 0.11297804980694574 0.10490842856998524 -0.3774289472350379 0.02890542747312936
2.1000000000000014 0.11041470617055893 0.01066792756319046 0.1084172744725884 0.10049483113912377 -0.359447679523048 0.028643538639354725
2.1500000000000012 0.10572405904531479 0.010483812540769577 0.10414154315296618 0.09636433401672452 -0.34459332089701705 0.028309586526726327
2.200000000000001 0.10169923305511475 0.010090434923768044 0.10012701752058939 0.09249281170862922 -0.3350912115368282 0.02774709236527001
2.2500000000000013 0.09727145731449127 0.00976477935910225 0.09635233435342751 0.08885868071024246 -0.33243152075545834 0.02683641078242399
2.3000000000000016 0.09488268941640854 0.009770119562745094 0.09279830071342374 0.08544258266742193 -0.33560200446338684 0.025751048668593214
2.3500000000000014 0.0934760719537735 0.009494960308074951 0.08944763230726259 0.08222711287853528 -0.3413478800626229 0.024927243120635614
2.4000000000000012 0.08958634734153748 0.01015640888363123 0.08628472814583905 0.07919658684666815 -0.34717081439502273 0.024645613667990934
2.4500000000000015 0.08077102154493332 0.010427696630358696 0.08329547583334436 0.07633683888720007 -0.3530712163512623 0.02469376919955139
2.5000000000000018 0.0773744136095047 0.010427264496684074 0.08046708279722875 0.07363504784060897 -0.35940257677260384 0.024803503628865468
2.900000000000002 0.062208935618400574 0.011921234428882599 0.06243052137071296 0.05650855031157689 -0.38484091511759994 0.022419200457640318
2.950000000000002 0.05838632583618164 0.012179081328213215 0.06063202957347759 0.054811580583965284 -0.37897015356893327 0.02128806856934981
3.0000000000000018 0.06071946769952774 0.010270180180668831 0.05891428603945015 0.053192824091525384 -0.3697967992934651 0.019884536161199784
3.0500000000000016 0.06040675938129425 0.009894020855426788 0.05727240851097568 0.05164746087499708 -0.3573999143665085 0.01835529131549092
3.1000000000000023 0.05868978053331375 0.00926880817860365 0.055701883477420694 0.05017104048931601 -0.34231319377675257 0.01701550419055954
3.150000000000002 0.05734163150191307 0.008312576450407505 0.054198532944692304 0.04875944829432483 -0.32509316401877364 0.0161868269745872
3.200000000000002 0.05743248760700226 0.008834531530737877 0.052758484669129614 0.04740887529628209 -0.3068337014256937 0.01602584987258519
3.2500000000000018 0.05548414587974548 0.00827781856060028 0.051378145447125885 0.046115791117575196 -0.2897897497880674 0.016332508851729745
3.3000000000000025 0.0543593093752861 0.008915933780372143 0.05005417710547142 0.04487691972794282 -0.2763676522368168 0.016860233351086055
3.3500000000000023 0.050976552069187164 0.0073979683220386505 0.04878347488330938 0.04368921761830021 -0.2686703617449647 0.01738577755788216
3.400000000000002 0.04961492121219635 0.007209553383290768 0.047563147935978295 0.04254985413921129 -0.26609685106156633 0.01789377866451
3.450000000000002 0.04660521820187569 0.007423666771501303 0.046390501724885166 0.04145619376123129 -0.26662650816459765 0.0184780120684716
3.5000000000000027 0.042605940252542496 0.0075402227230370045 0.045263022086747685 0.04040578004463276 -0.2682261577417589 0.019233218784471273
3.5500000000000025 0.039118602871894836 0.008310800418257713 0.0441783608007679 0.03939632113216828 -0.2692232705904128 0.02021643856944332
3.6000000000000023 0.040154099464416504 0.008504848927259445 0.043134322494137754 0.03842567660112982 -0.26926276095404816 0.021346988150379498
3.650000000000002 0.03868474066257477 0.008353392593562603 0.0421288527452257 0.03749184553055969 -0.2682902897229181 0.022512744772327023
3.700000000000003 0.03910627216100693 0.008346542716026306 0.041160027260267254 0.036592955656485 -0.2662515177872755 0.023601585680333107
3.7500000000000027 0.036803197115659714 0.00992697011679411 0.040226042013734135 0.03572725350285725 -0.2630921060373738 0.024501388119444936
3.8000000000000025 0.03577055782079697 0.008616030216217041 0.03932520425508316 0.034893095388791436 -0.25875771536346603 0.02510002933470972
3.8500000000000023 0.033370956778526306 0.009008757770061493 0.03845592429554086 0.03408893922398059 -0.2531940066558051 0.025285386571174663
3.900000000000003 0.035590704530477524 0.008728405460715294 0.037616707998176506 0.03331333701403375 -0.24634664080464408 0.02494533707388695
3.950000000000003 0.03158818557858467 0.008854329586029053 0.03680614990293947 0.03256492800614294 -0.23816127870023637 0.023967758087893816
4.000000000000003 0.0323454812169075 0.007827924564480782 0.036022926925741695 0.03184243241308689 -0.2285835812328348 0.022240526858242442
#4.600000000000003 0.020721077919006348 0.0123629504814744 0.028365304343415398 0.024816618979930278 0.014730382637369921 -0.09777180570573474
#4.650000000000003 0.014134478755295277 0.00842890702188015 0.027845750425092033 0.024342667447489297 0.04735329881065642 -0.11944768680364748
#4.700000000000004 0.013677984476089478 0.011387539096176624 0.02734111824987759 0.02388269252193824 0.08212929788339629 -0.14344293871455804
#4.7500000000000036 0.0008196234703063965 0.0122400913387537 0.026850827276501024 0.023436139850550698 0.11911271896533204 -0.16986968419341864
#4.800000000000003 0.0116434870287776 0.010735495015978813 0.02637432534032967 0.02300248259038286 0.15835790116621062 -0.19884004599518212
#4.900000000000003 0.01699981652200222 0.0067697190679609776 0.025460611932311365 0.022171874791868693 0.2438509053637894 -0.26486010958722894
#4.950000000000004 0.019882643595337868 0.011293336749076843 0.02502242359501724 0.02177399396844514 0.29020740557998437 -0.3021340568874191
Loading

0 comments on commit 0ab9da9

Please sign in to comment.