GENERAL USE AND SHARED FUNCTIONS

Shared Functions

model_fitter.pointwise_likelihood(data, model, filt_index=0)

Makes some plots to diagnose weirdness in GP fits.

model_fitter.debug_gp_nan(data, model, filt_index=0)

Makes some plots to diagnose weirdness in GP fits.

model_fitter.plot_params(model)

Print parameters

model_fitter.plot_photometry(data, model, input_model=None, dense_time=True, residuals=True, filt_index=0, zoomx=None, zoomy=None, zoomy_res=None, mnest_results=None, N_traces=50, gp=False, fitter=None)

Get the data out.

model_fitter.plot_photometry_gp(data, model, input_model=None, dense_time=True, residuals=True, filt_index=0, zoomx=None, zoomy=None, zoomy_res=None, mnest_results=None, N_traces=50, gp=False)
model_fitter.plot_astrometry(data, model, input_model=None, dense_time=True, residuals=True, n_phot_sets=0, filt_index=0, ast_filt_index=0, mnest_results=None, N_traces=50, fitter=None)

Astrometry on the sky

model_fitter.plot_astrometry_on_sky(data, model, ast_filt_index=0)
model_fitter.plot_astrometry_proper_motion_removed(data, model, ast_filt_index=0)

Proper Motion Subtracted

model_fitter.quantiles(mnest_results, sigma=1)

Calculate the median and N sigma credicble interval.

Parameters
mnest_resultsastropy table

The table that comes out of load_mnest_results.

sigmaint, optional

1, 2, or 3 sigma to determine which credible interval to return.

model_fitter.get_mnest_results(root_name, parameters)
Parameters
root_namestr

The directory and base name of the MultiNest output.

parameterslist or array

A list of strings with the parameter names to be displayed. There should be one name for each parameter in MultiNest and in the order that they appeared in the hyper-cube.

model_fitter.calc_AIC(k, maxlogL)
Calculate Akaike Information Criterion.
k = number of parameters
maxlogL = maximum log likelihood
model_fitter.calc_BIC(n, k, maxlogL)
Calculate Bayesian Information Criterion.
n = sample size
k = number of parameters

maxlogL = maximum log likelihood

model_fitter.postplot(results, span=None, quantiles=[0.025, 0.5, 0.975], q_color='gray', smooth=0.02, post_color='blue', post_kwargs=None, kde=True, nkde=1000, max_n_ticks=5, use_math_text=False, labels=None, label_kwargs=None, show_titles=False, title_fmt='.2f', title_kwargs=None, truths1=None, truths2=None, truth_color1='red', truth_color2='blue', truth_kwargs1=None, truth_kwargs2=None, verbose=False, fig=None)

Plot marginalized posteriors for each parameter. Basically copied half of traceplot.

Parameters
resultsResults instance

A Results instance from a nested sampling run. Compatible with results derived from nestle.

spaniterable with shape (ndim,), optional

A list where each element is either a length-2 tuple containing lower and upper bounds or a float from (0., 1.] giving the fraction of (weighted) samples to include. If a fraction is provided, the bounds are chosen to be equal-tailed. An example would be:

span = [(0., 10.), 0.95, (5., 6.)]

Default is 0.999999426697 (5-sigma credible interval) for each parameter.

quantilesiterable, optional

A list of fractional quantiles to overplot on the 1-D marginalized posteriors as vertical dashed lines. Default is [0.025, 0.5, 0.975] (the 95%/2-sigma credible interval).

smoothfloat or iterable with shape (ndim,), optional

The standard deviation (either a single value or a different value for each subplot) for the Gaussian kernel used to smooth the 1-D marginalized posteriors, expressed as a fraction of the span. Default is 0.02 (2% smoothing). If an integer is provided instead, this will instead default to a simple (weighted) histogram with bins=smooth.

post_colorstr or iterable with shape (ndim,), optional

A ~matplotlib-style color (either a single color or a different value for each subplot) used when plotting the histograms. Default is ‘blue’.

post_kwargsdict, optional

Extra keyword arguments that will be used for plotting the marginalized 1-D posteriors.

kdebool, optional

Whether to use kernel density estimation to estimate and plot the PDF of the importance weights as a function of log-volume (as opposed to the importance weights themselves). Default is True.

nkdeint, optional

The number of grid points used when plotting the kernel density estimate. Default is 1000.

max_n_ticksint, optional

Maximum number of ticks allowed. Default is 5.

use_math_textbool, optional

Whether the axis tick labels for very large/small exponents should be displayed as powers of 10 rather than using e. Default is False.

labelsiterable with shape (ndim,), optional

A list of names for each parameter. If not provided, the default name used when plotting will follow \(x_i\) style.

label_kwargsdict, optional

Extra keyword arguments that will be sent to the ~matplotlib.axes.Axes.set_xlabel and ~matplotlib.axes.Axes.set_ylabel methods.

show_titlesbool, optional

