Source Documentation

Contents

Source Documentation#

Code to run the MCMC using the models in models.py

syncfit.mcmc.do_dynesty(nu: list[float], F_mJy: list[float], F_error: list[float], lum_dist: float = None, t: float = None, model: ~syncfit.models.syncfit_model.SyncfitModel = <class 'syncfit.models.mq_model.MQModel'>, fix_p: float = None, upperlimits: list[bool] = None, ncores: int = 1, seed: int = None, prior=None, run_kwargs={}, dynesty_kwargs={}, logprob_kwargs={}) tuple[list[float], list[float]]#

Fit the data with the given model using the dynesty nested sampling package

Parameters:
  • nu (list) – list of frequencies in GHz

  • F_muJy (list) – list of fluxes in milli janskies

  • F_error (list) – list of flux error in milli janskies

  • model (SyncfitModel) – Model class to use from syncfit.fitter.models. Can also be a custom model but it must be a subclass of SyncfitModel!

  • lum_dist (float) – luminosity distance in cgs units. Only needed for MQModel. Default is None.

  • t (flost) – observation time in days. Only needed for MQModel. Default is None.

  • fix_p (float) – Will fix the p value to whatever you give, do not provide p in theta_init if this is the case!

  • upperlimits (list[bool]) – True if the point is an upperlimit, False otherwise.

  • ncores (int) – The number of cores to run on, default is 1 and won’t multiprocess

  • seed (int) – The seed for the random number generator passed to dynesty,

  • prior (dict) – dictionary defining the prior ranges. Keys must be same as model.get_labels(). Value should be a list of length 2 like [min, max], both exclusive.

  • run_kwargs (dict) – kwargs to pass to dynesty.run_sampler

  • dynesty_kwargs (dict) – kwargs to pass to dynesty.DynamicNestedSampler

  • logprob_kwargs (dict) – kwargs to pass to the logprob. For the most part this is handled internally but in case someone wrote a custom model they should be able to pass in custom kwargs.

Returns:

flat_samples, log_prob

syncfit.mcmc.do_emcee(theta_init: list[float], nu: list[float], F_mJy: list[float], F_error: list[float], lum_dist: float = None, t: float = None, model: ~syncfit.models.syncfit_model.SyncfitModel = <class 'syncfit.models.syncfit_model.SyncfitModel'>, niter: int = 2000, nwalkers: int = 100, fix_p: float = None, upperlimits: list[bool] = None, day: str = None, plot: bool = False, ncores: int = 1, prior=None) tuple[list[float], list[float]]#

Fit the data with the given model using the emcee package.

Parameters:
  • theta_init (list) – array of initial guesses, must be the length expected by model

  • nu (list) – list of frequencies in GHz

  • F_mJy (list) – list of fluxes in milli janskies

  • F_error (list) – list of flux error in milli janskies

  • model (SyncfitModel) – Model class to use from syncfit.fitter.models. Can also be a custom model but it must be a subclass of SyncfitModel!

  • niter (int) – The number of iterations to run on.

  • nwalkers (int) – The number of walkers to use for emcee

  • fix_p (float) – Will fix the p value to whatever you give, do not provide p in theta_init if this is the case!

  • lum_dist (float) – luminosity distance in cgs units. Only needed for MQModel. Default is None.

  • t (flost) – observation time in seconds. Only needed for MQModel. Default is None.

  • upperlimits (list[bool]) – True if the point is an upperlimit, False otherwise.

  • day (string) – day of observation, used for labeling plots

  • plot (bool) – If True, generate the plots used for debugging. Default is False.

  • ncores (int) – The number of cores to run on, default is 1 and won’t multiprocess

Returns:

flat_samples, log_prob

syncfit.models#

class syncfit.models.MQModel(prior=None, p=None, t=None)#
SED(nu, p, log_bG_sh, log_n, log_epsilon_T, log_epsilon_e, log_epsilon_B, t, z, ell_dec=1.0, f=0.1875, **kwargs)#

Describes the SED model for the model that subclasses this BaseModel

dynesty_transform(theta, **kwargs)#

Transform the input values to the correct prior ranges for dynesty

