Skip to content

Commit

Permalink
#10 Use Astroquery as backup
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-guangtou committed Aug 31, 2018
1 parent 92533ea commit b973733
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions kungpao/extinction.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,20 @@ def radec_extinction(ra, dec, a_lambda=1.0):
Convert the e_bv value into extinction in magnitude unit.
"""
coords = SkyCoord(ra, dec, frame='icrs', unit='deg')

try:
# mwdust by Jo Bovy
import mwdust
sfd = mwdust.SFD(sf10=True)
coords = SkyCoord(ra, dec, frame='icrs', unit='deg')
ebv = sfd(coords.galactic.l.deg, coords.galactic.b.deg, 0)
except ImportError:
raise Exception("# Both mwdust and sncosmo are not available")
try:
# Try querying the IRSA dust map instead
from astroquery.irsa_dust import IrsaDust
extinction_tab = IrsaDust.get_extinction_table(coords)
ebv = (extinction_tab['A_SFD'] / extinction_tab['A_over_E_B_V_SFD'])[1]
except ImportError:
raise Exception("# Need mwdust by Jo Bovy or Astroquery")

return a_lambda * ebv

0 comments on commit b973733

Please sign in to comment.