Whether to display a title above each 1-D marginalized posterior showing the 0.5 quantile along with the upper/lower bounds associated with the 0.025 and 0.975 (95%/2-sigma credible interval) quantiles. Default is True.

title_fmtstr, optional

The format string for the quantiles provided in the title. Default is ‘.2f’.

title_kwargsdict, optional

Extra keyword arguments that will be sent to the ~matplotlib.axes.Axes.set_title command.

truthsiterable with shape (ndim,), optional

A list of reference values that will be overplotted on the traces and marginalized 1-D posteriors as solid horizontal/vertical lines. Individual values can be exempt using None. Default is None.

truth_colorstr or iterable with shape (ndim,), optional

A ~matplotlib-style color (either a single color or a different value for each subplot) used when plotting truths. Default is ‘red’.

truth_kwargsdict, optional

Extra keyword arguments that will be used for plotting the vertical and horizontal lines with truths.

verbosebool, optional

Whether to print the values of the computed quantiles associated with each parameter. Default is False.

fig(~matplotlib.figure.Figure, ~matplotlib.axes.Axes), optional

If provided, overplot the traces and marginalized 1-D posteriors onto the provided figure. Otherwise, by default an internal figure is generated.

Returns
traceplot(~matplotlib.figure.Figure, ~matplotlib.axes.Axes)

Output trace plot.

model_fitter.cornerplot_2truth(results, dims=None, span=None, quantiles=[0.025, 0.5, 0.975], color='black', smooth=0.02, quantiles_2d=None, hist_kwargs=None, hist2d_kwargs=None, labels=None, label_kwargs=None, show_titles=False, title_fmt='.2f', title_kwargs=None, truths1=None, truth_color1='red', truth_kwargs1=None, truths2=None, truth_color2='blue', truth_kwargs2=None, max_n_ticks=5, top_ticks=False, use_math_text=False, verbose=False, fig=None)

Generate a corner plot of the 1-D and 2-D marginalized posteriors.

Parameters
resultsResults instance

A Results instance from a nested sampling run. Compatible with results derived from nestle.

dimsiterable of shape (ndim,), optional

The subset of dimensions that should be plotted. If not provided, all dimensions will be shown.

spaniterable with shape (ndim,), optional

A list where each element is either a length-2 tuple containing lower and upper bounds or a float from (0., 1.] giving the fraction of (weighted) samples to include. If a fraction is provided, the bounds are chosen to be equal-tailed. An example would be:

.. code::

span = [(0., 10.), 0.95, (5., 6.)]

Default is 0.999999426697 (5-sigma credible interval).

quantilesiterable, optional

A list of fractional quantiles to overplot on the 1-D marginalized posteriors as vertical dashed lines. Default is [0.025, 0.5, 0.975] (spanning the 95%/2-sigma credible interval).

colorstr or iterable with shape (ndim,), optional

A ~matplotlib-style color (either a single color or a different value for each subplot) used when plotting the histograms. Default is ‘black’.

smoothfloat or iterable with shape (ndim,), optional

The standard deviation (either a single value or a different value for each subplot) for the Gaussian kernel used to smooth the 1-D and 2-D marginalized posteriors, expressed as a fraction of the span. Default is 0.02 (2% smoothing). If an integer is provided instead, this will instead default to a simple (weighted) histogram with bins=smooth.

quantiles_2diterable with shape (nquant,), optional

The quantiles used for plotting the smoothed 2-D distributions. If not provided, these default to 0.5, 1, 1.5, and 2-sigma contours roughly corresponding to quantiles of [0.1, 0.4, 0.65, 0.85].

hist_kwargsdict, optional

Extra keyword arguments to send to the 1-D (smoothed) histograms.

hist2d_kwargsdict, optional

Extra keyword arguments to send to the 2-D (smoothed) histograms.

labelsiterable with shape (ndim,), optional

A list of names for each parameter. If not provided, the default name used when plotting will follow \(x_i\) style.

label_kwargsdict, optional

Extra keyword arguments that will be sent to the ~matplotlib.axes.Axes.set_xlabel and ~matplotlib.axes.Axes.set_ylabel methods.

show_titlesbool, optional

Whether to display a title above each 1-D marginalized posterior showing the 0.5 quantile along with the upper/lower bounds associated with the 0.025 and 0.975 (95%/2-sigma credible interval) quantiles. Default is True.

title_fmtstr, optional

The format string for the quantiles provided in the title. Default is ‘.2f’.

title_kwargsdict, optional

Extra keyword arguments that will be sent to the ~matplotlib.axes.Axes.set_title command.

truthsiterable with shape (ndim,), optional

A list of reference values that will be overplotted on the traces and marginalized 1-D posteriors as solid horizontal/vertical lines. Individual values can be exempt using None. Default is None.

truth_colorstr or iterable with shape (ndim,), optional

A ~matplotlib-style color (either a single color or a different value for each subplot) used when plotting truths. Default is ‘red’.