static get_kwargs(nu: list, F_mJy: list, F_error: list, lum_dist: float = None, t: float = None, upperlimits: list = None) dict#

Packages up the args to be passed into the model based on the user input.

Parameters:
  • nu (list) – frequencies in GHz

  • F_mJy (list) – Fluxes in milli janskies

  • F_error (list) – Flux errors in milli janskies

  • p (float) – A p-value to pass to the model, only used if p-value is fixed

Returns:

Dictionary of values, converted for the modeling used in the mcmc

get_labels(*args, **kwargs)#

Describes a list of labels used in the return values of the mcmc chain. This varies depending on the inputs to the MCMC.

static get_pos(theta_init: list, nwalkers: int) list[float]#

Gets the initial position of all of the walkers assuming a gaussian distribution centered at theta_init.

Parameters:
  • theta_init (list) – Initial location of the walkers

  • nwalkers (int) – Number of walkers

Returns:

A 2D array of the positions of all of the walkers

lnprior(theta, nu, F, F_error, upperlimits, **kwargs)#

Logarithmic prior function that can be changed based on the SED model.

lnprob(theta: list, **kwargs)#

Keep or throw away step likelihood and priors

Parameters:
  • theta (list) – location of the walker

  • **kwargs – Any other arguments to be past to lnprior or loglik

Returns:

The likelihood of the data at that location

loglik(theta, nu, F, F_error, upperlimits, **kwargs)#

Log Likelihood function

Parameters:
  • theta (list) – position of the walker

  • nu (list) – frequencies in GHz

  • F_muJy (list) – Fluxes in micro janskies

  • F_error (list) – Flux errors in micro janskies

  • p (float) – A p-value to pass to the model, only used if p-value is fixed

Returns:

The logarithmic likelihood of that theta position

classmethod override(func)#

This method should be used as a decorator to override other methods

pack_theta(theta, **kwargs)#

Pack theta into a dictionary

unpack_util(theta_init, nu, F_mJy, F_error, nwalkers, lum_dist=None, t=None, upperlimits=None)#

A wrapper on the utility functions.

Parameters:
  • theta_init (list) – List of initial theta locations

  • nu (list) – frequencies in GHz

  • F_mJy (list) – Fluxes in milli janskies

  • F_error (list) – Flux errors in milli janskies

  • p (float) – A p-value to pass to the model, only used if p-value is fixed

  • nwalkers (int) – THe number of walkers to use

class syncfit.models.B5(prior=None, p=None)#

Single break model for just the self-absorption break.

SED(nu, p, log_F_nu, log_nu_a, **kwargs)#

Describes the SED model for the model that subclasses this BaseModel

dynesty_transform(theta, **kwargs)#

Transform the input values to the correct prior ranges for dynesty

static get_kwargs(nu: list, F_mJy: list, F_error: list, lum_dist: float = None, t: float = None, upperlimits: list = None) dict#

Packages up the args to be passed into the model based on the user input.

Parameters:
  • nu (list) – frequencies in GHz

  • F_mJy (list) – Fluxes in milli janskies

  • F_error (list) – Flux errors in milli janskies

  • p (float) – A p-value to pass to the model, only used if p-value is fixed

Returns:

Dictionary of values, converted for the modeling used in the mcmc

get_labels(*args, **kwargs)#

Describes a list of labels used in the return values of the mcmc chain. This varies depending on the inputs to the MCMC.

static get_pos(theta_init: list, nwalkers: int) list[float]#

Gets the initial position of all of the walkers assuming a gaussian distribution centered at theta_init.

Parameters:
  • theta_init (list) – Initial location of the walkers

  • nwalkers (int) – Number of walkers

Returns:

A 2D array of the positions of all of the walkers

lnprior(theta, nu, F, upperlimits, **kwargs)#

Logarithmic prior function that can be changed based on the SED model.

lnprob(theta: list, **kwargs)#

Keep or throw away step likelihood and priors

Parameters:
  • theta (list) – location of the walker

  • **kwargs – Any other arguments to be past to lnprior or loglik

Returns:

The likelihood of the data at that location

