def make_frac_plot(self): if self.shnum not in sh1exp: raise ValueError("you must know the expected value") if sh1exp[self.shnum] != 0: gfield='g1' gtrue=sh1exp[self.shnum] elif sh2exp[self.shnum] != 0: gfield='g2' gtrue=sh2exp[self.shnum] else: raise ValueError("all expected are listed as zero") bindata=self.bindata bin_field=self.bin_field plt=FramedPlot() plt.title=self.get_title() plt.xlog=True plt.xrange=[0.5*bindata[bin_field].min(), 1.5*bindata[bin_field].max()] plt.xlabel=bin_field ylabel=r'$\Delta \gamma/\gamma$' plt.ylabel = ylabel xdata=bindata[bin_field] zero=zeros(xdata.size) zero_plt=Curve(xdata, zero) plt.add(zero_plt) xfill=[xdata.min(), xdata.max()] plt.add( biggles.FillBetween(xfill, [0.004,0.004], xfill, [-0.004,-0.004], color='grey80')) gfrac = bindata[gfield]/gtrue-1 gfrac_err = bindata[gfield+'_err']/gtrue type='filled circle' color='blue' gpts = Points(xdata, gfrac, type=type, color=color) gerrpts = SymmetricErrorBarsY(xdata, gfrac, gfrac_err,color=color) plt.add( gpts, gerrpts ) self.plt=plt
def doplot(self, fitres, h, minmag, maxmag): tab=biggles.Table(2,1) plt=FramedPlot() plt.title='%s %.2f %.2f ' % (self.objtype, minmag, maxmag) plt.xlabel=r'$\sigma$' sprior=fitres.get_model() nrand=100000 binsize=self.binsize hplt=Histogram(h['hist'], x0=h['low'][0], binsize=binsize) hplt.label='data' srand=sprior.sample(nrand) hrand=histogram(srand, binsize=binsize, min=h['low'][0], max=h['high'][-1], more=True) hrand['hist'] = hrand['hist']*float(h['hist'].sum())/nrand hpltrand=Histogram(hrand['hist'], x0=hrand['low'][0], binsize=binsize, color='blue') hpltrand.label='rand' key=PlotKey(0.9,0.9,[hplt,hpltrand],halign='right') plt.add(hplt, hpltrand, key) tplt=fitres.plot_trials(show=False,fontsize_min=0.88888888) tab[0,0] = plt tab[1,0] = tplt if self.show: tab.show() d=files.get_prior_dir() d=os.path.join(d, 'plots') epsfile='pofs-%.2f-%.2f-%s.eps' % (minmag,maxmag,self.objtype) epsfile=os.path.join(d,epsfile) eu.ostools.makedirs_fromfile(epsfile) print epsfile tab.write_eps(epsfile) os.system('converter -d 100 %s' % epsfile) return tab