In [1]:
%matplotlib inline
import numpy as np
from scipy import stats
import matplotlib
import matplotlib.pyplot as plt
from matplotlib.colors import LogNorm
import matplotlib.cm as cm
import pandas as pd
#MAKE SURE ALL MASS VALUES ARE POSITIVE!!!
In [2]:
# Making figures look nice
matplotlib.rcParams.update({'font.size':18})
matplotlib.rcParams.update({'font.family':'serif'})
In [3]:
Kep_ID, sep, prob, gkclr, prot = np.loadtxt ('Janes2017_data.txt', usecols=(1,6,7,9,10), unpack=True)
"""
Kep_ID = KIC number
sep = projected physical separation in arcseconds
prob = relative probability of chance alignment
gkclr = g-k color
prot = rotation period in days
"""
Out[3]:
In [4]:
row, Lfl_Lbol, jim_dist, giclr, kicnum, mass, tau = np.genfromtxt('kic_lflare_mass_dist.csv',
usecols = (0,1,8,9,10,11,12), delimiter = ',', unpack = True, skip_header=True)
"""
Lfl_Lbol = Flare luminosity ratio (FLR): Fraction of total stellar luminosity from flares
(see https://github.com/jradavenport/appaloosa for details)
jim_dist = parallaxes from Davenport (2016)
giclr = g-i color
kicnum = KIC number
mass = masses in units of M_sun
tau = Rosby number parameter
"""
#Normalizing very low-signal data
w=np.where((Lfl_Lbol < 1e-15))
Lfl_Lbol[w]=1e-15
In [5]:
#Check for negative mass values
print(len(mass))
for i in range(len(mass)):
if mass[i] <= 0:
np.delete(mass,[i])
print(len(mass))
No negative masses!
In [6]:
m = np.array(np.zeros(len(Kep_ID)), dtype='int')
## m is an array of indices that is the intersection of "Janes2017_data.txt" and "kic_lflare_mass_dist.csv"
## Removing zeros from Kep_ID
for k in range (len(Kep_ID)):
if k==72:
pass
elif k==114:
pass
else:
x = np.where(Kep_ID[k] == kicnum)
#print(x,k)
m[k] = x[0]
print(m,len(m))
# in database speak, this a Join (Inner Join)
In [7]:
m = np.delete(m,[72,114])#Deletes zeros in m - ONLY RUN ONCE!!!
print(len(m),m)
In [8]:
a = np.arange(0,184,2) #primary components
b = np.arange(1,184,2) #secondary components
for j in range(0,len(a)):
if mass[m][a[j]] < mass[m][b[j]]:
tmp = a[j]
a[j] = b[j]
b[j] = tmp
In [9]:
### Good_either index contains FLRs above minimum detection threshold: (1e-7)###
Good_either = np.where(((Lfl_Lbol[m][a] > 1e-7) | (Lfl_Lbol[m][b] > 1e-7)) &
((Lfl_Lbol[m][a] > 1e-15) & (Lfl_Lbol[m][b] > 1e-15)))
print(np.size(Good_either))
Sample size = 58 wide binaries
In [10]:
### FLR of primary vs. FLR of secondary ###
plt.figure(figsize=(8,8))
# plt.plot(np.log10(Lfl_Lbol[m][a][Good_both_a2]), np.log10(Lfl_Lbol[m][b][Good_both_a2]), 'ro', alpha = 0.6)
# plt.plot(np.log10(Lfl_Lbol[m][a][Good_both_b2]), np.log10(Lfl_Lbol[m][b][Good_both_b2]), 'bo', alpha = 0.6)
plt.scatter(np.log10(Lfl_Lbol[m][a][Good_either]), np.log10(Lfl_Lbol[m][b][Good_either]),
alpha = 0.6, s=80, c='r', edgecolor='k', label='Active pairs')
#plt.scatter(np.log10(Lfl_Lbol[m][a]+1e-10), np.log10(Lfl_Lbol[m][b]+1e-10), s=5, c='k', alpha=0.2,
#label='Kepler wide binary pairs')
plt.plot([-11,-2], [-11,-2],'b', lw=3, alpha=0.5,label='Idealized')
#plt.plot([-11,-2], [-12,-3],'y', lw=3, alpha=0.5,label='Within solar variability')
#plt.plot([-11,-2], [-10,-1],'y', lw=3, alpha=0.5)
plt.scatter(-3.93,-4.00, marker='*', color='orange', edgecolor = 'black', s=300, alpha = 1)
#box1 = plt.Polygon([[-5,-4],[-11,-4],[-11,-2],[-3,-2]],fc='g',alpha=0.2,label='Active Secondary')
#box2 = plt.Polygon([[-4,-5],[-4,-11],[-2,-11],[-2,-3]],fc='b',alpha=0.2,label='Active Primary')
#circle = plt.Circle((-11, -11), radius=5, fc='r',alpha=0.2,label='Below noise threshold')
#plt.gca().add_patch(circle)
#plt.gca().add_patch(box1)
#plt.gca().add_patch(box2)
plt.xlim(-11, -2)
plt.ylim(-11, -2)
plt.xlabel(r'log $L_{fl}/L_{kp}$ (A component)')
plt.ylabel(r'log $L_{fl}/L_{kp}$ (B component)')
#plt.legend(fontsize=10, loc=2)
plt.savefig('AB_v1.pdf',dpi=500)
In [11]:
### Adding zone of expected variability for a solar-like cycle ###
plt.figure(figsize=(8,8))
# plt.plot(np.log10(Lfl_Lbol[m][a][Good_both_a2]), np.log10(Lfl_Lbol[m][b][Good_both_a2]), 'ro', alpha = 0.6)
# plt.plot(np.log10(Lfl_Lbol[m][a][Good_both_b2]), np.log10(Lfl_Lbol[m][b][Good_both_b2]), 'bo', alpha = 0.6)
plt.scatter(np.log10(Lfl_Lbol[m][a][Good_either]), np.log10(Lfl_Lbol[m][b][Good_either]),
alpha = 0.6, s=80, c='r', edgecolor='k', label='Active pairs')
#plt.scatter(np.log10(Lfl_Lbol[m][a]+1e-10), np.log10(Lfl_Lbol[m][b]+1e-10), s=5, c='k', alpha=0.2,
#label='Kepler wide binary pairs')
plt.plot([-11,-2], [-11,-2],'b', lw=3, alpha=0.5,label='Idealized')
plt.plot([-11,-2], [-12,-3],'y', lw=3, alpha=0.5,label='Within solar variability')
plt.plot([-11,-2], [-10,-1],'y', lw=3, alpha=0.5)
#box1 = plt.Polygon([[-5,-4],[-11,-4],[-11,-2],[-3,-2]],fc='g',alpha=0.2,label='Active Secondary')
#box2 = plt.Polygon([[-4,-5],[-4,-11],[-2,-11],[-2,-3]],fc='b',alpha=0.2,label='Active Primary')
#circle = plt.Circle((-11, -11), radius=5, fc='r',alpha=0.2,label='Below noise threshold')
#plt.gca().add_patch(circle)
#plt.gca().add_patch(box1)
#plt.gca().add_patch(box2)
plt.xlim(-11, -2)
plt.ylim(-11, -2)
plt.xlabel(r'log $L_{fl}/L_{kp}$ (A component)')
plt.ylabel(r'log $L_{fl}/L_{kp}$ (B component)')
plt.legend(fontsize=10, loc=2)
plt.savefig('AB_v2.pdf',dpi=500)
In [13]:
### Adding zones for "weird" pairs ###
plt.figure(figsize=(8,8))
# plt.plot(np.log10(Lfl_Lbol[m][a][Good_both_a2]), np.log10(Lfl_Lbol[m][b][Good_both_a2]), 'ro', alpha = 0.6)
# plt.plot(np.log10(Lfl_Lbol[m][a][Good_both_b2]), np.log10(Lfl_Lbol[m][b][Good_both_b2]), 'bo', alpha = 0.6)
plt.scatter(np.log10(Lfl_Lbol[m][a][Good_either]), np.log10(Lfl_Lbol[m][b][Good_either]),
alpha = 0.6, s=80, c='r', edgecolor = 'k', label='Active pairs')
#plt.scatter(np.log10(Lfl_Lbol[m][a]+1e-10), np.log10(Lfl_Lbol[m][b]+1e-10), s=5, c='k', alpha=0.2,
#label='Kepler wide binary pairs')
plt.plot([-11,-2], [-11,-2],'b', lw=3, alpha=0.5,label='Idealized')
plt.plot([-11,-2], [-12,-3],'y', lw=3, alpha=0.5,label='Within solar variability')
plt.plot([-11,-2], [-10,-1],'y', lw=3, alpha=0.5)
box1 = plt.Polygon([[-5,-4],[-11,-4],[-11,-2],[-3,-2]],fc='g',alpha=0.1,label='Active Secondary')
box2 = plt.Polygon([[-4,-5],[-4,-11],[-2,-11],[-2,-3]],fc='b',alpha=0.1,label='Active Primary')
circle = plt.Circle((-11, -11), radius=5, fc='r',alpha=0.1,label='Below noise threshold')
plt.gca().add_patch(circle)
plt.gca().add_patch(box1)
plt.gca().add_patch(box2)
plt.xlim(-11, -2)
plt.ylim(-11, -2)
plt.xlabel(r'log $L_{fl}/L_{kp}$ (A component)')
plt.ylabel(r'log $L_{fl}/L_{kp}$ (B component)')
plt.legend(fontsize=10, loc=2)
plt.savefig('AB_v3.png',dpi=500)
In [17]:
### BOX FILTERS ###
gbox = np.where((Lfl_Lbol[m][b][Good_either] > 1e-4) & (Lfl_Lbol[m][a][Good_either] < 1e-4))
bbox = np.where((Lfl_Lbol[m][b][Good_either] < 1e-4) & (Lfl_Lbol[m][a][Good_either] > 1e-4))
ybox = np.where(((np.log10(Lfl_Lbol[m][b][Good_either]) - np.log10(Lfl_Lbol[m][a][Good_either])) < 1) &
((np.log10(Lfl_Lbol[m][b][Good_either]) - np.log10(Lfl_Lbol[m][a][Good_either])) > -1))
In [13]:
### Final form ###
plt.figure(figsize=(8,8.1))
# plt.plot(np.log10(Lfl_Lbol[m][a][Good_both_a2]), np.log10(Lfl_Lbol[m][b][Good_both_a2]), 'ro', alpha = 0.6)
# plt.plot(np.log10(Lfl_Lbol[m][a][Good_both_b2]), np.log10(Lfl_Lbol[m][b][Good_both_b2]), 'bo', alpha = 0.6)
plt.scatter(np.log10(Lfl_Lbol[m][a][Good_either][gbox]), np.log10(Lfl_Lbol[m][b][Good_either][gbox]),
alpha = 0.6, s=80, c='g', edgecolor='k')
plt.scatter(np.log10(Lfl_Lbol[m][a][Good_either][bbox]), np.log10(Lfl_Lbol[m][b][Good_either][bbox]),
alpha = 0.6, s=80, c='b', edgecolor='k')
plt.scatter(np.log10(Lfl_Lbol[m][a][Good_either][ybox]), np.log10(Lfl_Lbol[m][b][Good_either][ybox]),
alpha = 0.6, s=80, c='y', edgecolor='k')
plt.scatter(np.log10(Lfl_Lbol[m][a][Good_either]), np.log10(Lfl_Lbol[m][b][Good_either]), s=10, c='k', alpha=0.4)
plt.plot([-11,-2], [-11,-2],'b', lw=3, alpha=0.5,label='Idealized')
plt.plot([-11,-2], [-12,-3],'y', lw=3, alpha=0.5,label='Within solar variability')
plt.plot([-11,-2], [-10,-1],'y', lw=3, alpha=0.5)
box1 = plt.Polygon([[-5,-4],[-11,-4],[-11,-2],[-3,-2]],fc='g',alpha=0.1,label='Active Secondary')
box2 = plt.Polygon([[-4,-5],[-4,-11],[-2,-11],[-2,-3]],fc='b',alpha=0.1,label='Active Primary')
circle = plt.Circle((-11, -11), radius=5, fc='r',alpha=0.1,label='Below noise threshold')
plt.gca().add_patch(circle)
plt.gca().add_patch(box1)
plt.gca().add_patch(box2)
plt.xlim(-11, -2)
plt.ylim(-11, -2)
plt.xlabel(r'log $L_{fl}/L_{kp}$ (A component)')
plt.ylabel(r'log $L_{fl}/L_{kp}$ (B component)')
#plt.legend(fontsize=10, loc=2)
plt.savefig('AB_v4.pdf',dpi=600)
Adding theoretical mass ratio tracks:
In [16]:
ABfile = 'ABtracks.npz'
npz = np.load(ABfile)
In [17]:
Lfl_Lkp_wb = npz['ABarray']
mass_wb = npz['mass']
age_wb = npz['age']
In [18]:
mass_wb
Out[18]:
In [19]:
for k in range (mass_wb.size):
plt.plot(Lfl_Lkp_wb[-1,:],Lfl_Lkp_wb[k,:],color='b')
In [20]:
### Final w/ mass ratio tracks ###
plt.figure(figsize=(8,8.1))
# plt.plot(np.log10(Lfl_Lbol[m][a][Good_both_a2]), np.log10(Lfl_Lbol[m][b][Good_both_a2]), 'ro', alpha = 0.6)
# plt.plot(np.log10(Lfl_Lbol[m][a][Good_both_b2]), np.log10(Lfl_Lbol[m][b][Good_both_b2]), 'bo', alpha = 0.6)
plt.scatter(np.log10(Lfl_Lbol[m][a][Good_either][gbox]), np.log10(Lfl_Lbol[m][b][Good_either][gbox]),
alpha = 0.6, s=80, c='g', edgecolor='k')
plt.scatter(np.log10(Lfl_Lbol[m][a][Good_either][bbox]), np.log10(Lfl_Lbol[m][b][Good_either][bbox]),
alpha = 0.6, s=80, c='b', edgecolor='k')
plt.scatter(np.log10(Lfl_Lbol[m][a][Good_either][ybox]), np.log10(Lfl_Lbol[m][b][Good_either][ybox]),
alpha = 0.6, s=80, c='y', edgecolor='k')
plt.scatter(np.log10(Lfl_Lbol[m][a][Good_either]), np.log10(Lfl_Lbol[m][b][Good_either]), s=10, c='k', alpha=0.4)
plt.plot([-11,-2], [-11,-2],'b', lw=3, alpha=0.5,label='Idealized')
plt.plot([-11,-2], [-12,-3],'y', lw=3, alpha=0.5,label='Within solar variability')
plt.plot([-11,-2], [-10,-1],'y', lw=3, alpha=0.5)
box1 = plt.Polygon([[-5,-4],[-11,-4],[-11,-2],[-3,-2]],fc='g',alpha=0.1,label='Active Secondary')
box2 = plt.Polygon([[-4,-5],[-4,-11],[-2,-11],[-2,-3]],fc='b',alpha=0.1,label='Active Primary')
circle = plt.Circle((-11, -11), radius=5, fc='r',alpha=0.1,label='Below noise threshold')
plt.gca().add_patch(circle)
plt.gca().add_patch(box1)
plt.gca().add_patch(box2)
for k in range (mass_wb.size):
plt.plot(Lfl_Lkp_wb[-1,:],Lfl_Lkp_wb[k,:],color='k')
plt.xlim(-11, -2)
plt.ylim(-11, -2)
plt.xlabel(r'log $L_{fl}/L_{kp}$ (A)')
plt.ylabel(r'log $L_{fl}/L_{kp}$ (B)')
plt.legend(fontsize=10, loc=2)
plt.savefig('AB_v4.png',dpi=600)
In [14]:
### Mass vs. Activity ###
plt.figure(figsize=(8,8))
# Highlighting systems of interest:
plt.scatter(mass[m][a][Good_either][gbox][0],np.log10(Lfl_Lbol[m][a][Good_either][gbox][0]),s=260,c='white',edgecolor='k',lw=3)
plt.scatter(mass[m][b][Good_either][gbox][0],np.log10(Lfl_Lbol[m][b][Good_either][gbox][0]),s=260,c='white',edgecolor='k',lw=3,marker='s')
plt.scatter(mass[m][a][Good_either][bbox][2],np.log10(Lfl_Lbol[m][a][Good_either][bbox][2]),s=260,c='white',edgecolor='k',lw=3)
plt.scatter(mass[m][b][Good_either][bbox][2],np.log10(Lfl_Lbol[m][b][Good_either][bbox][2]),s=260,c='white',edgecolor='k',lw=3,marker='s')
plt.scatter(mass[m][a][Good_either][bbox],np.log10(Lfl_Lbol[m][a][Good_either][bbox]),alpha = 0.6,s=80,c='b',edgecolor='k')
plt.scatter(mass[m][a][Good_either][gbox],np.log10(Lfl_Lbol[m][a][Good_either][gbox]),alpha = 0.6,s=80,c='g',edgecolor='k')
plt.scatter(mass[m][a][Good_either][ybox],np.log10(Lfl_Lbol[m][a][Good_either][ybox]),alpha = 0.6,s=80,c='y',edgecolor='k')
plt.scatter(mass[m][b][Good_either][bbox],np.log10(Lfl_Lbol[m][b][Good_either][bbox]),alpha = 0.6,s=80,c='b',edgecolor='k',marker='s')
plt.scatter(mass[m][b][Good_either][gbox],np.log10(Lfl_Lbol[m][b][Good_either][gbox]),alpha = 0.6,s=80,c='g',edgecolor='k',marker='s')
plt.scatter(mass[m][b][Good_either][ybox],np.log10(Lfl_Lbol[m][b][Good_either][ybox]),alpha = 0.6,s=80,c='y',edgecolor='k',marker='s')
#Drawing lines between paired stars:
for k in range (len(bbox[0])):
plt.plot([mass[m][a][Good_either][bbox],mass[m][b][Good_either][bbox]],[np.log10(Lfl_Lbol[m][a][Good_either][bbox]),np.log10(Lfl_Lbol[m][b][Good_either][bbox])],'b',lw=0.2,alpha=0.5,
label='Active Secondary')
for k in range (len(gbox[0])):
plt.plot([mass[m][a][Good_either][gbox],mass[m][b][Good_either][gbox]],[np.log10(Lfl_Lbol[m][a][Good_either][gbox]),np.log10(Lfl_Lbol[m][b][Good_either][gbox])],'g',lw=0.2,alpha=0.5,
label='Active Primary')
for k in range (len(ybox[0])):
plt.plot([mass[m][a][Good_either][ybox],mass[m][b][Good_either][ybox]],[np.log10(Lfl_Lbol[m][a][Good_either][ybox]),np.log10(Lfl_Lbol[m][b][Good_either][ybox])],'y',lw=0.2,alpha=0.1,
label='Within solar variability')
# ok = np.where(np.isfinite(giclr))
# plt.hist2d(giclr[ok],np.log10(Lfl_Lbol[ok]),bins=100, range=[[-1,4],[-10,-2]], cmap=cm.Greys,norm=LogNorm())
# plt.colorbar()
plt.ylabel(r'log $L_{fl}/L_{kp}$')
plt.xlabel(r'Mass ($M_{\odot}$)')
plt.xlim(1.5,.2)
plt.savefig('MassPlot.pdf',dpi=500)
In [15]:
### Mass ratio distribution ###
plt.figure(figsize=(10,5))
_ = plt.hist((mass[m][b][Good_either][ybox])/(mass[m][a][Good_either][ybox]), bins = np.arange(.4,1.1,0.1), histtype = 'stepfilled', color = 'y', edgecolor = 'k')
_ = plt.hist((mass[m][b][Good_either][gbox])/(mass[m][a][Good_either][gbox]), bins = np.arange(.4,1.1,0.1), histtype = 'stepfilled', color = 'g', edgecolor = 'k')
_ = plt.hist((mass[m][b][Good_either][bbox])/(mass[m][a][Good_either][bbox]), bins = np.arange(.4,1.1,0.1), histtype = 'stepfilled', color = 'b', edgecolor = 'k')
plt.ylabel('Number of Pairs')
plt.xlabel('Mass Ratio (B/A)')
plt.xlim(0,1)
plt.savefig('MassHist.pdf',dpi=500)
In [16]:
ydist = (mass[m][b][Good_either][ybox])/(mass[m][a][Good_either][ybox])
gdist = (mass[m][b][Good_either][gbox])/(mass[m][a][Good_either][gbox])
bdist = (mass[m][b][Good_either][bbox])/(mass[m][a][Good_either][bbox])
gbdist = np.concatenate((gdist,bdist))
In [17]:
## KS TEST
stats.ks_2samp(gbdist,ydist)
Out[17]:
High p-value indicates we cannot reject the hypothesis that the samples are drawn from the same population.
In [18]:
print(np.where((mass[m][b][Good_either][gbox])/(mass[m][a][Good_either][gbox]) > 0.8))
print(np.where((mass[m][b][Good_either][bbox])/(mass[m][a][Good_either][bbox]) > 0.8))
In [19]:
# Mass ratios of green pairs:
print((mass[m][b][Good_either][gbox])/(mass[m][a][Good_either][gbox]))
In [20]:
# Grabbing indices of same-mass pairs:
print(m[a][Good_either][gbox][0])
print(m[b][Good_either][gbox][0])
print(m[a][Good_either][gbox][1])
print(m[b][Good_either][gbox][1])
print(m[a][Good_either][bbox][2])
print(m[b][Good_either][bbox][2])
In [21]:
## System 1 KICs
print(kicnum[146654])
print(kicnum[146653])
## System 2 KICs
print(kicnum[141965])
print(kicnum[38561])
print(kicnum[13986])
print(kicnum[173725])
In [22]:
## Rotation Periods
np.where((Kep_ID == 7871442) | (Kep_ID == 7871438))
print(prot[16])
print(prot[17])
In [23]:
## FLRs
print(Lfl_Lbol[146654])
print(Lfl_Lbol[146653])
In [24]:
gmass = np.where((mass[m][b][Good_either][gbox])/(mass[m][a][Good_either][gbox]) > 0.8)
bmass = np.where((mass[m][b][Good_either][bbox])/(mass[m][a][Good_either][bbox]) > 0.8)
ymass = np.where((mass[m][b][Good_either][ybox])/(mass[m][a][Good_either][ybox]) > 0.8)
allmass = np.where((mass[m][b][Good_either])/(mass[m][a][Good_either]) > 0.8)
In [25]:
### Activity Comparison for pairs w/ mass ratios > 0.8 ###
plt.figure(figsize=(8,8.1))
# plt.plot(np.log10(Lfl_Lbol[m][a][Good_both_a2]), np.log10(Lfl_Lbol[m][b][Good_both_a2]), 'ro', alpha = 0.6)
# plt.plot(np.log10(Lfl_Lbol[m][a][Good_both_b2]), np.log10(Lfl_Lbol[m][b][Good_both_b2]), 'bo', alpha = 0.6)
plt.scatter(np.log10(Lfl_Lbol[m][a][Good_either][gbox][gmass]), np.log10(Lfl_Lbol[m][b][Good_either][gbox][gmass]),
alpha = 0.6, s=80, c='g', edgecolor='k')
plt.scatter(np.log10(Lfl_Lbol[m][a][Good_either][bbox][bmass]), np.log10(Lfl_Lbol[m][b][Good_either][bbox][bmass]),
alpha = 0.6, s=80, c='b', edgecolor='k')
plt.scatter(np.log10(Lfl_Lbol[m][a][Good_either][ybox][ymass]), np.log10(Lfl_Lbol[m][b][Good_either][ybox][ymass]),
alpha = 0.6, s=80, c='y', edgecolor='k')
plt.scatter(np.log10(Lfl_Lbol[m][a][Good_either][allmass]), np.log10(Lfl_Lbol[m][b][Good_either][allmass]),
alpha = 0.6, s=80, c='none', edgecolor='k')
plt.scatter(np.log10(Lfl_Lbol[m][a][Good_either]), np.log10(Lfl_Lbol[m][b][Good_either]), s=10, c='k', alpha=0.4)
plt.plot([-11,-2], [-11,-2],'b', lw=3, alpha=0.5,label='Idealized')
plt.plot([-11,-2], [-12,-3],'y', lw=3, alpha=0.5,label='Within solar variability')
plt.plot([-11,-2], [-10,-1],'y', lw=3, alpha=0.5)
box1 = plt.Polygon([[-5,-4],[-11,-4],[-11,-2],[-3,-2]],fc='g',alpha=0.1,label='Active Secondary')
box2 = plt.Polygon([[-4,-5],[-4,-11],[-2,-11],[-2,-3]],fc='b',alpha=0.1,label='Active Primary')
circle = plt.Circle((-11, -11), radius=5, fc='r',alpha=0.1,label='Below noise threshold')
plt.gca().add_patch(circle)
plt.gca().add_patch(box1)
plt.gca().add_patch(box2)
plt.xlim(-11, -2)
plt.ylim(-11, -2)
plt.xlabel(r'log $L_{fl}/L_{kp}$ (A component)')
plt.ylabel(r'log $L_{fl}/L_{kp}$ (B component)')
#plt.legend(fontsize=10, loc=2)
plt.savefig('AB_v5.pdf',dpi=600)
In [26]:
## Since we deleted problem indices in m, we need to delete them in prot ##
prot = np.delete(prot,[72,114])
print(prot)
In [27]:
# Calculating rosby numbers:
rosby = prot/tau[m]
print(rosby)
In [28]:
rosby[gbox]
Out[28]:
In [150]:
### Rosby number vs. Activity w/ points colored by primary/secondary ###
fig = plt.figure(figsize=(8,8))
plt.scatter(rosby[a][Good_either],np.log10(Lfl_Lbol[m][a][Good_either]),alpha = 0.6,s=80,c='r')
plt.scatter(rosby[b][Good_either],np.log10(Lfl_Lbol[m][b][Good_either]),alpha = 0.6,s=80,c='b')
for j in range (np.size(Good_either[0])):
plt.plot([rosby[a][Good_either],rosby[b][Good_either]],[np.log10(Lfl_Lbol[m][a][Good_either]),np.log10(Lfl_Lbol[m][b][Good_either])],'k',lw=0.2,alpha=0.1)
plt.xscale('log')
plt.ylim(-8,-2)
plt.xlabel(r'Ro ($P_{rot}/\tau$)')
plt.ylabel(r'log $L_{fl}/L_{kp}$')
plt.savefig('ABrot.png',dpi=500)
In [36]:
### Rosby number vs. Activity w/ points colored by y/g/b activity populations ###
fig = plt.figure(figsize=(8,8))#connect these by lines
for j in range (len(bbox[0])):
plt.plot([rosby[a][Good_either][bbox],rosby[b][Good_either][bbox]],
[np.log10(Lfl_Lbol[m][a][Good_either][bbox]),np.log10(Lfl_Lbol[m][b][Good_either][bbox])],'b',lw=0.2,alpha=0.5)
for j in range (len(gbox[0])):
plt.plot([rosby[a][Good_either][gbox],rosby[b][Good_either][gbox]],
[np.log10(Lfl_Lbol[m][a][Good_either][gbox]),np.log10(Lfl_Lbol[m][b][Good_either][gbox])],'g',lw=0.2,alpha=0.5)
for j in range (len(ybox[0])):
plt.plot([rosby[a][Good_either][ybox],rosby[b][Good_either][ybox]],
[np.log10(Lfl_Lbol[m][a][Good_either][ybox]),np.log10(Lfl_Lbol[m][b][Good_either][ybox])],'y',lw=0.2,alpha=0.1)
# Highlighting pair of interest:
plt.scatter(rosby[a][Good_either][gbox][0],np.log10(Lfl_Lbol[m][a][Good_either][gbox][0]),s=260,c='white', edgecolor = 'k', linewidth=3)
plt.scatter(rosby[b][Good_either][gbox][0],np.log10(Lfl_Lbol[m][b][Good_either][gbox][0]),s=260,c='white', marker = 's', edgecolor = 'k', linewidth=3)
plt.scatter(rosby[a][Good_either][bbox][2],np.log10(Lfl_Lbol[m][a][Good_either][bbox][2]),s=260,c='white', edgecolor = 'k', linewidth=3)
plt.scatter(rosby[b][Good_either][bbox][2],np.log10(Lfl_Lbol[m][b][Good_either][bbox][2]),s=260,c='white', marker = 's', edgecolor = 'k', linewidth=3)
#plt.scatter(rosby[a][Good_either],np.log10(Lfl_Lbol[m][a][Good_either]),alpha = 0.3,s=80,c='k',marker = '.')
#plt.scatter(rosby[b][Good_either],np.log10(Lfl_Lbol[m][b][Good_either]),alpha = 0.3,s=80,c='k',marker = '.')
plt.scatter(rosby[a][Good_either][bbox],np.log10(Lfl_Lbol[m][a][Good_either][bbox]),alpha = 0.6,s=80,c='b',edgecolor = 'k')
plt.scatter(rosby[a][Good_either][gbox],np.log10(Lfl_Lbol[m][a][Good_either][gbox]),alpha = 0.6,s=80,c='g',edgecolor = 'k')
plt.scatter(rosby[a][Good_either][ybox],np.log10(Lfl_Lbol[m][a][Good_either][ybox]),alpha = 0.6,s=80,c='y',edgecolor = 'k')
plt.scatter(rosby[b][Good_either][bbox],np.log10(Lfl_Lbol[m][b][Good_either][bbox]),alpha = 0.6,s=80,c='b',marker='s',edgecolor = 'k')
plt.scatter(rosby[b][Good_either][gbox],np.log10(Lfl_Lbol[m][b][Good_either][gbox]),alpha = 0.6,s=80,c='g',marker='s',edgecolor = 'k')
plt.scatter(rosby[b][Good_either][ybox],np.log10(Lfl_Lbol[m][b][Good_either][ybox]),alpha = 0.6,s=80,c='y',marker='s',edgecolor = 'k')
plt.xscale('log')
plt.xlim(1e-2,1e1)
plt.xlabel(r'Ro ($P_{rot}/\tau$)')
plt.ylabel(r'log $L_{fl}/L_{kp}$')
plt.savefig('GBYrot.pdf',dpi=500)
In [37]:
# cross matched using CDS XMatch Service of:
# Gaia DR1 TGAS and KIC
file = '1497471274965A.csv'
In [38]:
gaia = pd.read_csv(file)
gaia.columns
Out[38]:
In [39]:
jfile = 'Janes2017_data.txt'
janes = pd.read_table(jfile, delim_whitespace=True, comment='#',
names=('Bid', 'KIC', 'pm_ra', 'pme_ra', 'pm_de', 'pme_de',
'Sep','Irp', 'gmag', 'g_Ks', 'per','e_per','V','e_V', 'NQtrs', 'flag'))
In [40]:
janes.shape
Out[40]:
In [41]:
big_table = pd.merge(janes, gaia, how='inner', left_on='KIC', right_on=u'KIC')
big_table.shape
Out[41]:
In [42]:
gaia_dist = np.zeros(len(janes)) - 1
for i in range(len(janes)):
x = np.where((gaia[u'KIC'] == janes['KIC'].values[i]))[0]
if len(x) > 0:
gaia_dist[i] = 1000./ gaia[u'parallax'].values[x]
In [43]:
psep1 = gaia_dist*sep # Distances from GAIA
In [44]:
sep = np.delete(sep,[72,114]) # Deleting problem indices
In [45]:
psep2 = jim_dist[m]*sep # Distances from Davenport (2016)
In [46]:
### Physical separation [AU] distribution ###
fig = plt.figure(figsize = (10,5))
plt.hist(psep2[a][Good_either],bins=20,range=(0,30000),histtype='stepfilled',color='grey',edgecolor='k')
plt.hist(psep2[a][Good_either][ybox],bins=20,range=(0,30000),histtype='stepfilled',color='y',edgecolor='k')
plt.hist(psep2[a][Good_either][gbox],bins=20,range=(0,30000),histtype='stepfilled',color='g',edgecolor='k')
plt.hist(psep2[a][Good_either][bbox],bins=20,range=(0,30000),histtype='stepfilled',color='b',edgecolor='k')
plt.xlabel('Projected Physical Separation [AU]')
plt.ylabel('Number of binaries')
plt.savefig('sephist.pdf', dpi=300)
In [47]:
prob = np.delete(prob,[72,114])
In [48]:
prob = prob*0.00001
In [49]:
fig = plt.figure(figsize = (10,5))
plt.hist(prob[a][Good_either][ybox],bins=20,histtype='stepfilled',color='y',edgecolor='k')
plt.hist(prob[a][Good_either][gbox],bins=20,histtype='stepfilled',color='g',edgecolor='k')
plt.hist(prob[a][Good_either][bbox],bins=20,histtype='stepfilled',color='b',edgecolor='k')
plt.xlabel('Probability of chance alignment')
plt.ylabel('Number of binaries')
plt.savefig('probhist.pdf',dpi=300)
In [50]:
from astropy.io import fits
In [51]:
target_1b = fits.open('kplr007871438-2009166043257_llc.fits')
target_1a = fits.open('kplr007871442-2009166043257_llc.fits')
target_2a = fits.open('kplr010536761-2009166043257_llc.fits')
target_2b = fits.open('kplr008888573-2009350155506_llc.fits')
In [52]:
target_1a.info()
In [53]:
target_1b.info()
In [54]:
target_1a[0].header
Out[54]:
In [55]:
target_1b[0].header
Out[55]:
In [56]:
cols = target_1a[1].columns
In [57]:
cols.info()
In [58]:
k1a_data = target_1a[1].data
k1b_data = target_1b[1].data
k2a_data = target_2a[1].data
k2b_data = target_2b[1].data
In [59]:
time_1a = k1a_data['TIME']
flux_1a = k1a_data['PDCSAP_FLUX']
rel_flux_1a = (flux_1a-np.nanmedian(flux_1a))/np.nanmedian(flux_1a)
err_1a = k1a_data['PDCSAP_FLUX_ERR']
time_1b = k1b_data['TIME']
flux_1b = k1b_data['PDCSAP_FLUX']
rel_flux_1b = (flux_1b-np.nanmedian(flux_1b))/np.nanmedian(flux_1b)
err_1b = k1b_data['PDCSAP_FLUX_ERR']
time_2a = k2a_data['TIME']
flux_2a = k2a_data['PDCSAP_FLUX']
rel_flux_2a = (flux_2a-np.nanmedian(flux_2a))/np.nanmedian(flux_2a)
err_2a = k2a_data['PDCSAP_FLUX_ERR']
time_2b = k2b_data['TIME']
flux_2b = k2b_data['PDCSAP_FLUX']
rel_flux_2b = (flux_2b-np.nanmedian(flux_2b))/np.nanmedian(flux_2b)
err_2b = k2b_data['PDCSAP_FLUX_ERR']
In [60]:
fig = plt.figure(figsize = (11,5))
plt.plot(time_1a,rel_flux_1a,color='g')
#plt.errorbar(time,flux,yerr=err,color='g',linestyle="None")
plt.xlim(150,160)
plt.ylim(-0.01,0.01)
plt.xlabel('Time [BJD-2454833]')
plt.ylabel('Relative Flux')
plt.title('KIC 7871442')
plt.savefig('lc1.pdf', dpi=300)
In [61]:
fig = plt.figure(figsize = (11,5))
plt.plot(time_1b,rel_flux_1b,color='g')
#plt.errorbar(time,flux,yerr=err,color='g',linestyle="None")
plt.xlim(150,160)
plt.ylim(-0.02,0.04)
plt.xlabel('Time [BJD-2454833]')
plt.ylabel('Relative Flux')
plt.title('KIC 7871438')
plt.savefig('lc2.pdf', dpi=300)
In [62]:
fig = plt.figure(figsize = (11,5))
plt.plot(time_2a,rel_flux_2a,color='b')
#plt.errorbar(time,flux,yerr=err,color='g',linestyle="None")
plt.xlim(150,160)
plt.ylim(-0.02,0.05)
plt.xlabel('Time [BJD-2454833]')
plt.ylabel('Relative Flux')
plt.title('KIC 10536761')
plt.savefig('lc3.pdf', dpi=300)
In [63]:
fig = plt.figure(figsize = (11,5))
plt.plot(time_2b,rel_flux_2b,color='b')
#plt.errorbar(time,flux,yerr=err,color='g',linestyle="None")
plt.ylim(-0.01,0.01)
plt.xlim(260,300)
plt.xlabel('Time [BJD-2454833]')
plt.ylabel('Relative Flux')
plt.title('KIC 8888573')
plt.savefig('lc4.pdf', dpi=300)
In [10]:
from astropy.table import Table,Column
In [53]:
## Need to combine lists of A- and B-components such that binary pairs are listed together in each column.
kicall = np.zeros(116)
x=0
y=0
for i in range(116):
if i%2 == 0:
kicall[i] = kicnum[m][a][Good_either][x]
x = x+1
else:
kicall[i] = kicnum[m][b][Good_either][y]
y = y+1
In [54]:
giall = np.zeros(116)
x=0
y=0
for i in range(116):
if i%2 == 0:
giall[i] = giclr[m][a][Good_either][x]
x = x+1
else:
giall[i] = giclr[m][b][Good_either][y]
y = y+1
In [55]:
protall = np.zeros(116)
x=0
y=0
for i in range(116):
if i%2 == 0:
protall[i] = prot[a][Good_either][x]
x = x+1
else:
protall[i] = prot[b][Good_either][y]
y = y+1
In [56]:
Lfl_Lbol_all = np.zeros(116)
x=0
y=0
for i in range(116):
if i%2 == 0:
Lfl_Lbol_all[i] = Lfl_Lbol[m][a][Good_either][x]
x = x+1
else:
Lfl_Lbol_all[i] = Lfl_Lbol[m][b][Good_either][y]
y = y+1
In [57]:
mass_all = np.zeros(116)
x=0
y=0
for i in range(116):
if i%2 == 0:
mass_all[i] = mass[m][a][Good_either][x]
x = x+1
else:
mass_all[i] = mass[m][b][Good_either][y]
y = y+1
In [58]:
jim_dist_all = np.zeros(116)
x=0
y=0
for i in range(116):
if i%2 == 0:
jim_dist_all[i] = jim_dist[m][a][Good_either][x]
x = x+1
else:
jim_dist_all[i] = jim_dist[m][b][Good_either][y]
y = y+1
In [59]:
## Making an array for pair ID numbers, i.e. [1,1,2,2,3,3,...]
bnum = np.zeros(116)
cnt = 0
for j in range(116):
if j%2 == 0:
bnum[j] = cnt+1
else:
bnum[j] = cnt+1
cnt = cnt+1
bnum = bnum.astype(int)
In [60]:
## Building table
t = Table(masked= True)
t['KIC'] = kicall.astype(int)
t['Binary Number'] = bnum
t['g-i'] = giall
t[r'$P_{rot}$ [days]'] = protall
t['Parallax [mas]'] = jim_dist_all
t[r'$L_{fl}/L_{kp}$'] = Lfl_Lbol_all
t[r'Mass $[M_{\odot}]$'] = mass_all
#Column formatting
t['g-i'].format = '7.2f'
t['Parallax [mas]'].format = '7.1f'
t[r'Mass $[M_{\odot}]$'].format = '7.3f'
t[r'$L_{fl}/L_{kp}$'].format = '7.3'
#Masking nans in giclr
t['g-i'].mask = np.isnan(giall)
In [61]:
t.show_in_notebook()
Out[61]:
In [62]:
## Write table to deluxetable .tex file
t.write('wbtable', format='ascii.aastex', delimiter = '&', overwrite = True)
In [ ]: