diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 04bc186..69fb280 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -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: diff --git a/HISTORY.txt b/HISTORY.txt index fec31d8..aa2b1cb 100644 --- a/HISTORY.txt +++ b/HISTORY.txt @@ -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) ================== diff --git a/README.rst b/README.rst index 626a22e..f1716c1 100644 --- a/README.rst +++ b/README.rst @@ -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 -`__). ``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 `__) +2011 `__), do .. code-block:: python @@ -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 +`__). ``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 --------------------------------------- diff --git a/mwdust/util/extCurves.py b/mwdust/util/extCurves.py index 9042f45..d1fa330 100644 --- a/mwdust/util/extCurves.py +++ b/mwdust/util/extCurves.py @@ -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") diff --git a/tests/test_ebv.py b/tests/test_ebv.py new file mode 100644 index 0000000..17ffaea --- /dev/null +++ b/tests/test_ebv.py @@ -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