forked from martinmcallister/lfit_python
-
Notifications
You must be signed in to change notification settings - Fork 1
/
find_dist_reddening.py
31 lines (23 loc) · 935 Bytes
/
find_dist_reddening.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import sys
from astropy import coordinates as coord
from astropy import units as u
from astroquery.gaia import Gaia
from dustmaps.bayestar import BayestarQuery
from dustmaps.sfd import SFDQuery
from sigfig import round
Gaia.MAIN_GAIA_TABLE = "gaiadr3.gaia_source"
try:
coo = coord.SkyCoord.from_name(sys.argv[1])
except Exception:
coo = coord.SkyCoord.from_name(sys.argv[1], parse=True)
r = Gaia.query_object_async(coordinate=coo, width=10 * u.arcsec, height=10 * u.arcsec)
d = coord.Distance(parallax=float(r["parallax"]) * u.mas)
coo = coord.SkyCoord(coo.ra, coo.dec, distance=d)
bayestar = BayestarQuery()
sfd = SFDQuery()
ebv_bayestar = bayestar(coo, mode="percentile", pct=[16.0, 50.0, 84.0])
ebv_sfd = sfd(coo)
pstring = round(float(r["parallax"]), float(r["parallax_error"]))
print(f"Gaia Parallax = {pstring}")
print(f"Bayestar 16th-84th percentiles = {ebv_bayestar}")
print(f"Max E(B-V) from SFD = {ebv_sfd}")