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