def plot_tri(self, ind=None, npar=8, *args, **kwargs): if ind is None: ind = np.arange(0, self.ndim) ind = np.atleast_1d(ind) nplots = int(np.ceil(len(ind) / npar)) plt.rcParams['font.size'] = 8 start = 0 for ii in range(nplots): ax = bu.triplot(self.chain[:,ind[start:npar+start]], interpolate=True, labels=list(self.pars[ind[start:npar+start]]), tex=False, figsize=(24,18), *args, **kwargs) start += npar if self.save: plt.savefig(self.outdir + '/tri_{0}.png'.format(ii), dpi=300, bbox_inches='tight')
def plot_tri(self, ind=None, npar=8, *args, **kwargs): if ind is None: ind = np.arange(0, self.ndim) ind = np.atleast_1d(ind) nplots = int(np.ceil(len(ind) / npar)) plt.rcParams["font.size"] = 8 start = 0 for ii in range(nplots): ax = bu.triplot( self.chain[:, ind[start : npar + start]], interpolate=True, labels=list(self.pars[ind[start : npar + start]]), tex=False, figsize=(24, 18), *args, **kwargs ) start += npar if self.save: plt.savefig(self.outdir + "/tri_{0}.png".format(ii), dpi=300, bbox_inches="tight")
# number of iterations and number of effective samples N = 100000 neff = 1000 # set up covariance matrix for jumps cov = model.initJumpCovariance() # define MCMC sampler sampler = PALInferencePTMCMC.PTSampler(len(p0), loglike, logprior, cov, outDir=args.outdir, loglkwargs=loglkwargs, groups=ind) # add in prior draws for red noise sampler.addProposalToCycle(model.drawFromRedNoisePrior, 5) # sample sampler.sample(p0, N, covUpdate=1000, AMweight=15, SCAMweight=30, DEweight=50, neff=neff, KDEweight=0) # read in chain chain = np.loadtxt(args.outdir + '/chain_1.txt') burn = int(0.25 * chain.shape[0]) pars = np.loadtxt(args.outdir + '/pars.txt', dtype='S42') # make triangle plot ax = bu.triplot(chain[burn:,-9:-4], labels=list(pars[-5:]), tex=False) plt.savefig(args.outdir + '/bwm_triplot.png', bbox_inches='tight')
print 'ploting for ' + this_group mask = [] for ii, this_param in enumerate(params): if this_group in this_param: mask.append(ii) this_names = [params[ii] for ii in mask] this_chain = np.array([chain_burned[:, ii] for ii in mask]) print this_names # plot triangle plot for parameter group size = np.array([4, 3]) * min(len(this_names) / 2., 5) title = this_PSR + ' -- ' + this_group plt.rcParams['font.size'] = 6 ax = bu.triplot(this_chain.T, labels=this_names[:], title=title, tex=False, figsize=tuple(size)) plt.savefig(plotsdir + '/' + this_group + '_tri.pdf') # finish with other params (red noise) print 'ploting for all others' mask = [] for ii, this_param in enumerate(params): isin = False for this_group in groups: if this_group in this_param: isin = True break if not isin: mask.append(ii)