diff --git a/examples/xspec/bayesian-workflow/plot_bxa.py b/examples/xspec/bayesian-workflow/plot_bxa.py index 2ea398e..44f3a0c 100644 --- a/examples/xspec/bayesian-workflow/plot_bxa.py +++ b/examples/xspec/bayesian-workflow/plot_bxa.py @@ -1528,6 +1528,7 @@ def _plot_posterior_statistic(self,solvers, # loop over the models and create a predictive plot for each if type(axs) is not np.ndarray: axs = (axs,) + self.posterior_flux_unc = [] # define for first use or clear for new use for ii,s in enumerate(solvers): # re-activate model and point solver to new instance if models is not None: @@ -1536,7 +1537,6 @@ def _plot_posterior_statistic(self,solvers, else: mname = None if stat == 'flux': - self.posterior_flux_unc = [] # define for first use or clear for new use # plot the flux distributions based on the posteriors self._posterior_flux_single_model(axs[ii],s, npost=nsample, @@ -1595,7 +1595,7 @@ def _posterior_flux_single_model(self,ax,solver, for row in solver.posterior[:npost]: bxa.solver.set_parameters(values=row,transformations=solver.transformations) xspec.AllModels.calcFlux(frange) - d += [xspec.AllData(1).flux[0]*1e12] # in units of 10^12 erg cm^-2 s^-1 + d += [xspec.AllData(1).flux[0]*1e12] # in units of 10^-12 erg cm^-2 s^-1 # plot the data c,b = np.histogram(d,bins=np.minimum(int(len(d)/10),20), density=True) @@ -1616,13 +1616,13 @@ def _posterior_flux_single_model(self,ax,solver, mname = solver.transformations[1]['model'].expression if printq: print(f'For model {mname}:') - print(f'Mean={np.mean(d):.3f} (+){q_high:.3f} (-){q_low:.3f} (10^12 erg cm^-2 s^-1)') + print(f'Mean={np.mean(d):.3f} (+){q_high:.3f} (-){q_low:.3f} (10^-12 erg cm^-2 s^-1)') print(f'With uncertainties estimated for +/- {q*100:.1f}%\n') self.posterior_flux_unc += [[mname,fluxrange,np.mean(d),q_high,q_low]] # plot details lblkw = dict( (('fontsize',20),('fontweight','bold')) ) rngstr = f'Flux {fluxrange[0]:.1f}-{fluxrange[1]:.1f} keV' - unitstr = r' ($10^{12}$ erg cm$^{-2}$ s$^{-1}$)' + unitstr = r' ($10^{-12}$ erg cm$^{-2}$ s$^{-1}$)' ax.set_xlabel(rngstr+unitstr,**lblkw) ax.set_ylabel('Probability Density',**lblkw) ax.set_ylim(yl) @@ -2001,7 +2001,7 @@ def _plot_bayes_factor_test(self, return if mnames is None: print('If loading existing data, please specify the model names') - return + return (None,None) m1name,m2name = mnames logz1, logz2 = [], [] fitd1, fitd2 = [], [] diff --git a/examples/xspec/bayesian-workflow/plot_xspec.py b/examples/xspec/bayesian-workflow/plot_xspec.py index abfd7d5..91422ec 100644 --- a/examples/xspec/bayesian-workflow/plot_xspec.py +++ b/examples/xspec/bayesian-workflow/plot_xspec.py @@ -106,7 +106,7 @@ def _get_xspec_data(self,model=True,plottype='folded', maxBins=rebinbnum, groupNum=-1) else: - xspec.Plot.setRebin(minSig=0,maxBins=-1,groupNum=-1) + xspec.Plot.setRebin(minSig=0,maxBins=1,groupNum=-1) if plottype == 'folded': plttype = 'data' elif plottype == 'counts':