loglik(theta, nu, F, F_error, upperlimits, **kwargs)#

Log Likelihood function

Parameters:
  • theta (list) – position of the walker

  • nu (list) – frequencies in GHz

  • F_muJy (list) – Fluxes in micro janskies

  • F_error (list) – Flux errors in micro janskies

  • p (float) – A p-value to pass to the model, only used if p-value is fixed

Returns:

The logarithmic likelihood of that theta position

classmethod override(func)#

This method should be used as a decorator to override other methods

pack_theta(theta, **kwargs)#

Pack theta into a dictionary

unpack_util(theta_init, nu, F_mJy, F_error, nwalkers, lum_dist=None, t=None, upperlimits=None)#

A wrapper on the utility functions.

Parameters:
  • theta_init (list) – List of initial theta locations

  • nu (list) – frequencies in GHz

  • F_mJy (list) – Fluxes in milli janskies

  • F_error (list) – Flux errors in milli janskies

  • p (float) – A p-value to pass to the model, only used if p-value is fixed

  • nwalkers (int) – THe number of walkers to use

class syncfit.models.B1B2(prior=None, p=None)#

Two-break model for the self-absorption break (nu_a) and the minimal energy break (nu_m). This model uses nu_m > nu_a, the opposite of the B4B5 model.

SED(nu, p, log_F_nu, log_nu_a, log_nu_m, **kwargs)#

Describes the SED model for the model that subclasses this BaseModel

dynesty_transform(theta, **kwargs)#

Transform the input values to the correct prior ranges for dynesty

static get_kwargs(nu: list, F_mJy: list, F_error: list, lum_dist: float = None, t: float = None, upperlimits: list = None) dict#

Packages up the args to be passed into the model based on the user input.

Parameters:
  • nu (list) – frequencies in GHz

  • F_mJy (list) – Fluxes in milli janskies

  • F_error (list) – Flux errors in milli janskies

  • p (float) – A p-value to pass to the model, only used if p-value is fixed

Returns:

Dictionary of values, converted for the modeling used in the mcmc

get_labels(*args, **kwargs)#

Describes a list of labels used in the return values of the mcmc chain. This varies depending on the inputs to the MCMC.

static get_pos(theta_init: list, nwalkers: int) list[float]#

Gets the initial position of all of the walkers assuming a gaussian distribution centered at theta_init.

Parameters:
  • theta_init (list) – Initial location of the walkers

  • nwalkers (int) – Number of walkers

Returns:

A 2D array of the positions of all of the walkers

lnprior(theta, nu, F, upperlimits, **kwargs)#

Logarithmic prior function that can be changed based on the SED model.

lnprob(theta: list, **kwargs)#

Keep or throw away step likelihood and priors

Parameters:
  • theta (list) – location of the walker

  • **kwargs – Any other arguments to be past to lnprior or loglik

Returns:

The likelihood of the data at that location

loglik(theta, nu, F, F_error, upperlimits, **kwargs)#

Log Likelihood function

Parameters:
  • theta (list) – position of the walker

  • nu (list) – frequencies in GHz

  • F_muJy (list) – Fluxes in micro janskies

  • F_error (list) – Flux errors in micro janskies

  • p (float) – A p-value to pass to the model, only used if p-value is fixed

Returns:

The logarithmic likelihood of that theta position

classmethod override(func)#

This method should be used as a decorator to override other methods

pack_theta(theta, **kwargs)#

Pack theta into a dictionary

unpack_util(theta_init, nu, F_mJy, F_error, nwalkers, lum_dist=None, t=None, upperlimits=None)#

A wrapper on the utility functions.

Parameters:
  • theta_init (list) – List of initial theta locations

  • nu (list) – frequencies in GHz

  • F_mJy (list) – Fluxes in milli janskies

  • F_error (list) – Flux errors in milli janskies

  • p (float) – A p-value to pass to the model, only used if p-value is fixed

  • nwalkers (int) – THe number of walkers to use

class syncfit.models.B4B5(prior=None, p=None)#

Two-break model for a combination of the self-absorption break (nu_a) and the minimal energy break (nu_m). This model requires that nu_m < nu_a, you should subclass this class and overwrite lnprior to redefine this.

