timothydmorton / isochrones

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

EEP minimization not successful when setting accurate=True in .generate() #125

Closed kuanweih closed 4 years ago

kuanweih commented 4 years ago

Hello, Thanks for making this great package.

I was trying to do the isochrone interpolation and I got this error:

tracks = get_ichrone('mist', tracks=True, bands=['V', 'G', 'BP', 'RP']) df = tracks.generate(mass_sample, AGE, FEH, accurate=True)


RuntimeError Traceback (most recent call last)

in 2 3 tracks = get_ichrone('mist', tracks=True, bands=['V', 'G', 'BP', 'RP']) ----> 4 df = tracks.generate(mass_sample, AGE, FEH, accurate=True) 5 # df = df.dropna() 6 # df.head() ~/.local/lib/python3.7/site-packages/isochrones-2.1-py3.7.egg/isochrones/models.py in generate(self, mass, age, feh, props, bands, eeps, return_df, return_dict, distance, AV, all_As, **kwargs) 602 bands = self.bands 603 if eeps is None: --> 604 eeps = self.get_eep(mass, age, feh, **kwargs) 605 values = self.interp_value([mass, eeps, feh], props) 606 if bands: ~/.local/lib/python3.7/site-packages/isochrones-2.1-py3.7.egg/isochrones/models.py in get_eep(self, mass, age, feh, accurate, **kwargs) 527 pars = [np.atleast_1d(np.resize(x, b.shape)).astype(float) for x in [age, feh, mass]] 528 if accurate: --> 529 return np.array([self.get_eep_accurate(m, a, f, **kwargs) for a, f, m in zip(*pars)]) 530 else: 531 if grid.eep_replaces == "age": ~/.local/lib/python3.7/site-packages/isochrones-2.1-py3.7.egg/isochrones/models.py in (.0) 527 pars = [np.atleast_1d(np.resize(x, b.shape)).astype(float) for x in [age, feh, mass]] 528 if accurate: --> 529 return np.array([self.get_eep_accurate(m, a, f, **kwargs) for a, f, m in zip(*pars)]) 530 else: 531 if grid.eep_replaces == "age": ~/.local/lib/python3.7/site-packages/isochrones-2.1-py3.7.egg/isochrones/models.py in get_eep_accurate(self, mass, age, feh, eep0, resid_tol, method, return_object, return_nan, **kwargs) 576 return np.nan 577 else: --> 578 raise RuntimeError("EEP minimization not successful: {}".format((mass, age, feh))) 579 580 def generate( RuntimeError: EEP minimization not successful: (1.7238362079750431, 10.079181246047625, -2.0) --------------------------------------------------------------------------- It would be fine without accurate=True thought. I'd like to ask if you might know what causes this error.
timothydmorton commented 4 years ago

What EEP does accurate=False give for this? I would hope anything with M ~ 1.7 Msun and log(age) of 10.07 to return nan (that is well beyond the expected lifetime).

timothydmorton commented 4 years ago

Oh- I think you can pass return_nan=True to return nans instead of raising the RuntimeError.

kuanweih commented 4 years ago

By passing return_nan=True together with accurate=True solves the problem. Thank you so much @timothydmorton!