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]:
({'H': 9.4150873209332282,
  'J': 9.5835010071697067,
  'K': 9.3829386004395285,
  'W1': 9.3715419441754726,
  'W2': 9.3672710453183541,
  'i': 10.242333925734332},
 {'J': 9.7131141237241412, 'K': 9.5486762976776376, 'i': 10.336472754458542},
 {'J': 14.049417008014405, 'K': 13.215133317539811, 'i': 15.891532079071984},
 {'J': 12.125863050974678, 'K': 11.75744605477176, 'i': 13.018336915488094})

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]:
band e_mag mag name pa relative resolution separation
0 J 0.02 9.583501 twomass 0.0 False 4.0 0.0
1 H 0.02 9.415087 twomass 0.0 False 4.0 0.0
2 K 0.02 9.382939 twomass 0.0 False 4.0 0.0
3 W1 0.02 9.371542 WISE 0.0 False 5.0 0.0
4 W2 0.02 9.367271 WISE 0.0 False 5.0 0.0
5 i 0.02 10.242334 SDSS 0.0 False 4.5 0.0
6 i 0.10 10.336473 RAO 0.0 True 0.1 0.0
7 i 0.10 15.891532 RAO 100.0 True 0.1 0.5
8 i 0.10 13.018337 RAO 45.0 True 0.1 1.2
9 J 0.10 9.713114 RAO 0.0 True 0.1 0.0
10 J 0.10 14.049417 RAO 100.0 True 0.1 0.5
11 J 0.10 12.125863 RAO 45.0 True 0.1 1.2
12 K 0.10 9.548676 RAO 0.0 True 0.1 0.0
13 K 0.10 13.215133 RAO 100.0 True 0.1 0.5
14 K 0.10 11.757446 RAO 45.0 True 0.1 1.2

In [78]:
from isochrones.observation import ObservationTree

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


test-triplet
 ╚═ WISE W1=(9.37, 0.02) @(0.00, 0 [5.00])
    ╚═ WISE W2=(9.37, 0.02) @(0.00, 0 [5.00])
       ╚═ SDSS i=(10.24, 0.02) @(0.00, 0 [4.50])
          ╚═ twomass H=(9.42, 0.02) @(0.00, 0 [4.00])
             ╚═ twomass J=(9.58, 0.02) @(0.00, 0 [4.00])
                ╚═ twomass K=(9.38, 0.02) @(0.00, 0 [4.00])
                   ╠═ RAO J=(9.71, 0.10) @(0.00, 0 [0.10])
                   ║  ╚═ RAO K=(9.55, 0.10) @(0.00, 0 [0.10])
                   ║     ╚═ RAO i=(10.34, 0.10) @(0.00, 0 [0.10])
                   ╠═ RAO J=(14.05, 0.10) @(0.50, 100 [0.10])
                   ║  ╚═ RAO K=(13.22, 0.10) @(0.50, 100 [0.10])
                   ║     ╚═ RAO i=(15.89, 0.10) @(0.50, 100 [0.10])
                   ╚═ RAO J=(12.13, 0.10) @(1.20, 45 [0.10])
                      ╚═ RAO K=(11.76, 0.10) @(1.20, 45 [0.10])
                         ╚═ RAO i=(13.02, 0.10) @(1.20, 45 [0.10])

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


test-triplet
 ╚═ WISE W1=(9.37, 0.02) @(0.00, 0 [5.00])
    ╚═ WISE W2=(9.37, 0.02) @(0.00, 0 [5.00])
       ╚═ SDSS i=(10.24, 0.02) @(0.00, 0 [4.50])
          ╚═ twomass H=(9.42, 0.02) @(0.00, 0 [4.00])
             ╚═ twomass J=(9.58, 0.02) @(0.00, 0 [4.00])
                ╚═ twomass K=(9.38, 0.02) @(0.00, 0 [4.00])
                   ╠═ RAO J=(9.71, 0.10) @(0.00, 0 [0.10])
                   ║  ╚═ RAO K=(9.55, 0.10) @(0.00, 0 [0.10])
                   ║     ╚═ RAO i=(10.34, 0.10) @(0.00, 0 [0.10])
                   ║        ╚═ 0_0
                   ╠═ RAO J=(14.05, 0.10) @(0.50, 100 [0.10])
                   ║  ╚═ RAO K=(13.22, 0.10) @(0.50, 100 [0.10])
                   ║     ╚═ RAO i=(15.89, 0.10) @(0.50, 100 [0.10])
                   ║        ╚═ 0_1
                   ╚═ RAO J=(12.13, 0.10) @(1.20, 45 [0.10])
                      ╚═ RAO K=(11.76, 0.10) @(1.20, 45 [0.10])
                         ╚═ RAO i=(13.02, 0.10) @(1.20, 45 [0.10])
                            ╚═ 0_2

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


