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

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