In [1]:
from isochrones.dartmouth import Dartmouth_Isochrone
dar = Dartmouth_Isochrone()

3 stars physically bound wih mass 0.5Msun, 1.0Msun , 2.0Msun


In [2]:
from isochrones.utils import addmags
import numpy as np
M1 = 2.
M2 = 1.0
M3 = 0.5
age = np.log10(5e8)
feh = 0.0
distance = 500
AV = 0.1

unresolved_bands = ['i','J','H','K','W1','W2']
resolved_bands = ['i','J','K']
args = (age, feh, distance, AV)
unresolved = {b:addmags(dar.mag[b](M1, *args), dar.mag[b](M2, *args), dar.mag[b](M3, *args)) for b in unresolved_bands}
resolved_1 = {b:dar.mag[b](M1, *args) for b in resolved_bands}
resolved_2 = {b:dar.mag[b](M2, *args) for b in resolved_bands}
resolved_3 = {b:dar.mag[b](M3, *args) for b in resolved_bands}

In [3]:
unresolved, resolved_1, resolved_2, resolved_3


Out[3]:
({'H': 9.7256583693171077,
  'J': 9.779566102660386,
  'K': 9.7007141247839961,
  'W1': 9.6944031577453735,
  'W2': 9.6931598667184637,
  'i': 10.250277342930602},
 {'J': 9.8842517232839757, 'K': 9.8482277980788435, 'i': 10.315409572448191},
 {'J': 12.457760436489632, 'K': 12.069009619730219, 'i': 13.37534244453469},
 {'J': 15.158660756096186, 'K': 14.324377065621592, 'i': 17.000775827153767})

In [4]:
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[4]:
band e_mag mag name pa relative resolution separation
0 J 0.02 9.779566 twomass 0.0 False 4.0 0.0
1 H 0.02 9.725658 twomass 0.0 False 4.0 0.0
2 K 0.02 9.700714 twomass 0.0 False 4.0 0.0
3 W1 0.02 9.694403 WISE 0.0 False 5.0 0.0
4 W2 0.02 9.693160 WISE 0.0 False 5.0 0.0
5 i 0.02 10.250277 SDSS 0.0 False 4.5 0.0
6 i 0.10 10.315410 RAO 0.0 True 0.1 0.0
7 i 0.10 13.375342 RAO 100.0 True 0.1 0.5
8 i 0.10 17.000776 RAO 45.0 True 0.1 1.2
9 J 0.10 9.884252 RAO 0.0 True 0.1 0.0
10 J 0.10 12.457760 RAO 100.0 True 0.1 0.5
11 J 0.10 15.158661 RAO 45.0 True 0.1 1.2
12 K 0.10 9.848228 RAO 0.0 True 0.1 0.0
13 K 0.10 12.069010 RAO 100.0 True 0.1 0.5
14 K 0.10 14.324377 RAO 45.0 True 0.1 1.2

In [5]:
from isochrones.observation import ObservationTree

In [6]:
t = ObservationTree.from_df(df, name='test-triplet')
t.print_ascii()


test-triplet
 ╚═ WISE W1=(9.69, 0.02) @(0.00, 0 [5.00])
    ╚═ WISE W2=(9.69, 0.02) @(0.00, 0 [5.00])
       ╚═ SDSS i=(10.25, 0.02) @(0.00, 0 [4.50])
          ╚═ twomass H=(9.73, 0.02) @(0.00, 0 [4.00])
             ╚═ twomass J=(9.78, 0.02) @(0.00, 0 [4.00])
                ╚═ twomass K=(9.70, 0.02) @(0.00, 0 [4.00])
                   ╠═ RAO J=(9.88, 0.10) @(0.00, 0 [0.10])
                   ║  ╚═ RAO K=(9.85, 0.10) @(0.00, 0 [0.10])
                   ║     ╚═ RAO i=(10.32, 0.10) @(0.00, 0 [0.10])
                   ╠═ RAO J=(12.46, 0.10) @(0.50, 100 [0.10])
                   ║  ╚═ RAO K=(12.07, 0.10) @(0.50, 100 [0.10])
                   ║     ╚═ RAO i=(13.38, 0.10) @(0.50, 100 [0.10])
                   ╚═ RAO J=(15.16, 0.10) @(1.20, 45 [0.10])
                      ╚═ RAO K=(14.32, 0.10) @(1.20, 45 [0.10])
                         ╚═ RAO i=(17.00, 0.10) @(1.20, 45 [0.10])

