示例#1
0
文件: wasy.py 项目: Jeff182/CJ
    def make_plot(self):
        AX = self.AX
        for k in AX.keys():
            p21, p3 = self.plot_dataset(k)
            AX[k].set_xlabel(r"$y$", size=20)
            AX[k].set_ylabel(tex(k.replace("_", "")), size=20)

        ax = AX["cdfLasy05"]
        ax.legend([p21, p3], [tex("CJ15"), tex("data")], frameon=0, loc=3, fontsize=20, numpoints=1)

        # ax.text(0.5,0.8,tex('nrep=%d'%nrows),transform=ax.transAxes,size=20)
        py.savefig("gallery/wasy.pdf")
        py.close()
示例#2
0
文件: wasy_NS.py 项目: Jeff182/CJ
  def make_plot(self):
    AX=self.AX
    for k in AX.keys():    
      p21,p3=self.plot_dataset(k)
      AX[k].set_xlabel(r'$y$',size=20)
      AX[k].set_ylabel(tex(k.replace('_','')),size=20)

    ax=AX['cdfLasy05']
    ax.legend([p21,p3],[tex('CJ15'),tex('data')]\
      ,frameon=0,loc=3,fontsize=20,numpoints=1)

    
    #ax.text(0.5,0.8,tex('nrep=%d'%nrows),transform=ax.transAxes,size=20)
    py.savefig('gallery/wasy.pdf')
    py.close()
示例#3
0
文件: db_ub.py 项目: Jeff182/CJ
def main():

    T = 10
    Q2 = 100
    X = np.linspace(1e-3, 0.4)

    CJ = COMPOSER(name="CJ15_NLO_KP_AV18")
    d = CJ.get_xpdf("db-ub", X=X, Q2=Q2)

    ax = py.subplot(111)
    p1, = ax.plot(X, d["xf0"] / X, color="r", ls="-")
    p2 = fill_between(
        X,
        (d["xf0"] - d["dxf-"] * T) / X,
        (d["xf0"] + d["dxf+"] * T) / X,
        ax=ax,
        facecolor="r",
        edgecolor="none",
        alpha=0.5,
    )

    H = [(p2, p1)]
    L = [tex("CJ15") + "\ $(T=%d)$" % T]
    ax.legend(H, L, loc=1, frameon=0, fontsize=20)
    ax.set_ylim(-0.2, 1.2)
    ax.axhline(0, ls="--", color="k", alpha=0.5)

    py.savefig("gallery/db_ub.pdf")
示例#4
0
文件: F2d_F2.py 项目: Jeff182/CJ
  def make_plotI(self):
    # retrieve data
    D=self.D

    kmap={}
    kmap['AV18']   = {'c':'r','ls':'-'}
    kmap['CDBONN'] = {'c':'g','ls':'--'}
    kmap['WJC1']   = {'c':'k','ls':'-.'}
    kmap['WJC2']   = {'c':'b','ls':':'}

    ax=py.subplot(111)
    for k in ['AV18','CDBONN','WJC1','WJC2']:
      DF=D[k]
      DF=DF[DF.Q2==10]
      if k=='CDBONN':
        label='CDBonn'
      else:
        label=k
      cls=kmap[k]['c']+kmap[k]['ls']
      ax.plot(DF.X,DF.THEORY,cls,lw=2.0,label=tex(label))

    ax.set_xlabel('$x$',size=25)
    ax.set_ylabel(r'$F_2^d\, /\, F_2^N$',size=25)
    ax.set_ylim(0.97,1.08)
    ax.axhline(1,color='k',ls='-',alpha=0.2)

    ax.legend(frameon=0,loc=2,fontsize=22)
    py.tick_params(axis='both',labelsize=22)
    py.tight_layout()
    py.savefig('gallery/F2d_F2_I.pdf')
    py.close()
示例#5
0
文件: Lasy.py 项目: Jeff182/CJ
  def make_plot(self):
    D=self.D
    ax=py.subplot(111)

    Y=D['d0Lasy_e15']['Y']
    T=D['d0Lasy_e15']['THEORY']
    ET=D['d0Lasy_e15']['ERROR']

    iT= interp1d(Y,T,kind='cubic')
    iET= interp1d(Y,ET, kind='cubic')
    Y=np.linspace(np.amin(Y),np.amax(Y),100)

    T=10
    p2=fill_between(Y,iT(Y)-iET(Y)*T,iT(Y)+iET(Y)*T,
      ax=ax,
      facecolor='yellow',
      edgecolor='yellow')
    p1,=ax.plot(Y,iT(Y),'r-')
    H=[(p2,p1)]
    L=[tex('CJ15')]

    dmap={}
    dmap['cdfLasy05']  = {'color':'g','marker':'d'}
    dmap['d0Lasy_e15'] = {'color':'b','marker':'o'}
    dmap['d0Lasy13']   = {'color':'c','marker':'^'}

    for k in D.keys():
      color=dmap[k]['color']
      marker=dmap[k]['marker']
      markersize=4
      p3=ax.errorbar(D[k]['Y'],D[k]['DATA'],\
        yerr=D[k]['DERROR'],fmt=color+marker,mfc=color,mec=color,\
        markersize=markersize,zorder=1,alpha=0.9)
      H.append(p3)
      #L.append(tex(k.replace('_','')))
      L=[tex('CJ15'),tex('CDF')+r'$\ e$',tex('D\O')+r'$\ \mu$',tex('D\O')+r'$\ e$']

    ax.set_xlabel(r'$\eta_{\ell}$',size=25)
    ax.set_ylabel(r'$A_{\ell}$',size=25)

    ax.legend(H,L,frameon=0,loc=3,fontsize=22,numpoints=1)
   
    ###ax.text(0.5,0.8,tex('nrep=%d'%nrows),transform=ax.transAxes,size=20)
    py.tick_params(axis='both',labelsize=20)
    py.tight_layout()
    py.savefig('gallery/Lasy.pdf')
    py.close()
