timothydmorton / isochrones

Pythonic stellar model grid access; easy MCMC fitting of stellar properties
http://isochrones.readthedocs.org
MIT License
120 stars 61 forks source link

Support for Baraffe et al. models #23

Open gully opened 8 years ago

gully commented 8 years ago

First, thanks for making this code open source and available. I am curious about adding support for the Baraffe et al. (e.g. BCAH 2002, BHAC 2015) pre-main sequence evolutionary models: http://perso.ens-lyon.fr/isabelle.baraffe/

My guess on how to get started is basically just copy from one of the existing example models:

This seems straighforward, but the devil is in the details. For example, one difference is that the Baraffe et al. models have fixed metallicity, so there'd be a delta function in Fe/H that could screw up parts of the code that are expecting this to be another dimension.

I'll see if this will work, but any tips or caveats are welcomed here.

timothydmorton commented 8 years ago

This would be great! If the tracks are all at the same metallicity, then it should actually be OK-- you should just be able to pass an array of all zeros, e.g., to the Isochrones constructor. My guess is the NDInterpolator machinery should still work even if they're all the same value.

kgullikson88 commented 8 years ago

I did a similar thing with some Dartmouth isochrones that Greg Feiden gave to me, and they were also only solar metallicity. In my case, the LinearNDInterpolator choked when making the delauney triangulation because there was no variation in one of the axes. I ended up cheating by making isochrones at +/- 0.1 metallicity that were just copies of the solar isochrones. That seems to work fine for me.

gully commented 8 years ago

I'm experimenting with this now, I'll let you know if it sticks. :)

gully commented 8 years ago

Ok, it seems like this worked. It's a minimal proof-of-concept, but with a little fixing-up it could be contributed back to the main repo, if desired. Notable demerits of the existing version:

In fact, this was a little easier than I had anticipated, so in principle other stellar evolution models could be included in the same way. The hard part is getting the models into a tidy DataFrame format in the first place, which in this case had already been done from another project. One interesting direction is to include models with non-standard physics, like variations in magnetic fields (presumably related to the Feiden models Kevin mentioned above?).

screen shot 2016-08-30 at 6 23 43 pm
gully commented 8 years ago

Code for above example:

for mass in [0.02, 0.05, 0.1, 0.3, 0.6, 0.9, 1.2]:
    ev = bcah.evtrack(mass,dage=0.01, minage=6.0, maxage=9.9)
    plt.plot((ev['Teff']),ev['logL'],'.', alpha=0.5)

for age in [6.0, 7.0, 8.0, 9.0, 9.9]:
    ev = bcah.isochrone(age, minm=0.02, maxm=1.2)
    plt.plot((ev['Teff']),ev['logL'],'k:')
timothydmorton commented 8 years ago

Awesome, thanks!

Just FYI, I'm also working on a significant update to the code, which you can check out on the refactor branch if you like. Besides making the StarModel object more flexible to deal with multiple stars, what I'm trying to do there (you can see in the dartmouth and scripts directories) is to make the "necessary standard dataframe" construction also transparent (rather than having it completely pre-packaged). That having been said, I'd be happy to include the BCAH even with a pre-packaged dataframe---though code for its generation from whatever standard raw tables Baraffe provides would also be great (e.g. in isochrones-bcah_write_hdf and isochrones-bcah_write_tri scripts). My hope is also not to break any backwards compatibility (or do so very minimally), so whatever you're working on could at some point be a test for that as well.

Regarding non-standard physics, I like that idea too. It would be a more major change to the base code, though, to move away from the three standard params (M, age, feh and have another parameter). But should definitely be doable! The other issue there is that 4-d interpolation will begin to kill you with the size of the tri object, so for this one might want to do something like generate a restricted-size grid applicable to a particular problem and then make the triangulation specific for that. Might not be as convenient and snappy as it is now, but should still work.

gully commented 4 years ago

There's been some renewed interest from a few folks about Chabrier/Baraffe isochrones models. Here is the notebook that generated the figure above, and also makes an animation useful for talks about how isochrones work: https://github.com/BrownDwarf/welter/blob/master/notebooks/welter_issue038-01_HRD_animation.ipynb

timothydmorton commented 4 years ago

Hi @gully! Does your Chabrier/Baraffe implementation work with isochrones >= 2? Are you still interested in helping to help implement something like this into the main isochrones codebase? I would be super excited to help you help me make that happen. Let me know if you're up for it, and maybe we can chat about it soon?

gully commented 4 years ago

Hi @timothydmorton ! I haven't tried this out since 2016 I think, so my hunch is that it won't work with version >= 2. The commits are linked here so if someone wanted to they could hypothetically reverse engineer how to put it into version 2. There are some students interested, so maybe I'll work on this if they prod me into it?

Students: if you're interested in seeing this functionality ported to version 2.0, upvote this comment with a :+1:

I also just found this link to tools for brown dwarf evolutionary models