truth_kwargsdict, optional

Extra keyword arguments that will be used for plotting the vertical and horizontal lines with truths.

max_n_ticksint, optional

Maximum number of ticks allowed. Default is 5.

top_ticksbool, optional

Whether to label the top (rather than bottom) ticks. Default is False.

use_math_textbool, optional

Whether the axis tick labels for very large/small exponents should be displayed as powers of 10 rather than using e. Default is False.

verbosebool, optional

Whether to print the values of the computed quantiles associated with each parameter. Default is False.

fig(~matplotlib.figure.Figure, ~matplotlib.axes.Axes), optional

If provided, overplot the traces and marginalized 1-D posteriors onto the provided figure. Otherwise, by default an internal figure is generated.

Returns
cornerplot(~matplotlib.figure.Figure, ~matplotlib.axes.Axes)

Output corner plot.

model_fitter.contour2d_alpha(x, y, smooth=0.02, span=None, weights=None, sigma_levels=[1, 2, 3], ax=None, color='gray', plot_density=True, plot_contours=True, contour_kwargs=None, **kwargs)

Simplified/modified from dynesty’s plotting._hist2d function. Plots non-filled 2D contours, where the contours are the 0.5, 1, 1.5, 2 sigma contours (note this)

Parameters
xinterable with shape (nsamps,)

Sample positions in the first dimension.

yiterable with shape (nsamps,)

Sample positions in the second dimension.

spaniterable with shape (ndim,), optional

A list where each element is either a length-2 tuple containing lower and upper bounds or a float from (0., 1.] giving the fraction of (weighted) samples to include. If a fraction is provided, the bounds are chosen to be equal-tailed. An example would be:

`span = [(0., 10.), 0.95, (5., 6.)]`

Default is 0.999999426697 (5-sigma credible interval).

weightsiterable with shape (nsamps,)

Weights associated with the samples. Default is None (no weights).

sigma_levelsiterable, optional

The contour levels to draw. Default are [1, 2, 3]-sigma. UNITS ARE IN SIGMA

ax~matplotlib.axes.Axes, optional

An ~matplotlib.axes.axes instance on which to add the 2-D histogram. If not provided, a figure will be generated.

colorstr, optional

The ~matplotlib-style color used to draw lines and color cells and contours. Default is ‘gray’.

plot_densitybool, optional

Whether to draw the density colormap. Default is True.

plot_contoursbool, optional

Whether to draw the contours. Default is True.

contour_kwargsdict

Any additional keyword arguments to pass to the contour method.

data_kwargsdict

Any additional keyword arguments to pass to the plot method when adding the individual data points.

model_fitter.traceplot_custom(results_list, quantiles=[0.025, 0.5, 0.975], smooth=0.02, thin=1, dims=None, contour_labels_list=None, post_color_list=['blue'], post_kwargs=None, kde=True, nkde=1000, trace_cmap='plasma', trace_color=None, trace_kwargs=None, connect=False, connect_highlight=10, connect_color='red', connect_kwargs=None, max_n_ticks=5, use_math_text=False, labels=None, label_kwargs=None, show_titles=False, title_fmt='.2f', title_kwargs=None, truths=None, truth_color='red', truth_kwargs=None, verbose=False, fig=None)

Plot traces and marginalized posteriors for each parameter. Allows you to plot multiple trace plots on top of each other. The keywords are mostly the same as the dynesty default, only listing the new keywords here.

Parameters
results_listlist of Results instance

A Results instance from a nested sampling run. Compatible with results derived from nestle.

color_listlist of length the same as results_list

List of ~matplotlib-style colors.

contour_labels_listlist of length the same as results_list

List of strings for labelling each contour.

Returns
traceplot(~matplotlib.figure.Figure, ~matplotlib.axes.Axes)

Output trace plot.

model_fitter.cornerplot_custom(results_list, dims=None, quantiles=[0.025, 0.5, 0.975], color_list=['blue'], smooth=0.02, quantiles_2d=None, hist_kwargs=None, hist2d_kwargs=None, labels=None, label_kwargs=None, contour_labels_list=None, show_titles=False, title_fmt='.2f', title_kwargs=None, truths=None, truth_color='red', truth_kwargs=None, max_n_ticks=5, top_ticks=False, use_math_text=False, verbose=False, fig=None)

Generate a corner plot of the 1-D and 2-D marginalized posteriors. Allows you to plot multiple corner plots on top of each other. The keywords are mostly the same as dynesty default, only listing the new keywords here.

Parameters
results_listlist of Results instance

A Results instance from a nested sampling run. Compatible with results derived from nestle.

color_listlist of length the same as results_list

List of ~matplotlib-style colors.

contour_labels_listlist of length the same as results_list

List of strings for labelling each contour.

Returns
cornerplot(~matplotlib.figure.Figure, ~matplotlib.axes.Axes)

Output corner plot.