Coverage for python/lsst/faro/utils/extinction_corr.py : 30%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1# This file is part of faro.
2#
3# Developed for the LSST Data Management System.
4# This product includes software developed by the LSST Project
5# (https://www.lsst.org).
6# See the COPYRIGHT file at the top-level directory of this distribution
7# for details of code ownership.
8#
9# This program is free software: you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation, either version 3 of the License, or
12# (at your option) any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with this program. If not, see <https://www.gnu.org/licenses/>.
22import logging
23from astropy.coordinates import SkyCoord
25log = logging.getLogger(__name__)
27try:
28 from dustmaps.sfd import SFDQuery
29except ModuleNotFoundError as e:
30 log.debug(
31 "The extinction_corr method is not available without first installing the dustmaps module:\n"
32 "$> pip install --user dustmaps\n\n"
33 "Then in a python interpreter:\n"
34 ">>> import dustmaps.sfd\n"
35 ">>> dustmaps.sfd.fetch()\n"
36 "%s",
37 e.msg,
38 )
40__all__ = ("extinction_corr",)
43def extinction_corr(catalog, bands):
45 # Extinction coefficients for HSC filters for conversion from E(B-V) to extinction, A_filter.
46 # Numbers provided by Masayuki Tanaka (NAOJ).
47 #
48 # Band, A_filter/E(B-V)
49 extinctionCoeffs_HSC = {
50 "g": 3.240,
51 "r": 2.276,
52 "i": 1.633,
53 "z": 1.263,
54 "y": 1.075,
55 "HSC-G": 3.240,
56 "HSC-R": 2.276,
57 "HSC-I": 1.633,
58 "HSC-Z": 1.263,
59 "HSC-Y": 1.075,
60 "NB0387": 4.007,
61 "NB0816": 1.458,
62 "NB0921": 1.187,
63 }
65 bands = list(bands)
66 sfd = SFDQuery()
67 coord_string_ra = "coord_ra_" + str(bands[0])
68 coord_string_dec = "coord_dec_" + str(bands[0])
69 coords = SkyCoord(catalog[coord_string_ra], catalog[coord_string_dec])
70 ebvValues = sfd(coords)
71 extinction_dict = {"E(B-V)": ebvValues}
73 # Create a dict with the extinction values for each band (and E(B-V), too):
74 for band in bands:
75 coeff_name = "A_" + str(band)
76 extinction_dict[coeff_name] = ebvValues * extinctionCoeffs_HSC[band]
78 return extinction_dict