示例#6
0
文件: advanced.py 项目: Jeff182/CJ
print u.keys()


# these lines add latex typefont.
# is kind of slow, so uncomment while a plot is been coded
#from matplotlib import rc
#rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})
#rc('text', usetex=True)  

# create matplotlib instance
ax=py.subplot(111)

# plot error band
T=10.0
UP=u['f0']+T*u['df+']
DO=u['f0']-T*u['df-']
fill_between(X,DO,UP,ax=ax,label=tex('u'),facecolor='r',edgecolor='r',alpha=0.5,hatch=None)

# plot central
ax.plot(X,u['f0'],'r-',label=tex('u'))

# makeup
ax.legend(loc=3,frameon=0,fontsize=20)
ax.semilogx()
ax.set_xlabel(tex('x'),size=20)
ax.set_ylabel(tex('xPDF(x)'),size=20)
py.tight_layout()
py.savefig('plots/advanced.pdf')


示例#7
0
文件: d_over_u.py 项目: Jeff182/CJ
def main():

  T=10
  Q2=10.0
  ax=py.subplot(111)

  f1='ddat_D.pdf'
  f2='ddat_D_BNS.pdf'
  f3='ddat_D_BNS_Zrap.pdf'
  f4='ddat_D_BNS_Zrap_Lasy.pdf'
  f5='ddat_D_BNS_Zrap_Lasy_WCDF.pdf'
  f6='ddat_D_BNS_Zrap_Lasy_Wasy.pdf'
  g1='ddat_nonuk_D.pdf'
  g2='ddat_nonuk_D_BNS.pdf'
  g3='ddat_nonuk_D_BNS_Zrap.pdf'
  g4='ddat_nonuk_D_BNS_Zrap_Lasy.pdf'
  g5='ddat_nonuk_D_BNS_Zrap_Lasy_WCDF.pdf'
  g6='ddat_nonuk_D_BNS_Zrap_Lasy_Wasy.pdf'
  h1='ddat_noD.pdf'

# plot d/u fig. 1
  pf1=plot(f1,ax,Q2,T,color='y',hatch=None,edgecolor='y',alpha=1.0)
  pf2=plot(f2,ax,Q2,T,color='g',hatch=None,edgecolor='g',alpha=1.0)
  pf4=plot(f4,ax,Q2,T,color='b',hatch=None,edgecolor='b',alpha=1.0)
  pf6=plot(f6,ax,Q2,T,color='r',hatch=None,edgecolor='r',alpha=1.0)

# plot d/u fig. 2
  #pg6=plot(g6,ax,Q2,T,color='y',hatch='...',edgecolor='y',alpha=0.7)
  #ph1=plot(h1,ax,Q2,T,color='g',hatch=None,edgecolor='g',alpha=0.5)
  #pf6=plot(f6,ax,Q2,T,color='r',hatch=None,edgecolor='r',alpha=0.7)

# plot d/u fig. ?
  #pf1=plot(g1,ax,Q2,T,color='y',hatch=None,edgecolor='y',alpha=0.5)
  #pf2=plot(g2,ax,Q2,T,color='g',hatch=None,edgecolor='g',alpha=0.5)
  #pf3=plot(g3,ax,Q2,T,color='m',hatch=None,edgecolor='m',alpha=1.0)
  #pf4=plot(g4,ax,Q2,T,color='b',hatch=None,edgecolor='b',alpha=1.0)
  #pf5=plot(g5,ax,Q2,T,color='k',hatch=None,edgecolor='k',alpha=1.0)
  #pf6=plot(g6,ax,Q2,T,color='r',hatch=None,edgecolor='r',alpha=1.0)


  H,L=[],[]
# legend fig. 1
  H.append(pf1);L.append(tex('DIS\ only'))
  H.append(pf2);L.append(tex('+\ BONuS'))
  H.append(pf4);L.append(r'$+\ \ell\ {\rm asym}\ (\&\ Z\ {\rm rap})$')
  H.append(pf6);L.append(r'$+\ W\ {\rm asym}$')

# legend fig. 2
  #H.append(pg6);L.append(tex('no\ nuclear'))
  #H.append(ph1);L.append(tex('no\ deuteron'))
  #H.append(pf6);L.append(tex('CJ15'))

# legend fig. ?
  #H.append(pf1);L.append(tex('DIS\ only'))
  #H.append(pf2);L.append(tex('+\ BONuS'))
  #H.append(pf3);L.append(r'$+\ Z\ {\rm rap})$')
  #H.append(pf4);L.append(r'$+\ \ell\ {\rm asym}$')
  #H.append(pf5);L.append(r'$+\ W\ {\rm CDF}$')
  #H.append(pf6);L.append(r'$+\ W\ {\rm asym}$')

  ax.legend(H,L,loc=1,frameon=0,fontsize=20,bbox_to_anchor=(0.95,1))
  ax.set_ylim(0.0,1.0)
  ax.set_xlim(0.0,0.95)
  ax.set_xlabel('$x$',size=25)
  ax.set_ylabel('$d/u$',size=25)
  py.tick_params(axis='both',labelsize=20)
  py.savefig('gallery/du1.pdf')
示例#8
0
文件: F2p.py 项目: Jeff182/CJ
  def make_F2_plot(self):
    D=self.D
    xbins=self.get_xbins()
    py.figure(figsize=(15,15))

    gs = gridspec.GridSpec(1,1)
    gs.update(left=0.1,right=0.98,top=0.98,bottom=0.1)
    ax=py.subplot(gs[0,0])

    for k in self.ordered_keys:
      dbinned=D[k]['dbinned']
      color=D[k]['color']
      sym=D[k]['symbol']
      flag=False
      for i in range(len(xbins)):
        dbin=dbinned[i]
        if dbin['X'].size!=0:
          if flag==False:
            ax.errorbar(dbin['Q2'],dbin['F2']*2**(i+1)\
              ,yerr=dbin['ERR'].values\
              ,fmt=color+sym\
              ,mec=color
              ,label=tex(D[k]['label']))
            flag=True
          else:
            ax.errorbar(dbin['Q2'],dbin['F2']*2**(i+1)\
              ,yerr=dbin['ERR'].values\
              ,fmt=color+sym\
              ,mec=color)

    for i in range(len(xbins)):
      Q2=1
      for k in D.keys():
        dbin=D[k]['dbinned'][i]
        if dbin['X'].size==0:continue
        imax=np.argmax(dbin['Q2'].values)
        if dbin['Q2'].values[imax]>Q2: 
          Q2=dbin['Q2'].values[imax]
          F2=dbin['F2'].values[imax]

      if any([i==k for k in [10,34,37,39,41,44,49,47,43,35,32,30,28,26,45,46]])!=True:
	if i>30:
          text='$x=%0.1e$'%(np.mean([xbins[i][0],xbins[i][1]]))
	  exp=int(text.split('-')[1].replace('$',''))
	  text=text.split('e')[0]+'e'
          text=text.replace('e',r'\times 10^{-%d}'%exp)+'\ (i=%d)$'%i
	elif i<16:
	  text='$x=%0.2f'%(np.mean([xbins[i][0],xbins[i][1]]))+'\ (i=%d)$'%i
	else:
	  text='$x=%0.3f'%(np.mean([xbins[i][0],xbins[i][1]]))+'\ (i=%d)$'%i

        ax.text(Q2*1.2,F2*2**(i+1),text)
        #ax.text(Q2*1.2,F2*2**(i+1),text+str(i))

    ax.legend(frameon=0,fontsize=20,numpoints=1)

    ax.set_xlim(8e-5,3e5)
    ax.set_ylim(1e-3,2e13)
    ax.semilogy()
    ax.semilogx()
    ax.set_xticks([1e-1,1,1e1,1e2,1e3,1e4,1e5])
    #ax.set_ylabel(tex('F_2')+'$(x,Q^2)$',size=30)
    ax.set_ylabel('$F_2^p(x,Q^2)\ * 2^{\ i}$',size=30)
    ax.set_xlabel('$Q^2$'+tex('\ (GeV^2)'),size=30)
    py.tick_params(axis='both',labelsize=20)

    xsq=0.45
    ysq=0.07
    ax.add_patch(patches.Rectangle((xsq,ysq),0.1,0.15\
      ,fill=False,transform=ax.transAxes))
    ax.plot([0.36,xsq],[0.07,ysq],'k:'
      ,transform=ax.transAxes)
    ax.plot([0.36,xsq],[0.47,ysq+0.15],'k:'
      ,transform=ax.transAxes)


    rect1 = [0.06,0.07,0.3,0.3]
    ax1 = self.add_subplot_axes(ax,rect1)
    rect2 = [0.06,0.47,0.3,0.3]
    ax2 = self.add_subplot_axes(ax,rect2)

    for k in D.keys():
      if 'JLab' not in k: continue
      d=D[k]['DF']
      color=D[k]['color']
      sym=D[k]['symbol']

      ax1.errorbar(d['Q2'],d['F2']\
        ,yerr=d['ERR'].values\
        ,fmt=color+sym\
        ,mec=color)

      ax2.errorbar(d['X'],d['F2']\
        ,yerr=d['ERR'].values\
        ,fmt=color+sym\
        ,mec=color)

    ax1.locator_params(nbins=5) 
    ax2.locator_params(nbins=5) 

    ax1.tick_params(axis='both',labelsize=12)
    ax2.tick_params(axis='both',labelsize=12)

    ax1.set_xlabel(r'$Q^2$'+tex('\ (GeV^2)'),size=20)
    ax2.set_xlabel(r'$x$',size=20)
    ax1.set_ylim(1e-3,0.25)
    ax2.set_ylim(1e-3,0.25)
    ax1.semilogy()
    ax2.semilogy()
    #py.tight_layout()
    py.savefig('gallery/F2p.pdf')
示例#9
0
文件: simple.py 项目: Jeff182/CJ
      #args['central color']='r'
      #args['central line style']='-'
      #args['band color']='#FFFF00'
      #args['label']=tex(grp)
      #CJ_Legend = plot_band(args)
      p1,=ax.plot(X,central,'r-')
      p2=fill_between(X,central-error,central+error,ax=ax,
        facecolor='#FFFF00',
        edgecolor='#FFFF00',
        alpha=1.0,hatch=None)

    else:
      X=np.linspace(1e-3,0.9,1000)
      grp_=grpmap[grp]['grp']
      col=grpmap[grp]['color']
      ax.plot(X,[get_pdfs(flav,x,Q2,iset,grp_) for x in X],col,label=tex(grp))

  # make legend
  if flav=='g':  
    H_,L_ = ax.get_legend_handles_labels()
    H=[(p2,p1)]
    L=[tex('CJ15')]
    for h in H_: H.append(h)
    for l in L_: L.append(l)
    ax.legend(H,L,loc=1,frameon=0,fontsize=15)

  # setup axis
  ax.semilogx()
  ax.set_xlim(1e-3,1.0)
  ax.set_ylim(ymap[flav]['min'],ymap[flav]['max'])
  if flav!='s' and flav!='g': ax.set_xticks([])
示例#10
0
文件: ratio.py 项目: Jeff182/CJ
def ratio():

  ###############################
  # plot geometry
  ###############################
  # set gloabl figure dimensions
  nrows=3
  ncols=2
  py.figure(figsize=(ncols*4,nrows*3))

  # construct LR AXs for each flav 
  AX={}

  # left side LR panels
  gs = gridspec.GridSpec(nrows,ncols)
  gs.update(left=0.1,right=0.48,wspace=0,hspace=0.3,\
    top=0.98,bottom=0.05)
  AX['u'] =get_LR(gs[0,0],gs[0,1])
  AX['ub']=get_LR(gs[1,0],gs[1,1])
  AX['s'] =get_LR(gs[2,0],gs[2,1])

  # right side LR panels
  gs = gridspec.GridSpec(nrows,ncols)
  gs.update(left=0.58,right=0.98,wspace=0,hspace=0.3,\
    top=0.98,bottom=0.05)
  AX['d'] =get_LR(gs[0,0],gs[0,1])
  AX['db']=get_LR(gs[1,0],gs[1,1])
  AX['g'] =get_LR(gs[2,0],gs[2,1])

  
  ###############################
  # plot content 
  ###############################
  # initialize composer for each pdf set
  CJ=COMPOSER('CJ15_NLO_KP_AV18')
  HERA15=COMPOSER('HERAPDF15NLO_EIG')
  MMHT14=COMPOSER('MMHT2014nlo68cl')
  NNPDF=COMPOSER4NNPDF('NNPDF30_nlo_as_0118')
  #CT10=COMPOSER('CT10nlo')
  
  Q2=10
  for flav in ['u','d','ub','db','s','g']:
    print 'plotting '+flav

    # the output of plot used to construct specialized 
    # legend marker
    p1=plotI(AX,Q2,CJ,CJ,flav,'yellow','-',T=10,\
      hatch=None,alpha=0.4,facecolor='yellow',edgecolor='yellow')
    p2=plotI(AX,Q2,CJ,CJ,flav,'r','-',T=1,\
      hatch=None,alpha=1.0,facecolor='r',edgecolor='none')
    p3=plotI(AX,Q2,CJ,MMHT14,flav,'b','-',T=1,\
      hatch='...',alpha=0.4,facecolor='none',edgecolor='b')
    p4=plotI(AX,Q2,CJ,HERA15,flav,'g','-',T=1,\
      hatch='...',alpha=0.4,facecolor='none',edgecolor='g')
    p5=plotI(AX,Q2,CJ,NNPDF,flav,'m','-',T=1,\
      hatch='...',alpha=0.4,facecolor='none',edgecolor='m')
    #p5=plotI(AX,Q2,CJ,CT10,flav,'k','-',T=1,\
    #  hatch='\\',alpha=0.4,facecolor='none',edgecolor='k')
  

# print single PDF as a function of x (grafted onto ratio.py code)
    if flav=='db':
      X=np.linspace(0.01,1.0,100)    
      mm=MMHT14.get_xpdf(flav,X=X,Q2=4.0)
      t=1
      for i in range(X.size):
        l='%0.2f %0.2e %0.2e %0.2e'       
        print l%(X[i],X[i]*mm['xf0'][i],X[i]*mm['dxf-'][i]*t,X[i]*mm['dxf+'][i]*t)
        #l='%0.2f %0.2e %0.2e'
        #print l%(X[i],X[i]*mm['xf0'][i],X[i]*mm['dxf'][i]*t)
      ax=py.subplot(111)
      ax.plot(X,X*mm['xf0'],'r-')
      ax.plot(X,X*mm['xf0']-X*mm['dxf-']*t,'r:')
      ax.plot(X,X*mm['xf0']+X*mm['dxf+']*t,'r:')
      #ax.plot(X,X*mm['xf0']-mm['dxf']*t,'r:')
      #ax.plot(X,X*mm['xf0']+mm['dxf']*t,'r:') 
      py.show()
      sys.exit()



    #retrieve LR ax for further proccesing 
    axL,axR=AX[flav]

    # plot specialized legend marker at the specific flav panel
    if flav=='d':
      H=[p1,p2,p3,p4,p5]
      L=[tex('CJ15')+'\ ($T=10$)'\
        ,tex('CJ15')+'\ ($T=1$)'\
        ,tex('MMHT14')\
        ,tex('HERA15')\
        ,tex('NNPDF3.0')]
      #  ,tex('CT10')]
      axR.legend(H,L,frameon=0,fontsize=11,\
        bbox_to_anchor=(0.05, 1.0))
    if flav=='u':
      axR.text(0.1,0.85,'$Q^2=%0.0f$'%(Q2)+tex('~GeV^2'),\
        transform=axL.transAxes,size=15)

    # plot some text at specific flav panel
    #if flav=='d':
    #  axL.text(0.06,0.1,'$T=10$',transform=axL.transAxes,size=20)

    # set ylims
    if flav=='u':
      ymin,ymax=0.795,1.205
    if flav=='d':
      ymin,ymax=0.6,1.7
    if flav=='s':
      ymin,ymax=0.6,1.9
    if flav=='g' or flav=='ub' or flav=='db':
      ymin,ymax=0.7,1.3
    #axL.set_yticks(np.arange(0.2,2.0,0.4))
    axL.set_ylim(ymin,ymax)
    axR.set_ylim(ymin,ymax)

    # set x axis
    axL.semilogx()
    axL.set_xticks(10**np.linspace(-4,-2,3))
    if flav=='u' or flav=='d':
      axR.set_xticks(np.arange(0.1,1.1,0.2))
      axR.set_xlim(0.1,0.95)
    else:
      axR.set_xticks(np.arange(0.1,0.4,0.1))
      axR.set_xlim(0.1,0.4)

    # set labels
    if flav=='db': _flav=r'\bar{d}'
    elif flav=='ub': _flav=r'\bar{u}'
    else: _flav=flav
    axL.set_ylabel(r'$%s/%s$\large$_{\rm CJ15}$'%(_flav,_flav),size=20)
    axL.set_xlabel('$x$',size=20)
    axL.xaxis.set_label_coords(1.0,-0.08,transform=axL.transAxes)

  py.savefig('gallery/ratio.pdf')
示例#11
0
文件: F2p.py 项目: Jeff182/CJ
  def make_F2_plot(self):
    D=self.D
    xbins=self.get_xbins()
    py.figure(figsize=(15,15))

    gs = gridspec.GridSpec(1,1)
    gs.update(left=0.1,right=0.98,top=0.98,bottom=0.1)
    ax=py.subplot(gs[0,0])

    for k in self.ordered_keys:
      dbinned=D[k]['dbinned']
      color=D[k]['color']
      sym=D[k]['symbol']
      markersize=10
      if k=='SLAC p': markersize=8
      if k=='BCDMS p': markersize=5
      flag=False
      for i in range(len(xbins)):
        dbin=dbinned[i]
        if dbin['X'].size!=0:
          if flag==False:
            ax.errorbar(dbin['Q2'],dbin['F2']*2**(i+1)\
              ,yerr=dbin['ERR'].values*2**(i+1)\
              ,fmt=color+sym\
              ,mec=color\
              #,mfc='none'\
              ,markersize=markersize\
              ,label=tex(D[k]['label']))
            flag=True
          else:
            ax.errorbar(dbin['Q2'],dbin['F2']*2**(i+1)\
              ,yerr=dbin['ERR'].values*2**(i+1)\
              ,fmt=color+sym\
              #,mfc='none'\
              ,markersize=markersize\
              ,mec=color)

    for i in range(len(xbins)):
      Q2=1
      for k in D.keys():
        dbin=D[k]['dbinned'][i]
        if dbin['X'].size==0:continue
        imax=np.argmax(dbin['Q2'].values)
        if dbin['Q2'].values[imax]>Q2: 
          Q2=dbin['Q2'].values[imax]
          F2=dbin['F2'].values[imax]

      #if any([i==k for k in [5,8,10,13,17,21,23,26,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,49]])!=True:
      if i<21:
        if i!=20 and i!=0:
	  if i>15:
	    text='$x=%0.3f$'%(np.mean([xbins[i][0],xbins[i][1]]))
	  else:
	    text='$x=%0.2f$'%(np.mean([xbins[i][0],xbins[i][1]]))
        elif i==0:
	  text='$x=%0.2f'%(np.mean([xbins[i][0],xbins[i][1]]))+'\ (i=%d)$'%i
        elif i==20:
	  text='$x=%0.3f'%(np.mean([xbins[i][0],xbins[i][1]]))+'\ (i=%d)$'%i
          
        ax.text(Q2*1.2,F2*2**(i+1),text,size=20)
        #ax.text(Q2*1.2,F2*2**(i+1),text+str(i))

    ax.legend(frameon=0,fontsize=30,numpoints=1,bbox_to_anchor=(0.96,0.98))

    ax.set_xlim(1.4e0,5e2)
    ax.set_ylim(2e-3,2e6)
    ax.semilogy()
    ax.semilogx()
    ax.set_xticks([2e0,5e0,1e1,2e1,5e1,1e2,2e2,5e2])
    xticklabels=[2e0,5e0,1e1,2e1,5e1,1e2,2e2,5e2]
    ax.set_xticklabels(['$%0.0f$'%x for x in xticklabels])
    #ax.set_ylabel(tex('F_2')+'$(x,Q^2)$',size=30)
    #ax.set_ylabel('$F_2^p(x,Q^2)$'+r'$\, \times\, 2^{\, i}$',size=30)
    ax.set_ylabel('$F_2^p$'+r'$\, \times\, 2^{\, i}$',size=30)
    ax.set_xlabel('$Q^2$'+tex('\ (GeV^2)'),size=30)
    ax.tick_params(axis='both',labelsize=25)

    #xsq=0.45
    #ysq=0.07
    #ax.add_patch(patches.Rectangle((xsq,ysq),0.1,0.15\
    #  ,fill=False,transform=ax.transAxes))
    #ax.plot([0.36,xsq],[0.07,ysq],'k:'
    #  ,transform=ax.transAxes)
    #ax.plot([0.36,xsq],[0.47,ysq+0.15],'k:'
    #  ,transform=ax.transAxes)


    #rect1 = [0.06,0.07,0.3,0.3]
    #ax1 = self.add_subplot_axes(ax,rect1)
    #rect2 = [0.06,0.47,0.3,0.3]
    #ax2 = self.add_subplot_axes(ax,rect2)

    #for k in D.keys():
      #if 'JLab' not in k: continue
      #d=D[k]['DF']
      #color=D[k]['color']
      #sym=D[k]['symbol']

      #ax1.errorbar(d['Q2'],d['F2']\
      #  ,yerr=d['ERR'].values\
      #  ,fmt=color+sym\
      #  ,mec=color)

      #ax2.errorbar(d['X'],d['F2']\
      #  ,yerr=d['ERR'].values\
      #  ,fmt=color+sym\
      #  ,mec=color)

    #ax1.locator_params(nbins=5) 
    #ax2.locator_params(nbins=5) 

    #ax1.tick_params(axis='both',labelsize=12)
    #ax2.tick_params(axis='both',labelsize=12)

    #ax1.set_xlabel(r'$Q^2$'+tex('\ (GeV^2)'),size=20)
    #ax2.set_xlabel(r'$x$',size=20)
    #ax1.set_ylim(1e-3,0.25)
    #ax2.set_ylim(1e-3,0.25)
    #ax1.semilogy()
    #ax2.semilogy()
    #py.tight_layout()
    py.savefig('gallery/F2p.pdf')
