Last active
July 16, 2020 12:37
-
-
Save dfm/b5a21357dc2d3191ffd30e3ebd219cee to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from astropy.io import ascii | |
import astropy.units as u | |
from astropy.coordinates import SkyCoord | |
from astroquery.gaia import Gaia | |
def find_one(ra, dec, mag): | |
coord = SkyCoord(ra=ra, dec=dec, unit=(u.deg, u.deg)) | |
radius = 5 * u.arcsec | |
j = Gaia.cone_search_async(coord, radius) | |
r = j.get_results() | |
# Restrict the magnitude | |
r = r[abs(r["phot_g_mean_mag"] - mag) < 1.0] | |
if not len(r): | |
return float("nan") | |
# Select the closest target | |
r = r[0] | |
return float(r["lum_val"]) | |
data = ascii.read("https://arxiv.org/src/1501.01635v3/anc/Tables5_6_7.txt") | |
with open("lbol.csv", "w") as f: | |
for row in data: | |
f.write( | |
f'{row["Name"]},{find_one(row["RAdeg"], row["DEdeg"], row["Gaiamag"])}\n' | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment