Skip to content

Commit 88a9bfc

Browse files
committed
Merge branch 'develop'
2 parents 7879317 + 9869457 commit 88a9bfc

8 files changed

Lines changed: 170 additions & 9 deletions

File tree

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ The currently supported dust maps are:
2424
11. Leike & Enßlin (2019)
2525
12. Leike, Glatzle & Enßlin (2020)
2626
13. Edenhofer et al. (2023)
27+
14. Chiang (2023; CSFD)
2728

2829
To request addition of another dust map in this package, [file an issue on
2930
GitHub](https://github.com/gregreen/dustmaps/issues), or submit a pull request.
@@ -49,7 +50,7 @@ To fetch the data for the SFD dust map, run:
4950

5051
python setup.py fetch --map-name=sfd
5152

52-
You can download the other dust maps by changing "sfd" to "planck",
53+
You can download the other dust maps by changing "sfd" to "csfd", "planck",
5354
"planckGNILC", "bayestar", "iphas", "marshall", "chen2014", "lenz2017",
5455
"pg2010", "leikeensslin2019", "leike2020", "edenhofer2023" or "bh".
5556

@@ -63,6 +64,9 @@ interpreter and running:
6364
>>> import dustmaps.sfd
6465
>>> dustmaps.sfd.fetch()
6566
>>>
67+
>>> import dustmaps.csfd
68+
>>> dustmaps.csfd.fetch()
69+
>>>
6670
>>> import dustmaps.planck
6771
>>> dustmaps.planck.fetch()
6872
>>>

docs/installation.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ Start up a python interpreter and type:
2626
import dustmaps.sfd
2727
dustmaps.sfd.fetch()
2828
29+
import dustmaps.csfd
30+
dustmaps.csfd.fetch()
31+
2932
import dustmaps.planck
3033
dustmaps.planck.fetch()
3134
@@ -55,10 +58,10 @@ Start up a python interpreter and type:
5558
5659
import dustmaps.leike2020
5760
dustmaps.leike2020.fetch()
58-
61+
5962
import dustmaps.edenhofer2023
6063
dustmaps.edenhofer2023.fetch()
61-
64+
6265
import dustmaps.gaia_tge
6366
dustmaps.gaia_tge.fetch()
6467
@@ -110,6 +113,7 @@ to only download those you think you'll need:
110113
.. code-block :: bash
111114
112115
python setup.py fetch --map-name=sfd
116+
python setup.py fetch --map-name=csfd
113117
python setup.py fetch --map-name=planck
114118
python setup.py fetch --map-name=planckGNILC
115119
python setup.py fetch --map-name=bayestar

docs/maps.rst

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,19 @@ conversions provided in
2323
* **Reference**: `Schlegel, Finkbeiner & Davis (1998) <http://adsabs.harvard.edu/abs/1998ApJ...500..525S>`_
2424
* **Recalibration**: `Schlafly & Finkbeiner (2011) <http://adsabs.harvard.edu/abs/2011ApJ...737..103S>`_
2525

26+
27+
CSFD (Chiang 2023)
28+
~~~~~~~~~~~~~~~~~~
29+
30+
"Corrected SFD," a 2D dust map based on a reanalysis of SFD, using
31+
tomographically constrained templates from WISE galaxy density fields to remove
32+
extragalactic contamination from the cosmic infrared background (CIB).
33+
34+
* **Reference**: `Chiang (2023) <https://ui.adsabs.harvard.edu/abs/2023arXiv230603926C/abstract>`_
35+
* **Website**: `Project description <https://idv.sinica.edu.tw/ykchiang/CSFD.html>`_
36+
* **Data**: `Zenodo <https://doi.org/10.5281/zenodo.8207159>`_
37+
38+
2639
Gaia Total Galactic Extinction (2022)
2740
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2841

@@ -173,8 +186,8 @@ estimates of Zhang, Green & Rix (2023), and therefore reports extinctions in
173186
their units. Accompanying the main reconstruciton is an additional map that uses
174187
less data but extends out to 2 kpc from the Sun.
175188

176-
* **Reference**: `Edenhofer et al. (2023) <https://arxiv.org/abs/2308.01295>`_
177-
* **Website**: `Zenodo <https://doi.org/10.5281/zenodo.8187943>`_
189+
* **Reference**: `Edenhofer et al. (2023) <https://ui.adsabs.harvard.edu/abs/2023arXiv230801295E/abstract>`_
190+
* **Data**: `Zenodo <https://doi.org/10.5281/zenodo.8187943>`_
178191

179192

180193
IPHAS
@@ -199,7 +212,7 @@ the Gaia DR2 catalog parallaxes and G-band extinctions, and spans a (600 pc)³
199212
box centered on the Sun.
200213

201214
* **Reference**: `Leike & Enßlin (2019) <https://ui.adsabs.harvard.edu/abs/2019arXiv190105971L/abstract>`_
202-
* **Website**: `Zenodo <https://doi.org/10.5281/zenodo.2542807>`_
215+
* **Data**: `Zenodo <https://doi.org/10.5281/zenodo.2542807>`_
203216

204217

205218
Leike, Glatzle & Enßlin (2020)
@@ -213,7 +226,7 @@ ALLWISE, and is calculated on a Cartesian grid spanning a
213226
centered on the Sun.
214227

215228
* **References**: `Leike, Glatzle & Enßlin (2020) <https://ui.adsabs.harvard.edu/abs/2020A%26A...639A.138L/abstract>`_
216-
* **Website**: `Zenodo <https://doi.org/10.5281/zenodo.3993082>`_
229+
* **Data**: `Zenodo <https://doi.org/10.5281/zenodo.3993082>`_
217230

218231

219232
Marshall et al. (2006)

docs/modules.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ chen2014 (Chen et al. 2014)
2626
:special-members:
2727
:show-inheritance:
2828

29+
csfd (Chiang 2023)
30+
---------------------------
31+
.. automodule:: dustmaps.csfd
32+
:members:
33+
:special-members:
34+
:show-inheritance:
35+
2936
gaia_tge (Delchambre et al. 2022)
3037
---------------------------
3138
.. automodule:: dustmaps.gaia_tge

dustmaps/csfd.py

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
#!/usr/bin/env python
2+
#
3+
# csfd.py
4+
# Reads the "Corrected SFD" dust reddening map of Chiang (2023).
5+
#
6+
# Copyright (C) 2023 Gregory M. Green
7+
#
8+
# This program is free software; you can redistribute it and/or modify
9+
# it under the terms of the GNU General Public License as published by
10+
# the Free Software Foundation; either version 2 of the License, or
11+
# (at your option) any later version.
12+
#
13+
# This program is distributed in the hope that it will be useful,
14+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
# GNU General Public License for more details.
17+
#
18+
# You should have received a copy of the GNU General Public License along
19+
# with this program; if not, write to the Free Software Foundation, Inc.,
20+
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21+
#
22+
23+
from __future__ import print_function, division
24+
25+
import os
26+
import numpy as np
27+
import healpy as hp
28+
import astropy.io.fits as fits
29+
import astropy.units as units
30+
31+
from .std_paths import *
32+
from .healpix_map import HEALPixQuery
33+
from . import fetch_utils
34+
from . import dustexceptions
35+
36+
37+
class CSFDQuery(HEALPixQuery):
38+
"""
39+
Queries the Corrected SFD dust map of Chiang (2023). This map is based
40+
on SFD, but contains a correction to remove contamination from
41+
large-scale structure (i.e., external galaxies).
42+
"""
43+
44+
def __init__(self, map_fname=None, mask_fname=None):
45+
"""
46+
Args:
47+
map_fname (Optional[:obj:`str`]): Filename of the CSFD EBV map.
48+
Defaults to ```None``, meaning that the default location is
49+
used.
50+
mask_fname (Optional[:obj:`str`]): Filename of the CSFD mask map.
51+
Defaults to ```None``, meaning that the default location is
52+
used.
53+
"""
54+
55+
if map_fname is None:
56+
map_fname = os.path.join(data_dir(), 'csfd', 'csfd_ebv.fits')
57+
if mask_fname is None:
58+
mask_fname = os.path.join(data_dir(), 'csfd', 'mask.fits')
59+
60+
try:
61+
with fits.open(map_fname) as hdulist:
62+
ebv_data = hdulist['xtension'].data[:]['T'].flatten()
63+
with fits.open(mask_fname) as hdulist:
64+
mask_data = hdulist['xtension'].data[:]['T'].flatten()
65+
except IOError as error:
66+
print(dustexceptions.data_missing_message('csfd',
67+
'CSFD (Chiang 2023)'))
68+
raise error
69+
70+
super(CSFDQuery, self).__init__(ebv_data, False, 'galactic',
71+
flags=mask_data)
72+
73+
def query(self, coords, **kwargs):
74+
"""
75+
Returns CSFD reddening on the same scale as SFD (similar to E(B-V)) at
76+
the specified location(s) on the sky. Also optionally returns a
77+
bit mask, where the bits (ordered from least to most significant) have
78+
the following meanings::
79+
80+
Bit 0: 'LSS_corr' - This bit is set in the footprint within which
81+
the LSS is reconstructed, and CSFD = SFD - LSS (otherwise
82+
CSFD = SFD).
83+
Bit 1: 'no_IRAS' - Set in the area with no IRAS data (DIRBE data
84+
filled in SFD); LSS removal in CSFD is done using a 1 deg
85+
smoothed LSS.
86+
Bit 2: 'cosmology' - Set in the area where both the LSS and CSFD
87+
are most reliable for precision cosmology analyses.
88+
89+
Args:
90+
coords (:obj:`astropy.coordinates.SkyCoord`): The coordinates to
91+
query.
92+
return_flags (Optional[:obj:`bool`]): If ``True``, then a
93+
bit mask is returned as well, indicating where CSFD
94+
has been corrected for large-scale structure, where IRAS data
95+
was used, and where the map is suitable for cosmology. See
96+
above description of bits. Defaults to ``False``.
97+
98+
Returns:
99+
A float array of the reddening, at the given coordinates. The
100+
shape of the output is the same as the shape of the input
101+
coordinate array, ``coords``. If ``return_flags`` is ``True``,
102+
a second array (a bit mask) of the same shape is returned. See
103+
above description of the meaning of each bit.
104+
"""
105+
return super(CSFDQuery, self).query(coords, **kwargs)
106+
107+
108+
def fetch(clobber=False):
109+
"""
110+
Downloads the Corrected SFD dust map of Chiang (2023).
111+
112+
Args:
113+
clobber (Optional[bool]): If ``True``, any existing file will be
114+
overwritten, even if it appears to match. If ``False`` (the
115+
default), ``fetch()`` will attempt to determine if the dataset
116+
already exists. This determination is not 100\% robust against data
117+
corruption.
118+
"""
119+
file_spec = [
120+
('csfd_ebv.fits', '31cd2eec51bcb5f106af84a610ced53c'),
121+
('mask.fits', '9142f5a5d184125836a68b6f48d1113f')
122+
]
123+
for fn,md5sum in file_spec:
124+
fname = os.path.join(data_dir(), 'csfd', fn)
125+
# Download from Zenodo
126+
url = 'https://zenodo.org/record/8207175/files/{}'.format(fn)
127+
fetch_utils.download_and_verify(url, md5sum, fname, clobber=clobber)
128+

dustmaps/leike2020.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def query(self, coords, component='mean'):
9898
standard deviation of extinction density). Defaults to 'mean'.
9999
100100
Returns:
101-
The extinction density, in units of e-foldings / pc, as either a
101+
The extinction density, in units of e-foldings / kpc, as either a
102102
numpy array or float, with the same shape as the input
103103
:obj:`coords`.
104104
"""

dustmaps/leike_ensslin_2019.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def query(self, coords, component='mean'):
9292
standard deviation of extinction density). Defaults to 'mean'.
9393
9494
Returns:
95-
The extinction density, in units of e-foldings / pc, as either a
95+
The extinction density, in units of e-foldings / kpc, as either a
9696
numpy array or float, with the same shape as the input
9797
:obj:`coords`.
9898
"""

setup.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ def fetch_sfd():
6161
import dustmaps.sfd
6262
dustmaps.sfd.fetch()
6363

64+
def fetch_csfd():
65+
import dustmaps.csfd
66+
dustmaps.csfd.fetch()
67+
6468
def fetch_planck():
6569
import dustmaps.planck
6670
dustmaps.planck.fetch()
@@ -121,6 +125,7 @@ class FetchCommand(distutils.cmd.Command):
121125

122126
map_funcs = {
123127
'sfd': fetch_sfd,
128+
'csfd': fetch_csfd,
124129
'planck': fetch_planck,
125130
'planckGNILC': fetch_planck_GNILC,
126131
'bayestar': fetch_bayestar,

0 commit comments

Comments
 (0)