Import these first-- I auto import them every time!:
In [1]:
#! cat /Users/gully/.ipython/profile_default/startup/start.ipy
In [2]:
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
%config InlineBackend.figure_format = 'retina'
%matplotlib inline
In [3]:
import pandas as pd
In [4]:
from astropy import units as u
from astropy.coordinates import SkyCoord
Retrieve Data file from here:
https://github.com/BrownDwarf/ApJdataFrames/blob/master/data/Luhman2012/tbl1_plusSimbad.csv
In [5]:
d1 = pd.read_csv('../../ApJdataFrames/data/Luhman2012/tbl1_plusSimbad.csv') #local version
In [6]:
d1 = d1[~d1.RA.isnull()]
In [7]:
d1.columns
Out[7]:
In [8]:
c1 = SkyCoord(d1.RA.values, d1.DEC.values, unit=(u.hourangle, u.deg), frame='icrs')
In [9]:
df_list = []
This takes a finite amount of RAM, but should be fine for modern laptops.
In [10]:
for i in range(16):
df_list.append(pd.read_csv('../data/TgasSource_000-000-{:03d}.csv'.format(i)))
In [11]:
tt = pd.concat(df_list, ignore_index=True)
In [12]:
plt.figure(figsize=(10,4))
ax = sns.jointplot(tt.ra, tt.dec, kind='hex', size=8)
ax.ax_joint.plot(c1.ra.deg, c1.dec.deg, '.', alpha=0.5)
Out[12]:
In [13]:
cg = SkyCoord(tt.ra.values, tt.dec.values, unit=(u.deg, u.deg), frame='icrs')
In [15]:
idx, d2d, blah = c1.match_to_catalog_sky(cg)
In [16]:
vec_units = d2d.to(u.arcsecond)
vec = vec_units.value
In [17]:
bins = np.arange(0, 4, 0.2)
sns.distplot(vec, bins=bins, kde=False),
plt.xlim(0,4)
plt.xlabel('match separation (arcsec)')
Out[17]:
Forced to match to nearest neighbor
In [21]:
len(set(idx)), idx.shape[0]
Out[21]:
... yielding some redundancies in cross matching
In [22]:
tt_sub = tt.iloc[idx]
tt_sub = tt_sub.reset_index()
tt_sub = tt_sub.drop('index', axis=1)
In [23]:
d1 = d1.reset_index()
d1 = d1.drop('index', axis=1)
In [24]:
x1 = pd.concat([d1, tt_sub], axis=1)
In [25]:
x1.shape
Out[25]:
In [26]:
col_order = d1.columns.values.tolist() + tt_sub.columns.values.tolist()
x1 = x1[col_order]
x0 = x1.copy()
In [27]:
x0['xmatch_sep_as'] = vec
In [28]:
x0['Gaia_match'] = vec < 2.0 #Fairly liberal, 1.0 might be better.
In [29]:
plt.figure(figsize=(8,4))
bins = np.arange(2, 14, 0.2)
sns.distplot(x0.parallax[x0.Gaia_match], bins=bins)
#sns.distplot(1.0/(x0.parallax[x0.Gaia_match]/1000.0))
plt.xlabel('Parallax (mas)')
plt.savefig('../results/luhman_mamajek2012.png', dpi=300)
In [32]:
x0.Gaia_match.sum(), len(d1)
Out[32]:
112 out of 862 have Gaia parallaxes... that seems high for some reason?
In [40]:
plt.figure(figsize=(10,4))
ax = sns.jointplot(tt.ra, tt.dec, kind='hex', size=8, xlim=(230,255), ylim=(-40,-10))
ax.ax_joint.plot(c1.ra.deg, c1.dec.deg, '.', alpha=0.5)
ax.ax_joint.scatter(x0.ra[x0.Gaia_match], x0.dec[x0.Gaia_match],
s=x0.parallax[x0.Gaia_match]**3*0.2, c='r',alpha=0.5)
Out[40]: