ApJdataFrames BCAH2002

Title: Evolutionary models for low-mass stars and brown dwarfs: uncertainties and limits at very young ages
Authors: BCAH

Data is from this website:
http://perso.ens-lyon.fr/isabelle.baraffe/


In [1]:
%pylab inline

import seaborn as sns
sns.set_context("notebook", font_scale=1.5)

import warnings
warnings.filterwarnings("ignore")


Populating the interactive namespace from numpy and matplotlib

In [2]:
import pandas as pd

BCAH98_models.1


In [4]:
web1 = "http://perso.ens-lyon.fr/isabelle.baraffe/BCAH98_models.1"
skiprows = range(32)
names = ["mass","age","Teff","logg","logL","Mv","Mr","Mi","Mj","Mh","Mk","Ml","Mm"]
BCAH98_m1 = pd.read_csv(web1, sep = '[ ]{1,}', skiprows=skiprows, names = names)
BCAH98_m1.drop([u'Mv', u'Mr', u'Mi', u'Mh', u'Mk', u'Ml', u'Mm'], axis=1, inplace=True)
BCAH98_m1.head()


Out[4]:
mass age Teff logg logL Mj
0 0.02 0.00128 2535.0 3.821 -2.52 8.85
1 0.02 0.00144 2530.0 3.834 -2.54 8.89
2 0.02 0.00161 2527.0 3.847 -2.55 8.93
3 0.02 0.00181 2523.0 3.860 -2.57 8.97
4 0.02 0.00205 2519.0 3.872 -2.58 9.00

Isochrones

The formatting for this file is so stupid.


In [5]:
web2 = "http://perso.ens-lyon.fr/isabelle.baraffe/BCAH98_iso.1"
skiprows = range(28)
names = ["mass","Teff","logg","logL","Mv","Mr","Mi","Mj","Mh","Mk","Ml","Mm"]
BCAH98_i1 = pd.read_csv(web2, delim_whitespace=True, skiprows=skiprows,
                        names = names, error_bad_lines=False, skip_blank_lines=True)

Extract the age data and forward fill it.


In [6]:
age_ids = BCAH98_i1[BCAH98_i1.mass == "log"].index.values
ages = BCAH98_i1.iloc[age_ids].Mv
BCAH98_i1["Age"] = np.NaN
BCAH98_i1.Age[age_ids] = ages
BCAH98_i1.Age.ffill(inplace=True)
BCAH98_i1.Age[BCAH98_i1.Age != BCAH98_i1.Age] = 6.0

Drop junk rows


In [7]:
BCAH98_i1.dropna(how='any', inplace=True)
BCAH98_i1.drop(BCAH98_i1[BCAH98_i1.mass == "m"].index, inplace=True)

Drop junk columns


In [8]:
BCAH98_i1.drop([u'Mv', u'Mr', u'Mi', u'Mh', u'Mk', u'Ml', u'Mm'], axis=1, inplace=True)

Group by isochrones


In [9]:
age_grouped = BCAH98_i1.groupby(axis=0, by="Age")

Now you can do group by operations:

for age, group in age_grouped:
    print age
    print group

Save data tables locally.


In [10]:
BCAH98_i1.to_csv("../data/BCAH2002/BCAH2002_isochrones.csv", sep='\t', index=False)
BCAH98_m1.to_csv("../data/BCAH2002/BCAH2002_models.csv", sep = '\t', index=False)

Script finished.