SED(nu, p, log_F_nu, log_nu_a, log_nu_m, **kwargs)#

Describes the SED model for the model that subclasses this BaseModel

dynesty_transform(theta, **kwargs)#

Transform the input values to the correct prior ranges for dynesty

static get_kwargs(nu: list, F_mJy: list, F_error: list, lum_dist: float = None, t: float = None, upperlimits: list = None) dict#

Packages up the args to be passed into the model based on the user input.

Parameters:
  • nu (list) – frequencies in GHz

  • F_mJy (list) – Fluxes in milli janskies

  • F_error (list) – Flux errors in milli janskies

  • p (float) – A p-value to pass to the model, only used if p-value is fixed

Returns:

Dictionary of values, converted for the modeling used in the mcmc

get_labels(*args, **kwargs)#

Describes a list of labels used in the return values of the mcmc chain. This varies depending on the inputs to the MCMC.

static get_pos(theta_init: list, nwalkers: int) list[float]#

Gets the initial position of all of the walkers assuming a gaussian distribution centered at theta_init.

Parameters:
  • theta_init (list) – Initial location of the walkers

  • nwalkers (int) – Number of walkers

Returns:

A 2D array of the positions of all of the walkers

lnprior(theta, nu, F, upperlimits, **kwargs)#

Logarithmic prior function that can be changed based on the SED model.

lnprob(theta: list, **kwargs)#

Keep or throw away step likelihood and priors

Parameters:
  • theta (list) – location of the walker

  • **kwargs – Any other arguments to be past to lnprior or loglik

Returns:

The likelihood of the data at that location

loglik(theta, nu, F, F_error, upperlimits, **kwargs)#

Log Likelihood function

Parameters:
  • theta (list) – position of the walker

  • nu (list) – frequencies in GHz

  • F_muJy (list) – Fluxes in micro janskies

  • F_error (list) – Flux errors in micro janskies

  • p (float) – A p-value to pass to the model, only used if p-value is fixed

Returns:

The logarithmic likelihood of that theta position

classmethod override(func)#

This method should be used as a decorator to override other methods

pack_theta(theta, **kwargs)#

Pack theta into a dictionary

unpack_util(theta_init, nu, F_mJy, F_error, nwalkers, lum_dist=None, t=None, upperlimits=None)#

A wrapper on the utility functions.

Parameters:
  • theta_init (list) – List of initial theta locations

  • nu (list) – frequencies in GHz

  • F_mJy (list) – Fluxes in milli janskies

  • F_error (list) – Flux errors in milli janskies

  • p (float) – A p-value to pass to the model, only used if p-value is fixed

  • nwalkers (int) – THe number of walkers to use

class syncfit.models.B4B5B3(prior=None, p=None)#

Three-break model using the self-absorption break (nu_a), cooling break (nu_c), and minimum energy break (nu_m). This model always requires that nu_m < nu_a < nu_c.

SED(nu, p, log_F_nu, log_nu_a, log_nu_m, log_nu_c, **kwargs)#

Describes the SED model for the model that subclasses this BaseModel

dynesty_transform(theta, **kwargs)#

Transform the input values to the correct prior ranges for dynesty

static get_kwargs(nu: list, F_mJy: list, F_error: list, lum_dist: float = None, t: float = None, upperlimits: list = None) dict#

Packages up the args to be passed into the model based on the user input.

Parameters:
  • nu (list) – frequencies in GHz

  • F_mJy (list) – Fluxes in milli janskies

  • F_error (list) – Flux errors in milli janskies

  • p (float) – A p-value to pass to the model, only used if p-value is fixed

Returns:

Dictionary of values, converted for the modeling used in the mcmc

get_labels(*args, **kwargs)#

Describes a list of labels used in the return values of the mcmc chain. This varies depending on the inputs to the MCMC.

static get_pos(theta_init: list, nwalkers: int) list[float]#

Gets the initial position of all of the walkers assuming a gaussian distribution centered at theta_init.

Parameters:
  • theta_init (list) – Initial location of the walkers

  • nwalkers (int) – Number of walkers