In [7]:
t.define_models(dar)
t.print_ascii()


test-triplet
 ╚═ WISE W1=(9.69, 0.02) @(0.00, 0 [5.00])
    ╚═ WISE W2=(9.69, 0.02) @(0.00, 0 [5.00])
       ╚═ SDSS i=(10.25, 0.02) @(0.00, 0 [4.50])
          ╚═ twomass H=(9.73, 0.02) @(0.00, 0 [4.00])
             ╚═ twomass J=(9.78, 0.02) @(0.00, 0 [4.00])
                ╚═ twomass K=(9.70, 0.02) @(0.00, 0 [4.00])
                   ╠═ RAO J=(9.88, 0.10) @(0.00, 0 [0.10])
                   ║  ╚═ RAO K=(9.85, 0.10) @(0.00, 0 [0.10])
                   ║     ╚═ RAO i=(10.32, 0.10) @(0.00, 0 [0.10])
                   ║        ╚═ 0_0
                   ╠═ RAO J=(12.46, 0.10) @(0.50, 100 [0.10])
                   ║  ╚═ RAO K=(12.07, 0.10) @(0.50, 100 [0.10])
                   ║     ╚═ RAO i=(13.38, 0.10) @(0.50, 100 [0.10])
                   ║        ╚═ 0_1
                   ╚═ RAO J=(15.16, 0.10) @(1.20, 45 [0.10])
                      ╚═ RAO K=(14.32, 0.10) @(1.20, 45 [0.10])
                         ╚═ RAO i=(17.00, 0.10) @(1.20, 45 [0.10])
                            ╚═ 0_2

In [8]:
t.add_limit(logg=(3.0,None))
t.print_ascii()


test-triplet
 ╚═ WISE W1=(9.69, 0.02) @(0.00, 0 [5.00])
    ╚═ WISE W2=(9.69, 0.02) @(0.00, 0 [5.00])
       ╚═ SDSS i=(10.25, 0.02) @(0.00, 0 [4.50])
          ╚═ twomass H=(9.73, 0.02) @(0.00, 0 [4.00])
             ╚═ twomass J=(9.78, 0.02) @(0.00, 0 [4.00])
                ╚═ twomass K=(9.70, 0.02) @(0.00, 0 [4.00])
                   ╠═ RAO J=(9.88, 0.10) @(0.00, 0 [0.10])
                   ║  ╚═ RAO K=(9.85, 0.10) @(0.00, 0 [0.10])
                   ║     ╚═ RAO i=(10.32, 0.10) @(0.00, 0 [0.10])
                   ║        ╚═ 0_0, logg limits=(3.0, inf)
                   ╠═ RAO J=(12.46, 0.10) @(0.50, 100 [0.10])
                   ║  ╚═ RAO K=(12.07, 0.10) @(0.50, 100 [0.10])
                   ║     ╚═ RAO i=(13.38, 0.10) @(0.50, 100 [0.10])
                   ║        ╚═ 0_1
                   ╚═ RAO J=(15.16, 0.10) @(1.20, 45 [0.10])
                      ╚═ RAO K=(14.32, 0.10) @(1.20, 45 [0.10])
                         ╚═ RAO i=(17.00, 0.10) @(1.20, 45 [0.10])
                            ╚═ 0_2

In [9]:
from isochrones.starmodel import StarModel
mod = StarModel(dar, obs=t)

In [10]:
mod.fit_multinest(n_live_points=1000)

In [11]:
mod.samples[['mass_0_0','mass_0_1','mass_0_2','age_0','feh_0','distance_0','AV_0']].head()


Out[11]:
mass_0_0 mass_0_1 mass_0_2 age_0 feh_0 distance_0 AV_0
0 2.205395 1.080208 0.588959 8.559030 0.436338 557.508494 0.082211
1 2.676419 1.309044 0.715143 8.602026 0.367837 851.394510 0.201325
2 1.866626 0.903275 0.452994 8.796218 -0.174071 460.426724 0.241857
3 1.532815 0.766149 0.366114 8.925964 -0.821347 352.436820 0.144645
4 2.679130 1.267498 0.663956 8.547142 0.076171 751.412080 0.438982

In [12]:
%matplotlib inline
#mod.corner(['mass_0_0', 'mass_0_1','logg_0_0','age_0','distance_0','AV_0']);
mod.corner_physical();



In [13]:
mod.corner_observed();



In [14]:
mod.obs.print_ascii(p=[M1,M2,M3, age,feh,distance,AV])


test-triplet
 ╚═ WISE W1=(9.69, 0.02) @(0.00, 0 [5.00]); model=9.69 (-3.94430452611e-27)
    ╚═ WISE W2=(9.69, 0.02) @(0.00, 0 [5.00]); model=9.69 (-3.94430452611e-27)
       ╚═ SDSS i=(10.25, 0.02) @(0.00, 0 [4.50]); model=10.25 (-3.94430452611e-27)
          ╚═ twomass H=(9.73, 0.02) @(0.00, 0 [4.00]); model=9.73 (-0.0)
             ╚═ twomass J=(9.78, 0.02) @(0.00, 0 [4.00]); model=9.78 (-3.94430452611e-27)
                ╚═ twomass K=(9.70, 0.02) @(0.00, 0 [4.00]); model=9.70 (-0.0)
                   ╠═ RAO J=(9.88, 0.10) @(0.00, 0 [0.10]); model=9.88 (0)
                   ║  ╚═ RAO K=(9.85, 0.10) @(0.00, 0 [0.10]); model=9.85 (0)
                   ║     ╚═ RAO i=(10.32, 0.10) @(0.00, 0 [0.10]); model=10.32 (0)
                   ║        ╚═ 0_0, logg limits=(3.0, inf): [2.0, 8.6989700043360187, 0.0, 500, 0.1]
                   ╠═ RAO J=(12.46, 0.10) @(0.50, 100 [0.10]); model=12.46 (-1.57772181044e-28)
                   ║  ╚═ RAO K=(12.07, 0.10) @(0.50, 100 [0.10]); model=12.07 (-1.57772181044e-28)
                   ║     ╚═ RAO i=(13.38, 0.10) @(0.50, 100 [0.10]); model=13.38 (-0.0)
                   ║        ╚═ 0_1: [1.0, 8.6989700043360187, 0.0, 500, 0.1]
                   ╚═ RAO J=(15.16, 0.10) @(1.20, 45 [0.10]); model=15.16 (-0.0)
                      ╚═ RAO K=(14.32, 0.10) @(1.20, 45 [0.10]); model=14.32 (-0.0)
                         ╚═ RAO i=(17.00, 0.10) @(1.20, 45 [0.10]); model=17.00 (-0.0)
                            ╚═ 0_2: [0.5, 8.6989700043360187, 0.0, 500, 0.1]

In [16]:
t2 = ObservationTree.from_df(df, name='triple2')
t2.define_models(dar, index=[0,1,2])
t2.print_ascii()


