PSPL_Solver

class model_fitter.PSPL_Solver(data, model_class, custom_additional_param_names=None, add_error_on_photometry=False, multiply_error_on_photometry=False, use_phot_optional_params=True, use_ast_optional_params=True, wrapped_params=None, importance_nested_sampling=False, multimodal=True, const_efficiency_mode=False, n_live_points=300, evidence_tolerance=0.5, sampling_efficiency=0.8, n_iter_before_update=100, null_log_evidence=-1e+90, max_modes=100, mode_tolerance=-1e+90, outputfiles_basename='chains/1-', seed=-1, verbose=False, resume=False, context=0, write_output=True, log_zero=-1e+100, max_iter=0, init_MPI=False, dump_callback='default')

Bases: Solver

A PyMultiNest solver to find the optimal PSPL parameters, given data and a microlensing model from model.py. DESPITE THE NAME YOU CAN ALSO USE IT TO FIT PSBL!

Examples

Assuming that a data dictionary has been instantiated with the above keys, and that a model has been loaded in from model.py, PSPL_Solver can be run with the following commands: .. code:

fitter = PSPL_Solver(data,
                     PSPL_PhotAstrom_Par_Param1,
                     add_error_on_photometry=True,
                     custom_additional_param_names=['dS', 'tE'],
                     outputfiles_basename='./model_output/test_')
fitter.solve()
Attributes
datadictionary

Observational data used to fit a microlensing model. What the data must contain depends on what type of microlensing model you are solving for.

The data dictionary must always photometry information of at least one filter. This data must contain the times, magnitudes, and magnitude errors of the observations. The keys to these arrays are:

  • t_phot1 (MJD)

  • mag1 (magnitudes)

  • mag_err1 (magnitudes)

PSPL_Solver supports multiple photometric filters. For each additional filter, increments the extension of the above keys by one. For example, a second filter would be:

  • t_phot2 (MJD)

  • mag2 (magnitudes)

  • mag_err2 (magnitudes)

PSPL_Solver supports solving microlensing models that calculate with parallax. These models must be accompanied with data that contains the right ascenscion and declination of the target. These keys are:

  • raL (decimal degrees)

  • decL (decimal degrees)

PSPL_Solver supports solving microlensing models that fit astrometry. These models must be accompanied with data that contains astrometric observations in the following keys:

  • t_ast (MJD)

  • xpos (arcsec along East-West increasing to the East)

  • ypos (arcsec along the North-South increasing to the North)

  • xpos_err (arcsec)

  • ypos_err (arcsec)

model_class

PSPL_Solver must be provided with the microlensing model that you are trying to fit to your data. These models are written out in model.py, along with extensive documentation as to their content and construction in the file’s docstring. The model can support either

  1. photometric data or photometric and astrometric data,

  2. parallax or no parallax, and

  3. different parameterizations of the model.

For example, a model with accepts both astrometric and photometric data, uses parallax, and uses a parameterization that includes the distance to the source and the lens is: PSPL_PhotAstrom_Par_Param1.

custom_additional_param_nameslist, optional

If provided, the fitter will override the default additional_param_names of the model_class. These are the parameters, besides those that are being fitted for, that are written out to disk for posterior plotting after the fit has completed. To see the default additional_param_names run:

print(model_class.additional _param_names)

add_error_on_photometryboolean, optional

If set to True, the fitter will fit for an additive error to the photometric magnitudes in the fitting process. This error will have the name add_errN, with an N equal to the filter number.

multiply_error_on_photometryboolean, optional

If set to True, the fitter will fit for a multiplicative error to the photometric magnitudes in the fitting process. This error will have the name mult_errN, with an N equal to the filter number.

All other parameters

See pymultinest.run() for a description of all other parameters.

Methods

LogLikelihood(cube[, ndim, n_params])

This is just a wrapper because PyMultinest requires passing in the ndim and nparams.

Prior(cube[, ndim, nparams])

Prior_from_post(cube[, ndim, nparams])

Get the bin midpoints

calc_best_fit(tab, smy[, s_idx, def_best])

Returns best-fit parameters, where best-fit can be median, maxl, or MAP.