Returns:

A 2D array of the positions of all of the walkers

lnprior(theta, nu, F, upperlimits, **kwargs)#

Logarithmic prior function that can be changed based on the SED model.

lnprob(theta: list, **kwargs)#

Keep or throw away step likelihood and priors

Parameters:
  • theta (list) – location of the walker

  • **kwargs – Any other arguments to be past to lnprior or loglik

Returns:

The likelihood of the data at that location

loglik(theta, nu, F, F_error, upperlimits, **kwargs)#

Log Likelihood function

Parameters:
  • theta (list) – position of the walker

  • nu (list) – frequencies in GHz

  • F_muJy (list) – Fluxes in micro janskies

  • F_error (list) – Flux errors in micro janskies

  • p (float) – A p-value to pass to the model, only used if p-value is fixed

Returns:

The logarithmic likelihood of that theta position

classmethod override(func)#

This method should be used as a decorator to override other methods

pack_theta(theta, **kwargs)#

Pack theta into a dictionary

unpack_util(theta_init, nu, F_mJy, F_error, nwalkers, lum_dist=None, t=None, upperlimits=None)#

A wrapper on the utility functions.

Parameters:
  • theta_init (list) – List of initial theta locations

  • nu (list) – frequencies in GHz

  • F_mJy (list) – Fluxes in milli janskies

  • F_error (list) – Flux errors in milli janskies

  • p (float) – A p-value to pass to the model, only used if p-value is fixed

  • nwalkers (int) – THe number of walkers to use

class syncfit.models.B5B3(prior=None, p=None)#

Two-break model that uses both the self-absorption break and the cooling break. This model forces the cooling break to always be larger than the self-absorption break.

SED(nu, p, log_F_nu, log_nu_a, log_nu_c, **kwargs)#

Describes the SED model for the model that subclasses this BaseModel

dynesty_transform(theta, **kwargs)#

Transform the input values to the correct prior ranges for dynesty

static get_kwargs(nu: list, F_mJy: list, F_error: list, lum_dist: float = None, t: float = None, upperlimits: list = None) dict#

Packages up the args to be passed into the model based on the user input.

Parameters:
  • nu (list) – frequencies in GHz

  • F_mJy (list) – Fluxes in milli janskies

  • F_error (list) – Flux errors in milli janskies

  • p (float) – A p-value to pass to the model, only used if p-value is fixed

Returns:

Dictionary of values, converted for the modeling used in the mcmc

get_labels(*args, **kwargs)#

Describes a list of labels used in the return values of the mcmc chain. This varies depending on the inputs to the MCMC.

static get_pos(theta_init: list, nwalkers: int) list[float]#

Gets the initial position of all of the walkers assuming a gaussian distribution centered at theta_init.

Parameters:
  • theta_init (list) – Initial location of the walkers

  • nwalkers (int) – Number of walkers

Returns:

A 2D array of the positions of all of the walkers

lnprior(theta, nu, F, upperlimits, **kwargs)#

Logarithmic prior function that can be changed based on the SED model.

lnprob(theta: list, **kwargs)#

Keep or throw away step likelihood and priors

Parameters:
  • theta (list) – location of the walker

  • **kwargs – Any other arguments to be past to lnprior or loglik

Returns:

The likelihood of the data at that location

loglik(theta, nu, F, F_error, upperlimits, **kwargs)#

Log Likelihood function

Parameters:
  • theta (list) – position of the walker

  • nu (list) – frequencies in GHz

  • F_muJy (list) – Fluxes in micro janskies

  • F_error (list) – Flux errors in micro janskies

  • p (float) – A p-value to pass to the model, only used if p-value is fixed

Returns:

The logarithmic likelihood of that theta position

classmethod override(func)#

This method should be used as a decorator to override other methods

pack_theta(theta, **kwargs)#

Pack theta into a dictionary

unpack_util(theta_init, nu, F_mJy, F_error, nwalkers, lum_dist=None, t=None, upperlimits=None)#

A wrapper on the utility functions.

