Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested sampling with MultiNest #379

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
6 changes: 3 additions & 3 deletions docs/faq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ imaged planets. A detailed description of how τ is related to other quantities

Our goal with the default prior is to have an isotropic distribution of the orbital plane.
To obtain this, we use inclination and position angle of the ascending node (PAN) to
define the orbital plane. They actually coorespond to the two angles in a spherical coordinate system:
inclinaion is the polar angle and PAN is the azimuthal angle. Becuase of this choice of coordinates,
define the orbital plane. They actually correspond to the two angles in a spherical coordinate system:
inclination is the polar angle and PAN is the azimuthal angle. Because of this choice of coordinates,
there are less orbital configurations near the poles (when inclination is near 0 or 180), so we use
a sine prior to downweigh those areas to give us an isotropic distribution.
a sine prior to downweight those areas to give us an isotropic distribution.
A more detailed discussion of this is here:

.. toctree::
Expand Down
4 changes: 3 additions & 1 deletion orbitize/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ class Driver(object):
input_data: Either a relative path to data file or astropy.table.Table object
in the orbitize format. See ``orbitize.read_input``
sampler_str (str): algorithm to use for orbit computation. "MCMC" for
Markov Chain Monte Carlo, "OFTI" for Orbits for the Impatient
Markov Chain Monte Carlo, "OFTI" for Orbits for the Impatient,
"NestedSampler" for nested sampling with Dynesty, or "MultiNest"
for nested sampling with (Py)MultiNest.
num_secondary_bodies (int): number of secondary bodies in the system.
Should be at least 1.
stellar_or_system_mass (float): mass of the primary star (if fitting for
Expand Down
19 changes: 13 additions & 6 deletions orbitize/results.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ def __init__(
self.lnlike = lnlike
self.curr_pos = curr_pos
self.version_number = version_number
self.ln_evidence = None
self.ln_evidence_err = None

if self.system is not None:
self.tau_ref_epoch = self.system.tau_ref_epoch
Expand Down Expand Up @@ -114,6 +116,12 @@ def save_results(self, filename):
hf.attrs['sampler_name'] = self.sampler_name
hf.attrs['version_number'] = self.version_number

if self.ln_evidence is not None:
hf.attrs['ln_evidence'] = self.ln_evidence

if self.ln_evidence_err is not None:
hf.attrs['ln_evidence_err'] = self.ln_evidence_err

# Now add post and lnlike from the results object as datasets
hf.create_dataset('post', data=self.post)
# hf.create_dataset('data', data=self.data)
Expand Down Expand Up @@ -147,19 +155,18 @@ def load_results(self, filename, append=False):
hf = h5py.File(filename, 'r') # Opens file for reading
# Load up each dataset from hdf5 file
sampler_name = str(hf.attrs['sampler_name'])
try:
if 'version_number' in hf.attrs:
version_number = str(hf.attrs['version_number'])
except KeyError:
else:
version_number = "<= 1.13"
post = np.array(hf.get('post'))
lnlike = np.array(hf.get('lnlike'))


try:
if 'num_secondary_bodies' in hf.attrs:
num_secondary_bodies = int(hf.attrs['num_secondary_bodies'])
except KeyError:
else:
# old, has to be single planet fit
num_secondary_bodies = 1
num_secondary_bodies = 1

try:
data_table = table.Table(np.array(hf.get('data')))
Expand Down
Loading
Loading