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
Look at Grankin list
In [5]:
d1 = pd.read_csv('../../ApJdataFrames/data/Grankin08/table1_plus.csv') #local version
In [8]:
d1.head(2)
Out[8]:
In [9]:
d1.columns
Out[9]:
In [10]:
c1 = SkyCoord(d1.RA.values, d1.DEC.values, unit=(u.hourangle, u.deg), frame='icrs')
In [11]:
df_list = []
This takes a finite amount of RAM, but should be fine for modern laptops.
In [12]:
for i in range(16):
df_list.append(pd.read_csv('../data/TgasSource_000-000-{:03d}.csv'.format(i)))
In [13]:
tt = pd.concat(df_list, ignore_index=True)
In [15]:
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=1.0)
Out[15]:
In [16]:
cg = SkyCoord(tt.ra.values, tt.dec.values, unit=(u.deg, u.deg), frame='icrs')
In [17]:
idx, d2d, blah = c1.match_to_catalog_sky(cg)
In [18]:
vec_units = d2d.to(u.arcsecond)
vec = vec_units.value
In [20]:
bins = np.arange(0, 4, 0.2)
sns.distplot(vec, bins=bins, kde=False),
plt.xlim(0,4)
plt.xlabel('match separation (arcsec)')
Out[20]:
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 [33]:
plt.figure(figsize=(8,4))
bins = np.arange(2, 14, 0.8)
sns.distplot(x0.parallax[x0.Gaia_match], bins=bins, rug=True)
#sns.distplot(1.0/(x0.parallax[x0.Gaia_match]/1000.0))
plt.xlabel('Parallax (mas)')
plt.savefig('../results/luhman_mamajek2012.png', dpi=300)
In [34]:
x0.Gaia_match.sum(), len(d1)
Out[34]:
In [37]:
x0.columns
Out[37]:
In [42]:
x0['dist_pc'] = 1.0/x0['parallax']*1000
In [49]:
x0.shape
Out[49]:
In [45]:
x0[x0.Gaia_match][['Name', 'SpT', 'parallax', 'dist_pc','phot_g_mean_mag', 'N_seasons']]
Out[45]:
11 out of 48 have Gaia parallaxes.
In [50]:
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[50]:
Not many Oph Targets from the North.