Parameters:
  • theta_init (list) – List of initial theta locations

  • nu (list) – frequencies in GHz

  • F_mJy (list) – Fluxes in milli janskies

  • F_error (list) – Flux errors in milli janskies

  • p (float) – A p-value to pass to the model, only used if p-value is fixed

  • nwalkers (int) – THe number of walkers to use

class syncfit.models.B1B2_B3B4_Weighted(prior=None, p=None)#

This is a specialized model that uses a weighted combination of the B1B2 model and the B3B4 model. The idea of this model is from XXXYXYXYX et al. (YYYY).

SED(nu, p, log_F_nu, log_nu_a, log_nu_m, **kwargs)#

Describes the SED model for the model that subclasses this BaseModel

dynesty_transform(theta, **kwargs)#

Transform the input values to the correct prior ranges for dynesty

static get_kwargs(nu: list, F_mJy: list, F_error: list, lum_dist: float = None, t: float = None, upperlimits: list = None) dict#

Packages up the args to be passed into the model based on the user input.

Parameters:
  • nu (list) – frequencies in GHz

  • F_mJy (list) – Fluxes in milli janskies

  • F_error (list) – Flux errors in milli janskies

  • p (float) – A p-value to pass to the model, only used if p-value is fixed

Returns:

Dictionary of values, converted for the modeling used in the mcmc

get_labels(*args, **kwargs)#

Describes a list of labels used in the return values of the mcmc chain. This varies depending on the inputs to the MCMC.

static get_pos(theta_init: list, nwalkers: int) list[float]#

Gets the initial position of all of the walkers assuming a gaussian distribution centered at theta_init.

Parameters:
  • theta_init (list) – Initial location of the walkers

  • nwalkers (int) – Number of walkers

Returns:

A 2D array of the positions of all of the walkers

lnprior(theta, nu, F, upperlimits, **kwargs)#

Logarithmic prior function that can be changed based on the SED model.

lnprob(theta: list, **kwargs)#

Keep or throw away step likelihood and priors

Parameters:
  • theta (list) – location of the walker

  • **kwargs – Any other arguments to be past to lnprior or loglik

Returns:

The likelihood of the data at that location

loglik(theta, nu, F, F_error, upperlimits, **kwargs)#

Log Likelihood function

Parameters:
  • theta (list) – position of the walker

  • nu (list) – frequencies in GHz

  • F_muJy (list) – Fluxes in micro janskies

  • F_error (list) – Flux errors in micro janskies

  • p (float) – A p-value to pass to the model, only used if p-value is fixed

Returns:

The logarithmic likelihood of that theta position

classmethod override(func)#

This method should be used as a decorator to override other methods

pack_theta(theta, **kwargs)#

Pack theta into a dictionary

unpack_util(theta_init, nu, F_mJy, F_error, nwalkers, lum_dist=None, t=None, upperlimits=None)#

A wrapper on the utility functions.

Parameters:
  • theta_init (list) – List of initial theta locations

  • nu (list) – frequencies in GHz

  • F_mJy (list) – Fluxes in milli janskies

  • F_error (list) – Flux errors in milli janskies

  • p (float) – A p-value to pass to the model, only used if p-value is fixed

  • nwalkers (int) – THe number of walkers to use

class syncfit.models.SyncfitModel(prior, p=None)#

An Abstract Base Class to define the basic methods that all syncfit models must contain. This will help maintain some level of standard for the models while also allowing users to customize their own.

abstractmethod SED(*args, **kwargs)#

Describes the SED model for the model that subclasses this BaseModel

dynesty_transform(theta, **kwargs)#

Transform the input values to the correct prior ranges for dynesty

static get_kwargs(nu: list, F_mJy: list, F_error: list, lum_dist: float = None, t: float = None, upperlimits: list = None) dict#

Packages up the args to be passed into the model based on the user input.

Parameters:
  • nu (list) – frequencies in GHz

  • F_mJy (list) – Fluxes in milli janskies

  • F_error (list) – Flux errors in milli janskies

  • p (float) – A p-value to pass to the model, only used if p-value is fixed

Returns:

Dictionary of values, converted for the modeling used in the mcmc

get_labels(*args, **kwargs)#