示例#12
0
文件: xpdf.py 项目: Jeff182/CJ
ymin=-0.1#np.amin([ylimL[0],ylimL[1],ylimR[0],ylimR[1]])
ymax=1.6#np.amax([ylimL[0],ylimL[1],ylimR[0],ylimR[1]])
axL.set_ylim(ymin,ymax)
axR.set_ylim(ymin,ymax)

# axis labels
axL.set_ylabel('$xf(x,Q^2)$',size=25)
axL.set_xlabel('$x$',size=25)
axL.xaxis.set_label_coords(1.0,-0.04,transform=axL.transAxes)

# legend
labelmap={}
labelmap['u']='$u$'
labelmap['d']='$d$'
labelmap['db+ub']=r'$\bar{d}+\bar{u}$'
labelmap['db-ub']=r'$\bar{d}-\bar{u}$'
labelmap['g']='$g/10$'

H,L=[],[]
for k in ['u','d','db+ub','db-ub','g']:
  p12=LH[k]
  H.append(LH[k])
  L.append(labelmap[k])
axR.legend(H,L,loc=1,frameon=0,fontsize=20)

# info
axL.text(0.1,0.1,'$Q^2=%0.0f$'%(Q2)+tex('~GeV^2'),transform=axL.transAxes,size=20)

# the end
py.savefig('gallery/xpdf.pdf')
示例#13
0
  DY=DrellYan()
  
  Q=91.1876
  RS=1900.0
  y=0

  BT=np.linspace(1e-3,1.4,100)[:1]

  ax=py.subplot(111)


  DY.TMD.set_NP_params(Set=2)
  BTW=[]
  for bT in BT: BTW.append(bT*DY.get_L_bT_space(Q,RS,y,bT))
  ax.plot(BT,BTW,'b--',lw=2,label=tex('b_{max}=%0.2f')%(DY.TMD.D['bT2max']**0.5))

  #DY.TMD.set_NP_params(Set=1)
  #BTW=[]
  #for bT in BT: BTW.append(bT*DY.get_L_bT_space(Q,RS,y,bT))
  #ax.plot(BT,BTW,'m-.',lw=2,label=tex('b_{max}=%0.2f')%(DY.TMD.D['bT2max']**0.5))

  #ax.set_ylabel(tex('b_T\\tilde{W}\;(nb/GeV)'),size=20)
  #ax.set_xlabel(tex('b_T(GeV^{-1})'),size=20)
  #ax.legend()
  #py.savefig('plot.pdf')




示例#14
0
文件: dou.py 项目: Jeff182/CJ
JR14=COMPOSER('JR14NLO08VF')
CT14=COMPOSER('CT14nlo')
#NNPDF=COMPOSER4NNPDF('NNPDF30_nlo_as_0118')
#ABM11=COMPOSER('abm11_4n_nlo')
#HERA15=COMPOSER('HERAPDF15NLO_EIG')

ax=py.subplot(111)
Q2=10
X=np.linspace(1e-3,0.95,1000)

ct=plot_dou(ax,CT14,Q2,X,color='g',ls='-',T=1,hatch=None,alpha=0.7,facecolor='g',edgecolor='g')
mmht=plot_dou(ax,MMHT14,Q2,X,color='y',ls='-',T=1,hatch=None,alpha=0.8,facecolor='y',edgecolor='y')
jr=plot_dou(ax,JR14,Q2,X,color='b',ls='-',T=10,hatch='..',alpha=0.7,facecolor='none',edgecolor='b')
cj=plot_dou(ax,CJ15,Q2,X,color='r',ls='-',T=10,hatch=None,alpha=0.8,facecolor='r',edgecolor='r')
#hera=plot_dou(ax,HERA15,Q2,X,color='k',ls='-',T=1,hatch='||',alpha=1.0,facecolor='none',edgecolor='k')
#nnpdf=plot_dou(ax,NNPDF,Q2,X,color='k',ls='-',T=1,hatch='//',alpha=0.4,edgecolor='k')
#abm=plot_dou(ax,ABM11,Q2,X,color='b',ls='-',T=10,hatch='...',alpha=0.7,facecolor='none',edgecolor='b')


# legend
H=[cj,mmht,ct,jr]
L=[tex('CJ15'),tex('MMHT14'),tex('CT14'),tex('JR14')]
ax.legend(H,L,frameon=0,fontsize=20,loc=3,bbox_to_anchor=(0.5,0.57))
ax.set_ylabel(r'$d/u$',size=25)
ax.set_xlabel(r'$x$',size=25)
ax.set_xlim(0,0.95)
ax.set_ylim(0,1)
ax.tick_params(axis='both',labelsize=20)
py.tight_layout()
py.savefig('gallery/du0.pdf')
示例#15
0
文件: ratio.py 项目: Jeff182/CJ
def ratio_off():

  ###############################
  # plot geometry
  ###############################
  # set gloabl figure dimensions
  nrows=3
  ncols=2
  py.figure(figsize=(ncols*4,nrows*3))

  # construct LR AXs for each flav 
  AX={}
  gs = gridspec.GridSpec(nrows,ncols)
  gs.update(left=0.1,right=0.98,wspace=0.3,hspace=0.3,top=0.98,bottom=0.08)
  AX['u'] =py.subplot(gs[0,0])  
  AX['ub']=py.subplot(gs[1,0])
  AX['s'] =py.subplot(gs[2,0])
  AX['d'] =py.subplot(gs[0,1])
  AX['db']=py.subplot(gs[1,1])
  AX['g'] =py.subplot(gs[2,1])


  ###############################
  # plot content 
  ###############################
  
  CJ15={'KP':{},'fmKP':{}}
  CJ15['KP']['AV18' ]   =COMPOSER('CJ15_NLO_KP_AV18')
  CJ15['KP']['CDBONN']  =COMPOSER('CJ15_NLO_KP_CDBONN',central_only=True)
  CJ15['KP']['WJC1' ]   =COMPOSER('CJ15_NLO_KP_WJC1',central_only=True)
  CJ15['KP']['WJC2' ]   =COMPOSER('CJ15_NLO_KP_WJC2',central_only=True)
  CJ15['fmKP']['AV18']  =COMPOSER('CJ15_NLO_fmKP_AV18',central_only=True)
  CJ15['fmKP']['CDBONN']=COMPOSER('CJ15_NLO_fmKP_CDBONN',central_only=True)
  CJ15['fmKP']['WJC1']  =COMPOSER('CJ15_NLO_fmKP_WJC1',central_only=True)
  CJ15['fmKP']['WJC2']  =COMPOSER('CJ15_NLO_fmKP_WJC2',central_only=True)
  
  Q2=10
  for flav in [ 'u','d','ub','db','s','g']:
    print flav
    p1=plotI0(AX,Q2,CJ15['KP']['AV18'],CJ15['KP']['AV18'],flav,'y','-',
      T=1,hatch=None,alpha=0.4,facecolor='yellow',edgecolor='none')
    p2=plotII0(AX,Q2,CJ15['KP']['AV18'],CJ15['fmKP']['AV18'],flav,'k',':',
      T=1,hatch=None,alpha=0.4,facecolor='k',edgecolor='none')
    p3=plotII0(AX,Q2,CJ15['KP']['AV18'],CJ15['fmKP']['CDBONN'],flav,'r','-',
      T=1,hatch=None,alpha=0.4,facecolor='b',edgecolor='none')
    p4=plotII0(AX,Q2,CJ15['KP']['AV18'],CJ15['fmKP']['WJC1'],flav,'g','--',
      T=1,hatch=None,alpha=0.4,facecolor='g',edgecolor='none')
    p5=plotII0(AX,Q2,CJ15['KP']['AV18'],CJ15['fmKP']['WJC2'],flav,'b','-',
      T=1,hatch=None,alpha=0.4,facecolor='y',edgecolor='none')
  
    ax=AX[flav]

    if flav=='d':
      H=[p1,p2,p3,p4,p5]
      L=[tex('CJ15\ (AV18)'),tex('AV18+OCS'),tex('CDBonn+OCS'),tex('WJC1+OCS'),tex('WJC2+OCS')]
      ax.legend(H,L,frameon=0,fontsize=10, bbox_to_anchor=(0.55, 0.55))
    if flav=='u':
      ax.text(0.06,0.85,'$Q^2=%0.0f$'%(Q2)+tex('~GeV^2'),\
        transform=ax.transAxes,size=15)

    # set ylims
    if flav=='d':
      ymin,ymax=0.8,1.1
    elif flav=='u':
      ymin,ymax=0.95,1.05
    elif flav=='g':
      ymin,ymax=0.9,1.1
    else:
      ymin,ymax=0.95,1.05
    ax.set_ylim(ymin,ymax)

    # set x axis
    if flav=='u' or flav=='d' or flav=='g':
      #ax.set_xticks(np.arange(0.1,1.1,0.2))
      ax.set_xlim(0,0.95)
    elif flav=='g':
      ax.set_xlim(0,0.8)
    else:
      #ax.set_xticks(np.arange(0.1,0.5,0.1))
      ax.set_xlim(0,0.5)

    # set labels
    if flav=='db': _flav=r'\bar{d}'
    elif flav=='ub': _flav=r'\bar{u}'
    else: _flav=flav
    ax.set_ylabel(r'$%s/%s$\large$_{\rm CJ15}$'%(_flav,_flav),size=20)
    ax.set_xlabel('$x$',size=20)
    if flav=='u' or flav=='d' or flav=='g':
      xticklabels=[0,0.2,0.4,0.6,0.8]
  
    # set labels
    if flav=='db': _flav=r'\bar{d}'
    elif flav=='ub': _flav=r'\bar{u}'
    else: _flav=flav
    ax.set_ylabel(r'$%s/%s$\large$_{\rm CJ15}$'%(_flav,_flav),size=20)
    ax.set_xlabel('$x$',size=20)
  
  py.savefig('gallery/ratio_off.pdf')
示例#16
0
文件: F2pd.py 项目: Jeff182/CJ
  def make_F2_plot(self):
    D=self.D
    xbins=self.get_xbins()
    py.figure(figsize=(15,15))

    gs = gridspec.GridSpec(1,1)
    gs.update(left=0.1,right=0.98,top=0.98,bottom=0.1)
    ax=py.subplot(gs[0,0])

    for k in self.ordered_keys:
      dbinned=D[k]['dbinned']
      color=D[k]['color']
      sym=D[k]['symbol']
      flag=False
      for i in range(len(xbins)):
        dbin=dbinned[i]
        if dbin['X'].size!=0:
          if flag==False:
            ax.errorbar(dbin['Q2'],dbin['F2']*2**(i+1)\
              ,yerr=dbin['ERR'].values\
              ,fmt=color+sym\
              ,mec=color
              ,label=tex(k.replace(' ','~')))
            flag=True
          else:
            ax.errorbar(dbin['Q2'],dbin['F2']*2**(i+1)\
              ,yerr=dbin['ERR'].values\
              ,fmt=color+sym\
              ,mec=color)

    for i in range(len(xbins)):
      Q2=-100
      for k in D.keys():
        dbin=D[k]['dbinned'][i]
        if dbin['X'].size==0:continue
        imax=np.argmax(dbin['Q2'].values)
        if dbin['Q2'].values[imax]>Q2: 
          Q2=dbin['Q2'].values[imax]
          F2=dbin['F2'].values[imax]

      if any([i==k for k in [10,34,37,39,41,44,49,47,43,35,32,30,28,26,45]])!=True:
        if xbins[i][1]<0.0001:
          text='$x\in[%0.6f,%0.6f]$'%(xbins[i][0],xbins[i][1])
        elif xbins[i][1]<0.001:
          text='$x\in[%0.5f,%0.5f]$'%(xbins[i][0],xbins[i][1])
        elif xbins[i][1]<0.01:
          text='$x\in[%0.4f,%0.4f]$'%(xbins[i][0],xbins[i][1])
        elif xbins[i][1]<0.12:
          text='$x\in[%0.3f,%0.3f]$'%(xbins[i][0],xbins[i][1])
        else:
          text='$x\in[%0.2f,%0.2f]$'%(xbins[i][0],xbins[i][1])
        ax.text(Q2*1.2,F2*2**(i+1),text)
        #ax.text(Q2*1.2,F2*2**(i+1),text+str(i))

    ax.legend(frameon=0,fontsize=20)

    ax.set_xlim(8e-5,3e5)
    ax.semilogy()
    ax.semilogx()
    ax.set_ylabel(tex('F_2')+'$(x,Q^2)$',size=30)
    ax.set_xlabel('$Q^2$'+tex('(GeV^2)'),size=30)
    py.tick_params(axis='both',labelsize=20)

    xsq=0.45
    ysq=0.07
    ax.add_patch(patches.Rectangle((xsq,ysq),0.1,0.15\
      ,fill=False,transform=ax.transAxes))
    ax.plot([0.36,xsq],[0.07,ysq],'k:'
      ,transform=ax.transAxes)
    ax.plot([0.36,xsq],[0.47,ysq+0.15],'k:'
      ,transform=ax.transAxes)


    rect1 = [0.06,0.07,0.3,0.3]
    ax1 = self.add_subplot_axes(ax,rect1)
    rect2 = [0.06,0.47,0.3,0.3]
    ax2 = self.add_subplot_axes(ax,rect2)

    for k in D.keys():
      if 'JLab' not in k: continue
      d=D[k]['DF']
      color=D[k]['color']
      sym=D[k]['symbol']

      ax1.errorbar(d['Q2'],d['F2']\
        ,yerr=d['ERR'].values\
        ,fmt=color+sym\
        ,mec=color)

      ax2.errorbar(d['X'],d['F2']\
        ,yerr=d['ERR'].values\
        ,fmt=color+sym\
        ,mec=color)

    ax1.locator_params(nbins=5) 
    ax2.locator_params(nbins=5) 

    ax1.tick_params(axis='both',labelsize=12)
    ax2.tick_params(axis='both',labelsize=12)

    ax1.set_xlabel(r'$Q^2$'+tex('(GeV^2)'),size=20)
    ax2.set_xlabel(r'$x$',size=20)
    ax1.semilogy()
    ax2.semilogy()
    #py.tight_layout()
    py.savefig('gallery/F2.pdf')
示例#17
0
文件: off.py 项目: Jeff182/CJ
import pylab as py
import tools
from tools import tex,plot_band,fill_between
from  matplotlib import rc
rc('font',**{'family':'sans-serif','sans-serif':['Times-Roman']})
rc('text',usetex=True)

D={}
D['AV18']  ={'p':[0.098,0.345,0.048] ,'c':'r','ls':'-'}   
D['CDBonn']={'p':[0.138,0.373,0.058] ,'c':'g','ls':'--'}
D['WJC1']  ={'p':[0.132,-0.253,0.152],'c':'k','ls':'-.'}
D['WJC2']  ={'p':[0.076,0.313,0.033] ,'c':'b','ls':':'}

f=lambda x,p:p[0]*(x-p[1])*(x-p[2])*(1+p[1]-x)
X=np.linspace(0,1,100)
ax=py.subplot(111)
for k in ['AV18','CDBonn','WJC1','WJC2']:
  ax.plot(X,f(X,D[k]['p']),\
    color=D[k]['c'],\
    lw=2.0,\
    ls=D[k]['ls'],\
    label=tex(k)
    )
ax.set_ylim(-0.025,0.04)
ax.set_ylabel(r'$\delta f^N$',size=25)
ax.set_xlabel('$x$',size=25)
ax.legend(frameon=0,loc=2,fontsize=20)
py.tick_params(axis='both',labelsize=20)
py.tight_layout()
py.savefig('gallery/off_shell.pdf')
示例#18
0
文件: CJ15.py 项目: Jeff182/CJ
    for grp in ["KP_AV18", "KP_CDBONN", "KP_WJC1", "KP_WJC2"]:

        cj15 = CJ15[grp]
        X = cj15["Q2"][Q2]["x"]
        if flav != "du" and flav != "dbub":
            central = cj15["Q2"][Q2]["x" + flav]
            error = cj15["Q2"][Q2]["err-x" + flav] * 10
        elif flav == "du":
            central = cj15["Q2"][Q2]["d/u"]
            error = cj15["Q2"][Q2]["err-d/u"] * 10
        elif flav == "dbub":
            central = cj15["Q2"][Q2]["db/ub"]
            error = cj15["Q2"][Q2]["err-db/ub"] * 10

        if grp != "KP_AV18":
            ax.plot(X, central, grpmap[grp]["color"], label=tex(grp.replace("KP_", "")))
        else:
            p1, = ax.plot(X, central, grpmap[grp]["color"])
            p2 = fill_between(
                X,
                central - error,
                central + error,
                ax=ax,
                facecolor="#FFFF00",
                edgecolor="#FFFF00",
                alpha=1.0,
                hatch=None,
            )

    # make legend
    if flav == "d":