triple2
 ╚═ WISE W1=(9.69, 0.02) @(0.00, 0 [5.00])
    ╚═ WISE W2=(9.69, 0.02) @(0.00, 0 [5.00])
       ╚═ SDSS i=(10.25, 0.02) @(0.00, 0 [4.50])
          ╚═ twomass H=(9.73, 0.02) @(0.00, 0 [4.00])
             ╚═ twomass J=(9.78, 0.02) @(0.00, 0 [4.00])
                ╚═ twomass K=(9.70, 0.02) @(0.00, 0 [4.00])
                   ╠═ RAO J=(9.88, 0.10) @(0.00, 0 [0.10])
                   ║  ╚═ RAO K=(9.85, 0.10) @(0.00, 0 [0.10])
                   ║     ╚═ RAO i=(10.32, 0.10) @(0.00, 0 [0.10])
                   ║        ╚═ 0_0
                   ╠═ RAO J=(12.46, 0.10) @(0.50, 100 [0.10])
                   ║  ╚═ RAO K=(12.07, 0.10) @(0.50, 100 [0.10])
                   ║     ╚═ RAO i=(13.38, 0.10) @(0.50, 100 [0.10])
                   ║        ╚═ 1_0
                   ╚═ RAO J=(15.16, 0.10) @(1.20, 45 [0.10])
                      ╚═ RAO K=(14.32, 0.10) @(1.20, 45 [0.10])
                         ╚═ RAO i=(17.00, 0.10) @(1.20, 45 [0.10])
                            ╚═ 2_0

In [17]:
mod2 = StarModel(dar, obs=t2)
mod2.fit_multinest(basename='unassoc')

In [18]:
mod2.corner_physical();



In [19]:
mod2.corner_observed();



In [24]:
mod.evidence


  analysing data from chains/triple.txt
Out[24]:
(-38.135431571329605, 0.02066304434255426)

In [21]:
mod2.evidence


  analysing data from chains/unassoc.txt
Out[21]:
(-68.1039093869501, 0.04319939757355251)

In [26]:
t3 = ObservationTree.from_df(df, name='triple3')
t3.define_models(dar, index=[0,0,1])
t3.print_ascii()


triple3
 ╚═ WISE W1=(9.69, 0.02) @(0.00, 0 [5.00])
    ╚═ WISE W2=(9.69, 0.02) @(0.00, 0 [5.00])
       ╚═ SDSS i=(10.25, 0.02) @(0.00, 0 [4.50])
          ╚═ twomass H=(9.73, 0.02) @(0.00, 0 [4.00])
             ╚═ twomass J=(9.78, 0.02) @(0.00, 0 [4.00])
                ╚═ twomass K=(9.70, 0.02) @(0.00, 0 [4.00])
                   ╠═ RAO J=(9.88, 0.10) @(0.00, 0 [0.10])
                   ║  ╚═ RAO K=(9.85, 0.10) @(0.00, 0 [0.10])
                   ║     ╚═ RAO i=(10.32, 0.10) @(0.00, 0 [0.10])
                   ║        ╚═ 0_0
                   ╠═ RAO J=(12.46, 0.10) @(0.50, 100 [0.10])
                   ║  ╚═ RAO K=(12.07, 0.10) @(0.50, 100 [0.10])
                   ║     ╚═ RAO i=(13.38, 0.10) @(0.50, 100 [0.10])
                   ║        ╚═ 0_1
                   ╚═ RAO J=(15.16, 0.10) @(1.20, 45 [0.10])
                      ╚═ RAO K=(14.32, 0.10) @(1.20, 45 [0.10])
                         ╚═ RAO i=(17.00, 0.10) @(1.20, 45 [0.10])
                            ╚═ 1_0

In [27]:
mod3 = StarModel(dar, obs=t3)
mod3.fit_multinest(basename='unassoc1')

In [28]:
mod3.corner_physical();



In [29]:
mod3.corner_observed();



In [31]:
t4 = ObservationTree.from_df(df, name='triple4')
t4.define_models(dar, index=[0,1,1])
t4.print_ascii()