Describes a list of labels used in the return values of the mcmc chain. This varies depending on the inputs to the MCMC.

static get_pos(theta_init: list, nwalkers: int) list[float]#

Gets the initial position of all of the walkers assuming a gaussian distribution centered at theta_init.

Parameters:
  • theta_init (list) – Initial location of the walkers

  • nwalkers (int) – Number of walkers

Returns:

A 2D array of the positions of all of the walkers

lnprior(theta, nu, F, upperlimits, **kwargs)#

Logarithmic prior function that can be changed based on the SED model.

lnprob(theta: list, **kwargs)#

Keep or throw away step likelihood and priors

Parameters:
  • theta (list) – location of the walker

  • **kwargs – Any other arguments to be past to lnprior or loglik

Returns:

The likelihood of the data at that location

loglik(theta, nu, F, F_error, upperlimits, **kwargs)#

Log Likelihood function

Parameters:
  • theta (list) – position of the walker

  • nu (list) – frequencies in GHz

  • F_muJy (list) – Fluxes in micro janskies

  • F_error (list) – Flux errors in micro janskies

  • p (float) – A p-value to pass to the model, only used if p-value is fixed

Returns:

The logarithmic likelihood of that theta position

classmethod override(func)#

This method should be used as a decorator to override other methods

pack_theta(theta, **kwargs)#

Pack theta into a dictionary

unpack_util(theta_init, nu, F_mJy, F_error, nwalkers, lum_dist=None, t=None, upperlimits=None)#

A wrapper on the utility functions.

Parameters:
  • theta_init (list) – List of initial theta locations

  • nu (list) – frequencies in GHz

  • F_mJy (list) – Fluxes in milli janskies

  • F_error (list) – Flux errors in milli janskies

  • p (float) – A p-value to pass to the model, only used if p-value is fixed

  • nwalkers (int) – THe number of walkers to use

syncfit.analysis#

Some useful analysis functions

syncfit.analysis.util.extract_output(sampler, **kwargs)#

Extracts the flattened samples and log_prob from sampler

syncfit.analysis.util.get_bounds(sampler, labels, toprint=False, **kwargs)#

Extract the median, upper, and lower limits from the flat_samples chain

syncfit.analysis.util.get_ndim(sampler)#

Gets the number of dimensions from an Emcee sampler

Some useful plotting code from the outputs of the mcmc

syncfit.analysis.plotter.plot_best_fit(model, sampler, nu, F, Ferr, nkeep=1000, nu_arr=None, method='random', fig=None, ax=None, day=None, **kwargs)#

Plot best fit model

Parameters:
  • [syncfit.fitter.models] (model) – A module from syncfit.fitter.models used to fit the data

  • [emcee.EnsembleSampler] (sampler) – Emcee EnsembleSampler object after running the MCMC

  • [list] (nu_arr) – the observed frequencies

  • [list] – The observed flux densities

  • [list] – The observed flux error

  • [int] (nkeep) – Number of values to keep

  • [list] – List of nus for the best fit lines to be plot with

  • [str] (method) – Either ‘max’ or ‘last’ or ‘random’, default is max. - max: takes the nkeep maximum probability values - last: takes the last nkeep values from the chain - random: Chooses the nkeep values from the last nkeep*10 values in the chain

  • [matplotlib.pyplot.Figure] (fig) – Matplotlib Figure object, Default is None and one will be created.

  • [matplotlib.pyplot.Axis] (axes) – list of Matplotlib Axis object, Default is None and one will be created.

Returns:

matplotlib fig, ax

syncfit.analysis.plotter.plot_chains(sampler, labels, fig=None, axes=None)#

Plot the flattened chains

Parameters:
  • [emcee.EnsembleSampler] (sampler) – Emcee EnsembleSampler object after running the MCMC

  • [list[str]] (labels) – list of labels corresponding to the chains

  • [matplotlib.pyplot.Figure] (fig) – Matplotlib Figure object, Default is None and one will be created.

  • [matplotlib.pyplot.Axis] (axes) – list of Matplotlib Axis object, Default is None and one will be created.

Returns:

matplotlib fig, ax