nespinoza / juliet

A versatile modelling tool for transiting and non-transiting (single and multiple) exoplanetary systems
MIT License
55 stars 30 forks source link

issue with adding 'rv_intercept' & 'rv_slope' to priors and fit #24

Closed jkteske closed 4 years ago

jkteske commented 4 years ago

In the "fitting radial velocities" tutorial, when I try to add 'rv_intercept' and 'rv_slope' to the priors and fit, I get the following error:

KeyError Traceback (most recent call last)

in 1 # Run juliet: 2 dataset = juliet.load(priors = priorsLT, rvfilename='rvs_toi141.dat', out_folder = 'toi141_rvs_3planets') ----> 3 results = dataset.fit(n_live_points = 300) ~/anaconda/envs/python3/lib/python3.6/site-packages/juliet/fit.py in fit(self, use_dynesty, dynamic, dynesty_bound, dynesty_sample, dynesty_nthreads, n_live_points, ecclim, delta_z_lim, pl, pu) 716 return fit(self, use_dynesty = use_dynesty, dynamic = dynamic, dynesty_bound = dynesty_bound, dynesty_sample = dynesty_sample, \ 717 dynesty_nthreads = dynesty_nthreads, n_live_points = n_live_points, ecclim = ecclim, delta_z_lim = delta_z_lim, \ --> 718 pl = pl, pu = pu) 719 720 def __init__(self,priors = None, input_folder = None, t_lc = None, y_lc = None, yerr_lc = None, \ ~/anaconda/envs/python3/lib/python3.6/site-packages/juliet/fit.py in __init__(self, data, use_dynesty, dynamic, dynesty_bound, dynesty_sample, dynesty_nthreads, n_live_points, ecclim, delta_z_lim, pl, pu, ta) 1308 for pname in self.posteriors.keys(): 1309 if data.priors[pname]['distribution'] != 'fixed': -> 1310 self.posteriors[pname] = np.median(out['posterior_samples'][pname]) 1311 posterior_samples = out['posterior_samples']['unnamed'] 1312 if 'pu' in out.keys(): KeyError: 'rv_intercept'
jkteske commented 4 years ago

I have a similar issue (I think) when trying to include 'GP_sigma_rv' in a global model (in Incorporating Gaussian Processes tutorial).

KeyError Traceback (most recent call last)

in 62 GPrveparamfile='GP_regressors_rv.dat') 63 ---> 64 results = dataset.fit(n_live_points = 300) ~/anaconda/envs/python3/lib/python3.6/site-packages/juliet/fit.py in fit(self, use_dynesty, dynamic, dynesty_bound, dynesty_sample, dynesty_nthreads, n_live_points, ecclim, delta_z_lim, pl, pu) 716 return fit(self, use_dynesty = use_dynesty, dynamic = dynamic, dynesty_bound = dynesty_bound, dynesty_sample = dynesty_sample, \ 717 dynesty_nthreads = dynesty_nthreads, n_live_points = n_live_points, ecclim = ecclim, delta_z_lim = delta_z_lim, \ --> 718 pl = pl, pu = pu) 719 720 def __init__(self,priors = None, input_folder = None, t_lc = None, y_lc = None, yerr_lc = None, \ ~/anaconda/envs/python3/lib/python3.6/site-packages/juliet/fit.py in __init__(self, data, use_dynesty, dynamic, dynesty_bound, dynesty_sample, dynesty_nthreads, n_live_points, ecclim, delta_z_lim, pl, pu, ta) 1308 for pname in self.posteriors.keys(): 1309 if data.priors[pname]['distribution'] != 'fixed': -> 1310 self.posteriors[pname] = np.median(out['posterior_samples'][pname]) 1311 posterior_samples = out['posterior_samples']['unnamed'] 1312 if 'pu' in out.keys(): KeyError: 'GP_sigma_rv'
nespinoza commented 4 years ago

Hi @jkteske,

Sorry for just returning to this! Your first problem stems from the code in the tutorial trying to save the results of the linear trend to the same folder as the 3-planet fit. When a folder already exists, juliet by default loads the priors in the folder but defines internally the ones given by the user in the dictionary (i.e., the priors dictionary). This is a way of letting the user know that the input dictionary and the priors file in the folder are inconsistent (like what you just experienced). I just changed the fact that the tutorial uses the same name for both fits in https://github.com/nespinoza/juliet/commit/6e987471dd65c3ac04c98ffff145d93c360d8065 (sorry about that).

Your second issue is similar to the first one --- it stems because you probably ran that fit in the same folder as the one in the "Fitting RVs" tutorial, so the folder named toi141_rvs already exists (from the very first RV fit, with no GPs and no second planet) and produces the same problem. To ensure future users that do the same in the future don't get the error, I've just changed the name of the folder in the GP tutorial in this commit: https://github.com/nespinoza/juliet/commit/1fdfe09da9c36bbbc01df8fff0f3132bca819601.

Let me know if all this fixes your issues, so I can close this issue! Thanks for bringing those to my attention.

Best, N.

jkteske commented 4 years ago

Thank you thank you! These changes fixed the issues.

nespinoza commented 4 years ago

Fantastic! Glad to know it was all resolved at the end. Closing this issue then and, if you have any more questions and/or bugs, please feel free to open another issue!

N.