calc_chi2([params, verbose])

Parameters

calc_chi2_manual([params, verbose])

Parameters

get_best_fit([def_best])

Returns best-fit parameters, where best-fit can be median, maxl, or MAP.

get_best_fit_model([def_best])

Identify best-fit model

get_best_fit_modes([def_best])

Returns a list of best-fit parameters, where best-fit can be median, maxl, or MAP.

load_mnest_modes([remake_fits])

Load up the separate modes results into an astropy table.

load_mnest_modes_results_for_dynesty([...])

Make a Dynesty-style results object that can be used in the nicer plotting codes.

load_mnest_results([remake_fits])

Load up the MultiNest results into an astropy table.

load_mnest_results_for_dynesty([remake_fits])

Make a Dynesty-style results object that can be used in the nicer plotting codes.

load_mnest_summary([remake_fits])

Load up the MultiNest results into an astropy table.

log_likely(cube[, verbose])

Parameters

make_default_priors()

Setup our prior distributions (i.e.

plot_dynesty_style([sim_vals, fit_vals, ...])

Parameters

plot_model_and_data(model[, input_model, ...])

Make and save the model and data plots.

plot_model_and_data_modes([def_best])

Plots photometry data, along with n random draws from the posterior.

print_likelihood([params, verbose])

Parameters

sample_post(binmids, cdf, bininds)

Randomly sample from a multinest posterior distribution.

separate_modes()

Reads in the fits for the different modes (post_separate.dat) and splits it into a .dat file per mode.

solve()

Run a MultiNest fit to find the optimal parameters (and their posteriors) given the data.

write_params_yaml()

Write a YAML file that contains the parameters to re-initialize this object, if desired.

Prior_copy

callback_plotter

check_data

dyn_log_likely

dyn_prior

get_best_fit_modes_model

get_model

get_modified_mag_err

log_likely_astrometry

log_likely_photometry

setup_params

summarize_results

summarize_results_modes

write_summary_maxL

make_default_priors()

Setup our prior distributions (i.e. random samplers). We will draw from these in the Prior() function. We set them up in advance because they depend on properties of the data. Also, they can be over-written by custom priors as desired.

To make your own custom priors, use the make_gen() functions with different limits.

Prior_from_post(cube, ndim=None, nparams=None)

Get the bin midpoints

sample_post(binmids, cdf, bininds)

Randomly sample from a multinest posterior distribution.

Parameters
Nparams:

number of parameters

Nbins:

number of histogram bins per dimension

Nnzero:

number of histogram bins with non-zero probability

binmidslist of length N, each list entry is an array of shape (M, )

The centers of the bins for each parameter

cdf(Nnzero, ) array

CDF of the distribution. Only the non-zero probability entries.

bininds(Nnzero, Nparams) array

Histogram indices of the non-zero probability entries.

LogLikelihood(cube, ndim=None, n_params=None)

This is just a wrapper because PyMultinest requires passing in the ndim and nparams.

log_likely(cube, verbose=False)
Parameters
cubelist or dict

The dictionary or cube of the model parameters.

write_params_yaml()

Write a YAML file that contains the parameters to re-initialize this object, if desired.

solve()

Run a MultiNest fit to find the optimal parameters (and their posteriors) given the data.

Note we will ALWAYS tell multinest to be verbose.

separate_modes()

Reads in the fits for the different modes (post_separate.dat) and splits it into a .dat file per mode.

Is there a more intelligent way to deal with all the indices??? Write better later, but it seems to work for now…

calc_best_fit(tab, smy, s_idx=0, def_best='maxl')

Returns best-fit parameters, where best-fit can be median, maxl, or MAP. Default is maxl.

If best-fit is median, then also return +/- 1 sigma uncertainties.

If best-fit is MAP, then also need to indicate which row of summary table to use. Default is s_idx = 0 (global solution). s_idx = 1, 2, … , n for the n different modes.

tab = self.load_mnest_results() smy = self.load_mnest_summary()

get_best_fit(def_best='maxl')

Returns best-fit parameters, where best-fit can be median, maxl, or MAP. Default is maxl.

If def_best is median, then also return +/- 1 sigma uncertainties.

Returns
Either a dicitonary or a tuple of length=2 holding
two dictionaries, one for values and one for uncertainty ranges.
See calc_best_fit() for details.
get_best_fit_modes(def_best='maxl')

Returns a list of best-fit parameters, where best-fit can be median, maxl, or MAP. Default is maxl.

If def_best is median, then also return +/- 1 sigma uncertainties.

Returns
Either a list of dicitonaries or a list where each entry is
a tuple of length=2 holding two dictionaries, one for values
and one for uncertainty ranges.
See calc_best_fit() for details.
get_best_fit_model(def_best='maxl')

Identify best-fit model

Parameters
def_beststr

Choices are ‘map’ (maximum a posteriori), ‘median’, or ‘maxl’ (maximum likelihood)

load_mnest_results(remake_fits=False)

Load up the MultiNest results into an astropy table.

load_mnest_summary(remake_fits=False)

Load up the MultiNest results into an astropy table.

load_mnest_modes(remake_fits=False)

Load up the separate modes results into an astropy table.

load_mnest_results_for_dynesty(remake_fits=False)

Make a Dynesty-style results object that can be used in the nicer plotting codes.

load_mnest_modes_results_for_dynesty(remake_fits=False)

Make a Dynesty-style results object that can be used in the nicer plotting codes.

plot_dynesty_style(sim_vals=None, fit_vals=None, remake_fits=False, dims=None, traceplot=True, cornerplot=True, kde=True)
Parameters
sim_valsdict

Dictionary of simulated input or comparison values to overplot on posteriors.

fit_valsstr

Choices are ‘map’ (maximum a posteriori), ‘mean’, or ‘maxl’ (maximum likelihood)

plot_model_and_data(model, input_model=None, mnest_results=None, suffix='', zoomx=None, zoomy=None, zoomy_res=None, fitter=None, N_traces=50)

Make and save the model and data plots.

zoomx, xoomy, zoomy_res : list the same length as self.n_phot_sets Each entry of the list is a list [a, b] cooresponding to the plot limits

plot_model_and_data_modes(def_best='maxl')

Plots photometry data, along with n random draws from the posterior.

print_likelihood(params='best', verbose=True)
Parameters
model_paramsstr or dict, optional
model_params = ‘best’ will load up the best solution and calculate

the chi^2 based on those values. Alternatively, pass in a dictionary with the model parameters to use.

calc_chi2(params='best', verbose=False)
Parameters
paramsstr or dict, optional

model_params = ‘best’ will load up the best solution and calculate the chi^2 based on those values. Alternatively, pass in a dictionary with the model parameters to use.

calc_chi2_manual(params='best', verbose=False)
Parameters
paramsstr or dict, optional

model_params = ‘best’ will load up the best solution and calculate the chi^2 based on those values. Alternatively, pass in a dictionary with the model parameters to use.

class model_fitter.PSPL_Solver_weighted(data, model_class, custom_additional_param_names=None, add_error_on_photometry=False, multiply_error_on_photometry=False, use_phot_optional_params=True, use_ast_optional_params=True, wrapped_params=None, importance_nested_sampling=False, multimodal=True, const_efficiency_mode=False, n_live_points=300, evidence_tolerance=0.5, sampling_efficiency=0.8, n_iter_before_update=100, null_log_evidence=-1e+90, max_modes=100, mode_tolerance=-1e+90, outputfiles_basename='chains/1-', seed=-1, verbose=False, resume=False, context=0, write_output=True, log_zero=-1e+100, max_iter=0, init_MPI=False, dump_callback=None, weights='phot_ast_equal')

Bases: PSPL_Solver

Soliver where the likelihood function has each data set weigthed equally (i.e. not the natural weighting by the number of points; but rather each contributes 1/n_k where n is the number of data points and k is the data set.

Methods

LogLikelihood(cube[, ndim, n_params])

This is just a wrapper because PyMultinest requires passing in the ndim and nparams.

Prior(cube[, ndim, nparams])

Prior_from_post(cube[, ndim, nparams])

Get the bin midpoints

calc_best_fit(tab, smy[, s_idx, def_best])

Returns best-fit parameters, where best-fit can be median, maxl, or MAP.

calc_chi2([params, verbose])

Parameters

calc_chi2_manual([params, verbose])

Parameters

calc_weights(weights)

order of weight_arr is `[phot_1, phot_2, .

get_best_fit([def_best])

Returns best-fit parameters, where best-fit can be median, maxl, or MAP.

get_best_fit_model([def_best])

Identify best-fit model

get_best_fit_modes([def_best])

Returns a list of best-fit parameters, where best-fit can be median, maxl, or MAP.

load_mnest_modes([remake_fits])

Load up the separate modes results into an astropy table.

load_mnest_modes_results_for_dynesty([...])

Make a Dynesty-style results object that can be used in the nicer plotting codes.

load_mnest_results([remake_fits])

Load up the MultiNest results into an astropy table.

load_mnest_results_for_dynesty([remake_fits])

Make a Dynesty-style results object that can be used in the nicer plotting codes.

load_mnest_summary([remake_fits])

Load up the MultiNest results into an astropy table.

log_likely(cube[, verbose])

Parameters

make_default_priors()

Setup our prior distributions (i.e.

plot_dynesty_style([sim_vals, fit_vals, ...])

Parameters

plot_model_and_data(model[, input_model, ...])

Make and save the model and data plots.

plot_model_and_data_modes([def_best])

Plots photometry data, along with n random draws from the posterior.

print_likelihood([params, verbose])

Parameters

sample_post(binmids, cdf, bininds)

Randomly sample from a multinest posterior distribution.

separate_modes()

Reads in the fits for the different modes (post_separate.dat) and splits it into a .dat file per mode.

solve()

Run a MultiNest fit to find the optimal parameters (and their posteriors) given the data.

write_params_yaml()

Write a YAML file that contains the parameters to re-initialize this object, if desired.

Prior_copy

callback_plotter

check_data

dyn_log_likely

dyn_prior

get_best_fit_modes_model

get_model

get_modified_mag_err

log_likely_astrometry

log_likely_photometry

setup_params

summarize_results

summarize_results_modes

write_summary_maxL

calc_weights(weights)

order of weight_arr is [phot_1, phot_2, … phot_n, ast_1, ast_2, … ast_n]

LogLikelihood(cube, ndim=None, n_params=None)

This is just a wrapper because PyMultinest requires passing in the ndim and nparams.

Prior_from_post(cube, ndim=None, nparams=None)

Get the bin midpoints

calc_best_fit(tab, smy, s_idx=0, def_best='maxl')

Returns best-fit parameters, where best-fit can be median, maxl, or MAP. Default is maxl.

If best-fit is median, then also return +/- 1 sigma uncertainties.

If best-fit is MAP, then also need to indicate which row of summary table to use. Default is s_idx = 0 (global solution). s_idx = 1, 2, … , n for the n different modes.

tab = self.load_mnest_results() smy = self.load_mnest_summary()

calc_chi2(params='best', verbose=False)
Parameters
paramsstr or dict, optional

model_params = ‘best’ will load up the best solution and calculate the chi^2 based on those values. Alternatively, pass in a dictionary with the model parameters to use.

calc_chi2_manual(params='best', verbose=False)
Parameters
paramsstr or dict, optional

model_params = ‘best’ will load up the best solution and calculate the chi^2 based on those values. Alternatively, pass in a dictionary with the model parameters to use.

get_best_fit(def_best='maxl')

Returns best-fit parameters, where best-fit can be median, maxl, or MAP. Default is maxl.

If def_best is median, then also return +/- 1 sigma uncertainties.

Returns
Either a dicitonary or a tuple of length=2 holding
two dictionaries, one for values and one for uncertainty ranges.
See calc_best_fit() for details.
get_best_fit_model(def_best='maxl')

Identify best-fit model

Parameters
def_beststr

Choices are ‘map’ (maximum a posteriori), ‘median’, or ‘maxl’ (maximum likelihood)

get_best_fit_modes(def_best='maxl')

Returns a list of best-fit parameters, where best-fit can be median, maxl, or MAP. Default is maxl.

If def_best is median, then also return +/- 1 sigma uncertainties.

Returns
Either a list of dicitonaries or a list where each entry is
a tuple of length=2 holding two dictionaries, one for values
and one for uncertainty ranges.
See calc_best_fit() for details.
load_mnest_modes(remake_fits=False)

Load up the separate modes results into an astropy table.

load_mnest_modes_results_for_dynesty(remake_fits=False)

Make a Dynesty-style results object that can be used in the nicer plotting codes.

load_mnest_results(remake_fits=False)

Load up the MultiNest results into an astropy table.

load_mnest_results_for_dynesty(remake_fits=False)

Make a Dynesty-style results object that can be used in the nicer plotting codes.

load_mnest_summary(remake_fits=False)

Load up the MultiNest results into an astropy table.

log_likely(cube, verbose=False)
Parameters
cubelist or dict

The dictionary or cube of the model parameters.

make_default_priors()

Setup our prior distributions (i.e. random samplers). We will draw from these in the Prior() function. We set them up in advance because they depend on properties of the data. Also, they can be over-written by custom priors as desired.

To make your own custom priors, use the make_gen() functions with different limits.

plot_dynesty_style(sim_vals=None, fit_vals=None, remake_fits=False, dims=None, traceplot=True, cornerplot=True, kde=True)
Parameters
sim_valsdict

Dictionary of simulated input or comparison values to overplot on posteriors.

fit_valsstr

Choices are ‘map’ (maximum a posteriori), ‘mean’, or ‘maxl’ (maximum likelihood)

plot_model_and_data(model, input_model=None, mnest_results=None, suffix='', zoomx=None, zoomy=None, zoomy_res=None, fitter=None, N_traces=50)

Make and save the model and data plots.

zoomx, xoomy, zoomy_res : list the same length as self.n_phot_sets Each entry of the list is a list [a, b] cooresponding to the plot limits

plot_model_and_data_modes(def_best='maxl')

Plots photometry data, along with n random draws from the posterior.

print_likelihood(params='best', verbose=True)
Parameters
model_paramsstr or dict, optional
model_params = ‘best’ will load up the best solution and calculate

the chi^2 based on those values. Alternatively, pass in a dictionary with the model parameters to use.

sample_post(binmids, cdf, bininds)

Randomly sample from a multinest posterior distribution.

Parameters
Nparams:

number of parameters

Nbins:

number of histogram bins per dimension

Nnzero:

number of histogram bins with non-zero probability

binmidslist of length N, each list entry is an array of shape (M, )

The centers of the bins for each parameter

cdf(Nnzero, ) array

CDF of the distribution. Only the non-zero probability entries.

bininds(Nnzero, Nparams) array

Histogram indices of the non-zero probability entries.

separate_modes()

Reads in the fits for the different modes (post_separate.dat) and splits it into a .dat file per mode.

Is there a more intelligent way to deal with all the indices??? Write better later, but it seems to work for now…

solve()

Run a MultiNest fit to find the optimal parameters (and their posteriors) given the data.

Note we will ALWAYS tell multinest to be verbose.

write_params_yaml()

Write a YAML file that contains the parameters to re-initialize this object, if desired.

class model_fitter.PSPL_Solver_Hobson_Weighted(data, model_class, custom_additional_param_names=None, add_error_on_photometry=False, multiply_error_on_photometry=False, use_phot_optional_params=True, use_ast_optional_params=True, wrapped_params=None, importance_nested_sampling=False, multimodal=True, const_efficiency_mode=False, n_live_points=300, evidence_tolerance=0.5, sampling_efficiency=0.8, n_iter_before_update=100, null_log_evidence=-1e+90, max_modes=100, mode_tolerance=-1e+90, outputfiles_basename='chains/1-', seed=-1, verbose=False, resume=False, context=0, write_output=True, log_zero=-1e+100, max_iter=0, init_MPI=False, dump_callback='default')

Bases: PSPL_Solver

Methods

LogLikelihood(cube[, ndim, n_params])

This is just a wrapper because PyMultinest requires passing in the ndim and nparams.

Prior(cube[, ndim, nparams])

Prior_from_post(cube[, ndim, nparams])

Get the bin midpoints

calc_best_fit(tab, smy[, s_idx, def_best])

Returns best-fit parameters, where best-fit can be median, maxl, or MAP.

calc_chi2([params, verbose])

Parameters

calc_chi2_manual([params, verbose])

Parameters

get_best_fit([def_best])

Returns best-fit parameters, where best-fit can be median, maxl, or MAP.

get_best_fit_model([def_best])

Identify best-fit model

get_best_fit_modes([def_best])

Returns a list of best-fit parameters, where best-fit can be median, maxl, or MAP.

get_hobson_effective_weights(cube)

Return the effective weights, alpha_k, for each data set.

hobson_weight_log_likely(ln_prob_dk_giv_ak_1)

Implement a data-set-specific weighting scheme by using a hyperparameter, alpha_k, for the kth data set as described in Hobson et al. 2002.

load_mnest_modes([remake_fits])

Load up the separate modes results into an astropy table.

load_mnest_modes_results_for_dynesty([...])

Make a Dynesty-style results object that can be used in the nicer plotting codes.

load_mnest_results([remake_fits])

Load up the MultiNest results into an astropy table.

load_mnest_results_for_dynesty([remake_fits])

Make a Dynesty-style results object that can be used in the nicer plotting codes.

load_mnest_summary([remake_fits])

Load up the MultiNest results into an astropy table.

log_likely(cube[, verbose])

Compute a log-likelihood where there is a hyperparameter, alpha_k, that controls the weighting between each data k set.

make_default_priors()

Setup our prior distributions (i.e.

plot_dynesty_style([sim_vals, fit_vals, ...])

Parameters

plot_model_and_data(model[, input_model, ...])

Make and save the model and data plots.

plot_model_and_data_modes([def_best])

Plots photometry data, along with n random draws from the posterior.

print_likelihood([params, verbose])

Parameters

sample_post(binmids, cdf, bininds)

Randomly sample from a multinest posterior distribution.

separate_modes()

Reads in the fits for the different modes (post_separate.dat) and splits it into a .dat file per mode.

solve()

Run a MultiNest fit to find the optimal parameters (and their posteriors) given the data.

write_params_yaml()

Write a YAML file that contains the parameters to re-initialize this object, if desired.

Prior_copy

callback_plotter

check_data

dyn_log_likely

dyn_prior

get_best_fit_modes_model

get_model

get_modified_mag_err

log_likely_astrometry

log_likely_photometry

setup_params

summarize_results

summarize_results_modes

write_summary_maxL

log_likely(cube, verbose=False)

Compute a log-likelihood where there is a hyperparameter, alpha_k, that controls the weighting between each data k set. This algorithm is described in Hobson et al. 2002.

Specifically, we are implementing Eq. 35.

Parameters
cubelist or dict

The dictionary or cube of the model parameters.

hobson_weight_log_likely(ln_prob_dk_giv_ak_1)

Implement a data-set-specific weighting scheme by using a hyperparameter, alpha_k, for the kth data set as described in Hobson et al. 2002.

Specifically, we are implementing Eq. 16 and 23-27, with the prior described in Eq. 21.

We are not using the simplifications in Section 5 for now.

get_hobson_effective_weights(cube)

Return the effective weights, alpha_k, for each data set. Photometry first, then astrometry.

LogLikelihood(cube, ndim=None, n_params=None)

This is just a wrapper because PyMultinest requires passing in the ndim and nparams.

Prior_from_post(cube, ndim=None, nparams=None)

Get the bin midpoints

calc_best_fit(tab, smy, s_idx=0, def_best='maxl')

Returns best-fit parameters, where best-fit can be median, maxl, or MAP. Default is maxl.

If best-fit is median, then also return +/- 1 sigma uncertainties.

If best-fit is MAP, then also need to indicate which row of summary table to use. Default is s_idx = 0 (global solution). s_idx = 1, 2, … , n for the n different modes.

tab = self.load_mnest_results() smy = self.load_mnest_summary()

calc_chi2(params='best', verbose=False)
Parameters
paramsstr or dict, optional

model_params = ‘best’ will load up the best solution and calculate the chi^2 based on those values. Alternatively, pass in a dictionary with the model parameters to use.

calc_chi2_manual(params='best', verbose=False)
Parameters
paramsstr or dict, optional

model_params = ‘best’ will load up the best solution and calculate the chi^2 based on those values. Alternatively, pass in a dictionary with the model parameters to use.

get_best_fit(def_best='maxl')

Returns best-fit parameters, where best-fit can be median, maxl, or MAP. Default is maxl.

If def_best is median, then also return +/- 1 sigma uncertainties.

Returns
Either a dicitonary or a tuple of length=2 holding
two dictionaries, one for values and one for uncertainty ranges.
See calc_best_fit() for details.
get_best_fit_model(def_best='maxl')

Identify best-fit model

Parameters
def_beststr

Choices are ‘map’ (maximum a posteriori), ‘median’, or ‘maxl’ (maximum likelihood)

get_best_fit_modes(def_best='maxl')

Returns a list of best-fit parameters, where best-fit can be median, maxl, or MAP. Default is maxl.

If def_best is median, then also return +/- 1 sigma uncertainties.

Returns
Either a list of dicitonaries or a list where each entry is
a tuple of length=2 holding two dictionaries, one for values
and one for uncertainty ranges.
See calc_best_fit() for details.
load_mnest_modes(remake_fits=False)

Load up the separate modes results into an astropy table.

load_mnest_modes_results_for_dynesty(remake_fits=False)

Make a Dynesty-style results object that can be used in the nicer plotting codes.

load_mnest_results(remake_fits=False)

Load up the MultiNest results into an astropy table.

load_mnest_results_for_dynesty(remake_fits=False)

Make a Dynesty-style results object that can be used in the nicer plotting codes.

load_mnest_summary(remake_fits=False)

Load up the MultiNest results into an astropy table.

make_default_priors()

Setup our prior distributions (i.e. random samplers). We will draw from these in the Prior() function. We set them up in advance because they depend on properties of the data. Also, they can be over-written by custom priors as desired.

To make your own custom priors, use the make_gen() functions with different limits.

plot_dynesty_style(sim_vals=None, fit_vals=None, remake_fits=False, dims=None, traceplot=True, cornerplot=True, kde=True)
Parameters
sim_valsdict

Dictionary of simulated input or comparison values to overplot on posteriors.

fit_valsstr

Choices are ‘map’ (maximum a posteriori), ‘mean’, or ‘maxl’ (maximum likelihood)

plot_model_and_data(model, input_model=None, mnest_results=None, suffix='', zoomx=None, zoomy=None, zoomy_res=None, fitter=None, N_traces=50)

Make and save the model and data plots.

zoomx, xoomy, zoomy_res : list the same length as self.n_phot_sets Each entry of the list is a list [a, b] cooresponding to the plot limits

plot_model_and_data_modes(def_best='maxl')

Plots photometry data, along with n random draws from the posterior.

print_likelihood(params='best', verbose=True)
Parameters
model_paramsstr or dict, optional
model_params = ‘best’ will load up the best solution and calculate

the chi^2 based on those values. Alternatively, pass in a dictionary with the model parameters to use.

sample_post(binmids, cdf, bininds)

Randomly sample from a multinest posterior distribution.

Parameters
Nparams:

number of parameters

Nbins:

number of histogram bins per dimension

Nnzero:

number of histogram bins with non-zero probability

binmidslist of length N, each list entry is an array of shape (M, )

The centers of the bins for each parameter

cdf(Nnzero, ) array

CDF of the distribution. Only the non-zero probability entries.

bininds(Nnzero, Nparams) array

Histogram indices of the non-zero probability entries.

separate_modes()

Reads in the fits for the different modes (post_separate.dat) and splits it into a .dat file per mode.

Is there a more intelligent way to deal with all the indices??? Write better later, but it seems to work for now…

solve()

Run a MultiNest fit to find the optimal parameters (and their posteriors) given the data.

Note we will ALWAYS tell multinest to be verbose.

write_params_yaml()

Write a YAML file that contains the parameters to re-initialize this object, if desired.