-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata_prep.py
More file actions
89 lines (73 loc) · 2.51 KB
/
data_prep.py
File metadata and controls
89 lines (73 loc) · 2.51 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
def clean_data(df):
import numpy as np
df = df.replace([np.inf, -np.inf], np.nan)
df = df.dropna()
return df
def get_gaia(df):
import numpy as np
import pandas as pd
from astroquery.vizier import Vizier
Vizier.VIZIER_SERVER = 'vizier.ast.cam.ac.uk'
v2 = Vizier()
Gaia_teff = np.zeros(len(df))
Gaia_rad = np.ones(len(df))
ii = 0
for index, row in df.iterrows():
star_name = index[7:] #Get the J-coordinates
try:
tab = v2.query_object(star_name, radius=2*u.arcsec, catalog='Gaia DR2')['I/345/gaia2']
except:
tab=[]
if len(tab) == 1:
Gaia_teff[ii] = tab['Teff'][0]
Gaia_rad[ii] = tab['Rad'][0]
elif len(tab) == 0:
#print('%s is not in Gaia dr2. Replace with j-h value'%star_name)
Gaia_rad[ii] = row['rstar_jh']
Gaia_teff[ii] = row['teff_jh']
else:
#print('%s has %s star(s) within 2 arcsecs. Sticking with j-h radius and teff'%(star_name,len(tab)))
Gaia_rad[ii] = row['rstar_jh']
Gaia_teff[ii] = row['teff_jh']
ii+=1
return(Gaia_rad, Gaia_teff)
def get_trans_ratio(df):
trans_ratio = (df['npts_intrans']/df['npts_good'])/df['width']
return trans_ratio
def get_near_int(df):
near_int = abs(((df['period']+0.5)%1)-0.5)
return near_int
#Use Gaia radius instead?
def get_rm_ratio(df):
rm_ratio = df['rstar_mcmc']/df['mstar_mcmc']
return rm_ratio
def get_depth_to_width(df):
depth_to_width = df['depth']/df['width']
return depth_to_width
#There were some problems with the radius and effective temperature measures in the original datafile.
#It looks like they were calculated before updated jh values were given
#re-calculate them with the equations given in the Cameron et al 2007 appendix
def get_temp(df):
import numpy as np
teff_jh = np.multiply(-4369.5,df['jmag-hmag']) + 7188.2
teff_jh = teff_jh.astype(int)
return teff_jh
#Update the radius estimate based on the revised j-h values
def get_rstar_jh(df):
rstar_jh = (-3.925e-14*df['teff_jh']**4) + (8.3909e-10*df['teff_jh']**3)- (6.555e-6*df['teff_jh']**2) + (0.02245*df['teff_jh']) - 27.9788
return rstar_jh
#G
def get_mstar_jh(df):
mstar_jh = df['rstar_jh']**(1/0.8)
return mstar_jh
#Find the difference between the stellar mass inferred by color and the mcmc
def get_delta_m(df):
delta_m = (df['mstar_jh'] - df['mstar_mcmc'])/df['mstar_jh']
return delta_m
#Find the difference between radius inferred by color and mcmc
def get_delta_r(df):
delta_r = (df['rstar_jh'] - df['rstar_mcmc'])/df['rstar_jh']
return delta_r
def get_delta_Gaia(df):
delta_Gaia = (df['rstar_Gaia'] - df['rstar_mcmc'])/df['rstar_Gaia']
return delta_Gaia