Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if priors is not None:
# Creates the priors from dave_priors
as_priors = ModelHelper.get_astropy_priors(priors)
if len(as_priors.keys()) > 0:
# If there are priors then is a Bayesian Parameters Estimation
max_post=True
fitmethod="BFGS"
else:
as_priors=None
logging.warn("fit_power_density_spectrum: can't create priors from dave_priors.")
if as_priors:
# Creates a Posterior object with the priors
lpost = PSDPosterior(pds.freq, pds.power, fit_model, priors=as_priors, m=pds.m)
else:
# Creates the Maximum Likelihood object for fitting
lpost = PSDLogLikelihood(pds.freq, pds.power, fit_model, m=pds.m)
# Creates the PSD Parameters Estimation object and runs the fitting
parest = PSDParEst(pds, fitmethod=fitmethod, max_post=max_post)
res = parest.fit(lpost, starting_pars, neg=True)
sample = None
if as_priors and sampling_params is not None:
# If is a Bayesian Par. Est. and has sampling parameters
# then sample the posterior distribution defined in `lpost` using MCMC
sample = parest.sample(lpost, res.p_opt, cov=res.cov,
nwalkers=sampling_params["nwalkers"],
niter=sampling_params["niter"],
burnin=sampling_params["burnin"],