forked from warrickball/figures
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gaia_HR.py
42 lines (37 loc) · 1.44 KB
/
gaia_HR.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
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env python3
# intended to mimic Gaia DR2 HR diagrams (A&A 616, A10, 2018),
# specifically, Fig. 6c because I can't be bothered with this extinction business
# https://www.aanda.org/articles/aa/abs/2018/08/aa32843-18/aa32843-18.html
import numpy as np
import matplotlib.pyplot as pl
from matplotlib.colors import PowerNorm
try:
r = np.load('data/gaia_HR.npy')
except IOError:
from astroquery.gaia import Gaia
job = Gaia.launch_job_async("""
SELECT \
phot_g_mean_mag AS g, \
parallax,
e_bp_min_rp_val AS e_bp_rp, \
phot_bp_mean_mag AS bp, \
phot_rp_mean_mag AS rp \
FROM gaiadr2.gaia_source \
WHERE parallax_over_error > 10 \
AND parallax > 10
AND phot_g_mean_flux_over_error > 50 \
AND phot_rp_mean_flux_over_error > 20 \
AND phot_bp_mean_flux_over_error > 20 \
AND phot_bp_rp_excess_factor < 1.3+0.06*power(phot_bp_mean_mag-phot_rp_mean_mag,2) \
AND phot_bp_rp_excess_factor > 1.0+0.015*power(phot_bp_mean_mag-phot_rp_mean_mag,2) \
AND visibility_periods_used > 8 \
AND astrometric_chi2_al/(astrometric_n_good_obs_al-5)<1.44*greatest(1,exp(-0.4*(phot_g_mean_mag-19.5)))""")
r = job.get_results().as_array().data
np.save('data/gaia_HR.npy', r)
G = r['g']+5.*np.log10(r['parallax'])-10
pl.plot(r['bp']-r['rp'], G, 'k.', ms=1, alpha=0.1, rasterized=True, zorder=0);
pl.hist2d(r['bp']-r['rp'], G, cmap='viridis', bins=200, cmin=10, norm=PowerNorm(gamma=0.5), zorder=1)
pl.gca().invert_yaxis()
pl.xlabel('Bp-Rp')
pl.ylabel('G')
pl.show()