In [74]:
from isochrones.dartmouth import Dartmouth_Isochrone
dar = Dartmouth_Isochrone()
2 stars physically bound wih mass 0.5Msun, 1.5Msun. Another separate star with mass 1.0Msun
In [75]:
from isochrones.utils import addmags
import numpy as np
M1 = 1.5
M2 = 0.5
M3 = 1.0
age1 = np.log10(5e8)
age3 = np.log10(5e9)
feh = 0.0
distance1 = 300
distance3 = 500
AV = 0.1
unresolved_bands = ['i','J','H','K','W1','W2']
resolved_bands = ['i','J','K']
args1 = (age1, feh, distance1, AV)
args3 = (age3, feh, distance3, AV)
unresolved = {b:addmags(dar.mag[b](M1, *args1), dar.mag[b](M2, *args1), dar.mag[b](M3, *args3)) for b in unresolved_bands}
resolved_1 = {b:dar.mag[b](M1, *args1) for b in resolved_bands}
resolved_2 = {b:dar.mag[b](M2, *args1) for b in resolved_bands}
resolved_3 = {b:dar.mag[b](M3, *args3) for b in resolved_bands}
In [76]:
unresolved, resolved_1, resolved_2, resolved_3
Out[76]:
In [77]:
import pandas as pd
instruments = ['twomass','WISE','SDSS','RAO']
bands = {'twomass':['J','H','K'],
'WISE':['W1','W2'],
'SDSS':['i'],
'RAO':['i','J','K']}
mag_unc = {'twomass': 0.02, 'WISE':0.02, 'SDSS':0.02, 'RAO':0.1}
resolution = {'twomass':4.0, 'WISE':5.0, 'SDSS':4.5, 'RAO':0.1}
relative = {'twomass':False, 'WISE':False, 'SDSS':False, 'RAO':True}
separation2 = 0.5
separation3 = 1.2
PA2, PA3 = 100.,45.
columns = ['name', 'band', 'resolution', 'relative', 'separation', 'pa', 'mag', 'e_mag']
df = pd.DataFrame(columns=columns)
i=0
for inst in ['twomass', 'WISE','SDSS']: #Unresolved observations
for b in bands[inst]:
row = {}
row['name'] = inst
row['band'] = b
row['resolution'] = resolution[inst]
row['relative'] = relative[inst]
row['separation'] = 0.
row['pa'] = 0.
row['mag'] = unresolved[b]
row['e_mag'] = mag_unc[inst]
df = df.append(pd.DataFrame(row, index=[i]))
i += 1
for inst in ['RAO']: #Resolved observations
for b in bands[inst]:
mags = [resolved_1[b], resolved_2[b], resolved_3[b]]
pas = [0, PA2, PA3]
seps = [0., separation2, separation3]
for mag,sep,pa in zip(mags,seps,pas):
row = {}
row['name'] = inst
row['band'] = b
row['resolution'] = resolution[inst]
row['relative'] = relative[inst]
row['separation'] = sep
row['pa'] = pa
row['mag'] = mag
row['e_mag'] = mag_unc[inst]
df = df.append(pd.DataFrame(row, index=[i]))
i += 1
df
Out[77]:
In [78]:
from isochrones.observation import ObservationTree
In [79]:
t = ObservationTree.from_df(df, name='test-triplet')
t.print_ascii()
In [80]:
t.define_models(dar)
t.print_ascii()
In [81]:
t.add_limit(logg=(3.0,None))
t.print_ascii()
In [82]:
from isochrones.starmodel import StarModel
mod = StarModel(dar, obs=t)
In [83]:
%timeit mod.fit_multinest(n_live_points=1000)
In [35]:
mod.samples[['mass_0_0','mass_0_1','mass_0_2','age_0','feh_0','distance_0','AV_0']].head()
Out[35]:
In [36]:
%matplotlib inline
#mod.corner(['mass_0_0', 'mass_0_1','logg_0_0','age_0','distance_0','AV_0']);
mod.corner_physical();
In [37]:
mod.corner_observed();
In [38]:
mod.obs.print_ascii(p=[M1,M2,M3, age1,feh,distance1,AV])
In [39]:
t2 = ObservationTree.from_df(df, name='triple2')
t2.define_models(dar, index=[0,1,2])
t2.print_ascii()
In [40]:
mod2 = StarModel(dar, obs=t2)
%timeit mod2.fit_multinest(basename='unassoc')
In [41]:
mod2.corner_physical();
In [42]:
mod2.corner_observed();
In [43]:
mod.evidence
Out[43]:
In [44]:
mod2.evidence
Out[44]:
In [45]:
t3 = ObservationTree.from_df(df, name='triple3')
t3.define_models(dar, index=[0,0,1])
t3.print_ascii()
In [46]:
mod3 = StarModel(dar, obs=t3)
%timeit mod3.fit_multinest(basename='unassoc1')
In [47]:
mod3.corner_physical();
In [48]:
mod3.corner_observed();
In [49]:
t4 = ObservationTree.from_df(df, name='triple4')
t4.define_models(dar, index=[0,1,1])
t4.print_ascii()
In [50]:
mod4 = StarModel(dar, obs=t4)
%timeit mod4.fit_multinest(basename='unassoc2')
In [51]:
mod4.corner_physical();
In [52]:
mod4.corner_observed();
In [53]:
mod3.evidence
Out[53]:
In [54]:
mod4.evidence
Out[54]:
In [55]:
t5 = ObservationTree.from_df(df, name='triple5')
t5.define_models(dar, index=[1,0,1])
t5.print_ascii()
In [56]:
mod5 = StarModel(dar, obs=t5)
%timeit mod5.fit_multinest(basename='unassoc5')
In [57]:
mod5.corner_physical();
In [58]:
mod5.corner_observed();
In [59]:
mod5.evidence
Out[59]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]: