Skip to content

Commit

Permalink
Return true E(B-V) for filter=E(B-V) (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
jobovy committed Aug 31, 2023
1 parent ed5341b commit 0fb2da0
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
uses: actions/cache@v3
with:
path: ${{github.workspace}}/data/
key: sfd-green19-${{ runner.os }}-
key: sfd-green19-marshall06-combined15-${{ runner.os }}-
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
Expand Down
2 changes: 2 additions & 0 deletions HISTORY.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ v1.4 (XXXX-XX-XX)
- Allowed array inputs to dust maps derived from HierarchicalHealpixMap
(GreenX and CombinedX maps) and use vectorization to speed these up signficantly.

- Allow filter=E(B-V) to get the true color excess E(B-V).

v1.3 (2023-03-07)
==================

Expand Down
29 changes: 16 additions & 13 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -146,20 +146,11 @@ Note that this requires ``healpy`` to be installed, so this does not work on Win
Supported bandpasses
---------------------

Currently only a few filters are supported; if no filter is supplied,
*E(B-V)* is returned on the SFD scale if the object is initialized
with ``sf10=True`` (which tells the code to use re-scalings from
`Schlafly & Finkbeiner 2011
<https://adsabs.harvard.edu/abs/2011ApJ...737..103S>`__). ``sf10=True``
is the default initialization for every map, so be careful in
interpreting the raw *E(B-V)* that come out of the code. *Only use*
``sf10=False`` *when you have an extinction map in true E(B-V)*, **not**
*SFD E(B-V)*. No map currently included in this package is in this
situation, so using ``sf10=False`` is never recommended.

To check what bandpasses are supported on the ``sf10=True`` scale do
Currently only a few filters are supported.
To obtain E(B-V), specify ``filter=E(B-V)``.
To check what bandpasses are supported on the ``sf10=True`` scale
(these are all the bandpasses from Table 6 in `Schlafly & Finkbeiner
2011 <https://adsabs.harvard.edu/abs/2011ApJ...737..103S>`__)
2011 <https://adsabs.harvard.edu/abs/2011ApJ...737..103S>`__), do

.. code-block:: python
Expand Down Expand Up @@ -195,6 +186,18 @@ which gives
'SDSS r', 'SDSS u', 'SDSS z', 'SDSS g', 'SDSS i', '2MASS Ks',
'2MASS J'], dtype='|S14')
If no filter is supplied, *E(B-V)* is returned on the SFD scale if the object is initialized
with ``sf10=True`` (which tells the code to use re-scalings from
`Schlafly & Finkbeiner 2011
<https://adsabs.harvard.edu/abs/2011ApJ...737..103S>`__). ``sf10=True``
is the default initialization for every map, so be careful in
interpreting the raw *E(B-V)* that come out of the code when
not setting ``filter`` or when setting ``filter=None``. *Only use*
``sf10=False`` *when you have an extinction map in true E(B-V)*, **not**
*SFD E(B-V)*. No map currently included in this package is in this
situation, so using ``sf10=False`` is never recommended.

Acknowledging ``mwdust`` and its data
---------------------------------------

Expand Down
5 changes: 4 additions & 1 deletion mwdust/util/extCurves.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,13 @@ def aebv(filter,sf10=True):
HISTORY:
2013-11-24 - Written - Bovy (IAS)
"""
if filter.lower() == 'e(b-v)':
return 0.884
if sf10:
if not filter in avebvsf:
raise ValueError("Requested filter is not supported")
return avebvsf[filter]
else:
return avebvsf[filter]
else:
if not filter in avebv:
raise ValueError("Requested filter is not supported")
Expand Down
65 changes: 65 additions & 0 deletions tests/test_ebv.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Test that asking for E(B-V) returns the correct value for all dust maps
import numpy
import mwdust

def test_SFD():
sfd_ebv= mwdust.SFD(filter='E(B-V)')
sfd_b= mwdust.SFD(filter='Landolt B')
sfd_v= mwdust.SFD(filter='Landolt V')
l,b,d= 10., 1., 2.
assert numpy.fabs(sfd_ebv(l,b,d)-(sfd_b(l,b,d)-sfd_v(l,b,d))) \
< 10.**-12., \
'SFD E(B-V) does not agree with A(B)-A(V)'
return None

def test_Drimmel03():
drim_ebv= mwdust.Drimmel03(filter='E(B-V)')
drim_b= mwdust.Drimmel03(filter='Landolt B')
drim_v= mwdust.Drimmel03(filter='Landolt V')
l,b,d= 10., 1., 2.
assert numpy.fabs(drim_ebv(l,b,d)-(drim_b(l,b,d)-drim_v(l,b,d))) \
< 10.**-12., \
'Drimmel03 E(B-V) does not agree with A(B)-A(V)'
return None

def test_Marshall06():
mar_ebv= mwdust.Marshall06(filter='E(B-V)')
mar_b= mwdust.Marshall06(filter='Landolt B')
mar_v= mwdust.Marshall06(filter='Landolt V')
l,b,d= 10., 1., 2.
assert numpy.fabs(mar_ebv(l,b,d)-(mar_b(l,b,d)-mar_v(l,b,d))) \
< 10.**-12., \
'Marshall06 E(B-V) does not agree with A(B)-A(V)'
return None

def test_Green19():
# Need to preserve memory
l,b,d= 10., 1., 2.
green_ebv= mwdust.Green19(filter='E(B-V)')
ebv= green_ebv(l,b,d)
del green_ebv
green_b= mwdust.Green19(filter='Landolt B')
ab= green_b(l,b,d)
del green_b
green_v= mwdust.Green19(filter='Landolt V')
av= green_v(l,b,d)
assert numpy.fabs(ebv-(ab-av)) \
< 10.**-12., \
'Green19 E(B-V) does not agree with A(B)-A(V)'
return None

def test_Combined15():
# Need to preserve memory
l,b,d= 10., 1., 2.
combined_ebv= mwdust.Combined15(filter='E(B-V)')
ebv= combined_ebv(l,b,d)
del combined_ebv
combined_b= mwdust.Combined15(filter='Landolt B')
ab= combined_b(l,b,d)
del combined_b
combined_v= mwdust.Combined15(filter='Landolt V')
av= combined_v(l,b,d)
assert numpy.fabs(ebv-(ab-av)) \
< 10.**-12., \
'Combined15 E(B-V) does not agree with A(B)-A(V)'
return None

0 comments on commit 0fb2da0

Please sign in to comment.