test-triplet
 ╚═ WISE W1=(9.37, 0.02) @(0.00, 0 [5.00])
    ╚═ WISE W2=(9.37, 0.02) @(0.00, 0 [5.00])
       ╚═ SDSS i=(10.24, 0.02) @(0.00, 0 [4.50])
          ╚═ twomass H=(9.42, 0.02) @(0.00, 0 [4.00])
             ╚═ twomass J=(9.58, 0.02) @(0.00, 0 [4.00])
                ╚═ twomass K=(9.38, 0.02) @(0.00, 0 [4.00])
                   ╠═ RAO J=(9.71, 0.10) @(0.00, 0 [0.10])
                   ║  ╚═ RAO K=(9.55, 0.10) @(0.00, 0 [0.10])
                   ║     ╚═ RAO i=(10.34, 0.10) @(0.00, 0 [0.10])
                   ║        ╚═ 0_0, logg limits=(3.0, inf)
                   ╠═ RAO J=(14.05, 0.10) @(0.50, 100 [0.10])
                   ║  ╚═ RAO K=(13.22, 0.10) @(0.50, 100 [0.10])
                   ║     ╚═ RAO i=(15.89, 0.10) @(0.50, 100 [0.10])
                   ║        ╚═ 0_1
                   ╚═ RAO J=(12.13, 0.10) @(1.20, 45 [0.10])
                      ╚═ RAO K=(11.76, 0.10) @(1.20, 45 [0.10])
                         ╚═ RAO i=(13.02, 0.10) @(1.20, 45 [0.10])
                            ╚═ 0_2

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

In [83]:
%timeit mod.fit_multinest(n_live_points=1000)


Traceback (most recent call last):
  File "/u/np5/anaconda2/lib/python2.7/site-packages/IPython/core/ultratb.py", line 1118, in get_records
    return _fixed_getinnerframes(etb, number_of_lines_of_context, tb_offset)
  File "/u/np5/anaconda2/lib/python2.7/site-packages/IPython/core/ultratb.py", line 300, in wrapped
    return f(*args, **kwargs)
  File "/u/np5/anaconda2/lib/python2.7/site-packages/IPython/core/ultratb.py", line 345, in _fixed_getinnerframes
    records = fix_frame_records_filenames(inspect.getinnerframes(etb, context))
  File "/u/np5/anaconda2/lib/python2.7/inspect.py", line 1049, in getinnerframes
    framelist.append((tb.tb_frame,) + getframeinfo(tb, context))
  File "/u/np5/anaconda2/lib/python2.7/inspect.py", line 1009, in getframeinfo
    filename = getsourcefile(frame) or getfile(frame)
  File "/u/np5/anaconda2/lib/python2.7/inspect.py", line 454, in getsourcefile
    if hasattr(getmodule(object, filename), '__loader__'):
  File "/u/np5/anaconda2/lib/python2.7/inspect.py", line 483, in getmodule
    file = getabsfile(object, _filename)
  File "/u/np5/anaconda2/lib/python2.7/inspect.py", line 467, in getabsfile
    return os.path.normcase(os.path.abspath(_filename))
  File "/u/np5/anaconda2/lib/python2.7/posixpath.py", line 364, in abspath
    cwd = os.getcwd()
OSError: [Errno 2] No such file or directory
ERROR: Internal Python error in the inspect module.
Below is the traceback from this internal error.


Unfortunately, your original traceback can not be constructed.

---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
/u/np5/anaconda2/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in run_code(self, code_obj, result)
   2900             if result is not None:
   2901                 result.error_in_exec = sys.exc_info()[1]
-> 2902             self.showtraceback()
   2903         else:
   2904             outflag = 0

/u/np5/anaconda2/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in showtraceback(self, exc_tuple, filename, tb_offset, exception_only)
   1828                     except Exception:
   1829                         stb = self.InteractiveTB.structured_traceback(etype,
-> 1830                                             value, tb, tb_offset=tb_offset)
   1831 
   1832                     self._showtraceback(etype, value, stb)

/u/np5/anaconda2/lib/python2.7/site-packages/IPython/core/ultratb.pyc in structured_traceback(self, etype, value, tb, tb_offset, number_of_lines_of_context)
   1390         self.tb = tb
   1391         return FormattedTB.structured_traceback(
-> 1392             self, etype, value, tb, tb_offset, number_of_lines_of_context)
   1393 
   1394 

/u/np5/anaconda2/lib/python2.7/site-packages/IPython/core/ultratb.pyc in structured_traceback(self, etype, value, tb, tb_offset, number_of_lines_of_context)
   1298             # Verbose modes need a full traceback
   1299             return VerboseTB.structured_traceback(
-> 1300                 self, etype, value, tb, tb_offset, number_of_lines_of_context
   1301             )
   1302         else:

/u/np5/anaconda2/lib/python2.7/site-packages/IPython/core/ultratb.pyc in structured_traceback(self, etype, evalue, etb, tb_offset, number_of_lines_of_context)
   1182                 structured_traceback_parts += formatted_exception
   1183         else:
-> 1184             structured_traceback_parts += formatted_exception[0]
   1185 
   1186         return structured_traceback_parts

IndexError: string index out of range

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


Out[35]:
mass_0_0 mass_0_1 mass_0_2 age_0 feh_0 distance_0 AV_0
0 1.862876 0.593160 0.925961 8.814292 -0.263696 400.854685 0.740275
1 2.320298 0.704372 1.146368 8.641494 -0.043682 522.044341 0.961120
2 1.518805 0.538402 0.849506 8.753596 -0.044243 312.148051 0.077685
3 1.540449 0.498210 0.908181 8.920017 0.152738 327.571932 0.020482
4 2.972194 0.894766 1.453104 8.415920 0.269324 723.021344 0.979774

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();