class orbitize.results.Results(sampler_name=None, post=None, lnlike=None, tau_ref_epoch=None, labels=None, data=None, num_secondary_bodies=None, version_number=None, curr_pos=None, fitting_basis='Standard', basis=None, extra_basis_args=None)[source]

A class to store accepted orbital configurations from the sampler

  • sampler_name (string) – name of sampler class that generated these results (default: None).

  • post (np.array of float) – MxN array of orbital parameters (posterior output from orbit-fitting process), where M is the number of orbits generated, and N is the number of varying orbital parameters in the fit (default: None).

  • lnlike (np.array of float) – M array of log-likelihoods corresponding to the orbits described in post (default: None).

  • tau_ref_epoch (float) – date (in days, typically MJD) that tau is defined relative to

  • labels (list of str) – parameter labels in same order as post

  • data (astropy.table.Table) – output from orbitize.read_input.read_file()

  • num_secondary_bodies (int) – number of companions fit

  • curr_pos (np.array of float) – for MCMC only. A multi-D array of the current walker positions that is used for restarting a MCMC sampler.

  • fitting_basis (string) – name of the basis that the sampler fit into (default: ‘Standard’).

  • basis (orbitize.Basis) – basis object corresponding to the fitting basis being used (default: None).

  • extra_basis_args (dict) – additional arguments needed to initialize the basis class and make necessary conversions (default: None).

The post array is in the following order:

semimajor axis 1, eccentricity 1, inclination 1,
argument of periastron 1, position angle of nodes 1,
epoch of periastron passage 1,
[semimajor axis 2, eccentricity 2, etc.],
[parallax, masses (see docstring for orbitize.system.System)]

where 1 corresponds to the first orbiting object, 2 corresponds to the second, etc.

Written: Henry Ngo, Sarah Blunt, 2018

add_samples(orbital_params, lnlikes, labels, curr_pos=None)[source]

Add accepted orbits, their likelihoods, and the orbitize version number to the results

  • orbital_params (np.array) – add sets of orbital params (could be multiple) to results

  • lnlike (np.array) – add corresponding lnlike values to results

  • labels (list of str) – list of parameter labels specifying the order in orbital_params

  • curr_pos (np.array of float) – for MCMC only. A multi-D array of the current walker positions

Written: Henry Ngo, 2018

load_results(filename, append=False)[source]

Populate the results.Results object with data from a datafile

  • filename (string) – filepath where data is saved

  • append (boolean) – if True, then new data is added to existing object. If False (default), new data overwrites existing object

See the save_results() method in this module for information on how the data is structured.

Written: Henry Ngo, 2018

plot_corner(param_list=None, **corner_kwargs)[source]

Make a corner plot of posterior on orbit fit from any sampler

  • param_list (list of strings) –

    each entry is a name of a parameter to include. Valid strings:

    sma1: semimajor axis
    ecc1: eccentricity
    inc1: inclination
    aop1: argument of periastron
    pan1: position angle of nodes
    tau1: epoch of periastron passage, expressed as fraction of orbital period
    per1: period
    K1: stellar radial velocity semi-amplitude
    [repeat for 2, 3, 4, etc if multiple objects]
    plx:  parallax
    pm_ra: RA proper motion
    pm_dec: Dec proper motion
    alpha0: primary offset from reported Hipparcos RA @ alphadec0_epoch (generally 1991.25)
    delta0: primary offset from reported Hipparcos Dec @ alphadec0_epoch (generally 1991.25)
    gamma: rv offset
    sigma: rv jitter
    mi: mass of individual body i, for i = 0, 1, 2, ... (only if fit_secondary_mass == True)
    mtot: total mass (only if fit_secondary_mass == False)

  • **corner_kwargs – any remaining keyword args are sent to corner.corner. See here. Note: default axis labels used unless overwritten by user input.


corner plot

Return type



Example: Use param_list = ['sma1,ecc1,inc1,sma2,ecc2,inc2'] to only plot posteriors for semimajor axis, eccentricity and inclination of the first two companions

Written: Henry Ngo, 2018

plot_orbits(object_to_plot=1, start_mjd=51544.0, num_orbits_to_plot=100, num_epochs_to_plot=100, square_plot=True, show_colorbar=True, cmap=<matplotlib.colors.LinearSegmentedColormap object>, sep_pa_color='lightgrey', sep_pa_end_year=2025.0, cbar_param='Epoch [year]', mod180=False, rv_time_series=False, plot_astrometry=True, plot_astrometry_insts=False, fig=None)[source]

Plots one orbital period for a select number of fitted orbits for a given object, with line segments colored according to time

  • object_to_plot (int) – which object to plot (default: 1)

  • start_mjd (float) – MJD in which to start plotting orbits (default: 51544, the year 2000)

  • num_orbits_to_plot (int) – number of orbits to plot (default: 100)

  • num_epochs_to_plot (int) – number of points to plot per orbit (default: 100)

  • square_plot (Boolean) – Aspect ratio is always equal, but if square_plot is True (default), then the axes will be square, otherwise, white space padding is used

  • show_colorbar (Boolean) – Displays colorbar to the right of the plot [True]

  • cmap ( – color map to use for making orbit tracks (default: modified Purples_r)

  • sep_pa_color (string) – any valid matplotlib color string, used to set the color of the orbit tracks in the Sep/PA panels (default: ‘lightgrey’).

  • sep_pa_end_year (float) – decimal year specifying when to stop plotting orbit tracks in the Sep/PA panels (default: 2025.0).

  • cbar_param (string) – options are the following: ‘Epoch [year]’, ‘sma1’, ‘ecc1’, ‘inc1’, ‘aop1’, ‘pan1’, ‘tau1’, ‘plx. Number can be switched out. Default is Epoch [year].

  • mod180 (Bool) – if True, PA will be plotted in range [180, 540]. Useful for plotting short arcs with PAs that cross 360 deg during observations (default: False)

  • rv_time_series (Boolean) – if fitting for secondary mass using MCMC for rv fitting and want to display time series, set to True.

  • plot_astrometry (Boolean) – set to True by default. Plots the astrometric data.

  • plot_astrometry_insts (Boolean) – set to False by default. Plots the astrometric data by instruments.

  • fig (matplotlib.pyplot.Figure) – optionally include a predefined Figure object to plot the orbit on. Most users will not need this keyword.


the orbit plot if input is valid, None otherwise

Return type


(written): Henry Ngo, Sarah Blunt, 2018 Additions by Malena Rice, 2019


Prints median and 68% credible intervals alongside fitting labels


Save results.Results object to an hdf5 file


filename (string) – filepath to save to

Save attributes from the results.Results object.

sampler_name, tau_ref_epcoh, version_number are attributes of the root group. post, lnlike, and parameter_labels are datasets that are members of the root group.

Written: Henry Ngo, 2018