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
1import logging
2from astropy.coordinates import SkyCoord
4log = logging.getLogger(__name__)
6try:
7 from dustmaps.sfd import SFDQuery
8except ModuleNotFoundError as e:
9 log.debug(
10 "The extinction_corr method is not available without first installing the dustmaps module:\n"
11 "$> pip install --user dustmaps\n\n"
12 "Then in a python interpreter:\n"
13 ">>> import dustmaps.sfd\n"
14 ">>> dustmaps.sfd.fetch()\n"
15 "%s",
16 e.msg,
17 )
19__all__ = ("extinction_corr",)
22def extinction_corr(catalog, bands):
24 # Extinction coefficients for HSC filters for conversion from E(B-V) to extinction, A_filter.
25 # Numbers provided by Masayuki Tanaka (NAOJ).
26 #
27 # Band, A_filter/E(B-V)
28 extinctionCoeffs_HSC = {
29 "g": 3.240,
30 "r": 2.276,
31 "i": 1.633,
32 "z": 1.263,
33 "y": 1.075,
34 "HSC-G": 3.240,
35 "HSC-R": 2.276,
36 "HSC-I": 1.633,
37 "HSC-Z": 1.263,
38 "HSC-Y": 1.075,
39 "NB0387": 4.007,
40 "NB0816": 1.458,
41 "NB0921": 1.187,
42 }
44 bands = list(bands)
45 sfd = SFDQuery()
46 coord_string_ra = "coord_ra_" + str(bands[0])
47 coord_string_dec = "coord_dec_" + str(bands[0])
48 coords = SkyCoord(catalog[coord_string_ra], catalog[coord_string_dec])
49 ebvValues = sfd(coords)
50 extinction_dict = {"E(B-V)": ebvValues}
52 # Create a dict with the extinction values for each band (and E(B-V), too):
53 for band in bands:
54 coeff_name = "A_" + str(band)
55 extinction_dict[coeff_name] = ebvValues * extinctionCoeffs_HSC[band]
57 return extinction_dict