Skip to content

Commit

Permalink
Merge pull request #328 from California-Planet-Search/next-release
Browse files Browse the repository at this point in the history
Version 1.4.2
  • Loading branch information
bjfultn authored Sep 23, 2020
2 parents 2f93693 + 67ef2d1 commit b241f74
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ Follow examples in
- `radvel/docs/tutorials/SyntheticData.ipynb`
- `radvel/docs/tutorials/K2-24_Fitting+MCMC.ipynb`
- `radvel/docs/tutorials/164922_Fitting+MCMC.ipynb`
- `radvel/docs/tutorials/GaussianProcess-tutorial.ipynb`
- `radvel/docs/tutorials/GaussianProcess-tutorial.ipynb`
2 changes: 1 addition & 1 deletion radvel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def _custom_warningfmt(msg, *a, **b):
__all__ = ['model', 'likelihood', 'posterior', 'mcmc', 'prior', 'utils',
'fitting', 'report', 'cli', 'driver', 'gp']

__version__ = '1.4.1'
__version__ = '1.4.2'
__spec__ = __name__
__package__ = __path__[0]

Expand Down
2 changes: 2 additions & 0 deletions radvel/basis.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ def _setpar(key, new_value):

if isinstance(params_out, radvel.model.Parameters):
params_out.basis = Basis('per tp e w k', self.num_planets)
params_out.planet_parameters = params_out.basis.name.split()
return params_out

def v_from_synth(self, params_in, newbasis):
Expand Down Expand Up @@ -727,6 +728,7 @@ def _delpar(key):
self.params = newbasis.split()

params_out.basis = Basis(newbasis, self.num_planets)
params_out.planet_parameters = params_out.basis.name.split()

return params_out

Expand Down
5 changes: 3 additions & 2 deletions radvel/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import pandas as pd
import numpy as np
from numpy import inf
from astropy import constants as c

if sys.version_info[0] < 3:
Expand Down Expand Up @@ -582,8 +583,8 @@ def report(args):
else:
derived = False
try:
compstats = eval(status.get('ic_compare', args.comptype))
except:
compstats = eval(status.get('ic_compare', 'ic'))
except KeyError:
print("WARNING: Could not find {} model comparison \
in {}.\nPlease make sure that you have run `radvel ic -t {}` (or, e.g., `radvel \
ic -t nplanets e trend jit gp`)\
Expand Down
26 changes: 25 additions & 1 deletion radvel/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,31 @@ def __call__(self,t,*args,**kwargs):
vel += self.vector.vector[self.vector.indices['curv']][0] * (t - self.time_base)**2
return vel


def array_to_params(self,param_values):

new_params = self.params

vary_parameters = self.list_vary_params()

for i in range(len(vary_parameters)):
new_params[vary_parameters[i]] = Parameter(value=param_values[i])

return new_params

def list_vary_params(self):
keys = self.list_params()

return [key for key in keys if self.params[key].vary]

def list_params(self):
try:
keys = self.params_order
except AttributeError:
keys = list(self.params.keys())
self.params_order = keys
return keys


def _standard_rv_calc(t,params,vector,planet_num=None):
vel = np.zeros(len(t))
params_synth = params.basis.v_to_synth(vector)
Expand Down
4 changes: 2 additions & 2 deletions radvel/plot/orbit_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,8 +451,8 @@ def plot_multipanel(self, nophase=False, letter_labels=True):

# phase-folded plots
if not nophase:
gs_phase = gridspec.GridSpec(self.phase_nrows, self.phase_ncols)

gs_phase = gridspec.GridSpec(max([1,self.phase_nrows]), max([1,self.phase_ncols]))
if self.phase_ncols == 1:
gs_phase.update(left=0.12, right=0.93,
top=divide - self.rv_phase_space * 0.5,
Expand Down
2 changes: 1 addition & 1 deletion radvel/posterior.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from .likelihood import Likelihood
import numpy as np
import pickle
import dill as pickle
import radvel
from radvel.gp import CeleriteKernel

Expand Down
7 changes: 3 additions & 4 deletions radvel/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -654,12 +654,11 @@ def draw_models_from_chain(mod, chain, t, nsamples=50):
"""

np.random.seed(0)
chain_samples = chain.ix[np.random.choice(chain.index, nsamples)]
chain_samples = chain.iloc[np.random.choice(chain.index, nsamples)]
models = []
for i in chain_samples.index:
params = np.array(chain.ix[i, mod.vary_parameters])
params = np.array(chain.loc[i, mod.list_vary_params()])
params = mod.array_to_params(params)
models += [mod.model(params, t)]
models += [mod(t)]
models = np.vstack(models)
return models

1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ ipykernel>=4.10.0
jinja2>=2.9
python-dateutil>=2.5.0
h5py>=2.10.0
dill

0 comments on commit b241f74

Please sign in to comment.