triple4
 ╚═ WISE W1=(9.69, 0.02) @(0.00, 0 [5.00])
    ╚═ WISE W2=(9.69, 0.02) @(0.00, 0 [5.00])
       ╚═ SDSS i=(10.25, 0.02) @(0.00, 0 [4.50])
          ╚═ twomass H=(9.73, 0.02) @(0.00, 0 [4.00])
             ╚═ twomass J=(9.78, 0.02) @(0.00, 0 [4.00])
                ╚═ twomass K=(9.70, 0.02) @(0.00, 0 [4.00])
                   ╠═ RAO J=(9.88, 0.10) @(0.00, 0 [0.10])
                   ║  ╚═ RAO K=(9.85, 0.10) @(0.00, 0 [0.10])
                   ║     ╚═ RAO i=(10.32, 0.10) @(0.00, 0 [0.10])
                   ║        ╚═ 0_0
                   ╠═ RAO J=(12.46, 0.10) @(0.50, 100 [0.10])
                   ║  ╚═ RAO K=(12.07, 0.10) @(0.50, 100 [0.10])
                   ║     ╚═ RAO i=(13.38, 0.10) @(0.50, 100 [0.10])
                   ║        ╚═ 1_0
                   ╚═ RAO J=(15.16, 0.10) @(1.20, 45 [0.10])
                      ╚═ RAO K=(14.32, 0.10) @(1.20, 45 [0.10])
                         ╚═ RAO i=(17.00, 0.10) @(1.20, 45 [0.10])
                            ╚═ 1_1

In [33]:
mod4 = StarModel(dar, obs=t4)
mod4.fit_multinest(basename='unassoc2')

In [34]:
mod4.corner_physical();



In [35]:
mod4.corner_observed();



In [36]:
mod3.evidence


  analysing data from chains/unassoc1.txt
Out[36]:
(-52.13071997736737, 0.13455920094486717)

In [37]:
mod4.evidence


  analysing data from chains/unassoc2.txt
Out[37]:
(-53.79165661807573, 0.046715963099082235)

In [39]:
t5 = ObservationTree.from_df(df, name='triple5')
t5.define_models(dar, index=[1,0,1])
t5.print_ascii()


triple5
 ╚═ WISE W1=(9.69, 0.02) @(0.00, 0 [5.00])
    ╚═ WISE W2=(9.69, 0.02) @(0.00, 0 [5.00])
       ╚═ SDSS i=(10.25, 0.02) @(0.00, 0 [4.50])
          ╚═ twomass H=(9.73, 0.02) @(0.00, 0 [4.00])
             ╚═ twomass J=(9.78, 0.02) @(0.00, 0 [4.00])
                ╚═ twomass K=(9.70, 0.02) @(0.00, 0 [4.00])
                   ╠═ RAO J=(9.88, 0.10) @(0.00, 0 [0.10])
                   ║  ╚═ RAO K=(9.85, 0.10) @(0.00, 0 [0.10])
                   ║     ╚═ RAO i=(10.32, 0.10) @(0.00, 0 [0.10])
                   ║        ╚═ 1_0
                   ╠═ RAO J=(12.46, 0.10) @(0.50, 100 [0.10])
                   ║  ╚═ RAO K=(12.07, 0.10) @(0.50, 100 [0.10])
                   ║     ╚═ RAO i=(13.38, 0.10) @(0.50, 100 [0.10])
                   ║        ╚═ 0_0
                   ╚═ RAO J=(15.16, 0.10) @(1.20, 45 [0.10])
                      ╚═ RAO K=(14.32, 0.10) @(1.20, 45 [0.10])
                         ╚═ RAO i=(17.00, 0.10) @(1.20, 45 [0.10])
                            ╚═ 1_1

In [40]:
mod5 = StarModel(dar, obs=t5)
mod5.fit_multinest(basename='unassoc3')

In [41]:
mod5.corner_physical();



In [42]:
mod5.corner_observed();



In [43]:
mod5.evidence


  analysing data from chains/unassoc3.txt
Out[43]:
(-53.60565295226619, 0.0534382492240048)

In [ ]:


In [ ]: