コード例 #1
0
def plot_caustic_halos(plt, outdir, sats_vproj, sats_rproj, sats_type):

    fig = plt.figure(figsize=(9,9))
    xtit = "$r/r_{\\rm vir}$"
    ytit = "$v_{\\rm r}/v_{\\rm vir}$"
    xmin, xmax, ymin, ymax = 0, 1.2, -5, 5
    xleg = xmin + 0.02 * (xmax - xmin)
    yleg = ymax - 0.1 * (ymax - ymin)

    ax = fig.add_subplot(111)
    common.prepare_ax(ax, xmin, xmax, ymin, ymax, xtit, ytit, locators=(0.1, 1, 0.1, 1))

    #ind = np.where(sats_type == 2)
    #xdata = sats_rproj[ind]
    #ydata = sats_vproj[ind]
    #us.density_contour(ax, xdata, ydata, 30, 30) #, **contour_kwargs)

    ind = np.where(sats_type == 2)
    xdata = sats_rproj[ind]
    ydata = sats_vproj[ind]
    ax.plot(xdata,ydata,'ro',markersize=0.7) #, **contour_kwargs)

    ind = np.where(sats_type == 1)
    xdata = sats_rproj[ind]
    ydata = sats_vproj[ind]
    ax.plot(xdata,ydata,'ko',markersize=0.7) #, **contour_kwargs)

    common.savefig(outdir, fig, 'caustic_groups.pdf')
コード例 #2
0
ファイル: hothalo.py プロジェクト: viogp/shark
def plot_cooling_rate(plt, outdir, med_tvir):

    fig = plt.figure(figsize=(5,5))
    xmin, xmax, ymin, ymax = -1.8, 1.2, -1, 6

    ax = fig.add_subplot(111)
    xtit="$\\rm log_{10}(T_{\\rm vir}/\\rm keV)$"
    ytit="$\\rm log_{10}(L_{\\rm cool}/ 10^{40}\\rm erg\,s^{-1})$"
    common.prepare_ax(ax, xmin, xmax, ymin, ymax, xtit, ytit, locators=(0.1, 1, 0.1, 1))
    xleg= xmax - 0.2 * (xmax - xmin)
    yleg= ymax - 0.1 * (ymax - ymin)
    ax.text(xleg, yleg, 'z=0')

    ind = np.where(med_tvir[0, :] != 0)
    xplot = tfunc[ind]
    yplot = med_tvir[0, ind]
    errdn = med_tvir[1, ind]
    errup = med_tvir[2, ind]

    ax.errorbar(xplot,yplot[0],color='k', label="SHArk")
    ax.errorbar(xplot,yplot[0],yerr=[errdn[0],errup[0]], ls='None', mfc='None', ecolor = 'k', mec='k',marker='+',markersize=2)
    ax.plot(tfunc, 3.0 * tfunc + 1.9, 'r', linestyle='dashed', label='Anderson+15')

    common.prepare_legend(ax, ['r','k'], loc=2)
    common.savefig(outdir, fig, 'cooling_rate.pdf')
コード例 #3
0
ファイル: global_quantities.py プロジェクト: viogp/shark
def plot_baryon_fractions(plt, outdir, redshifts, mstar_dm, mcold_dm, mhot_dm,
                          meje_dm, mbar_dm):

    fig = plt.figure(figsize=(9.5, 9.5))

    xtit = "$\\rm redshift$"
    ytit = "$\\rm log_{10}(\\rho/\\rho_{\\rm m})$"

    ax = fig.add_subplot(111)
    common.prepare_ax(ax, 0, 10, -4, 0.5, xtit, ytit, locators=(0.1, 1, 0.1))

    ax.plot(redshifts, mstar_dm, 'k', label='stars')
    ax.plot(redshifts, mcold_dm, 'b', label='ISM gas')
    ax.plot(redshifts, mhot_dm, 'r', label='halo gas')
    ax.plot(redshifts, meje_dm, 'g', label='ejected gas')
    ax.plot(redshifts, mbar_dm, 'm', label='total baryons')

    yplot = [0.1866920152, 0.1866920152]
    xplot = [0, 10]

    ax.plot(xplot,
            np.log10(yplot),
            'k',
            linestyle='dashed',
            label='Universal $f_{\\rm baryon}$')

    common.prepare_legend(ax, ['k', 'b', 'r', 'g', 'm', 'k'])
    common.savefig(outdir, fig, "baryon_frac.pdf")
コード例 #4
0
ファイル: global_quantities.py プロジェクト: viogp/shark
def plot_mass_cosmic_density(plt, outdir, redshifts, mcold, mHI, mH2):

    fig = plt.figure(figsize=(5, 4.5))

    ax = fig.add_subplot(111)
    plt.subplots_adjust(bottom=0.15, left=0.15)

    xtit = "$\\rm Lookback\,time/Gyr$"
    ytit = "$\\rm log_{10}(\\Omega_{\\rm gas})$"
    common.prepare_ax(ax,
                      0,
                      13.5,
                      -4,
                      -2.7,
                      xtit,
                      ytit,
                      locators=(0.1, 1, 0.1, 1))
    ax2 = ax.twiny()
    ax2.set_xlim(ax.get_xlim())
    new_tick_locations = np.array([0., 2., 4., 6., 8., 10., 12.])

    ax2.set_xticks(new_tick_locations)
    ax2.set_xticklabels(us.redshift(new_tick_locations), fontsize=12)

    ax2.set_xlabel("redshift", fontsize=13)

    #note that only h^2 is needed because the volume provides h^3, and the SFR h^-1.
    ax.plot(us.look_back_time(redshifts),
            mcold + np.log10(Omegab) - np.log10(XH),
            'k',
            label='total neutral ISM')
    ax.plot(us.look_back_time(redshifts),
            mHI + np.log10(Omegab) - np.log10(XH),
            'b',
            linestyle='dotted',
            label='atomic')
    ax.plot(us.look_back_time(redshifts),
            mH2 + np.log10(Omegab) - np.log10(XH),
            'r',
            linestyle='dashed',
            label='molecular')

    common.prepare_legend(ax, ['k', 'b', 'r'], loc=1)
    common.savefig(outdir, fig, "omega_neutral.pdf")
コード例 #5
0
ファイル: global_quantities.py プロジェクト: viogp/shark
def plot_sft_efficiency(plt, outdir, redshifts, sfre, sfreH2, mhrat):

    fig = plt.figure(figsize=(9.5, 11))
    xmin, xmax, ymin, ymax = 0, 10, -6, 0

    # panel 1
    ax = fig.add_subplot(311)
    plt.subplots_adjust(bottom=0.15, left=0.15)

    xtit = "$\\rm redshift$"
    ytit = "$\\rm log_{10}(SFR/M_{\\rm cold} Gyr^{-1})$"
    common.prepare_ax(ax,
                      xmin,
                      xmax,
                      ymin,
                      ymax,
                      xtit,
                      ytit,
                      locators=(0.1, 1, 0.1))

    #note that only h^2 is needed because the volume provides h^3, and the SFR h^-1.
    ind = np.where(sfre > 0)
    ax.plot(redshifts[ind], np.log10(sfre[ind]), 'r', label='Shark')
    common.prepare_legend(ax, ['r'])

    #panel 2
    ax = fig.add_subplot(312)
    ytit = "$\\rm log_{10}(SFE_{\\rm H_2}/Gyr^{-1})$"
    common.prepare_ax(ax,
                      xmin,
                      xmax,
                      ymin,
                      ymax,
                      xtit,
                      ytit,
                      locators=(0.1, 1, 0.1))

    #note that only h^2 is needed because the volume provides h^3, and the SFR h^-1.
    ind = np.where(sfreH2 > 0)
    ax.plot(redshifts[ind], np.log10(sfreH2[ind]), 'r', label='Shark')
    common.prepare_legend(ax, ['r'])

    #panel 3
    ax = fig.add_subplot(313)
    ytit = "$\\rm log_{10}(M_{\\rm mol}/M_{\\rm atom})$"
    common.prepare_ax(ax,
                      xmin,
                      xmax,
                      -3,
                      2,
                      xtit,
                      ytit,
                      locators=(0.1, 1, 0.1))

    #note that only h^2 is needed because the volume provides h^3, and the SFR h^-1.
    ind = np.where(mhrat > 0)
    ax.plot(redshifts[ind], np.log10(mhrat[ind]), 'r', label='Shark')
    common.prepare_legend(ax, ['r'])

    common.savefig(outdir, fig, "cosmic_sfe.pdf")
コード例 #6
0
def plot_sizes_combined(plt, outdir, rcomb):

    fig = plt.figure(figsize=(5, 4.5))

    # Total ##################################
    xtit = "$\\rm log_{10} (\\rm M_{\\rm stars, total}/M_{\odot})$"
    ytit = "$\\rm log_{10} (\\rm r_{\\rm 50, comb}/kpc)$"
    xmin, xmax, ymin, ymax = 8, 12, -0.5, 2

    ax = fig.add_subplot(111)
    plt.subplots_adjust(bottom=0.15, left=0.15)

    common.prepare_ax(ax,
                      xmin,
                      xmax,
                      ymin,
                      ymax,
                      xtit,
                      ytit,
                      locators=(0.1, 1, 0.1))

    #Predicted size-mass for disks
    ind = np.where(rcomb[0, 0, :] != 0)
    xplot = xmf[ind]
    yplot = rcomb[0, 0, ind]
    errdn = rcomb[0, 1, ind]
    errup = rcomb[0, 2, ind]
    ax.errorbar(xplot,
                yplot[0],
                yerr=[errdn[0], errup[0]],
                ls='None',
                mfc='None',
                ecolor='k',
                mec='k',
                marker='o',
                label="Shark disk+bulge combined")

    common.prepare_legend(ax, ['k', 'k', 'k'], loc=2)
    common.savefig(outdir, fig, 'sizes_combined.pdf')
コード例 #7
0
ファイル: galaxy_analysis.py プロジェクト: pelahi/VR-Analysis
def prepare_ax(ax, xmin, xmax, ymin, ymax, xtit, ytit):
    common.prepare_ax(ax, xmin, xmax, ymin, ymax, xtit, ytit)
    xleg = xmax - 0.2 * (xmax - xmin)
    yleg = ymax - 0.1 * (ymax - ymin)
コード例 #8
0
def plot_con_lambda(plt, outdir, con, lam, snap):

    xtit="$\\rm log_{10} (\\rm M_{\\rm tot}/M_{\odot})$"
    ytit="$\\rm concentration$"
    xmin, xmax, ymin, ymax = 8, 14, 0.5, 30
    xleg = xmax - 0.2 * (xmax-xmin)
    yleg = ymax - 0.1 * (ymax-ymin)

    fig = plt.figure(figsize=(5,10))

    idx = [0,1,2]

    zins = [0, 1, 2]
    subplots = [311, 312, 313]

    for subplot, idx, z, s in zip(subplots, idx, zins, snap):
          ax = fig.add_subplot(subplot)
          if (idx == 2):
              xtitplot = xtit
          else:
              xtitplot = ' '
          common.prepare_ax(ax, xmin, xmax, ymin, ymax, xtitplot, ytit, locators=(0.1, 1, 0.1))
          ax.text(xleg,yleg, 'z=%s' % (str(z)))
  
          #Predicted HMF
          ind = np.where(con[0,idx,0,:] != 0.)
          xplot = xmf[ind]
          yplot = con[0,idx,0,ind]
          errdn = con[0,idx,1,ind]
          errup = con[0,idx,2,ind]

          if idx == 0:
              ax.plot(xplot,yplot[0],'r', label ='VR hosts')
          if idx > 0:
              ax.plot(xplot,yplot[0],'r')
          ax.fill_between(xplot,yplot[0],yplot[0]-errdn[0], facecolor='r', alpha=0.2,interpolate=True)
          ax.fill_between(xplot,yplot[0],yplot[0]+errup[0], facecolor='r', alpha=0.2,interpolate=True)

          ind = np.where(con[1,idx,0,:] != 0.)
          xplot = xmf[ind]
          yplot = con[1,idx,0,ind]
          errdn = con[1,idx,1,ind]
          errup = con[1,idx,2,ind]

          if idx == 0:
              ax.plot(xplot,yplot[0],'r', linestyle='dashed', label ='VR subh')
          if idx > 0:
              ax.plot(xplot,yplot[0],'r', linestyle='dashed')

          if idx == 0:
              common.prepare_legend(ax, ['r','r'], loc='upper left')

    common.savefig(outdir, fig, "con_mtot_z.pdf")

    xtit="$\\rm log_{10} (\\rm M_{\\rm tot}/M_{\odot})$"
    ytit="$\lambda_{\\rm Bullock}$"
    xmin, xmax, ymin, ymax = 8, 14, 0.01, 1
    xleg = xmax - 0.2 * (xmax-xmin)
    yleg = ymax - 0.3 * (ymax-ymin)

    fig = plt.figure(figsize=(5,10))
    plt.subplots_adjust(left=0.15)
    idx = [0,1,2]

    zins = [0, 1, 2]
    subplots = [311, 312, 313]

    for subplot, idx, z, s in zip(subplots, idx, zins, snap):
          ax = fig.add_subplot(subplot)
          if (idx == 2):
              xtitplot = xtit
          else:
              xtitplot = ' '
          common.prepare_ax(ax, xmin, xmax, ymin, ymax, xtitplot, ytit, locators=(0.1, 1, 0.1))
          ax.text(xleg,yleg, 'z=%s' % (str(z)))
          ax.set_yscale("log")
 
          #Predicted HMF
          ind = np.where(lam[0,idx,0,:] != 0.)
          xplot = xmf[ind]
          yplot = lam[0,idx,0,ind]
          errdn = lam[0,idx,1,ind]
          errup = lam[0,idx,2,ind]

          if idx == 0:
              ax.plot(xplot,yplot[0],'r', label ='VR hosts')
          if idx > 0:
              ax.plot(xplot,yplot[0],'r')
          ax.fill_between(xplot,yplot[0],yplot[0]-errdn[0], facecolor='r', alpha=0.2,interpolate=True)
          ax.fill_between(xplot,yplot[0],yplot[0]+errup[0], facecolor='r', alpha=0.2,interpolate=True)

          ind = np.where(lam[1,idx,0,:] != 0.)
          xplot = xmf[ind]
          yplot = lam[1,idx,0,ind]
          errdn = lam[1,idx,1,ind]
          errup = lam[1,idx,2,ind]

          if idx == 0:
              ax.plot(xplot,yplot[0],'r', linestyle='dashed', label ='VR subh')
          if idx > 0:
              ax.plot(xplot,yplot[0],'r', linestyle='dashed')

          if idx == 0:
              common.prepare_legend(ax, ['r','r'], loc='upper center')

    common.savefig(outdir, fig, "lambda_mtot_z.pdf")
コード例 #9
0
def plot_r200_z(plt, outdir, r200, snap):

    bin_it = functools.partial(us.wmedians, xbins=xmf)

    xtit="$\\rm log_{10} (\\rm M_{\\rm 200crit}/M_{\odot})$"
    ytit="$\\rm log_{10}(\\rm R_{\\rm 200crit}/pMpc)$"
    xmin, xmax, ymin, ymax = 8, 14, -3, 1
    xleg = xmax - 0.2 * (xmax-xmin)
    yleg = ymax - 0.1 * (ymax-ymin)

    fig = plt.figure(figsize=(5,10))

    idx = [0,1,2]

    zins = [0, 1, 2]
    subplots = [311, 312, 313]

    sn, subgn, m200s, r200s = common.load_observation('/fred/oz009/clagos/EAGLE/L0025N0376/REFERENCE/data/', 'SUBFIND-EAGLE-DATABASE.data', [2, 1, 4, 5])

    for subplot, idx, z, s in zip(subplots, idx, zins, snap):
          ax = fig.add_subplot(subplot)
          if (idx == 2):
              xtitplot = xtit
          else:
              xtitplot = ' '
          common.prepare_ax(ax, xmin, xmax, ymin, ymax, xtitplot, ytit, locators=(0.1, 1, 0.1))
          ax.text(xleg,yleg, 'z=%s' % (str(z)))
  
          #HMF from SUBFIND
          ind = np.where((m200s > 0) & (subgn == 0) & (sn == s) & (r200s > 0))
          rplot = bin_it(x= np.log10(m200s[ind]), y = np.log10(r200s[ind])-3.0)
 
          ind = np.where(rplot[0,:] != 0.)
          xplot = xmf[ind]
          yplot = rplot[0,ind]
          errdn = rplot[1,ind]
          errup = rplot[2,ind]

          if idx == 0:
              ax.plot(xplot,yplot[0],'b', linestyle='dashed', label ='SF')
          if idx > 0:
              ax.plot(xplot,yplot[0],'b', linestyle='dashed')
          ax.fill_between(xplot,yplot[0],yplot[0]-errdn[0], facecolor='b', alpha=0.2,interpolate=True)
          ax.fill_between(xplot,yplot[0],yplot[0]+errup[0], facecolor='b', alpha=0.2,interpolate=True)

          #Predicted HMF
          ind = np.where(r200[0,idx,0,:] != 0.)
          xplot = xmf[ind]
          yplot = r200[0,idx,0,ind]
          errdn = r200[0,idx,1,ind]
          errup = r200[0,idx,2,ind]

          if idx == 0:
              ax.plot(xplot,yplot[0],'r', label ='VR')
          if idx > 0:
              ax.plot(xplot,yplot[0],'r')
          ax.fill_between(xplot,yplot[0],yplot[0]-errdn[0], facecolor='r', alpha=0.2,interpolate=True)
          ax.fill_between(xplot,yplot[0],yplot[0]+errup[0], facecolor='r', alpha=0.2,interpolate=True)

          if idx == 0:
              common.prepare_legend(ax, ['b','r'])

    common.savefig(outdir, fig, "r200M200_crit_z.pdf")

    xtit="$\\rm log_{10} (\\rm M_{\\rm 200mean}/M_{\odot})$"
    ytit="$\\rm log_{10}(\\rm R_{\\rm 200mean}/pMpc)$"
    xmin, xmax, ymin, ymax = 8, 14, -3, 1
    xleg = xmax - 0.2 * (xmax-xmin)
    yleg = ymax - 0.1 * (ymax-ymin)

    fig = plt.figure(figsize=(5,10))

    idx = [0,1,2]

    zins = [0, 1, 2]
    subplots = [311, 312, 313]

    sn, subgn, m200s, r200s = common.load_observation('/fred/oz009/clagos/EAGLE/L0025N0376/REFERENCE/data/', 'SUBFIND-EAGLE-DATABASE.data', [2, 1, 6, 7])

    for subplot, idx, z, s in zip(subplots, idx, zins, snap):
          ax = fig.add_subplot(subplot)
          if (idx == 2):
              xtitplot = xtit
          else:
              xtitplot = ' '
          common.prepare_ax(ax, xmin, xmax, ymin, ymax, xtitplot, ytit, locators=(0.1, 1, 0.1))
          ax.text(xleg,yleg, 'z=%s' % (str(z)))
  
          #HMF from SUBFIND
          ind = np.where((m200s > 0) & (subgn == 0) & (sn == s) & (r200s > 0))
          rplot = bin_it(x= np.log10(m200s[ind]), y = np.log10(r200s[ind])-3.0)
 
          ind = np.where(rplot[0,:] != 0.)
          xplot = xmf[ind]
          yplot = rplot[0,ind]
          errdn = rplot[1,ind]
          errup = rplot[2,ind]

          if idx == 0:
              ax.plot(xplot,yplot[0],'b', linestyle='dashed', label ='SF')
          if idx > 0:
              ax.plot(xplot,yplot[0],'b', linestyle='dashed')
          ax.fill_between(xplot,yplot[0],yplot[0]-errdn[0], facecolor='b', alpha=0.2,interpolate=True)
          ax.fill_between(xplot,yplot[0],yplot[0]+errup[0], facecolor='b', alpha=0.2,interpolate=True)

          #Predicted HMF
          ind = np.where(r200[1,idx,0,:] != 0.)
          xplot = xmf[ind]
          yplot = r200[1,idx,0,ind]
          errdn = r200[1,idx,1,ind]
          errup = r200[1,idx,2,ind]

          if idx == 0:
              ax.plot(xplot,yplot[0],'r', label ='VR')
          if idx > 0:
              ax.plot(xplot,yplot[0],'r')
          ax.fill_between(xplot,yplot[0],yplot[0]-errdn[0], facecolor='r', alpha=0.2,interpolate=True)
          ax.fill_between(xplot,yplot[0],yplot[0]+errup[0], facecolor='r', alpha=0.2,interpolate=True)

          if idx == 0:
              common.prepare_legend(ax, ['b','r'])

    common.savefig(outdir, fig, "r200M200_mean_z.pdf")
コード例 #10
0
def plot_lambda(plt, outdir, obsdir, lambdaH,  lambda_jiang, lambda_mass, bt, ms, ssfr_z0):

    lambda_allstar = lambda_jiang[3,:] 
    lambda_disk= lambda_jiang[0,:]
    lambda_star= lambda_jiang[1,:]
    lambda_gas = lambda_jiang[2,:]

    fig = plt.figure(figsize=(5,12))
    xtit = ""
    ytit = "$\\rm log_{10}(\\lambda_{\\star})$"
    xmin, xmax, ymin, ymax = -3, 0, -4, 0
    xleg = xmin + 0.02 * (xmax - xmin)
    yleg = ymax - 0.1 * (ymax - ymin)
    cutms = 7.5

    med = np.zeros(shape = (3, len(xlf)))

    ax = fig.add_subplot(411)
    common.prepare_ax(ax, xmin, xmax, ymin, ymax, xtit, ytit, locators=(0.1, 1, 0.1, 1))
    ax.text(xleg, yleg, 'all galaxies, stars+gas')

    ind = np.where((lambdaH > 0) & (lambda_allstar > 0) & (lambda_allstar < 10) & (ms > cutms))
    if(len(lambdaH[ind]) > 0):
       #xdata = np.log10(lambdaH[ind])
       #ydata = np.log10(lambda_allstar[ind])
       #us.density_contour(ax, xdata, ydata, 30, 30) #, **contour_kwargs)

       coeff = np.corrcoef(np.log10(lambdaH[ind]),np.log10(lambda_allstar[ind]))
       ax.text(xmin + 0.02 * (xmax - xmin), ymax - 0.25 * (ymax - ymin), 'R=%s' % str(np.around(coeff[0,1], decimals=3)))

       med[:] = us.wmedians(x=np.log10(lambdaH[ind]), y=np.log10(lambda_allstar[ind]), xbins = xlf, low_numbers=True)
       ind    = np.where((med[0,:] != 0) & (med[0,:] > -5))
       xobs   = xlf[ind]
       yobs   = med[0,ind]
       yerrdn = med[1,ind]
       yerrup = med[2,ind]
       ax.errorbar(xobs, yobs[0], yerr=[yerrdn[0],yerrup[0]], ls='None', mfc='None', ecolor = 'grey', mec='grey',linestyle='solid', color='k')
 
    #ind = np.where((lambdaH > 0) & (lambda_allstar > 0) & (lambda_allstar < 10) & (ms > 10))
    #med[:] = us.wmedians(x=np.log10(lambdaH[ind]), y=np.log10(lambda_allstar[ind]), xbins = xlf, low_numbers=True)
    #ind    = np.where((med[0,:] != 0) & (med[0,:] > -5))
    #xobs   = xlf[ind]
    #yobs   = med[0,ind]
    #ax.plot(xobs, yobs[0], color='k',linestyle='dotted', label='$\\rm log_{10}(M_{\\star}/M_{\\odot}) > 10$')

    #ind = np.where((lambdaH > 0) & (lambda_allstar > 0) & (lambda_allstar < 10) & (ms > 7.5) & (ms < 9))
    #med[:] = us.wmedians(x=np.log10(lambdaH[ind]), y=np.log10(lambda_allstar[ind]), xbins = xlf, low_numbers=True)
    #ind    = np.where((med[0,:] != 0) & (med[0,:] > -5))
    #xobs   = xlf[ind]
    #yobs   = med[0,ind]
    #ax.plot(xobs, yobs[0], color='k',linestyle='dashed', label='$\\rm 7.5<log_{10}(M_{\\star}/M_{\\odot})<9$')

    ax = fig.add_subplot(412)
    ytit = "$\\rm log_{10}(\\lambda_{\\rm disk})$"
    common.prepare_ax(ax, xmin, xmax, ymin, ymax, xtit, ytit, locators=(0.1, 1, 0.1, 1))
    ax.text(xleg, yleg, 'disk-dominated, stars+gas')

    ind = np.where((lambdaH > 0) & (lambda_disk > 0) & (bt < 0.5) & (ms > cutms))
    #xdata = np.log10(lambdaH[ind])
    #ydata = np.log10(lambda_disk[ind])
    #us.density_contour(ax, xdata, ydata, 30, 30) #, **contour_kwargs)
    coeff = np.corrcoef(np.log10(lambdaH[ind]),np.log10(lambda_disk[ind]))
    ax.text(xmin + 0.02 * (xmax - xmin), ymax - 0.25 * (ymax - ymin), 'R=%s' % str(np.around(coeff[0,1], decimals=3)))

    med[:] = us.wmedians(x=np.log10(lambdaH[ind]), y=np.log10(lambda_disk[ind]), xbins = xlf, low_numbers=True)
    ind    = np.where((med[0,:] != 0) & (med[0,:] > -5))
    xobs   = xlf[ind]
    yobs   = med[0,ind]
    yerrdn = med[1,ind]
    yerrup = med[2,ind]
    ax.errorbar(xobs, yobs[0], yerr=[yerrdn[0],yerrup[0]], ls='None', mfc='None', ecolor = 'grey', mec='grey',linestyle='solid', color='k')

    ax = fig.add_subplot(413)
    common.prepare_ax(ax, xmin, xmax, ymin, ymax, xtit, ytit, locators=(0.1, 1, 0.1, 1))
    ax.text(xleg, yleg, 'disk-dominated, stars')

    ind = np.where((lambdaH > 0) & (lambda_star > 0) & (bt < 0.5) & (ms > cutms))
    xdata = np.log10(lambdaH[ind])
    ydata = np.log10(lambda_star[ind])
    us.density_contour(ax, xdata, ydata, 30, 30) #, **contour_kwargs)
    coeff = np.corrcoef(np.log10(lambdaH[ind]),np.log10(lambda_star[ind]))
    ax.text(xmin + 0.02 * (xmax - xmin), ymax - 0.25 * (ymax - ymin), 'R=%s' % str(np.around(coeff[0,1], decimals=3)))

    med[:] = us.wmedians(x=np.log10(lambdaH[ind]), y=np.log10(lambda_star[ind]), xbins = xlf, low_numbers=True)
    ind    = np.where((med[0,:] != 0) & (med[0,:] > -5))
    xobs   = xlf[ind]
    yobs   = med[0,ind]
    yerrdn = med[1,ind]
    yerrup = med[2,ind]
    ax.errorbar(xobs, yobs[0], yerr=[yerrdn[0],yerrup[0]], ls='None', mfc='None', ecolor = 'grey', mec='grey',linestyle='solid', color='k')

    ax = fig.add_subplot(414)
    xtit = "$\\rm log_{10}(\\lambda_{\\rm halo})$"
    common.prepare_ax(ax, xmin, xmax, ymin, ymax, xtit, ytit, locators=(0.1, 1, 0.1, 1))
    ax.text(xmin + 0.02 * (xmax - xmin), yleg, 'disk-dominated, gas')

    ind = np.where((lambdaH > 0) & (lambda_gas > 0) & (bt < 0.5) & (ms > cutms))
    #xdata = np.log10(lambdaH[ind])
    #ydata = np.log10(lambda_gas[ind])
    #us.density_contour(ax, xdata, ydata, 30, 30) #, **contour_kwargs)
    coeff = np.corrcoef(np.log10(lambdaH[ind]),np.log10(lambda_gas[ind]))
    ax.text(xmin + 0.02 * (xmax - xmin), ymax - 0.25 * (ymax - ymin), 'R=%s' % str(np.around(coeff[0,1], decimals=3)))

    med[:] = us.wmedians(x=np.log10(lambdaH[ind]), y=np.log10(lambda_gas[ind]), xbins = xlf, low_numbers=True)
    ind    = np.where((med[0,:] != 0) & (med[0,:] > -5))
    xobs   = xlf[ind]
    yobs   = med[0,ind]
    yerrdn = med[1,ind]
    yerrup = med[2,ind]
    ax.errorbar(xobs, yobs[0], yerr=[yerrdn[0],yerrup[0]], ls='None', mfc='None', ecolor = 'grey', mec='grey',linestyle='solid', color='k')

    common.savefig(outdir, fig, 'lambda_relation.pdf')
コード例 #11
0
def plot_specific_am(plt, outdir, obsdir, sam_stars_disk, sam_gas_disk_atom, sam_gas_disk_mol, sam_halo, sam_bar, sam_stars):

    fig = plt.figure(figsize=(4.5,4.5))
    xtit = "$\\rm log_{10} (\\rm M_{\\star}/M_{\odot})$"
    ytit = "$\\rm log_{10} (\\rm j_{\\rm disk}/kpc\\, km s^{-1})$"
    xmin, xmax, ymin, ymax = 8, 11.5, 1.5, 5
    xleg = xmax - 0.5 * (xmax - xmin)
    yleg = ymax - 0.1 * (ymax - ymin)

    # choose type of selection:
    selec = 1 #disk-dominated galaxies
    s = 0
    # LTG ##################################
    ax = fig.add_subplot(111)
    common.prepare_ax(ax, xmin, xmax, ymin, ymax, xtit, ytit, locators=(0.1, 1, 0.1, 1))
    ax.text(xleg, yleg, 'z=0 Shark-default', fontsize = 12)

    ind = np.where(sam_halo[s,0,:,selec] != 0)
    xplot = xmf[ind]
    yplot = sam_halo[s,0,ind,selec] + 3.0
    errdn = sam_halo[s,1,ind,selec]
    errup = sam_halo[s,2,ind,selec]
    ax.plot(xplot,yplot[0],color='k',label="DM")
    ax.fill_between(xplot,yplot[0],yplot[0]-errdn[0], facecolor='k', alpha=0.2,interpolate=True)
    ax.fill_between(xplot,yplot[0],yplot[0]+errup[0], facecolor='k', alpha=0.2,interpolate=True)

    #Predicted sAM-mass for disks in disk=dominated galaxies
    ind = np.where(sam_stars[s,0,:,selec] != 0)
    xplot = xmf[ind]
    yplot = sam_stars[s,0,ind,selec]+ 3.0
    errdn = sam_stars[s,1,ind,selec]
    errup = sam_stars[s,2,ind,selec]
    ax.plot(xplot,yplot[0],color='r',linestyle='dashed',label="stars")
    ax.fill_between(xplot,yplot[0],yplot[0]-errdn[0], facecolor='r', alpha=0.25,interpolate=True)
    ax.fill_between(xplot,yplot[0],yplot[0]+errup[0], facecolor='r', alpha=0.25,interpolate=True)

    #Predicted size-mass for disks in disk=dominated galaxies
    ind = np.where(sam_gas_disk_atom[s,0,:,selec] != 0)
    xplot = xmf[ind]
    yplot = sam_gas_disk_atom[s,0,ind,selec] + 3.0
    errdn = sam_gas_disk_atom[s,1,ind,selec]
    errup = sam_gas_disk_atom[s,2,ind,selec]
    ax.plot(xplot,yplot[0],color='b',linestyle='dotted',label="atomic ISM")
    ax.fill_between(xplot,yplot[0],yplot[0]-errdn[0], facecolor='b', alpha=0.25,interpolate=True)
    ax.fill_between(xplot,yplot[0],yplot[0]+errup[0], facecolor='b', alpha=0.25,interpolate=True)

    #Predicted size-mass for disks in disk=dominated galaxies
    ind = np.where(sam_gas_disk_mol[s,0,:,selec] != 0)
    xplot = xmf[ind]
    yplot = sam_gas_disk_mol[s,0,ind,selec] + 3.0
    errdn = sam_gas_disk_mol[s,1,ind,selec]
    errup = sam_gas_disk_mol[s,2,ind,selec]
    ax.plot(xplot,yplot[0],color='g',linestyle='dashdot',label="molecular ISM")
    ax.fill_between(xplot,yplot[0],yplot[0]-errdn[0], facecolor='g', alpha=0.25,interpolate=True)
    ax.fill_between(xplot,yplot[0],yplot[0]+errup[0], facecolor='g', alpha=0.25,interpolate=True)

    common.prepare_legend(ax, ['k'], loc=2)

    common.savefig(outdir, fig, 'specific_am_onlyz0.pdf')

    fig = plt.figure(figsize=(9.5,9.5))
    xtit = "$\\rm log_{10} (\\rm M_{\\star}/M_{\odot})$"
    ytit = "$\\rm log_{10} (\\rm j_{\\rm disk}/kpc\\, km s^{-1})$"
    xmin, xmax, ymin, ymax = 8, 11.5, 1.5, 5
    xleg = xmax - 0.2 * (xmax - xmin)
    yleg = ymax - 0.1 * (ymax - ymin)

    subplots = (221, 222, 223, 224)
    indz = (0, 1, 2, 3)

    # choose type of selection:
    selec = 1 #disk-dominated galaxies
    # LTG ##################################
    for z,s,p in zip(zlist, indz, subplots):
	    ax = fig.add_subplot(p)
	    common.prepare_ax(ax, xmin, xmax, ymin, ymax, xtit, ytit, locators=(0.1, 1, 0.1, 1))
            ax.text(xleg, yleg, 'z=%s' % str(z))

	    ind = np.where(sam_halo[s,0,:,selec] != 0)
	    xplot = xmf[ind]
	    yplot = sam_halo[s,0,ind,selec] + 3.0
	    errdn = sam_halo[s,1,ind,selec]
	    errup = sam_halo[s,2,ind,selec]
	    ax.plot(xplot,yplot[0],color='k',label="DM")
	    ax.fill_between(xplot,yplot[0],yplot[0]-errdn[0], facecolor='k', alpha=0.2,interpolate=True)
	    ax.fill_between(xplot,yplot[0],yplot[0]+errup[0], facecolor='k', alpha=0.2,interpolate=True)

            #Predicted sAM-mass for disks in disk=dominated galaxies
            ind = np.where(sam_stars[s,0,:,selec] != 0)
            xplot = xmf[ind]
            yplot = sam_stars[s,0,ind,selec]+ 3.0
            errdn = sam_stars[s,1,ind,selec]
            errup = sam_stars[s,2,ind,selec]
            ax.plot(xplot,yplot[0],color='r',label="stars")
            ax.fill_between(xplot,yplot[0],yplot[0]-errdn[0], facecolor='r', alpha=0.5,interpolate=True)
            ax.fill_between(xplot,yplot[0],yplot[0]+errup[0], facecolor='r', alpha=0.5,interpolate=True)

            #Predicted size-mass for disks in disk=dominated galaxies
            ind = np.where(sam_gas_disk_atom[s,0,:,selec] != 0)
            xplot = xmf[ind]
            yplot = sam_gas_disk_atom[s,0,ind,selec] + 3.0
            errdn = sam_gas_disk_atom[s,1,ind,selec]
            errup = sam_gas_disk_atom[s,2,ind,selec]
            ax.plot(xplot,yplot[0],color='b',label="atomic ISM")
            ax.fill_between(xplot,yplot[0],yplot[0]-errdn[0], facecolor='b', alpha=0.5,interpolate=True)
            ax.fill_between(xplot,yplot[0],yplot[0]+errup[0], facecolor='b', alpha=0.5,interpolate=True)
    
            #Predicted size-mass for disks in disk=dominated galaxies
            ind = np.where(sam_gas_disk_mol[s,0,:,selec] != 0)
            xplot = xmf[ind]
            yplot = sam_gas_disk_mol[s,0,ind,selec] + 3.0
            errdn = sam_gas_disk_mol[s,1,ind,selec]
            errup = sam_gas_disk_mol[s,2,ind,selec]
            ax.plot(xplot,yplot[0],color='g',label="molecular ISM")
            ax.fill_between(xplot,yplot[0],yplot[0]-errdn[0], facecolor='g', alpha=0.5,interpolate=True)
            ax.fill_between(xplot,yplot[0],yplot[0]+errup[0], facecolor='g', alpha=0.5,interpolate=True)

	    common.prepare_legend(ax, ['k'], loc=2)


    common.savefig(outdir, fig, 'specific_am.pdf')
  
    #plot angular momentum components separately. 
    fig = plt.figure(figsize=(15,5))
    s = 0 
    #plot stars
    xtit = "$\\rm log_{10} (\\rm M_{\\star}/M_{\odot})$"
    ytit = "$\\rm log_{10} (\\rm j_{\\star}/kpc\\, km s^{-1})$"
    xmin, xmax, ymin, ymax = 8, 11.5, 1.5, 4
    xleg = xmax - 0.2 * (xmax - xmin)
    yleg = ymax - 0.1 * (ymax - ymin)

    ax = fig.add_subplot(141)
    common.prepare_ax(ax, xmin, xmax, ymin, ymax, xtit, ytit, locators=(0.1, 1, 0.1, 1))

    jst, jmole, jatomic, jbar = common.load_observation(obsdir, 'Models/SharkVariations/AngularMomentum.dat', [0,1,2,3])
    jsL18    = np.zeros(shape = (3, len(xmf)))
    jmolL18  = np.zeros(shape = (3, len(xmf)))
    jatomL18 = np.zeros(shape = (3, len(xmf)))
    jbarL18  = np.zeros(shape = (3, len(xmf)))
    i = 0
    p =0
    for j in range(0,len(jst)/2):
	jsL18[i,p]    = jst[j]
        jmolL18[i,p]  = jmole[j]
        jatomL18[i,p] = jatomic[j]
        jbarL18[i,p]  = jbar[j]
        p = p + 1
        if(p >= len(xmf)):
		p = 0
		i = i +1
   
    #Predicted sAM-mass for disks in disk=dominated galaxies
    ind = np.where(sam_stars[s,0,:,selec] != 0)
    xplot = xmf[ind]
    yplot = sam_stars[s,0,ind,selec]+ 3.0
    errdn = sam_stars[s,1,ind,selec]
    errup = sam_stars[s,2,ind,selec]
    ax.plot(xplot,yplot[0],color='r')
    ax.fill_between(xplot,yplot[0],yplot[0]-errdn[0], facecolor='r', alpha=0.35,interpolate=True)
    ax.fill_between(xplot,yplot[0],yplot[0]+errup[0], facecolor='r', alpha=0.35,interpolate=True)

    ind = np.where(sam_stars_disk[s,0,:,selec] != 0)
    xplot = xmf[ind]
    yplot = sam_stars_disk[s,0,ind,selec]+ 3.0
    errdn = sam_stars_disk[s,1,ind,selec]
    errup = sam_stars_disk[s,2,ind,selec]
    ax.plot(xplot,yplot[0],color='r', linestyle='dotted')

    ind = np.where(jsL18[0,:] != 0)
    xplot = xmf[ind]
    yplot = jsL18[0,ind]+ 3.0
    errdn = jsL18[1,ind]
    errup = jsL18[2,ind]
    ax.plot(xplot,yplot[0],color='r',linestyle='dashed')
    ax.fill_between(xplot,yplot[0],yplot[0]-errdn[0], facecolor='r', linestyle='dashed', alpha=0.2,interpolate=True)
    ax.fill_between(xplot,yplot[0],yplot[0]+errup[0], facecolor='r', linestyle='dashed', alpha=0.2,interpolate=True)

    #Read observational data.
    ms, mserr, js, jserr  = common.load_observation(obsdir, 'SizesAndAM/Posti18_AMdata.dat', [3,5,6,8])
    errmdn = np.log10(ms) - np.log10(ms - mserr)
    errmup = np.log10(ms + mserr) - np.log10(ms)
    errjdn = np.log10(js) - np.log10(js - jserr)
    errjup = np.log10(js + jserr) - np.log10(js) 
    ax.errorbar(np.log10(ms), np.log10(js), yerr=[errjdn,errjup], xerr=[errmdn,errmup],ls='None', mfc='None', ecolor = 'r', mec='r',marker='+',label="Posti+18")

    bt, mbO14, msO14, mgO14, jbO14, jsO14, jgO14, jmolO14 = common.load_observation(obsdir, 'SizesAndAM/Obreschkow14_FP.dat', [2,6,7,8,11,12,14,15])
    ax.plot(msO14, jsO14, 'ro',fillstyle='none', label="Obreschkow+14")

    mgB17, msB17, errmsB17, mbB17, errmbB17, jgB17, errjgB17, jsB17, errjsB17, jbB17, errjbB17 = common.load_observation(obsdir, 'SizesAndAM/LITTLETHINGS_Butler16.dat', [1,3,4,5,6,7,8,9,10,11,12])
    ax.errorbar(msB17, jsB17, yerr=[errjsB17,errjsB17], xerr=[errmsB17,errmsB17], ls='None', mfc='None', ecolor = 'r', mec='r',marker='s',label="Butler+16")

    msC17, mgC17, mbC17, errupmbC17, errdnmbC17, JstarC17, JgasC17, errupJgasC17, errdnJgasC17, jbarC17, errupjbarC17, errdnjbarC17 = common.load_observation(obsdir, 'SizesAndAM/Chowdhury17.dat', [1,2,5,6,7,8,8,10,11,15,16,17])
    ax.plot(msC17, JstarC17-msC17, 'rp', fillstyle='none',label="Chowdhury+17")

    mbE17, jbE17 = common.load_observation(obsdir, 'SizesAndAM/Elson17.dat', [5,7]) 
    mbE17 = np.log10(mbE17 * 1e8)
    jbE17 = np.log10(jbE17)
   
    #IDGalaxy Mstar errup errdn Mgas errup errdn Mbar errup errdn jstar errup errdn jgas errup errdn  jbar  errup errdn
    (msK18, errupmsK18, errdnmsK18, mgK18, errupmgK18, errdnmgK18, mbK18, errupmbK18, errdnmbK18, jsK18, errupjsK18, errdnjsK18, jgK18, 
    errupjgK18, errdnjgK18, jbarK18, errupjbarK18, errdnjbarK18) = common.load_observation(obsdir, 'SizesAndAM/Kurapati18.dat', [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18]) 
    ax.errorbar(msK18, jsK18, yerr=[errdnjsK18,errupjsK18], xerr=[errdnmsK18,errupmsK18],ls='None', mfc='None', ecolor = 'r', mec='r',marker='*',label="Kurapati+18")

    common.prepare_legend(ax, ['r', 'r', 'r','r','r'], loc=2)


    #plot molecular gas
    xtit = "$\\rm log_{10} (\\rm M_{\\star}/M_{\odot})$"
    ytit = "$\\rm log_{10} (\\rm j_{\\rm H_2}/kpc\\, km s^{-1})$"
    ax = fig.add_subplot(142)
    common.prepare_ax(ax, xmin, xmax, ymin, ymax, xtit, ytit, locators=(0.1, 1, 0.1, 1))

    #Predicted size-mass for disks in disk=dominated galaxies
    ind = np.where(sam_gas_disk_mol[s,0,:,selec] != 0)
    xplot = xmf[ind]
    yplot = sam_gas_disk_mol[s,0,ind,selec] + 3.0
    errdn = sam_gas_disk_mol[s,1,ind,selec]
    errup = sam_gas_disk_mol[s,2,ind,selec]
    ax.plot(xplot,yplot[0],color='g', label="ISM/stars AM transfer")
    ax.fill_between(xplot,yplot[0],yplot[0]-errdn[0], facecolor='g', alpha=0.35,interpolate=True)
    ax.fill_between(xplot,yplot[0],yplot[0]+errup[0], facecolor='g', alpha=0.35,interpolate=True)

    ind = np.where(jmolL18[0,:] != 0)
    xplot = xmf[ind]
    yplot = jmolL18[0,ind]+ 3.0
    errdn = jmolL18[1,ind]
    errup = jmolL18[2,ind]
    ax.plot(xplot,yplot[0],color='g',linestyle='dashed', label="Lagos+18")
    ax.fill_between(xplot,yplot[0],yplot[0]-errdn[0], facecolor='g', linestyle='dashed', alpha=0.2,interpolate=True)
    ax.fill_between(xplot,yplot[0],yplot[0]+errup[0], facecolor='g', linestyle='dashed', alpha=0.2,interpolate=True)

    ax.plot(msO14, jmolO14, 'go',fillstyle='none')
    common.prepare_legend(ax, ['k'], loc=2)

    #plot atomic gas
    xtit = "$\\rm log_{10} (\\rm M_{\\star}/M_{\odot})$"
    ytit = "$\\rm log_{10} (\\rm j_{\\rm HI}/kpc\\, km s^{-1})$"
    ax = fig.add_subplot(143)
    common.prepare_ax(ax, xmin, xmax, ymin, ymax, xtit, ytit, locators=(0.1, 1, 0.1, 1))

    #Predicted size-mass for disks in disk=dominated galaxies
    ind = np.where(sam_gas_disk_atom[s,0,:,selec] != 0)
    xplot = xmf[ind]
    yplot = sam_gas_disk_atom[s,0,ind,selec] + 3.0
    errdn = sam_gas_disk_atom[s,1,ind,selec]
    errup = sam_gas_disk_atom[s,2,ind,selec]
    ax.plot(xplot,yplot[0],color='b')
    ax.fill_between(xplot,yplot[0],yplot[0]-errdn[0], facecolor='b', alpha=0.35,interpolate=True)
    ax.fill_between(xplot,yplot[0],yplot[0]+errup[0], facecolor='b', alpha=0.35,interpolate=True)

    ind = np.where(jatomL18[0,:] != 0)
    xplot = xmf[ind]
    yplot = jatomL18[0,ind]+ 3.0
    errdn = jatomL18[1,ind]
    errup = jatomL18[2,ind]
    ax.plot(xplot,yplot[0],color='b',linestyle='dashed')
    ax.fill_between(xplot,yplot[0],yplot[0]-errdn[0], facecolor='b', linestyle='dashed', alpha=0.2,interpolate=True)
    ax.fill_between(xplot,yplot[0],yplot[0]+errup[0], facecolor='b', linestyle='dashed', alpha=0.2,interpolate=True)

    ax.errorbar(msB17, jgB17, yerr=[errjgB17,errjgB17], xerr=[errmsB17,errmsB17,],ls='None', mfc='None', ecolor = 'b', mec='b',marker='s')
    ax.plot(msO14, jgO14, 'bo',fillstyle='none')
    ax.plot(msC17, JgasC17-mgC17, 'bp', fillstyle='none')
    ax.errorbar(msK18, jgK18, yerr=[errdnjgK18,errupjgK18], xerr=[errdnmsK18,errupmsK18],ls='None', mfc='None', ecolor = 'b', mec='b',marker='*')

    #plot total baryon
    xtit = "$\\rm log_{10} (\\rm M_{\\rm bar}/M_{\odot})$"
    ytit = "$\\rm log_{10} (\\rm j_{\\rm bar}/kpc\\, km s^{-1})$"
    ax = fig.add_subplot(144)
    common.prepare_ax(ax, xmin, xmax, ymin, ymax, xtit, ytit, locators=(0.1, 1, 0.1, 1))

    #Predicted size-mass for disks in disk=dominated galaxies
    ind = np.where(sam_bar[s,0,:,selec] != 0)
    xplot = xmf[ind]
    yplot = sam_bar[s,0,ind,selec] + 3.0
    errdn = sam_bar[s,1,ind,selec]
    errup = sam_bar[s,2,ind,selec]
    ax.plot(xplot,yplot[0],color='k')
    ax.fill_between(xplot,yplot[0],yplot[0]-errdn[0], facecolor='k', alpha=0.25,interpolate=True)
    ax.fill_between(xplot,yplot[0],yplot[0]+errup[0], facecolor='k', alpha=0.25,interpolate=True)

    ind = np.where(jbarL18[0,:] != 0)
    xplot = xmf[ind]
    yplot = jbarL18[0,ind]+ 3.0
    errdn = jbarL18[1,ind]
    errup = jbarL18[2,ind]
    ax.plot(xplot,yplot[0],color='k',linestyle='dashed')
    ax.fill_between(xplot,yplot[0],yplot[0]-errdn[0], facecolor='k', linestyle='dashed', alpha=0.1,interpolate=True)
    ax.fill_between(xplot,yplot[0],yplot[0]+errup[0], facecolor='k', linestyle='dashed', alpha=0.1,interpolate=True)

    ax.errorbar(mbB17, jbB17, yerr=[errjbB17,errjbB17], xerr=[errmbB17,errmbB17],ls='None', mfc='None', ecolor = 'k', mec='k',marker='s')
    ax.plot(mbO14, jbO14, 'ko',fillstyle='none')
    ax.errorbar(mbC17, jbarC17, yerr=[errdnjbarC17,errupjbarC17], xerr=[errdnmbC17,errupmbC17], ls='None', mfc='None', ecolor = 'k', mec='k',marker='p')
    ax.errorbar(mbK18, jbarK18, yerr=[errdnjbarK18,errupjbarK18], xerr=[errdnmbK18,errupmbK18],ls='None', mfc='None', ecolor = 'k', mec='k',marker='*')
    ax.plot(mbE17, jbE17, 'k^', fillstyle='none', label='Elson17')

    common.prepare_legend(ax, ['k'], loc=2)
    common.savefig(outdir, fig, 'specific_am_z0_components.pdf')

    for c in range (0,2):
       print 'will change selection'
       for i in range (0,3):
            print 'will change within the same sample'
            for x,y,z,a in zip(sam_stars_disk[s,i,:,c],sam_gas_disk_mol[s,i,:,c],sam_gas_disk_atom[s,i,:,c],sam_bar[s,i,:,c]):
                 print x,y,z,a
コード例 #12
0
def plot_specific_am_ratio(plt, outdir, obsdir, sam_vs_sam_halo_disk,
                           sam_vs_sam_halo_gal, sam_vs_sam_halo_disk_gas,
                           sam_vs_sam_halo_bar, m_vs_m_halo_disk,
                           m_vs_m_halo_gal, m_vs_m_halo_disk_gas,
                           m_vs_m_halo_bar, r_vs_r_halo_disk, r_vs_r_halo_gal,
                           r_vs_r_halo_disk_gas, r_vs_r_halo_bar):

    selec = 0  #all galaxies

    #plot specific AM vs. specific AM
    fig = plt.figure(figsize=(9, 8))
    xtit = "$\\rm log_{10} (\\rm j_{\\rm halo}/kpc\,km\,s^{-1})$"
    ytit = "$\\rm log_{10} (\\rm j_{\\rm gas}/kpc\,km\,s^{-1}$)"
    xmin, xmax, ymin, ymax = 1, 6, 1, 6
    xleg = xmax - 0.2 * (xmax - xmin)
    yleg = ymax - 0.1 * (ymax - ymin)

    subplots = (221, 222, 223, 224)
    indz = (0, 1, 2, 3)
    zinplot = (0, 0.5, 1, 2)

    # LTG ##################################
    for z, s, p in zip(zinplot, indz, subplots):
        ax = fig.add_subplot(p)
        common.prepare_ax(ax,
                          xmin,
                          xmax,
                          ymin,
                          ymax,
                          xtit,
                          ytit,
                          locators=(0.1, 1, 0.1, 1))
        ax.text(xleg, yleg, 'z=%s' % str(z), fontsize=10)
        #if(s == 0):
        #    ax.text(5.5,6.4,'Lagos+18',fontsize=14)

        ind = np.where(sam_vs_sam_halo_gal[s, 0, :, selec] != 0)
        xplot = xlf[ind] + 3
        yplot = sam_vs_sam_halo_gal[s, 0, ind, selec] + 3
        errdn = sam_vs_sam_halo_gal[s, 1, ind, selec]
        errup = sam_vs_sam_halo_gal[s, 2, ind, selec]
        ax.plot(xplot, yplot[0], color='k', label="all stars")
        ax.fill_between(xplot,
                        yplot[0],
                        yplot[0] - errdn[0],
                        facecolor='k',
                        alpha=0.2,
                        interpolate=True)
        ax.fill_between(xplot,
                        yplot[0],
                        yplot[0] + errup[0],
                        facecolor='k',
                        alpha=0.2,
                        interpolate=True)

        ind = np.where(sam_vs_sam_halo_disk[s, 0, :, selec] != 0)
        xplot = xlf[ind] + 3
        yplot = sam_vs_sam_halo_disk[s, 0, ind, selec] + 3
        errdn = sam_vs_sam_halo_disk[s, 1, ind, selec]
        errup = sam_vs_sam_halo_disk[s, 2, ind, selec]
        ax.plot(xplot, yplot[0], color='g', label="disk stars")
        ax.fill_between(xplot,
                        yplot[0],
                        yplot[0] - errdn[0],
                        facecolor='g',
                        alpha=0.2,
                        interpolate=True)
        ax.fill_between(xplot,
                        yplot[0],
                        yplot[0] + errup[0],
                        facecolor='g',
                        alpha=0.2,
                        interpolate=True)

        ind = np.where(sam_vs_sam_halo_disk_gas[s, 0, :, selec] != 0)
        xplot = xlf[ind] + 3
        yplot = sam_vs_sam_halo_disk_gas[s, 0, ind, selec] + 3
        errdn = sam_vs_sam_halo_disk_gas[s, 1, ind, selec]
        errup = sam_vs_sam_halo_disk_gas[s, 2, ind, selec]
        ax.plot(xplot, yplot[0], color='b', label="disk gas")
        ax.fill_between(xplot,
                        yplot[0],
                        yplot[0] - errdn[0],
                        facecolor='b',
                        alpha=0.2,
                        interpolate=True)
        ax.fill_between(xplot,
                        yplot[0],
                        yplot[0] + errup[0],
                        facecolor='b',
                        alpha=0.2,
                        interpolate=True)

        xplot = [1, 5]
        ax.plot(xplot, xplot, color='grey', linestyle='dotted')
        if (s == 0):
            common.prepare_legend(ax, ['k', 'g', 'b'], loc=2)

    common.savefig(outdir, fig, 'specific_am_halo_vs_galaxy.pdf')

    #plot specific AM vs. specific AM z=0 only
    fig = plt.figure(figsize=(4, 11.5))
    xtit = "$\\rm log_{10} (\\rm j_{\\rm halo}/kpc\,km\,s^{-1})$"
    ytit = "$\\rm log_{10} (\\rm j_{\\rm gal}/kpc\,km\,s^{-1}$)"
    xmin, xmax, ymin, ymax = 1, 6, 1, 5
    xleg = xmax - 0.2 * (xmax - xmin)
    yleg = ymax - 0.1 * (ymax - ymin)

    # LTG ##################################
    ax = fig.add_subplot(311)
    common.prepare_ax(ax,
                      xmin,
                      xmax,
                      ymin,
                      ymax,
                      xtit,
                      ytit,
                      locators=(0.1, 1, 0.1, 1))
    plt.subplots_adjust(left=0.2)
    #ax.text(2.7,5.1,'Shark-AM',fontsize=14)
    #ax.text(2.5,5.1,'Shark-default',fontsize=14)
    #ax.text(0.99,5.1,'No AGN feedback, no disk-inst',fontsize=14)
    ax.text(2.45, 5.1, 'No disk-inst', fontsize=14)

    s = 0  #z=0
    ind = np.where(sam_vs_sam_halo_bar[s, 0, :, selec] != 0)
    xplot = xlf[ind] + 3
    yplot = sam_vs_sam_halo_bar[s, 0, ind, selec] + 3
    errdn = sam_vs_sam_halo_bar[s, 1, ind, selec]
    errup = sam_vs_sam_halo_bar[s, 2, ind, selec]
    ax.plot(xplot, yplot[0], color='k', label="all baryons")
    ax.fill_between(xplot,
                    yplot[0],
                    yplot[0] - errdn[0],
                    facecolor='k',
                    alpha=0.2,
                    interpolate=True)
    ax.fill_between(xplot,
                    yplot[0],
                    yplot[0] + errup[0],
                    facecolor='k',
                    alpha=0.2,
                    interpolate=True)

    ind = np.where(sam_vs_sam_halo_gal[s, 0, :, selec] != 0)
    xplot = xlf[ind] + 3
    yplot = sam_vs_sam_halo_gal[s, 0, ind, selec] + 3
    errdn = sam_vs_sam_halo_gal[s, 1, ind, selec]
    errup = sam_vs_sam_halo_gal[s, 2, ind, selec]
    ax.plot(xplot, yplot[0], color='r', linestyle='dashdot', label="all stars")
    ax.fill_between(xplot,
                    yplot[0],
                    yplot[0] - errdn[0],
                    facecolor='r',
                    alpha=0.2,
                    interpolate=True)
    ax.fill_between(xplot,
                    yplot[0],
                    yplot[0] + errup[0],
                    facecolor='r',
                    alpha=0.2,
                    interpolate=True)

    ind = np.where(sam_vs_sam_halo_disk[s, 0, :, selec] != 0)
    xplot = xlf[ind] + 3
    yplot = sam_vs_sam_halo_disk[s, 0, ind, selec] + 3
    errdn = sam_vs_sam_halo_disk[s, 1, ind, selec]
    errup = sam_vs_sam_halo_disk[s, 2, ind, selec]
    ax.plot(xplot, yplot[0], color='g', linestyle='dashed', label="disk stars")
    ax.fill_between(xplot,
                    yplot[0],
                    yplot[0] - errdn[0],
                    facecolor='g',
                    alpha=0.2,
                    interpolate=True)
    ax.fill_between(xplot,
                    yplot[0],
                    yplot[0] + errup[0],
                    facecolor='g',
                    alpha=0.2,
                    interpolate=True)

    ind = np.where(sam_vs_sam_halo_disk_gas[s, 0, :, selec] != 0)
    xplot = xlf[ind] + 3
    yplot = sam_vs_sam_halo_disk_gas[s, 0, ind, selec] + 3
    errdn = sam_vs_sam_halo_disk_gas[s, 1, ind, selec]
    errup = sam_vs_sam_halo_disk_gas[s, 2, ind, selec]
    ax.plot(xplot, yplot[0], color='b', linestyle='dotted', label="disk gas")
    ax.fill_between(xplot,
                    yplot[0],
                    yplot[0] - errdn[0],
                    facecolor='b',
                    alpha=0.2,
                    interpolate=True)
    ax.fill_between(xplot,
                    yplot[0],
                    yplot[0] + errup[0],
                    facecolor='b',
                    alpha=0.2,
                    interpolate=True)

    ax.plot(xlf, xlf, color='grey', linestyle='dotted')

    common.prepare_legend(ax, ['k', 'r', 'g', 'b'], loc=2)

    xtit = "$\\rm log_{10} (\\rm M_{\\rm halo}/M_{\odot})$"
    ytit = "$\\rm log_{10} (\\rm M_{\\rm gal}(\\Omega_{\\rm DM}/\\Omega_{\\rm b})/M_{\odot})$"
    xmin, xmax, ymin, ymax = 10, 15, 8, 13.5
    xleg = xmax - 0.2 * (xmax - xmin)
    yleg = ymax - 0.1 * (ymax - ymin)

    ##################################
    ax = fig.add_subplot(312)
    common.prepare_ax(ax,
                      xmin,
                      xmax,
                      ymin,
                      ymax,
                      xtit,
                      ytit,
                      locators=(0.1, 1, 0.1, 1))
    plt.subplots_adjust(left=0.2)

    ind = np.where(m_vs_m_halo_bar[s, 0, :, selec] != 0)
    xplot = xmf[ind]
    yplot = m_vs_m_halo_bar[s, 0, ind, selec] - np.log10(fbar)
    print 'fbar', np.log10(fbar), fbar, yplot[0]
    errdn = m_vs_m_halo_bar[s, 1, ind, selec]
    errup = m_vs_m_halo_bar[s, 2, ind, selec]
    ax.plot(xplot, yplot[0], color='k')
    ax.fill_between(xplot,
                    yplot[0],
                    yplot[0] - errdn[0],
                    facecolor='k',
                    alpha=0.2,
                    interpolate=True)
    ax.fill_between(xplot,
                    yplot[0],
                    yplot[0] + errup[0],
                    facecolor='k',
                    alpha=0.2,
                    interpolate=True)

    ind = np.where(m_vs_m_halo_gal[s, 0, :, selec] != 0)
    xplot = xmf[ind]
    yplot = m_vs_m_halo_gal[s, 0, ind, selec] - np.log10(fbar)
    errdn = m_vs_m_halo_gal[s, 1, ind, selec]
    errup = m_vs_m_halo_gal[s, 2, ind, selec]
    ax.plot(xplot, yplot[0], color='r', linestyle='dashdot')
    ax.fill_between(xplot,
                    yplot[0],
                    yplot[0] - errdn[0],
                    facecolor='r',
                    alpha=0.2,
                    interpolate=True)
    ax.fill_between(xplot,
                    yplot[0],
                    yplot[0] + errup[0],
                    facecolor='r',
                    alpha=0.2,
                    interpolate=True)

    ind = np.where(m_vs_m_halo_disk[s, 0, :, selec] != 0)
    xplot = xmf[ind]
    yplot = m_vs_m_halo_disk[s, 0, ind, selec] - np.log10(fbar)
    errdn = m_vs_m_halo_disk[s, 1, ind, selec]
    errup = m_vs_m_halo_disk[s, 2, ind, selec]
    ax.plot(xplot, yplot[0], color='g', linestyle='dashed')
    ax.fill_between(xplot,
                    yplot[0],
                    yplot[0] - errdn[0],
                    facecolor='g',
                    alpha=0.2,
                    interpolate=True)
    ax.fill_between(xplot,
                    yplot[0],
                    yplot[0] + errup[0],
                    facecolor='g',
                    alpha=0.2,
                    interpolate=True)

    ind = np.where(m_vs_m_halo_disk_gas[s, 0, :, selec] != 0)
    xplot = xmf[ind]
    yplot = m_vs_m_halo_disk_gas[s, 0, ind, selec] - np.log10(fbar)
    errdn = m_vs_m_halo_disk_gas[s, 1, ind, selec]
    errup = m_vs_m_halo_disk_gas[s, 2, ind, selec]
    ax.plot(xplot, yplot[0], color='b', linestyle='dotted')
    ax.fill_between(xplot,
                    yplot[0],
                    yplot[0] - errdn[0],
                    facecolor='b',
                    alpha=0.2,
                    interpolate=True)
    ax.fill_between(xplot,
                    yplot[0],
                    yplot[0] + errup[0],
                    facecolor='b',
                    alpha=0.2,
                    interpolate=True)

    ax.plot(xmf, xmf, color='grey', linestyle='dotted')

    xtit = "$\\rm log_{10} (\\rm r_{\\rm halo}/kpc)$"
    ytit = "$\\rm log_{10} (\\rm r_{\\rm gal}/kpc$)"
    xmin, xmax, ymin, ymax = 1.7, 3.3, 0, 1.5
    xleg = xmax - 0.2 * (xmax - xmin)
    yleg = ymax - 0.1 * (ymax - ymin)

    ##################################
    ax = fig.add_subplot(313)
    common.prepare_ax(ax,
                      xmin,
                      xmax,
                      ymin,
                      ymax,
                      xtit,
                      ytit,
                      locators=(0.1, 1, 0.1, 1))
    plt.subplots_adjust(left=0.2)
    s = 0  #z=0
    ind = np.where(r_vs_r_halo_bar[s, 0, :, selec] != 0)
    xplot = xlf[ind]
    yplot = r_vs_r_halo_bar[s, 0, ind, selec]
    errdn = r_vs_r_halo_bar[s, 1, ind, selec]
    errup = r_vs_r_halo_bar[s, 2, ind, selec]
    ax.plot(xplot, yplot[0], color='k')
    ax.fill_between(xplot,
                    yplot[0],
                    yplot[0] - errdn[0],
                    facecolor='k',
                    alpha=0.2,
                    interpolate=True)
    ax.fill_between(xplot,
                    yplot[0],
                    yplot[0] + errup[0],
                    facecolor='k',
                    alpha=0.2,
                    interpolate=True)

    ind = np.where(r_vs_r_halo_gal[s, 0, :, selec] != 0)
    xplot = xlf[ind]
    yplot = r_vs_r_halo_gal[s, 0, ind, selec]
    errdn = r_vs_r_halo_gal[s, 1, ind, selec]
    errup = r_vs_r_halo_gal[s, 2, ind, selec]
    ax.plot(xplot, yplot[0], color='r', linestyle='dashdot')
    ax.fill_between(xplot,
                    yplot[0],
                    yplot[0] - errdn[0],
                    facecolor='r',
                    alpha=0.2,
                    interpolate=True)
    ax.fill_between(xplot,
                    yplot[0],
                    yplot[0] + errup[0],
                    facecolor='r',
                    alpha=0.2,
                    interpolate=True)

    ind = np.where(r_vs_r_halo_disk[s, 0, :, selec] != 0)
    xplot = xlf[ind]
    yplot = r_vs_r_halo_disk[s, 0, ind, selec]
    errdn = r_vs_r_halo_disk[s, 1, ind, selec]
    errup = r_vs_r_halo_disk[s, 2, ind, selec]
    ax.plot(xplot, yplot[0], color='g', linestyle='dashed')
    ax.fill_between(xplot,
                    yplot[0],
                    yplot[0] - errdn[0],
                    facecolor='g',
                    alpha=0.2,
                    interpolate=True)
    ax.fill_between(xplot,
                    yplot[0],
                    yplot[0] + errup[0],
                    facecolor='g',
                    alpha=0.2,
                    interpolate=True)

    ind = np.where(r_vs_r_halo_disk_gas[s, 0, :, selec] != 0)
    xplot = xlf[ind]
    yplot = r_vs_r_halo_disk_gas[s, 0, ind, selec]
    errdn = r_vs_r_halo_disk_gas[s, 1, ind, selec]
    errup = r_vs_r_halo_disk_gas[s, 2, ind, selec]
    ax.plot(xplot, yplot[0], color='b', linestyle='dotted')
    ax.fill_between(xplot,
                    yplot[0],
                    yplot[0] - errdn[0],
                    facecolor='b',
                    alpha=0.2,
                    interpolate=True)
    ax.fill_between(xplot,
                    yplot[0],
                    yplot[0] + errup[0],
                    facecolor='b',
                    alpha=0.2,
                    interpolate=True)

    ax.plot(xlf,
            xlf + np.log10(0.017),
            color='DarkOrange',
            linewidth=1,
            label='Somerville+18')
    ax.plot(xlf,
            xlf + np.log10(0.019),
            color='DarkOrange',
            linewidth=1,
            linestyle='dotted')
    ax.plot(xlf,
            xlf + np.log10(0.016),
            color='DarkOrange',
            linewidth=1,
            linestyle='dotted')

    common.prepare_legend(ax, ['DarkOrange'], loc=2)

    common.savefig(outdir, fig, 'halo_galaxy_connection.pdf')
コード例 #13
0
ファイル: global_quantities.py プロジェクト: viogp/shark
def plot_omega_h2(plt, outdir, obsdir, redshifts, h0, mH2den):

    fig = plt.figure(figsize=(5, 4.5))

    ax = fig.add_subplot(111)
    plt.subplots_adjust(bottom=0.15, left=0.15)

    xtit = "$\\rm Lookback\, time/Gyr$"
    ytit = "$\\rm log_{10}(\\rho_{\\rm H_2}/ M_{\odot}\,cMpc^{-3})$"
    common.prepare_ax(ax,
                      0,
                      13.5,
                      6.2,
                      8.4,
                      xtit,
                      ytit,
                      locators=(0.1, 1, 0.1, 1))

    ax2 = ax.twiny()
    ax2.set_xlim(ax.get_xlim())
    new_tick_locations = np.array([0., 2., 4., 6., 8., 10., 12.])

    ax2.set_xticks(new_tick_locations)
    ax2.set_xticklabels(us.redshift(new_tick_locations), fontsize=12)

    ax2.set_xlabel("redshift", fontsize=13)

    #note that only h^2 is needed because the volume provides h^3, and the SFR h^-1.
    ind = np.where(mH2den > 0)
    ax.plot(us.look_back_time(redshifts[ind]),
            np.log10(mH2den[ind] * pow(h0, 2.0)) + np.log10(XH), 'r')

    z, h2_modelvar = common.load_observation(
        obsdir, 'Models/SharkVariations/Global_OtherModels.dat', [0, 2])
    h2_modelvar_burst3 = h2_modelvar[0:179]
    h2_modelvar_nu0p5 = h2_modelvar[181:360]
    h2_modelvar_burst20 = h2_modelvar[360:539]

    ind = np.where(h2_modelvar_burst20 > -10)
    ax.plot(us.look_back_time(z[ind]),
            h2_modelvar_burst20[ind],
            'Sienna',
            linestyle='dotted')
    ind = np.where(h2_modelvar_burst3 > -10)
    ax.plot(us.look_back_time(z[ind]),
            h2_modelvar_burst3[ind],
            'Crimson',
            linestyle='dashdot')
    ind = np.where(h2_modelvar_nu0p5 > -10)
    ax.plot(us.look_back_time(z[ind]),
            h2_modelvar_nu0p5[ind],
            'Salmon',
            linestyle='dotted')

    #Walter ASPECS ALMA program
    zD16, zloD16, zupD16, rhoH2D16, rhoH2loD16, rhoH2upD16 = common.load_observation(
        obsdir, 'Global/Walter17_H2.dat', [0, 1, 2, 3, 4, 5])

    hobs = 0.7

    xobs = zD16
    errxlow = zD16 - zloD16
    errxup = zupD16 - zD16
    yobs = np.log10(rhoH2D16) + np.log10(pow(hobs / h0, 3.0))
    errylow = np.log10(rhoH2D16) - np.log10(rhoH2loD16)
    erryup = np.log10(rhoH2upD16) - np.log10(rhoH2D16)

    ax.errorbar(us.look_back_time(xobs),
                yobs,
                xerr=[errxlow, errxup],
                yerr=[errylow, erryup],
                ls='None',
                mfc='None',
                ecolor='grey',
                mec='grey',
                marker='+',
                label="Decarli+16")
    ax.errorbar(us.look_back_time(xobs[0:1]),
                yobs[0:1],
                xerr=[errxlow[0:1], errxup[0:1]],
                yerr=[errylow[0:1], erryup[0:1]],
                ls='None',
                mfc='None',
                ecolor='grey',
                mec='grey',
                marker='o',
                label="Boselli+14")

    # Legend
    common.prepare_legend(ax, ['grey', 'grey', 'grey'], loc=0)

    common.savefig(outdir, fig, "omega_H2.pdf")
コード例 #14
0
ファイル: global_quantities.py プロジェクト: viogp/shark
def plot_stellar_mass_cosmic_density(plt, outdir, obsdir, redshifts, h0,
                                     mstarden, mstarbden_mergers,
                                     mstarbden_diskins):

    # Plots stellar mass cosmic density
    xtit = "$\\rm redshift$"
    ytit = "$\\rm log_{10}(\\rho_{\\rm star}/ M_{\odot}\,cMpc^{-3})$"

    fig = plt.figure(figsize=(5, 9))
    ax = fig.add_subplot(211)
    plt.subplots_adjust(left=0.15)

    common.prepare_ax(ax, 0, 10, 5, 8.7, xtit, ytit, locators=(0.1, 1, 0.1, 1))

    #note that only h^2 is needed because the volume provides h^3, and the SFR h^-1.
    ind = np.where(mstarden > 0)
    ax.plot(redshifts[ind], np.log10(mstarden[ind] * pow(h0, 2.0)), 'k')

    ind = np.where(mstarbden_mergers > 0)
    ax.plot(redshifts[ind],
            np.log10(mstarbden_mergers[ind] * pow(h0, 2.0)),
            'r',
            linestyle='dashed')
    ind = np.where(mstarbden_diskins > 0)
    ax.plot(redshifts[ind],
            np.log10(mstarbden_diskins[ind] * pow(h0, 2.0)),
            'b',
            linestyle='dotted')

    z, sm_modelvar = common.load_observation(
        obsdir, 'Models/SharkVariations/Global_OtherModels.dat', [0, 4])
    sm_modelvar_burst3 = sm_modelvar[0:179]
    sm_modelvar_nu0p5 = sm_modelvar[181:360]
    sm_modelvar_burst20 = sm_modelvar[360:539]

    ind = np.where(sm_modelvar_burst20 > -10)
    ax.plot(z[ind], sm_modelvar_burst20[ind], 'Sienna', linestyle='dotted')
    ind = np.where(sm_modelvar_burst3 > -10)
    ax.plot(z[ind],
            sm_modelvar_burst3[ind],
            'DarkSlateGray',
            linestyle='dashdot')
    ind = np.where(sm_modelvar_nu0p5 > -10)
    ax.plot(z[ind], sm_modelvar_nu0p5[ind], 'SlateGray', linestyle='dotted')

    #Baldry (Chabrier IMF), ['Baldry+2012, z<0.06']
    redD17d, redD17u, smdD17, err1, err2, err3, err4 = common.load_observation(
        obsdir, 'Global/Driver18_smd.dat', [1, 2, 3, 4, 5, 6, 7])

    hobs = 0.7
    xobs = (redD17d + redD17u) / 2.0
    yobs = smdD17 + np.log10(hobs / h0)

    err = yobs * 0. - 999.
    err = np.sqrt(
        pow(err1, 2.0) + pow(err2, 2.0) + pow(err3, 2.0) + pow(err4, 2.0))
    ax.errorbar(xobs,
                yobs,
                yerr=[err, err],
                ls='None',
                mfc='None',
                ecolor='grey',
                mec='grey',
                marker='o',
                label="Driver+18")

    common.prepare_legend(ax, ['grey'], loc=3)

    xtit = "$\\rm Lookback\, time/Gyr$"
    ax = fig.add_subplot(212)
    plt.subplots_adjust(left=0.15)
    common.prepare_ax(ax,
                      0,
                      13.5,
                      5,
                      8.7,
                      xtit,
                      ytit,
                      locators=(0.1, 1, 0.1, 1))

    #note that only h^2 is needed because the volume provides h^3, and the SFR h^-1.
    ind = np.where(mstarden > 0)
    ax.plot(us.look_back_time(redshifts[ind]),
            np.log10(mstarden[ind] * pow(h0, 2.0)),
            'k',
            label='Shark all galaxies')

    ind = np.where(mstarbden_mergers > 0)
    ax.plot(us.look_back_time(redshifts[ind]),
            np.log10(mstarbden_mergers[ind] * pow(h0, 2.0)),
            'r',
            linestyle='dashed',
            label='formed in galaxy mergers')
    ind = np.where(mstarbden_diskins > 0)
    ax.plot(us.look_back_time(redshifts[ind]),
            np.log10(mstarbden_diskins[ind] * pow(h0, 2.0)),
            'b',
            linestyle='dotted',
            label='formed in disk instabilities')

    ind = np.where(sm_modelvar_burst20 > -10)
    ax.plot(us.look_back_time(z[ind]),
            sm_modelvar_burst20[ind],
            'Sienna',
            linestyle='dotted',
            label='$\\eta_{\\rm burst}=20$')
    ind = np.where(sm_modelvar_burst3 > -10)
    ax.plot(us.look_back_time(z[ind]),
            sm_modelvar_burst3[ind],
            'DarkSlateGray',
            linestyle='dashdot',
            label='$\\eta_{\\rm burst}=3$')
    ind = np.where(sm_modelvar_nu0p5 > -10)
    ax.plot(us.look_back_time(z[ind]),
            sm_modelvar_nu0p5[ind],
            'SlateGray',
            linestyle='dotted',
            label='$\\nu_{\\rm SF}=0.5 \\rm Gyr^{-1}$')

    ax.errorbar(us.look_back_time(xobs),
                yobs,
                yerr=[err, err],
                ls='None',
                mfc='None',
                ecolor='grey',
                mec='grey',
                marker='o')

    common.prepare_legend(
        ax, ['k', 'r', 'b', 'Sienna', 'DarkSlateGray', 'SlateGray'], loc=3)

    common.savefig(outdir, fig, "cosmic_smd.pdf")
コード例 #15
0
ファイル: global_quantities.py プロジェクト: viogp/shark
def plot_cosmic_sfr(plt, outdir, obsdir, redshifts, h0, sfr, sfrd, sfrb,
                    history_interactions, mDMden):

    fig = plt.figure(figsize=(5, 9))

    xtit = "$\\rm redshift$"
    ytit = "$\\rm log_{10}(CSFRD/ M_{\odot}\,yr^{-1}\,cMpc^{-3})$"

    ax = fig.add_subplot(211)
    plt.subplots_adjust(left=0.15)

    common.prepare_ax(ax,
                      0,
                      10,
                      -3,
                      -0.5,
                      xtit,
                      ytit,
                      locators=(0.1, 1, 0.1, 1))

    #Baldry (Chabrier IMF), ['Baldry+2012, z<0.06']
    redK11, SFRK11, err_upK11, err_dnK11 = common.load_observation(
        obsdir, 'Global/SFRD_Karim11.dat', [0, 1, 2, 3])

    hobs = 0.7
    xobs = redK11

    yobs = xobs * 0. - 999.
    indx = np.where(SFRK11 > 0)
    yobs[indx] = np.log10(SFRK11[indx] * pow(hobs / h0, 2.0))

    lerr = yobs * 0. - 999.
    indx = np.where((SFRK11 - err_dnK11) > 0)
    lerr[indx] = np.log10(SFRK11[indx] - err_dnK11[indx])

    herr = yobs * 0. + 999.
    indx = np.where((SFRK11 + err_upK11) > 0)
    herr[indx] = np.log10(SFRK11[indx] + err_upK11[indx])

    ax.errorbar(xobs[0:8],
                yobs[0:8],
                yerr=[yobs[0:8] - lerr[0:8], herr[0:8] - yobs[0:8]],
                ls='None',
                mfc='None',
                ecolor='grey',
                mec='grey',
                marker='D')
    ax.errorbar(xobs[9:17],
                yobs[9:17],
                yerr=[yobs[9:17] - lerr[9:17], herr[9:17] - yobs[9:17]],
                ls='None',
                mfc='None',
                ecolor='grey',
                mec='grey',
                marker='x')

    #Driver (Chabrier IMF), ['Baldry+2012, z<0.06']
    redD17d, redD17u, sfrD17, err1, err2, err3, err4 = common.load_observation(
        obsdir, 'Global/Driver18_sfr.dat', [0, 1, 2, 3, 4, 5, 6])

    hobs = 0.7
    xobsD17 = (redD17d + redD17u) / 2.0
    yobsD17 = sfrD17 + np.log10(hobs / h0)

    errD17 = yobs * 0. - 999.
    errD17 = np.sqrt(
        pow(err1, 2.0) + pow(err2, 2.0) + pow(err3, 2.0) + pow(err4, 2.0))
    ax.errorbar(xobsD17,
                yobsD17,
                yerr=[errD17, errD17],
                ls='None',
                mfc='None',
                ecolor='grey',
                mec='grey',
                marker='o')

    #note that only h^2 is needed because the volume provides h^3, and the SFR h^-1.
    ind = np.where(sfr > 0)
    ax.plot(redshifts[ind],
            np.log10(sfr[ind] * pow(h0, 2.0)),
            'k',
            linewidth=1,
            label='total')

    ind = np.where(sfrd > 0)
    ax.plot(redshifts[ind],
            np.log10(sfrd[ind] * pow(h0, 2.0)),
            'b',
            linestyle='dashed',
            linewidth=1,
            label='quiescent')
    ind = np.where(sfrb > 0)
    ax.plot(redshifts[ind],
            np.log10(sfrb[ind] * pow(h0, 2.0)),
            'r',
            linestyle='dotted',
            linewidth=1,
            label='bursts')

    z, sfr_modelvar = common.load_observation(
        obsdir, 'Models/SharkVariations/Global_OtherModels.dat', [0, 3])
    sfr_modelvar_burst3 = sfr_modelvar[0:179]
    sfr_modelvar_nu0p5 = sfr_modelvar[179:359]
    sfr_modelvar_burst20 = sfr_modelvar[360:539]

    ind = np.where(sfr_modelvar_burst20 > -10)
    ax.plot(z[ind],
            sfr_modelvar_burst20[ind],
            'Sienna',
            linestyle='dotted',
            label='$\\eta_{\\rm burst}=20$')
    ind = np.where(sfr_modelvar_burst3 > -10)
    ax.plot(z[ind],
            sfr_modelvar_burst3[ind],
            'DarkSlateGray',
            linestyle='dashdot',
            label='$\\eta_{\\rm burst}=3$')
    ind = np.where(sfr_modelvar_nu0p5 > -10)
    ax.plot(z[ind],
            sfr_modelvar_nu0p5[ind],
            'SlateGray',
            linestyle='dotted',
            label='$\\nu_{\\rm SF}=0.5 \\rm Gyr^{-1}$')

    common.prepare_legend(ax, [
        'k', 'b', 'r', 'Sienna', 'DarkSlateGray', 'SlateGray', 'grey', 'grey',
        'grey'
    ],
                          bbox_to_anchor=(0.52, 0.47))

    xtit = "$\\rm Lookback\, time/Gyr$"
    ax = fig.add_subplot(212)
    plt.subplots_adjust(left=0.15)

    common.prepare_ax(ax,
                      0,
                      13.5,
                      -3,
                      -0.5,
                      xtit,
                      ytit,
                      locators=(0.1, 1, 0.1, 1))
    ax.errorbar(us.look_back_time(xobs[0:8]),
                yobs[0:8],
                yerr=[yobs[0:8] - lerr[0:8], herr[0:8] - yobs[0:8]],
                ls='None',
                mfc='None',
                ecolor='grey',
                mec='grey',
                marker='D',
                label="Karim+11 obs")
    ax.errorbar(us.look_back_time(xobs[9:17]),
                yobs[9:17],
                yerr=[yobs[9:17] - lerr[9:17], herr[9:17] - yobs[9:17]],
                ls='None',
                mfc='None',
                ecolor='grey',
                mec='grey',
                marker='x',
                label="Karim+11 extr")
    ax.errorbar(us.look_back_time(xobsD17),
                yobsD17,
                yerr=[errD17, errD17],
                ls='None',
                mfc='None',
                ecolor='grey',
                mec='grey',
                marker='o',
                label="Driver+18")

    ind = np.where(sfr > 0)
    ax.plot(us.look_back_time(redshifts[ind]),
            np.log10(sfr[ind] * pow(h0, 2.0)),
            'k',
            linewidth=1)

    ind = np.where(sfrd > 0)
    ax.plot(us.look_back_time(redshifts[ind]),
            np.log10(sfrd[ind] * pow(h0, 2.0)),
            'b',
            linestyle='dashed',
            linewidth=1)
    ind = np.where(sfrb > 0)
    ax.plot(us.look_back_time(redshifts[ind]),
            np.log10(sfrb[ind] * pow(h0, 2.0)),
            'r',
            linestyle='dotted',
            linewidth=1)

    ind = np.where(sfr_modelvar_burst20 > -10)
    ax.plot(us.look_back_time(z[ind]),
            sfr_modelvar_burst20[ind],
            'Sienna',
            linestyle='dotted')
    ind = np.where(sfr_modelvar_burst3 > -10)
    ax.plot(us.look_back_time(z[ind]),
            sfr_modelvar_burst3[ind],
            'DarkSlateGray',
            linestyle='dashdot')
    ind = np.where(sfr_modelvar_nu0p5 > -10)
    ax.plot(us.look_back_time(z[ind]),
            sfr_modelvar_nu0p5[ind],
            'SlateGray',
            linestyle='dotted')

    common.prepare_legend(ax, ['grey', 'grey', 'grey'], loc=2)
    common.savefig(outdir, fig, "cosmic_sfr.pdf")

    #create plot with interaction history
    fig = plt.figure(figsize=(5, 4))

    xtit = "$\\rm redshift$"
    ytit = "$\\rm log_{10}(density\,rate/Mpc^{-3} h^{-3} Gyr^{-1})$"

    ax = fig.add_subplot(111)
    plt.subplots_adjust(left=0.15)

    common.prepare_ax(ax, 0, 10, -4, 0, xtit, ytit, locators=(0.1, 1, 0.1, 1))
    delta_time = np.zeros(shape=(len(redshifts)))
    for i in range(0, len(redshifts)):
        if (i == 0):
            delta_time[i] = 13.7969 - us.look_back_time(redshifts[i])
        if (i < len(redshifts)):
            delta_time[i] = us.look_back_time(
                redshifts[i - 1]) - us.look_back_time(redshifts[i])

    #note that only h^2 is needed because the volume provides h^3, and the SFR h^-1.
    ind = np.where(history_interactions[0, :] + history_interactions[1, :] > 0)
    yplot = np.log10(
        (history_interactions[0, ind] + history_interactions[1, ind]) /
        delta_time[ind])
    ax.plot(redshifts[ind], yplot[0], 'k', linewidth=1, label='mergers')
    ind = np.where(history_interactions[2, :] > 0)
    yplot = np.log10(history_interactions[2, ind] / delta_time[ind])
    ax.plot(redshifts[ind],
            yplot[0],
            'b',
            linewidth=1,
            label='disk instabilities')

    ind = np.where(mDMden[:] > 0)
    yplot = np.log10(mDMden[ind]) - 11.0
    ax.plot(redshifts[ind], yplot, 'r', linewidth=1, label='DM mass(-11dex)')

    common.prepare_legend(ax, ['k', 'b', 'r'], loc=3)

    common.savefig(outdir, fig, "interaction_history.pdf")

    #create plot with interaction history
    fig = plt.figure(figsize=(5, 4))

    xtit = "$\\rm redshift$"
    ytit = "$\\rm delta\, time/Gyr$"

    ax = fig.add_subplot(111)
    plt.subplots_adjust(left=0.15)

    common.prepare_ax(ax,
                      0,
                      10,
                      0,
                      0.3,
                      xtit,
                      ytit,
                      locators=(0.1, 1, 0.1, 0.1))

    #note that only h^2 is needed because the volume provides h^3, and the SFR h^-1.
    ax.plot(redshifts, delta_time, 'k', linewidth=1)

    common.savefig(outdir, fig, "delta_time_history.pdf")
コード例 #16
0
def plot_mf_z(plt, outdir, obsdir, snap, vol_eagle, histmtot, histm30):

    #construct relevant observational datasets for SMF

    z0obs = []
    lm, p, dpdn, dpup = common.load_observation(obsdir,
                                                'mf/SMF/GAMAII_BBD_GSMFs.dat',
                                                [0, 1, 2, 3])
    xobs = lm
    indx = np.where(p > 0)
    yobs = np.log10(p[indx])
    ydn = yobs - np.log10(p[indx] - dpdn[indx])
    yup = np.log10(p[indx] + dpup[indx]) - yobs
    z0obs.append((observation("Wright+2017",
                              xobs[indx],
                              yobs,
                              ydn,
                              yup,
                              err_absolute=False), 'o'))

    # Moustakas (Chabrier IMF), ['Moustakas+2013, several redshifts']
    zdnM13, lmM13, pM13, dp_dn_M13, dp_up_M13 = common.load_observation(
        obsdir, 'mf/SMF/SMF_Moustakas2013.dat', [0, 3, 5, 6, 7])
    xobsM13 = lmM13

    yobsM13 = np.full(xobsM13.shape, -999.)
    lerrM13 = np.full(xobsM13.shape, -999.)
    herrM13 = np.full(xobsM13.shape, 999.)
    indx = np.where(pM13 < 1)
    yobsM13[indx] = (pM13[indx])
    indx = np.where(dp_dn_M13 > 0)
    lerrM13[indx] = dp_dn_M13[indx]
    indx = np.where(dp_up_M13 > 0)
    herrM13[indx] = dp_up_M13[indx]

    # Muzzin (Kroupa IMF), ['Moustakas+2013, several redshifts']
    zdnMu13, zupMu13, lmMu13, pMu13, dp_dn_Mu13, dp_up_Mu13 = common.load_observation(
        obsdir, 'mf/SMF/SMF_Muzzin2013.dat', [0, 1, 2, 4, 5, 5])
    # -0.09 corresponds to the IMF correction
    xobsMu13 = lmMu13 - 0.09
    yobsMu13 = np.full(xobsMu13.shape, -999.)
    lerrMu13 = np.full(xobsMu13.shape, -999.)
    herrMu13 = np.full(xobsMu13.shape, 999.)
    indx = np.where(pMu13 < 1)
    yobsMu13[indx] = (pMu13[indx])
    indx = np.where(dp_dn_Mu13 > 0)
    lerrMu13[indx] = dp_dn_Mu13[indx]
    indx = np.where(dp_up_Mu13 > 0)
    herrMu13[indx] = dp_up_Mu13[indx]

    # Santini 2012 (Salpeter IMF)
    zdnS12, lmS12, pS12, dp_dn_S12, dp_up_S12 = common.load_observation(
        obsdir, 'mf/SMF/SMF_Santini2012.dat', [0, 2, 3, 4, 5])
    hobs = 0.7
    # factor 0.24 corresponds to the IMF correction.
    xobsS12 = lmS12 - 0.24 + np.log10(hobs / h0)
    yobsS12 = np.full(xobsS12.shape, -999.)
    lerrS12 = np.full(xobsS12.shape, -999.)
    herrS12 = np.full(xobsS12.shape, 999.)
    indx = np.where(pS12 < 1)
    yobsS12[indx] = (pS12[indx]) + np.log10(pow(h0 / hobs, 3.0))
    indx = np.where(dp_dn_S12 > 0)
    lerrS12[indx] = dp_dn_S12[indx]
    indx = np.where(dp_up_S12 > 0)
    herrS12[indx] = dp_up_S12[indx]

    # Wright et al. (2018, several reshifts). Assumes Chabrier IMF.
    zD17, lmD17, pD17, dp_dn_D17, dp_up_D17 = common.load_observation(
        obsdir, 'mf/SMF/Wright18_CombinedSMF.dat', [0, 1, 2, 3, 4])
    hobs = 0.7
    pD17 = pD17 - 3.0 * np.log10(hobs)
    lmD17 = lmD17 - np.log10(hobs)

    # z0.5 obs
    z05obs = []
    in_redshift = np.where(zdnM13 == 0.4)
    z05obs.append((observation("Moustakas+2013",
                               xobsM13[in_redshift],
                               yobsM13[in_redshift],
                               lerrM13[in_redshift],
                               herrM13[in_redshift],
                               err_absolute=False), 'o'))
    in_redshift = np.where(zdnMu13 == 0.5)
    z05obs.append((observation("Muzzin+2013",
                               xobsMu13[in_redshift],
                               yobsMu13[in_redshift],
                               lerrMu13[in_redshift],
                               herrMu13[in_redshift],
                               err_absolute=False), '+'))
    in_redshift = np.where(zD17 == 0.5)
    z05obs.append((observation("Wright+2018",
                               lmD17[in_redshift],
                               pD17[in_redshift],
                               dp_dn_D17[in_redshift],
                               dp_up_D17[in_redshift],
                               err_absolute=False), 'D'))

    # z1 obs
    z1obs = []
    in_redshift = np.where(zdnM13 == 0.8)
    z1obs.append((observation("Moustakas+2013",
                              xobsM13[in_redshift],
                              yobsM13[in_redshift],
                              lerrM13[in_redshift],
                              herrM13[in_redshift],
                              err_absolute=False), 'o'))
    in_redshift = np.where(zdnMu13 == 1)
    z1obs.append((observation("Muzzin+2013",
                              xobsMu13[in_redshift],
                              yobsMu13[in_redshift],
                              lerrMu13[in_redshift],
                              herrMu13[in_redshift],
                              err_absolute=False), '+'))
    in_redshift = np.where(zD17 == 1)
    z1obs.append((observation("Wright+2018",
                              lmD17[in_redshift],
                              pD17[in_redshift],
                              dp_dn_D17[in_redshift],
                              dp_up_D17[in_redshift],
                              err_absolute=False), 'D'))

    #z2 obs
    z2obs = []
    in_redshift = np.where(zupMu13 == 2.5)
    z2obs.append((observation("Muzzin+2013",
                              xobsMu13[in_redshift],
                              yobsMu13[in_redshift],
                              lerrMu13[in_redshift],
                              herrMu13[in_redshift],
                              err_absolute=False), '+'))
    in_redshift = np.where(zdnS12 == 1.8)
    z2obs.append((observation("Santini+2012",
                              xobsS12[in_redshift],
                              yobsS12[in_redshift],
                              lerrS12[in_redshift],
                              herrS12[in_redshift],
                              err_absolute=False), 'o'))
    in_redshift = np.where(zD17 == 2)
    z2obs.append((observation("Wright+2018",
                              lmD17[in_redshift],
                              pD17[in_redshift],
                              dp_dn_D17[in_redshift],
                              dp_up_D17[in_redshift],
                              err_absolute=False), 'D'))

    # z3 obs
    z3obs = []
    in_redshift = np.where(zupMu13 == 3.0)
    z3obs.append((observation("Muzzin+2013",
                              xobsMu13[in_redshift],
                              yobsMu13[in_redshift],
                              lerrMu13[in_redshift],
                              herrMu13[in_redshift],
                              err_absolute=False), '+'))
    in_redshift = np.where(zdnS12 == 2.5)
    z3obs.append((observation("Santini+2012",
                              xobsS12[in_redshift],
                              yobsS12[in_redshift],
                              lerrS12[in_redshift],
                              herrS12[in_redshift],
                              err_absolute=False), 'o'))
    in_redshift = np.where(zD17 == 3)
    z3obs.append((observation("Wright+2018",
                              lmD17[in_redshift],
                              pD17[in_redshift],
                              dp_dn_D17[in_redshift],
                              dp_up_D17[in_redshift],
                              err_absolute=False), 'D'))

    # z4 obs
    z4obs = []
    in_redshift = np.where(zupMu13 == 4.0)
    z4obs.append((observation("Muzzin+2013",
                              xobsMu13[in_redshift],
                              yobsMu13[in_redshift],
                              lerrMu13[in_redshift],
                              herrMu13[in_redshift],
                              err_absolute=False), '+'))
    in_redshift = np.where(zdnS12 == 3.5)
    z4obs.append((observation("Santini+2012",
                              xobsS12[in_redshift],
                              yobsS12[in_redshift],
                              lerrS12[in_redshift],
                              herrS12[in_redshift],
                              err_absolute=False), 'o'))
    in_redshift = np.where(zD17 == 4)
    z4obs.append((observation("Wright+2018",
                              lmD17[in_redshift],
                              pD17[in_redshift],
                              dp_dn_D17[in_redshift],
                              dp_up_D17[in_redshift],
                              err_absolute=False), 'D'))

    ########################### total stellar mass function
    xtit = "$\\rm log_{10} (\\rm M_{\\star,\\rm tot}/M_{\odot})$"
    ytit = "$\\rm log_{10}(\Phi/dlog{\\rm M_{\\star}}/{\\rm Mpc}^{-3} )$"
    xmin, xmax, ymin, ymax = 7, 12, -6, 1
    xleg = xmax - 0.2 * (xmax - xmin)
    yleg = ymax - 0.1 * (ymax - ymin)

    fig = plt.figure(figsize=(5, 10))

    idx = [0, 1, 2]

    zins = [0, 1, 2]
    subplots = [311, 312, 313]
    observations = (z0obs, z1obs, z2obs)

    for subplot, idx, z, s, obs_and_markers in zip(subplots, idx, zins, snap,
                                                   observations):
        ax = fig.add_subplot(subplot)
        if (idx == 2):
            xtitplot = xtit
        else:
            xtitplot = ' '
        common.prepare_ax(ax,
                          xmin,
                          xmax,
                          ymin,
                          ymax,
                          xtitplot,
                          ytit,
                          locators=(0.1, 1, 0.1))
        ax.text(xleg, yleg, 'z=%s' % (str(z)))

        # Observations
        for obs, marker in obs_and_markers:
            common.errorbars(ax,
                             obs.x,
                             obs.y,
                             obs.yerrdn,
                             obs.yerrup,
                             'grey',
                             marker,
                             err_absolute=obs.err_absolute,
                             label=obs.label)

        #Predicted HMF
        y = histmtot[idx, :]
        ind = np.where(y != 0.)
        if idx == 0:
            ax.plot(xmf[ind], y[ind], 'r', linestyle='solid', label='VR')
        if idx > 0:
            ax.plot(xmf[ind], y[ind], 'r', linestyle='solid')
        if idx == 0:
            cols = ['r'] + ['grey', 'grey', 'grey']
            common.prepare_legend(ax, cols)

    common.savefig(outdir, fig, "smf_tot_z_comp_obs.pdf")

    ############################# stellar mass function (30kpc aperture)
    xtit = "$\\rm log_{10} (\\rm M_{\\star,\\rm 30kpc}/M_{\odot})$"
    ytit = "$\\rm log_{10}(\Phi/dlog{\\rm M_{\\star}}/{\\rm Mpc}^{-3} )$"
    xmin, xmax, ymin, ymax = 7, 12, -6, 1
    xleg = xmax - 0.2 * (xmax - xmin)
    yleg = ymax - 0.1 * (ymax - ymin)

    fig = plt.figure(figsize=(5, 10))

    idx = [0, 1, 2]

    zins = [0, 1, 2]
    subplots = [311, 312, 313]

    for subplot, idx, z, s, obs_and_markers in zip(subplots, idx, zins, snap,
                                                   observations):
        ax = fig.add_subplot(subplot)
        if (idx == 2):
            xtitplot = xtit
        else:
            xtitplot = ' '
        common.prepare_ax(ax,
                          xmin,
                          xmax,
                          ymin,
                          ymax,
                          xtitplot,
                          ytit,
                          locators=(0.1, 1, 0.1))
        ax.text(xleg, yleg, 'z=%s' % (str(z)))

        # Observations
        for obs, marker in obs_and_markers:
            common.errorbars(ax,
                             obs.x,
                             obs.y,
                             obs.yerrdn,
                             obs.yerrup,
                             'grey',
                             marker,
                             err_absolute=obs.err_absolute,
                             label=obs.label)

        #Predicted HMF
        y = histm30[idx, :]
        ind = np.where(y != 0.)
        if idx == 0:
            ax.plot(xmf[ind], y[ind], 'r', linestyle='solid', label='VR')
        if idx > 0:
            ax.plot(xmf[ind], y[ind], 'r', linestyle='solid')
        if idx == 0:
            cols = ['r'] + ['grey', 'grey', 'grey']
            common.prepare_legend(ax, cols)
        else:
            cols = ['grey', 'grey', 'grey']
            common.prepare_legend(ax, cols)

    common.savefig(outdir, fig, "smf_30kpc_z_comp_obs.pdf")
コード例 #17
0
def plot_sizes(plt, outdir, obsdir, disk_size_cen, disk_size_sat, bulge_size, vmax_halo_gal):

    print 'sizes disk centrals'
    for i,j,p in zip(disk_size_cen[0,0,:],disk_size_cen[0,1,:],disk_size_cen[0,2,:]):
        print i,j,p
    print 'disk sizes satellites'
    for i,j,p in zip(disk_size_sat[0,0,:],disk_size_sat[0,1,:],disk_size_sat[0,2,:]):
        print i,j,p
    print 'sizes bulges'
    for i,j,p in zip(bulge_size[0,0,:],bulge_size[0,1,:],bulge_size[0,2,:]):
        print i,j,p

    rb, r16, r84 = common.load_observation(obsdir, 'Models/SharkVariations/SizeDisksAndBulges_OtherModels.dat', [0,1,2])
    
    fig = plt.figure(figsize=(5,11.5))
    xtit = "$\\rm log_{10} (\\rm M_{\\star,disk}/M_{\odot})$"
    ytit = "$\\rm log_{10} (\\rm r_{\\star,disk}/kpc)$"
    xmin, xmax, ymin, ymax = 8, 12, -0.1, 2
    xleg = xmax - 0.2 * (xmax - xmin)
    yleg = ymax - 0.1 * (ymax - ymin)

    # LTG ##################################
    ax = fig.add_subplot(311)
    common.prepare_ax(ax, xmin, xmax, ymin, ymax, xtit, ytit, locators=(0.1, 1, 0.1, 1))
    ax.text(8.1,1.7,'disks of centrals',fontsize=12)

    #Predicted size-mass for disks in disk=dominated galaxies
    ind = np.where(disk_size_cen[0,0,:] != 0)
    xplot = xmf[ind]
    yplot = disk_size_cen[0,0,ind]
    errdn = disk_size_cen[0,1,ind]
    errup = disk_size_cen[0,2,ind]
    ax.plot(xplot,yplot[0],color='b',linestyle='solid',label="ISM/stars AM transfer")
    ax.fill_between(xplot,yplot[0],yplot[0]-errdn[0], facecolor='b', alpha=0.3,interpolate=True)
    ax.fill_between(xplot,yplot[0],yplot[0]+errup[0], facecolor='b', alpha=0.3,interpolate=True)

    rdisk_am   = rb[30:59]
    rdisk_am16 = r16[30:59]
    rdisk_am84 = r84[30:59]
    ind = np.where(rdisk_am != 0)
    xplot = xmf[ind]
    yplot = rdisk_am[ind]
    errdn = rdisk_am16[ind]
    errup = rdisk_am84[ind]
    ax.plot(xplot,yplot,color='b',linestyle='dashed', label="Lagos+18")
    ax.fill_between(xplot,yplot,yplot-errdn, facecolor='b', linestyle='solid', alpha=0.4,interpolate=True)
    ax.fill_between(xplot,yplot,yplot+errup, facecolor='b', linestyle='solid', alpha=0.4,interpolate=True)

    #Lange et al. (2016)
    m,r = common.load_observation(obsdir, 'SizesAndAM/rdisk_L16.dat', [0,1])
    ax.plot(m[0:36], r[0:36], linestyle='dotted',color='k')
    ax.plot(m[38:83], r[38:83], linestyle='dotted',color='k')
    ax.plot(m[85:128], r[85:129], linestyle='dotted',color='k')

    common.prepare_legend(ax, ['b','b'], bbox_to_anchor=(0.005, 0.62))

    ax = fig.add_subplot(312)
    common.prepare_ax(ax, xmin, xmax, ymin, ymax, xtit, ytit, locators=(0.1, 1, 0.1, 1))
    ax.text(8.1,1.7,'disks of satellites',fontsize=12)

    #Predicted size-mass for disks in disk=dominated galaxies satellites
    ind = np.where(disk_size_sat[0,0,:] != 0)
    xplot = xmf[ind]
    yplot = disk_size_sat[0,0,ind]
    errdn = disk_size_sat[0,1,ind]
    errup = disk_size_sat[0,2,ind]
    ax.plot(xplot,yplot[0],color='g',linestyle='solid')
    ax.fill_between(xplot,yplot[0],yplot[0]-errdn[0], facecolor='g', alpha=0.3,interpolate=True)
    ax.fill_between(xplot,yplot[0],yplot[0]+errup[0], facecolor='g', alpha=0.3,interpolate=True)

    rdisk_am   = rb[0:29]
    rdisk_am16 = r16[0:29]
    rdisk_am84 = r84[0:29]

    ind = np.where(rdisk_am != 0)
    xplot = xmf[ind]
    yplot = rdisk_am[ind]
    errdn = rdisk_am16[ind]
    errup = rdisk_am84[ind]
    ax.plot(xplot,yplot,color='g',linestyle='dashed')
    ax.fill_between(xplot,yplot,yplot-errdn, facecolor='g', linestyle='solid', alpha=0.4,interpolate=True)
    ax.fill_between(xplot,yplot,yplot+errup, facecolor='g', linestyle='solid', alpha=0.4,interpolate=True)

    #Lange et al. (2016)
    m,r = common.load_observation(obsdir, 'SizesAndAM/rdisk_L16.dat', [0,1])
    ax.plot(m[0:36], r[0:36], linestyle='dotted',color='k',label="L16 50th, 68th, 90th")
    ax.plot(m[38:83], r[38:83], linestyle='dotted',color='k')
    ax.plot(m[85:128], r[85:129], linestyle='dotted',color='k')

    common.prepare_legend(ax, ['k'], bbox_to_anchor=(0.005, 0.67))

    # ETGs ##################################
    xtit = "$\\rm log_{10} (\\rm M_{\\star,bulge}/M_{\odot})$"
    ytit = "$\\rm log_{10} (\\rm r_{\\star,bulge}/kpc)$"
    xmin, xmax, ymin, ymax = 8, 12, -0.35, 2
    xleg = xmax - 0.2 * (xmax - xmin)
    yleg = ymax - 0.1 * (ymax - ymin)

    ax = fig.add_subplot(313)
    common.prepare_ax(ax, xmin, xmax, ymin, ymax, xtit, ytit, locators=(0.1, 1, 0.1, 1))
    ax.text(8.1,1.7,'bulges of all galaxies',fontsize=12)

    #Predicted size-mass for bulges in bulge-dominated systems
    ind = np.where(bulge_size[0,0,:] != 0)
    if(len(xmf[ind]) > 0):
        xplot = xmf[ind]
        yplot = bulge_size[0,0,ind]
        errdn = bulge_size[0,1,ind]
        errup = bulge_size[0,2,ind]
        ax.plot(xplot,yplot[0],color='r',linestyle='solid')
        ax.fill_between(xplot,yplot[0],yplot[0]-errdn[0], facecolor='r', alpha=0.3,interpolate=True)
        ax.fill_between(xplot,yplot[0],yplot[0]+errup[0], facecolor='r', alpha=0.3,interpolate=True)

    rdisk_am   = rb[60:99]
    rdisk_am16 = r16[60:99]
    rdisk_am84 = r84[60:99]

    ind = np.where(rdisk_am != 0)
    xplot = xmf[ind]
    yplot = rdisk_am[ind]
    errdn = rdisk_am16[ind]
    errup = rdisk_am84[ind]
    ax.plot(xplot,yplot,color='r',linestyle='dashed')
    ax.fill_between(xplot,yplot,yplot-errdn, facecolor='LightCoral', linestyle='solid', alpha=0.4,interpolate=True)
    ax.fill_between(xplot,yplot,yplot+errup, facecolor='LightCoral', linestyle='solid', alpha=0.4,interpolate=True)

    #Lange et al. (2016)
    m,r = common.load_observation(obsdir, 'SizesAndAM/rbulge_L16.dat', [0,1])
    ax.plot(m[0:39], r[0:39], linestyle='dotted',color='k')
    ax.plot(m[41:76], r[41:76], linestyle='dotted',color='k')
    ax.plot(m[78:115], r[78:115], linestyle='dotted',color='k')

    common.savefig(outdir, fig, 'sizes_angular_momentum_model.pdf')

    fig = plt.figure(figsize=(9.5,9.5))
    xtit = "$\\rm log_{10} (\\rm M_{\\rm halo}/M_{\odot})$"
    ytit = "$\\rm log_{10} (\\rm v_{\\rm max}/km s^{-1}$)"
    xmin, xmax, ymin, ymax = 10, 15, 1.3, 3.5
    xleg = xmax - 0.2 * (xmax - xmin)
    yleg = ymax - 0.1 * (ymax - ymin)

    subplots = (221, 222, 223, 224)
    indz = (0, 1, 2, 3)

    # choose type of selection:
    selec = 0 #all galaxies

    # LTG ##################################
    for z,s,p in zip(zlist, indz, subplots):
	    ax = fig.add_subplot(p)
	    common.prepare_ax(ax, xmin, xmax, ymin, ymax, xtit, ytit, locators=(0.1, 1, 0.1, 1))
            ax.text(xleg, yleg, 'z=%s' % str(z))

	    ind = np.where(vmax_halo_gal[s,0,:,selec] != 0)
	    xplot = xmfh[ind]
	    yplot = vmax_halo_gal[s,0,ind,selec]
	    errdn = vmax_halo_gal[s,1,ind,selec]
	    errup = vmax_halo_gal[s,2,ind,selec]
	    ax.plot(xplot,yplot[0],color='k',label="central subhalos")
	    ax.fill_between(xplot,yplot[0],yplot[0]-errdn[0], facecolor='k', alpha=0.2,interpolate=True)
	    ax.fill_between(xplot,yplot[0],yplot[0]+errup[0], facecolor='k', alpha=0.2,interpolate=True)

	    common.prepare_legend(ax, ['k'], loc=2)


    common.savefig(outdir, fig, 'vmax_vs_subhalo.pdf')
コード例 #18
0
ファイル: csed.py プロジェクト: viogp/shark
def plot_csed(plt, outdir, obsdir, h0, CSED, nbands):

    #wavelength in angstroms.
    file = obsdir+'/Models/Shark_SED_bands.dat'
    lambda_bands = np.loadtxt(file,usecols=[0],unpack=True)
    freq_bands   = c_light / (lambda_bands * 1e-10) #in Hz
    lambda_bands = np.log10(lambda_bands)

    xtit="$\\rm log_{10}(\lambda/Ang\, (rest-frame))$"
    ytit="$\\rm log_{10}(\\nu \\epsilon_{\\rm int}/ h\,W\, Mpc^{-3})$"

    fig = plt.figure(figsize=(6,13))

    subplots = (411, 412, 413, 414)
    idx = (0, 1, 2, 3)
    labels= ('z=0', 'z=0.25', 'z=0.5', 'z=1')
    obs = ('z0p05', 'z0p25', 'z0p5', 'z0p95')
    colors = ('Indigo','purple','Navy','MediumBlue','Green','MediumAquamarine','LightGreen','YellowGreen','Gold','Orange','Coral','OrangeRed','red','DarkRed','FireBrick','Crimson','IndianRed','LightCoral','Maroon','brown','Sienna','SaddleBrown','Chocolate','Peru','DarkGoldenrod','Goldenrod','SandyBrown')

    for subplot, idx in zip(subplots, idx):
        xmin, xmax, ymin, ymax = 3.0, 7.0, 30, 36
        xleg = xmin + 0.1 * (xmax-xmin)
        yleg = ymin + 0.1 * (ymax-ymin)

        ax = fig.add_subplot(subplot)
        if (idx == 3):
            xtitplot = xtit
        else:
            xtitplot = ' '
        common.prepare_ax(ax, xmin, xmax, ymin, ymax, xtitplot, ytit, locators=(1, 1, 1, 1))
        ax.text(xleg,yleg, labels[idx], fontsize=12)

        #plot observations
        file = obsdir+'/lf/CSED/CSED_Andrews17_'+obs[idx]+'.dat'
        lw,p1,p2 = np.loadtxt(file,usecols=[0,1,2],unpack=True)
        lw = np.log10(lw * 1e10) #in angstroms 
        p1 = np.log10(p1)
        p2 = np.log10(p2)
   
        xobs = np.zeros(shape = 2)
        yobs = np.zeros(shape = 2)
        for xi,ymin,ymax in zip(lw,p1,p2):
            xobs[0] = xi
            xobs[1] = xi
            yobs[0] = ymin
            yobs[1] = ymax
            ax.plot(xobs,yobs, color='grey', linestyle='solid',linewidth=5)  

        #plot model
        ax.plot(lambda_bands,np.log10(CSED[idx,4,:]*freq_bands)-np.log10(h0), 'k', linewidth=1)

        for xi,yi,c in zip(lambda_bands,np.log10(CSED[idx,4,:]*freq_bands),colors):
            ax.plot(xi,yi-np.log10(h0), 'x', markersize=6, color=c)
        ax.plot(lambda_bands,np.log10(CSED[idx,3,:]*freq_bands)-np.log10(h0), marker = 'o', mec = 'b', markersize=3, linewidth=1)
        ax.plot(lambda_bands,np.log10(CSED[idx,1,:]*freq_bands)-np.log10(h0), marker = 'd', mec = 'r', markersize=3, linewidth=1)
        ax.plot(lambda_bands,np.log10(CSED[idx,0,:]*freq_bands)-np.log10(h0), marker = 'p', mec = 'LightSalmon', markersize=3, linewidth=1)

    common.savefig(outdir, fig, "CSED_Shark.pdf")

    fig = plt.figure(figsize=(6,16))

    subplots = (511, 512, 513, 514, 515)
    idx = (0, 1, 2, 3, 4)
    labels= ('z=1.5', 'z=2', 'z=3', 'z=4', 'z=6')
    colors = ('Indigo','purple','Navy','MediumBlue','Green','MediumAquamarine','LightGreen','YellowGreen','Gold','Orange','Coral','OrangeRed','red','DarkRed','FireBrick','Crimson','IndianRed','LightCoral','Maroon','brown','Sienna','SaddleBrown','Chocolate','Peru','DarkGoldenrod','Goldenrod','SandyBrown')

    for subplot, idx in zip(subplots, idx):
        xmin, xmax, ymin, ymax = 3.0, 7.0, 30, 36
        xleg = xmin + 0.1 * (xmax-xmin)
        yleg = ymin + 0.1 * (ymax-ymin)

        ax = fig.add_subplot(subplot)
        if (idx == 4):
            xtitplot = xtit
        else:
            xtitplot = ' '
        common.prepare_ax(ax, xmin, xmax, ymin, ymax, xtitplot, ytit, locators=(1, 1, 1, 1))
        ax.text(xleg,yleg, labels[idx], fontsize=12)

        ax.plot(lambda_bands,np.log10(CSED[idx,4,:]*freq_bands)-np.log10(h0), 'k', linewidth=1)

        for xi,yi,c in zip(lambda_bands,np.log10(CSED[idx,4,:]*freq_bands),colors):
            ax.plot(xi,yi-np.log10(h0), 'x', markersize=6, color=c)
        ax.plot(lambda_bands,np.log10(CSED[idx,3,:]*freq_bands)-np.log10(h0), marker = 'o', mec = 'b', markersize=3, linewidth=1)
        ax.plot(lambda_bands,np.log10(CSED[idx,1,:]*freq_bands)-np.log10(h0), marker = 'd', mec = 'r', markersize=3, linewidth=1)
        ax.plot(lambda_bands,np.log10(CSED[idx,0,:]*freq_bands)-np.log10(h0), marker = 'p', mec = 'LightSalmon', markersize=3, linewidth=1)

    common.savefig(outdir, fig, "CSED_Shark_highz.pdf")
コード例 #19
0
def plot_specific_am_ratio(plt, outdir, obsdir, sam_ratio_halo_disk, sam_ratio_halo_gal, sam_ratio_halo_disk_gas, 
                           sam_vs_sam_halo_disk, sam_vs_sam_halo_gal, sam_vs_sam_halo_disk_gas):

    fig = plt.figure(figsize=(9.5,9.5))
    xtit = "$\\rm log_{10} (\\rm M_{\\rm halo}/M_{\odot})$"
    ytit = "$\\rm log_{10} (\\rm j_{\\star}/j_{\\rm halo}$)"
    xmin, xmax, ymin, ymax = 10, 15, -3, 1
    xleg = xmax - 0.2 * (xmax - xmin)
    yleg = ymax - 0.1 * (ymax - ymin)

    subplots = (221, 222, 223, 224)
    indz = (0, 1, 2, 3)

    # choose type of selection:
    selec = 1 #disk-dominated galaxies

    # LTG ##################################
    for z,s,p in zip(zlist, indz, subplots):
	    ax = fig.add_subplot(p)
	    common.prepare_ax(ax, xmin, xmax, ymin, ymax, xtit, ytit, locators=(0.1, 1, 0.1, 1))
            ax.text(xleg, yleg, 'z=%s' % str(z))

	    ind = np.where(sam_ratio_halo_gal[s,0,:,selec] != 0)
	    xplot = xmfh[ind]
	    yplot = sam_ratio_halo_gal[s,0,ind,selec]
	    errdn = sam_ratio_halo_gal[s,1,ind,selec]
	    errup = sam_ratio_halo_gal[s,2,ind,selec]
	    ax.plot(xplot,yplot[0],color='k',label="all stars")
	    ax.fill_between(xplot,yplot[0],yplot[0]-errdn[0], facecolor='k', alpha=0.2,interpolate=True)
	    ax.fill_between(xplot,yplot[0],yplot[0]+errup[0], facecolor='k', alpha=0.2,interpolate=True)

	    ind = np.where(sam_ratio_halo_disk[s,0,:,selec] != 0)
	    xplot = xmfh[ind]
	    yplot = sam_ratio_halo_disk[s,0,ind,selec]
	    errdn = sam_ratio_halo_disk[s,1,ind,selec]
	    errup = sam_ratio_halo_disk[s,2,ind,selec]
	    ax.plot(xplot,yplot[0],color='g',label="disk stars")
	    ax.fill_between(xplot,yplot[0],yplot[0]-errdn[0], facecolor='g', alpha=0.2,interpolate=True)
	    ax.fill_between(xplot,yplot[0],yplot[0]+errup[0], facecolor='g', alpha=0.2,interpolate=True)

	    ind = np.where(sam_ratio_halo_disk_gas[s,0,:,selec] != 0)
	    xplot = xmfh[ind]
	    yplot = sam_ratio_halo_disk_gas[s,0,ind,selec]
	    errdn = sam_ratio_halo_disk_gas[s,1,ind,selec]
	    errup = sam_ratio_halo_disk_gas[s,2,ind,selec]
	    ax.plot(xplot,yplot[0],color='b',label="disk gas")
	    ax.fill_between(xplot,yplot[0],yplot[0]-errdn[0], facecolor='b', alpha=0.2,interpolate=True)
	    ax.fill_between(xplot,yplot[0],yplot[0]+errup[0], facecolor='b', alpha=0.2,interpolate=True)

	    common.prepare_legend(ax, ['k'], loc=2)


    common.savefig(outdir, fig, 'specific_am_ratio.pdf')

    selec = 0 #disk-dominated galaxies

    #plot specific AM vs. specific AM 
    fig = plt.figure(figsize=(9,8))
    xtit = "$\\rm log_{10} (\\rm j_{\\rm halo}/kpc\,km\,s^{-1})$"
    ytit = "$\\rm log_{10} (\\rm j_{\\star},j_{\\star,disk},j_{\\rm gas,disk}/kpc\,km\,s^{-1}$)"
    xmin, xmax, ymin, ymax = 1,6,1,6
    xleg = xmax - 0.2 * (xmax - xmin)
    yleg = ymax - 0.1 * (ymax - ymin)

    subplots = (221, 222, 223, 224)
    indz = (0, 1, 2, 3)
    zinplot = (0, 0.5, 1, 2) 

    # LTG ##################################
    for z,s,p in zip(zinplot, indz, subplots):
	    ax = fig.add_subplot(p)
	    common.prepare_ax(ax, xmin, xmax, ymin, ymax, xtit, ytit, locators=(0.1, 1, 0.1, 1))
            ax.text(xleg, yleg, 'z=%s' % str(z), fontsize=10)
            #if(s == 0):
            #    ax.text(5.5,6.4,'Lagos+18',fontsize=14)

	    ind = np.where(sam_vs_sam_halo_gal[s,0,:,selec] != 0)
	    xplot = xlf[ind]+3
	    yplot = sam_vs_sam_halo_gal[s,0,ind,selec]+3
	    errdn = sam_vs_sam_halo_gal[s,1,ind,selec]
	    errup = sam_vs_sam_halo_gal[s,2,ind,selec]
	    ax.plot(xplot,yplot[0],color='k',label="all stars")
	    ax.fill_between(xplot,yplot[0],yplot[0]-errdn[0], facecolor='k', alpha=0.2,interpolate=True)
	    ax.fill_between(xplot,yplot[0],yplot[0]+errup[0], facecolor='k', alpha=0.2,interpolate=True)

	    ind = np.where(sam_vs_sam_halo_disk[s,0,:,selec] != 0)
	    xplot = xlf[ind]+3
	    yplot = sam_vs_sam_halo_disk[s,0,ind,selec]+3
	    errdn = sam_vs_sam_halo_disk[s,1,ind,selec]
	    errup = sam_vs_sam_halo_disk[s,2,ind,selec]
	    ax.plot(xplot,yplot[0],color='g',label="disk stars")
	    ax.fill_between(xplot,yplot[0],yplot[0]-errdn[0], facecolor='g', alpha=0.2,interpolate=True)
	    ax.fill_between(xplot,yplot[0],yplot[0]+errup[0], facecolor='g', alpha=0.2,interpolate=True)

	    ind = np.where(sam_vs_sam_halo_disk_gas[s,0,:,selec] != 0)
	    xplot = xlf[ind]+3
	    yplot = sam_vs_sam_halo_disk_gas[s,0,ind,selec]+3
	    errdn = sam_vs_sam_halo_disk_gas[s,1,ind,selec]
	    errup = sam_vs_sam_halo_disk_gas[s,2,ind,selec]
	    ax.plot(xplot,yplot[0],color='b',label="disk gas")
	    ax.fill_between(xplot,yplot[0],yplot[0]-errdn[0], facecolor='b', alpha=0.2,interpolate=True)
	    ax.fill_between(xplot,yplot[0],yplot[0]+errup[0], facecolor='b', alpha=0.2,interpolate=True)

            xplot = [1,5]
            ax.plot(xplot,xplot,color='grey',linestyle='dotted')
            if(s == 0):
               common.prepare_legend(ax, ['k','g','b'], loc=2)

    common.savefig(outdir, fig, 'specific_am_halo_vs_galaxy.pdf')
 
    selec = 0 #all galaxies

    #plot specific AM vs. specific AM 
    fig = plt.figure(figsize=(5,5))
    xtit = "$\\rm log_{10} (\\rm j_{\\rm halo}/kpc\,km\,s^{-1})$"
    ytit = "$\\rm log_{10} (\\rm j_{\\star},j_{\\star,disk},j_{\\rm gas,disk}/kpc\,km\,s^{-1}$)"
    xmin, xmax, ymin, ymax = 1,6,1,6
    xleg = xmax - 0.2 * (xmax - xmin)
    yleg = ymax - 0.1 * (ymax - ymin)

    s = 0
    # LTG ##################################
    ax = fig.add_subplot(111)
    common.prepare_ax(ax, xmin, xmax, ymin, ymax, xtit, ytit, locators=(0.1, 1, 0.1, 1))
    ax.text(xleg, yleg, 'z=0', fontsize=10)
    #if(s == 0):
    #    ax.text(5.5,6.4,'Lagos+18',fontsize=14)
    
    ind = np.where(sam_vs_sam_halo_gal[s,0,:,selec] != 0)
    xplot = xlf[ind]+3
    yplot = sam_vs_sam_halo_gal[s,0,ind,selec]+3
    errdn = sam_vs_sam_halo_gal[s,1,ind,selec]
    errup = sam_vs_sam_halo_gal[s,2,ind,selec]
    ax.plot(xplot,yplot[0],color='k',label="all stars")
    ax.fill_between(xplot,yplot[0],yplot[0]-errdn[0], facecolor='k', alpha=0.2,interpolate=True)
    ax.fill_between(xplot,yplot[0],yplot[0]+errup[0], facecolor='k', alpha=0.2,interpolate=True)

    ind = np.where(sam_vs_sam_halo_disk[s,0,:,selec] != 0)
    xplot = xlf[ind]+3
    yplot = sam_vs_sam_halo_disk[s,0,ind,selec]+3
    errdn = sam_vs_sam_halo_disk[s,1,ind,selec]
    errup = sam_vs_sam_halo_disk[s,2,ind,selec]
    ax.plot(xplot,yplot[0],color='g',label="disk stars")
    ax.fill_between(xplot,yplot[0],yplot[0]-errdn[0], facecolor='g', alpha=0.2,interpolate=True)
    ax.fill_between(xplot,yplot[0],yplot[0]+errup[0], facecolor='g', alpha=0.2,interpolate=True)

    ind = np.where(sam_vs_sam_halo_disk_gas[s,0,:,selec] != 0)
    xplot = xlf[ind]+3
    yplot = sam_vs_sam_halo_disk_gas[s,0,ind,selec]+3
    errdn = sam_vs_sam_halo_disk_gas[s,1,ind,selec]
    errup = sam_vs_sam_halo_disk_gas[s,2,ind,selec]
    ax.plot(xplot,yplot[0],color='b',label="disk gas")
    ax.fill_between(xplot,yplot[0],yplot[0]-errdn[0], facecolor='b', alpha=0.2,interpolate=True)
    ax.fill_between(xplot,yplot[0],yplot[0]+errup[0], facecolor='b', alpha=0.2,interpolate=True)

    xplot = [1,5]
    ax.plot(xplot,xplot,color='grey',linestyle='dotted')
    common.prepare_legend(ax, ['k','g','b'], loc=2)

    common.savefig(outdir, fig, 'specific_am_halo_vs_galaxy_z0.pdf')
コード例 #20
0
ファイル: smhm.py プロジェクト: viogp/shark
def plot_BMHM_z(plt, outdir, massbar, massbar_inside):

    fig = plt.figure(figsize=(5, 6))
    xtit = ""
    ytit = ""
    xmin, xmax, ymin, ymax = 10, 15, -1, 1
    xleg = xmax - 0.2 * (xmax - xmin)
    yleg = ymin + 0.15 * (ymax - ymin)

    ax = fig.add_subplot(311)
    plt.subplots_adjust(left=0.17)

    common.prepare_ax(ax,
                      xmin,
                      xmax,
                      ymin,
                      ymax,
                      xtit,
                      ytit,
                      locators=(0.1, 1, 0.1))
    ax.text(xleg, yleg, 'z=0')

    #Predicted SMHM
    ind = np.where(massbar[0, 0, :] != 0)
    xplot = xmf[ind]
    yplot = massbar[0, 0, ind]
    errdn = massbar[0, 1, ind]
    errup = massbar[0, 2, ind]

    ax.errorbar(xplot, yplot[0], color='k', label="all baryons")
    ax.errorbar(xplot,
                yplot[0],
                yerr=[errdn[0], errup[0]],
                ls='None',
                mfc='None',
                ecolor='k',
                mec='k',
                marker='+',
                markersize=2)

    ind = np.where(massbar_inside[0, 0, :] != 0)
    xplot = xmf[ind]
    yplot = massbar_inside[0, 0, ind]
    errdn = massbar_inside[0, 1, ind]
    errup = massbar_inside[0, 2, ind]

    ax.plot(xplot,
            yplot[0],
            color='b',
            linestyle='dotted',
            label="inside halos")

    xline = [10.0, 15.0]
    yline = [0.0, 0.0]
    ax.plot(xline, yline, 'r', linestyle='dashed')

    common.prepare_legend(ax, ['b', 'k'], loc=2)

    # z=0.5 ##################################
    #ax = fig.add_subplot(222)
    #common.prepare_ax(ax, xmin, xmax, ymin, ymax, xtit, ytit, locators=(0.1, 1, 0.1))
    #ax.text(xleg,yleg, 'z=0.5')

    #Predicted SMHM
    #ind = np.where(massbar[1,0,:] != 0)
    #xplot = xmf[ind]
    #yplot = massbar[1,0,ind]
    #errdn = massbar[1,1,ind]
    #errup = massbar[1,2,ind]

    #ax.errorbar(xplot,yplot[0],color='k', label="Shark")
    #ax.errorbar(xplot,yplot[0],yerr=[errdn[0],errup[0]], ls='None', mfc='None', ecolor = 'k', mec='k',marker='+',markersize=2)

    #ax.plot(xmf,xmf,'r', linestyle='dashed')

    # z=1 ##################################
    ax = fig.add_subplot(312)
    xtit = ""
    ytit = "$\\rm log_{10} (\\rm M_{\\rm bar}(\\Omega_{\\rm DM}/\\Omega_{\\rm b})/\\rm M_{\\rm halo, DM})$"

    common.prepare_ax(ax,
                      xmin,
                      xmax,
                      ymin,
                      ymax,
                      xtit,
                      ytit,
                      locators=(0.1, 1, 0.1))
    ax.text(xleg, yleg, 'z=1')

    # Predicted SMHM
    ind = np.where(massbar[2, 0, :] != 0)
    xplot = xmf[ind]
    yplot = massbar[2, 0, ind]
    errdn = massbar[2, 1, ind]
    errup = massbar[2, 2, ind]

    ax.errorbar(xplot, yplot[0], color='k', label="Shark")
    ax.errorbar(xplot,
                yplot[0],
                yerr=[errdn[0], errup[0]],
                ls='None',
                mfc='None',
                ecolor='k',
                mec='k',
                marker='+',
                markersize=2)

    ind = np.where(massbar_inside[2, 0, :] != 0)
    xplot = xmf[ind]
    yplot = massbar_inside[2, 0, ind]
    errdn = massbar_inside[2, 1, ind]
    errup = massbar_inside[2, 2, ind]

    ax.plot(xplot, yplot[0], color='b', linestyle='dotted')

    ax.plot(xline, yline, 'r', linestyle='dashed')

    # z=1 ##################################
    ax = fig.add_subplot(313)
    xtit = "$\\rm log_{10} (\\rm M_{\\rm halo, DM}/M_{\odot})$"
    ytit = ""

    common.prepare_ax(ax,
                      xmin,
                      xmax,
                      ymin,
                      ymax,
                      xtit,
                      ytit,
                      locators=(0.1, 1, 0.1))
    ax.text(xleg, yleg, 'z=2')

    #Predicted SMHM
    ind = np.where(massbar[3, 0, :] != 0)
    xplot = xmf[ind]
    yplot = massbar[3, 0, ind]
    errdn = massbar[3, 1, ind]
    errup = massbar[3, 2, ind]

    ax.errorbar(xplot, yplot[0], color='k', label="Shark")
    ax.errorbar(xplot,
                yplot[0],
                yerr=[errdn[0], errup[0]],
                ls='None',
                mfc='None',
                ecolor='k',
                mec='k',
                marker='+',
                markersize=2)

    ind = np.where(massbar_inside[3, 0, :] != 0)
    xplot = xmf[ind]
    yplot = massbar_inside[3, 0, ind]
    errdn = massbar_inside[3, 1, ind]
    errup = massbar_inside[3, 2, ind]

    ax.plot(xplot, yplot[0], color='b', linestyle='dotted')

    ax.plot(xline, yline, 'r', linestyle='dashed')

    common.savefig(outdir, fig, 'BMHM_z.pdf')
コード例 #21
0
def plot_halomf_z(plt, outdir, obsdir, z, h0, hist, histsh, plotz):

    xtit = "$\\rm log_{10} (\\rm M_{\\rm halo}/M_{\odot})$"
    ytit = "$\\rm log_{10}(\Phi/dlog{\\rm M_{\\rm halo}}/{\\rm Mpc}^{-3} )$"
    xmin, xmax, ymin, ymax = 10.1, 15, -6, -1
    xleg = xmax - 0.2 * (xmax - xmin)
    yleg = ymax - 0.1 * (ymax - ymin)

    fig = plt.figure(figsize=(7, 7))

    subplots = (221, 222, 223, 224)
    idx = (0, 1, 2, 3)
    for subplot, idx, z, plot_this_z in zip(subplots, idx, z, plotz):

        ax = fig.add_subplot(subplot)
        if (idx == 0 or idx == 2):
            ytitplot = ytit
        else:
            ytitplot = ' '
        common.prepare_ax(ax,
                          xmin,
                          xmax,
                          ymin,
                          ymax,
                          xtit,
                          ytitplot,
                          locators=(0.1, 1, 0.1))
        ax.text(xleg, yleg, 'z=%s' % (str(z)))

        #HMF calc HMF calculated by Sheth & Tormen (2001)
        lmp, dp = common.load_observation(
            obsdir,
            'mf/HMF/mVector_PLANCK-SMT_z%s.dat' % str(z).replace('.', ''),
            [0, 7])
        lmp_plot = np.log10(lmp) - np.log10(h0)
        dp_plot = np.log10(dp) + np.log10(pow(h0, 3.))
        if idx == 0:
            ax.plot(lmp_plot, dp_plot, 'b', label='HMF calc')
        elif idx > 0:
            ax.plot(lmp_plot, dp_plot, 'b')

        #Predicted HMF
        if plot_this_z:
            y = hist[idx, :]
            ind = np.where(y < 0.)
            if idx == 0:
                ax.plot(xmf[ind], y[ind], 'r', label='HMF Shark')
            if idx > 0:
                ax.plot(xmf[ind], y[ind], 'r')
            y = histsh[idx, :]
            ind = np.where(y < 0.)
            if idx == 0:
                ax.plot(xmf[ind],
                        y[ind],
                        'r',
                        linestyle='dashed',
                        label='SHMF Shark')
            if idx > 0:
                ax.plot(xmf[ind], y[ind], 'r', linestyle='dashed')

        if idx == 0:
            common.prepare_legend(ax, ['b', 'r', 'r'])

    common.savefig(outdir, fig, "halomf_z.pdf")

    xtit = "$\\rm log_{10}(\\rm M/M_{\odot})$"
    ytit = "$\\rm log_{10}(\Phi/dlog{\\rm M}/{\\rm Mpc}^{-3})$"
    xmin, xmax, ymin, ymax = 8, 15, -6, 1.2
    xleg = xmax - 0.2 * (xmax - xmin)
    yleg = ymax - 0.1 * (ymax - ymin)

    fig = plt.figure(figsize=(5, 5))

    idx = 0
    ax = fig.add_subplot(111)
    ytitplot = ytit
    common.prepare_ax(ax,
                      xmin,
                      xmax,
                      ymin,
                      ymax,
                      xtit,
                      ytitplot,
                      locators=(0.1, 1, 0.1))

    #lmp, dp = common.load_observation(obsdir, 'mf/HMF/mVector_PLANCK-SMT_z0_extended.dat', [0, 7])
    #lmp_plot = np.log10(lmp) - np.log10(h0)
    #dp_plot = np.log10(dp) + np.log10(pow(h0,3.))
    #ax.plot(lmp_plot,dp_plot,'k')
    #ax.plot(lmp_plot+np.log10(fb),dp_plot,'b', linestyle='dashed')

    y = hist[idx, :]
    ind = np.where((y < 0.) & (xmf > 10.3))
    ax.plot(xmf[ind], y[ind], 'k')
    ax.plot(xmf[ind] + np.log10(fb), y[ind], 'b', linestyle='dashed')

    lm, p, dpdn, dpup = common.load_observation(obsdir,
                                                'mf/SMF/GAMAII_BBD_GSMFs.dat',
                                                [0, 1, 2, 3])
    xobs = lm
    indx = np.where(p > 0)
    yobs = np.log10(p[indx])
    ydn = yobs - np.log10(p[indx] - dpdn[indx])
    yup = np.log10(p[indx] + dpup[indx]) - yobs
    ax.errorbar(xobs[indx], yobs, ydn, yup, 'ro', label='Wright+17')

    smfdensity = common.load_observation(
        obsdir, 'Models/SharkVariations/SMF_FeedbackExperiment.dat', [0])
    ynofeed = smfdensity[0:len(xsmf) - 1]
    yreio = smfdensity[len(xsmf):2 * len(xsmf) - 1]
    ystarf = smfdensity[2 * len(xsmf):3 * len(xsmf) - 1]
    yfinal = smfdensity[3 * len(xsmf):4 * len(xsmf) - 1]

    ind = np.where(ynofeed != 0)
    ax.plot(xsmf[ind], ynofeed[ind], 'DarkRed')
    ind = np.where(ystarf != 0)
    ax.plot(xsmf[ind], ystarf[ind], 'LightCoral')
    ind = np.where(yfinal != 0)
    ax.plot(xsmf[ind], yfinal[ind], 'Orange')

    common.prepare_legend(ax, ['r'])

    common.savefig(outdir, fig, "halomf_z0.pdf")
コード例 #22
0
ファイル: smhm.py プロジェクト: viogp/shark
def plot_SMHM_z(plt, outdir, z, massgal):

    fig = plt.figure(figsize=(9.7, 11.7))
    xtit = "$\\rm log_{10} (\\rm M_{\\rm halo, DM}/M_{\odot})$"
    ytit = "$\\rm log_{10} (\\rm M_{\\star}/M_{\odot})$"
    xmin, xmax, ymin, ymax = 10.5, 15, 7, 13
    xleg = xmin + 0.2 * (xmax - xmin)
    yleg = ymax - 0.1 * (ymax - ymin)

    #Moster et al. (2013) abundance matching SMHM relation
    M10 = 11.590
    M11 = 1.195
    N10 = 0.0351
    N11 = -0.0247
    beta10 = 1.376
    beta11 = -0.826
    gamma10 = 0.608
    gamma11 = 0.329

    subplots = (321, 322, 323, 324, 325, 326)
    all_labels = (('Shark', 'Moster+13', 'Behroozi+13'), )

    for i, (z, subplot) in enumerate(zip(z, subplots)):
        labels = all_labels[0]

        # z=0 ##################################
        ax = fig.add_subplot(subplot)
        common.prepare_ax(ax,
                          xmin,
                          xmax,
                          ymin,
                          ymax,
                          xtit,
                          ytit,
                          locators=(0.1, 1, 0.1))

        ax.tick_params(labelsize=13)
        ax.text(xleg, yleg, 'z=%s' % str(z))

        #Predicted SMHM
        ind = np.where(massgal[i, 0, :] != 0)
        xplot = xmf[ind]
        yplot = massgal[i, 0, ind]
        errdn = massgal[i, 1, ind]
        errup = massgal[i, 2, ind]

        if not labels:
            ax.errorbar(xplot, yplot[0], color='k')
            ax.fill_between(xplot,
                            yplot[0],
                            yplot[0] - errdn[0],
                            facecolor='grey',
                            interpolate=True)
            ax.fill_between(xplot,
                            yplot[0],
                            yplot[0] + errup[0],
                            facecolor='grey',
                            interpolate=True)
        else:
            ax.errorbar(xplot, yplot[0], color='k', label=labels[0])
            ax.fill_between(xplot,
                            yplot[0],
                            yplot[0] - errdn[0],
                            facecolor='grey',
                            interpolate=True)
            ax.fill_between(xplot,
                            yplot[0],
                            yplot[0] + errup[0],
                            facecolor='grey',
                            interpolate=True)

        M1 = pow(10.0, M10 + M11 * z / (z + 1))
        N = N10 + N11 * z / (z + 1)
        beta = beta10 + beta11 * z / (z + 1)
        gamma = gamma10 + gamma11 * z / (z + 1)

        mh = pow(10.0, xmf)
        m = mh * 2 * N * pow((pow(mh / M1, -beta) + pow(mh / M1, gamma)), -1)

        if not labels:
            ax.plot(xmf, np.log10(m), 'r', linestyle='dashed', linewidth=3)
        else:
            ax.plot(xmf,
                    np.log10(m),
                    'r',
                    linestyle='dashed',
                    linewidth=3,
                    label=labels[1])

        a = 1.0 / (1.0 + z)
        nu = np.exp(-4 * a * a)
        log_epsilon = -1.777 + (-0.006 * (a - 1)) * nu
        M1 = 11.514 + (-1.793 * (a - 1) - 0.251 * z) * nu
        alpha = -1.412 + 0.731 * nu * (a - 1)
        delta = 3.508 + (2.608 * (a - 1) - 0.043 * z) * nu
        gamma = 0.316 + (1.319 * (a - 1) + 0.279 * z) * nu
        Min = xmf - M1
        fx = -np.log10(pow(10, alpha * Min) + 1.0) + delta * pow(
            np.log10(1 + np.exp(Min)), gamma) / (1 + np.exp(pow(10, -Min)))
        f = -0.3 + delta * pow(np.log10(2.0), gamma) / (1 + np.exp(1))

        m = log_epsilon + M1 + fx - f

        if not labels:
            ax.plot(xmf, m, 'b', linestyle='dashdot', linewidth=3)
        else:
            ax.plot(xmf,
                    m,
                    'b',
                    linestyle='dashdot',
                    linewidth=3,
                    label=labels[2])

        if labels:
            common.prepare_legend(ax, ['r', 'b', 'k'], loc=4)

    common.savefig(outdir, fig, 'SMHM_z.pdf')
コード例 #23
0
def plot_rivmax_vmax_z(plt, outdir, rvmax, hist, snap, vol_eagle):

    bin_it = functools.partial(us.wmedians, xbins=xvf)

    xtit="$\\rm log_{10} (\\rm V_{\\rm max}/km s^{-1})$"
    ytit="$\\rm log_{10}(\\rm R_{\\rm V_{max}}/pMpc)$"
    xmin, xmax, ymin, ymax = 1, 3.2, -3, 1
    xleg = xmax - 0.2 * (xmax-xmin)
    yleg = ymax - 0.1 * (ymax-ymin)

    fig = plt.figure(figsize=(5,10))

    idx = [0,1,2]

    zins = [0, 1, 2]
    subplots = [311, 312, 313]

    sn, subgn, rvs, vs = common.load_observation('/fred/oz009/clagos/EAGLE/L0025N0376/REFERENCE/data/', 'SUBFIND-EAGLE-DATABASE.data', [2, 1, 18, 19])

    for subplot, idx, z, s in zip(subplots, idx, zins, snap):
          ax = fig.add_subplot(subplot)
          if (idx == 2):
              xtitplot = xtit
          else:
              xtitplot = ' '
          common.prepare_ax(ax, xmin, xmax, ymin, ymax, xtitplot, ytit, locators=(0.1, 1, 0.1))
          ax.text(xleg,yleg, 'z=%s' % (str(z)))
  
          #HMF from SUBFIND
          ind = np.where((rvs > 0) & (subgn == 0) & (sn == s) & (vs> 0))
          rplot = bin_it(x= np.log10(vs[ind]), y = np.log10(rvs[ind])-3.0)
 
          ind = np.where((rvs > 0) & (subgn > 0) & (sn == s) & (vs> 0))
          rplotsubh = bin_it(x= np.log10(vs[ind]), y = np.log10(rvs[ind])-3.0)

          ind = np.where(rplot[0,:] != 0.)
          xplot = xvf[ind]
          yplot = rplot[0,ind]
          errdn = rplot[1,ind]
          errup = rplot[2,ind]

          if idx == 0:
              ax.plot(xplot,yplot[0],'b', linestyle='solid', label ='SF hosts')
          if idx > 0:
              ax.plot(xplot,yplot[0],'b', linestyle='solid')
          ax.fill_between(xplot,yplot[0],yplot[0]-errdn[0], facecolor='b', alpha=0.2,interpolate=True)
          ax.fill_between(xplot,yplot[0],yplot[0]+errup[0], facecolor='b', alpha=0.2,interpolate=True)

          ind = np.where(rplotsubh[0,:] != 0.)
          xplot = xvf[ind]
          yplot = rplotsubh[0,ind]
          errdn = rplotsubh[1,ind]
          errup = rplotsubh[2,ind]

          if idx == 0:
              ax.plot(xplot,yplot[0],'b', linestyle='dashed', label ='SF subh')
          if idx > 0:
              ax.plot(xplot,yplot[0],'b', linestyle='dashed')

          #Predicted HMF
          ind = np.where(rvmax[0,idx,0,:] != 0.)
          xplot = xvf[ind]
          yplot = rvmax[0,idx,0,ind]
          errdn = rvmax[0,idx,1,ind]
          errup = rvmax[0,idx,2,ind]

          if idx == 0:
              ax.plot(xplot,yplot[0],'r', label ='VR hosts')
          if idx > 0:
              ax.plot(xplot,yplot[0],'r')
          ax.fill_between(xplot,yplot[0],yplot[0]-errdn[0], facecolor='r', alpha=0.2,interpolate=True)
          ax.fill_between(xplot,yplot[0],yplot[0]+errup[0], facecolor='r', alpha=0.2,interpolate=True)

          ind = np.where(rvmax[1,idx,0,:] != 0.)
          xplot = xvf[ind]
          yplot = rvmax[1,idx,0,ind]
          errdn = rvmax[1,idx,1,ind]
          errup = rvmax[1,idx,2,ind]

          if idx == 0:
              ax.plot(xplot,yplot[0],'r', linestyle='dashed', label ='VR subh')
          if idx > 0:
              ax.plot(xplot,yplot[0],'r', linestyle='dashed')

          if idx == 0:
              common.prepare_legend(ax, ['b','b','r','r'], loc='upper left')

    common.savefig(outdir, fig, "rvmax_vmax_z.pdf")

    xtit="$\\rm log_{10} (\\rm V_{\\rm max}/km s^{-1})$"
    ytit="$\\rm log_{10}(\Phi/dlog{\\rm M_{\\rm halo}}/{\\rm Mpc}^{-3} )$"
    xmin, xmax, ymin, ymax = 1, 3.2, -6, 1
    xleg = xmax - 0.2 * (xmax-xmin)
    yleg = ymax - 0.1 * (ymax-ymin)

    fig = plt.figure(figsize=(5,10))

    idx = [0,1,2]

    zins = [0, 1, 2]
    subplots = [311, 312, 313]

    for subplot, idx, z, s in zip(subplots, idx, zins, snap):
          ax = fig.add_subplot(subplot)
          if (idx == 2):
              xtitplot = xtit
          else:
              xtitplot = ' '
          common.prepare_ax(ax, xmin, xmax, ymin, ymax, xtitplot, ytit, locators=(0.1, 1, 0.1))
          ax.text(xleg,yleg, 'z=%s' % (str(z)))
  
          #HMF from SUBFIND
          ind = np.where((rvs > 0) & (subgn == 0) & (sn == s) & (vs> 0))
          H, bins_edges = np.histogram(np.log10(vs[ind]),bins=np.append(vbins,vupp))
          histsvh = H
          ind = np.where((rvs > 0) & (subgn > 0) & (sn == s) & (vs> 0))
          H, bins_edges = np.histogram(np.log10(vs[ind]),bins=np.append(vbins,vupp))
          histsvsubh =  H
  
          y = histsvh[:]
          ind = np.where(y != 0.)
          if idx == 0:
              ax.plot(xvf[ind],np.log10(y[ind]/vol_eagle/dm),'g', label ='EAGLE L25 SF hosts')
          if idx > 0:
              ax.plot(xvf[ind],np.log10(y[ind]/vol_eagle/dm),'g')
  
          y = histsvsubh[:]
          ind = np.where(y != 0.)
          if idx == 0:
              ax.plot(xvf[ind],np.log10(y[ind]/vol_eagle/dm),'g', linestyle='dashed', label ='SF subh')
          if idx > 0:
              ax.plot(xvf[ind],np.log10(y[ind]/vol_eagle/dm),'g', linestyle='dashed')
 
          #Predicted HMF
          y = hist[0,idx,:]
          ind = np.where(y != 0.)
          if idx == 0:
              ax.plot(xvf[ind],y[ind],'r', linestyle='solid', label ='VR hosts')
          if idx > 0:
              ax.plot(xvf[ind],y[ind],'r', linestyle='solid')
          y = hist[1,idx,:]
          ind = np.where(y != 0.)
          if idx == 0:
              ax.plot(xvf[ind],y[ind],'r',  linestyle='dashed', label ='VR subh')
          if idx > 0:
              ax.plot(xvf[ind],y[ind],'r',  linestyle='dashed')
  
          if idx == 0:
              common.prepare_legend(ax, ['g','g','r','r'])

    common.savefig(outdir, fig, "vmaxf_z.pdf")
コード例 #24
0
ファイル: resolve_comparison.py プロジェクト: viogp/shark
def plot_bt_resolve(plt, outdir, obsdir, ETGsmhalo, LTGsmhalo):

    resolve_obs_as_errorbars = functools.partial(_resolve_obs_as_errorbars,
                                                 obsdir)

    fig = plt.figure(figsize=(5, 9))
    xtit = "$\\rm log_{10} (\\rm M_{\\rm halo}/M_{\odot})$"
    ytit = "$\\rm frequency$"
    xmin, xmax, ymin, ymax = 11.5, 15, -0.05, 1.05
    xleg = xmax - 0.5 * (xmax - xmin)
    yleg = ymax - 0.1 * (ymax - ymin)

    # LTG ##################################
    ax = fig.add_subplot(311)
    common.prepare_ax(ax,
                      xmin,
                      xmax,
                      ymin,
                      ymax,
                      xtit=None,
                      ytit=ytit,
                      locators=(0.1, 1, 0.1, 1))
    ax.text(xleg, yleg, '$\\rm all\, masses$')

    #Predicted size-mass for disks
    ind = np.where(ETGsmhalo[0, :] >= 0)
    xplot = xmf[ind]
    yplot = ETGsmhalo[0, ind]
    ax.plot(xplot, yplot[0], 'r', label='SHArk ETGs')

    ind = np.where(LTGsmhalo[0, :] >= 0)
    xplot = xmf[ind]
    yplot = LTGsmhalo[0, ind]
    ax.plot(xplot, yplot[0], 'b', linestyle='dashed', label='SHArk LTGs')

    #Baldry (Chabrier IMF), ['Baldry+2012, z<0.06']
    resolve_obs_as_errorbars(ax,
                             'ETall_frac.txt', [0, 1, 2, 3],
                             'r',
                             'o',
                             err_absolute=False,
                             label='RESOLVE/ECO ETGs')
    resolve_obs_as_errorbars(ax,
                             'LTall_frac.txt', [0, 1, 2, 3],
                             'b',
                             's',
                             err_absolute=False,
                             label='RESOLVE/ECO LTGs')

    common.prepare_legend(ax, ['r', 'b', 'r', 'b'],
                          loc=2,
                          bbox_to_anchor=(0.0, 1.45))

    # LTG ##################################
    ax = fig.add_subplot(312)
    common.prepare_ax(ax,
                      xmin,
                      xmax,
                      ymin,
                      ymax,
                      xtit=None,
                      ytit=ytit,
                      locators=(0.1, 1, 0.1, 1))
    ax.text(xleg, yleg, '$M^{\\prime}_{\\rm bar}/M_{\odot} > 10^{10}$')

    #Predicted size-mass for disks
    ind = np.where(ETGsmhalo[1, :] >= 0)
    xplot = xmf[ind]
    yplot = ETGsmhalo[1, ind]
    ax.plot(xplot, yplot[0], 'r')

    ind = np.where(LTGsmhalo[1, :] >= 0)
    xplot = xmf[ind]
    yplot = LTGsmhalo[1, ind]
    ax.plot(xplot, yplot[0], 'b', linestyle='dashed')

    #Baldry (Chabrier IMF), ['Baldry+2012, z<0.06']
    resolve_obs_as_errorbars(ax,
                             'EThimbary_frac.txt', [0, 1, 2, 3],
                             'r',
                             'o',
                             err_absolute=False)
    resolve_obs_as_errorbars(ax,
                             'LThimbary_frac.txt', [0, 1, 2, 3],
                             'b',
                             's',
                             err_absolute=False)

    # LTG ##################################
    ax = fig.add_subplot(313)
    common.prepare_ax(ax,
                      xmin,
                      xmax,
                      ymin,
                      ymax,
                      xtit,
                      ytit,
                      locators=(0.1, 1, 0.1, 1))
    ax.text(xleg, yleg, '$M^{\\prime}_{\\rm bar}/M_{\odot} < 10^{10}$')

    #Predicted size-mass for disks
    ind = np.where(ETGsmhalo[2, :] >= 0)
    xplot = xmf[ind]
    yplot = ETGsmhalo[2, ind]
    ax.plot(xplot, yplot[0], 'r')

    ind = np.where(LTGsmhalo[2, :] >= 0)
    xplot = xmf[ind]
    yplot = LTGsmhalo[2, ind]
    ax.plot(xplot, yplot[0], 'b', linestyle='dashed')

    #Baldry (Chabrier IMF), ['Baldry+2012, z<0.06']
    resolve_obs_as_errorbars(ax,
                             'ETlowmbary_frac.txt', [0, 1, 2, 3],
                             'r',
                             'o',
                             err_absolute=False)
    resolve_obs_as_errorbars(ax,
                             'LTlowmbary_frac.txt', [0, 1, 2, 3],
                             'b',
                             's',
                             err_absolute=False)

    common.savefig(outdir, fig, 'bt_resolve.pdf')
コード例 #25
0
def plot_halomf_z(plt, outdir, obs_dir, snap, vol_eagle, hist, histsh):

    xtit="$\\rm log_{10} (\\rm M_{\\rm halo}/M_{\odot})$"
    ytit="$\\rm log_{10}(\Phi/dlog{\\rm M_{\\rm halo}}/{\\rm Mpc}^{-3} )$"
    xmin, xmax, ymin, ymax = 8, 14, -6, 1
    xleg = xmax - 0.2 * (xmax-xmin)
    yleg = ymax - 0.1 * (ymax-ymin)

    fig = plt.figure(figsize=(5,10))

    idx = [0,1,2]

    zins = [0, 1, 2]
    subplots = [311, 312, 313]

    sn, subgn, mfofs, m200s,  m200sm = common.load_observation('/fred/oz009/clagos/EAGLE/L0025N0376/REFERENCE/data/', 'SUBFIND-EAGLE-DATABASE.data', [2, 1, 3, 4, 6])

    for subplot, idx, z, s in zip(subplots, idx, zins, snap):
          ax = fig.add_subplot(subplot)
          if (idx == 2):
              xtitplot = xtit
          else:
              xtitplot = ' '
          common.prepare_ax(ax, xmin, xmax, ymin, ymax, xtitplot, ytit, locators=(0.1, 1, 0.1))
          ax.text(xleg,yleg, 'z=%s' % (str(z)))
  
          #HMF calc HMF calculated by Sheth & Tormen (2001)
          lmp, dp = common.load_observation(obs_dir, 'hmf_calc_z%01d.dat'% z, [0, 7])
          lmp_plot = np.log10(lmp) - np.log10(h0)
          dp_plot = np.log10(dp) + np.log10(pow(h0,3.))

          if(idx == 0):
             ax.plot(lmp_plot,dp_plot,'b', label = 'HMF SMT01')
          if(idx > 0):
             ax.plot(lmp_plot,dp_plot,'b')

          #HMF from SUBFIND
          ind = np.where((mfofs > 0) & (subgn == 0) & (sn == s))
          H, bins_edges = np.histogram(np.log10(mfofs[ind]),bins=np.append(mbins,mupp))
          histsfof = H
          ind = np.where((m200s > 0) & (subgn == 0) & (sn == s))
          H, bins_edges = np.histogram(np.log10(m200s[ind]),bins=np.append(mbins,mupp))
          hists200 =  H
          ind = np.where((m200sm > 0) & (subgn == 0) & (sn == s))
          H, bins_edges = np.histogram(np.log10(m200sm[ind]),bins=np.append(mbins,mupp))
          hists200m =  H 

          y = histsfof[:]
          ind = np.where(y != 0.)
          if idx == 0:
              ax.plot(xmf[ind],np.log10(y[ind]/vol_eagle/dm),'g', label ='EAGLE L25 SF $M_{\\rm FOF}$')
          if idx > 0:
              ax.plot(xmf[ind],np.log10(y[ind]/vol_eagle/dm),'g')
  
          y = hists200[:]
          ind = np.where(y != 0.)
          if idx == 0:
              ax.plot(xmf[ind],np.log10(y[ind]/vol_eagle/dm),'g', linestyle='dashed', label ='SF $M_{200\,crit}$')
          if idx > 0:
              ax.plot(xmf[ind],np.log10(y[ind]/vol_eagle/dm),'g', linestyle='dashed')
 
          y = hists200m[:]
          ind = np.where(y != 0.)
          if idx == 0:
              ax.plot(xmf[ind],np.log10(y[ind]/vol_eagle/dm),'g', linestyle='dotted', label ='SF $M_{200\,mean}$')
          if idx > 0:
              ax.plot(xmf[ind],np.log10(y[ind]/vol_eagle/dm),'g', linestyle='dotted')
          #Predicted HMF
          y = hist[0,idx,:]
          ind = np.where(y != 0.)
          if idx == 0:
              ax.plot(xmf[ind],y[ind],'r', linestyle='dashed', label ='VR $M_{200\,crit}$')
          if idx > 0:
              ax.plot(xmf[ind],y[ind],'r', linestyle='dashed')
          y = histsh[idx,:]
          ind = np.where(y != 0.)
          if idx == 0:
              ax.plot(xmf[ind],y[ind],'r', label ='VR $M_{\\rm FOF}$')
          if idx > 0:
              ax.plot(xmf[ind],y[ind],'r')
 
          y = hist[1,idx,:]
          ind = np.where(y != 0.)
          if idx == 0:
              ax.plot(xmf[ind],y[ind],'r', linestyle='dotted', label ='VR $M_{200\,mean}$')
          if idx > 0:
              ax.plot(xmf[ind],y[ind],'r', linestyle='dotted') 
          if idx == 0:
              common.prepare_legend(ax, ['b','g','g','g','r','r','r'])

    common.savefig(outdir, fig, "halomf_z.pdf")
コード例 #26
0
ファイル: resolve_comparison.py プロジェクト: viogp/shark
def plot_bmf_resolve(plt, outdir, obsdir, hist_bmf, hist_bmf_sat):

    load_resolve_mf_obs = functools.partial(_load_resolve_mf_obs, obsdir)

    fig = plt.figure(figsize=(9.5, 10.5))

    xtit = "$\\rm log_{10} (\\rm M^{\\prime}_{\\rm bar}/M_{\odot})$"
    ytit = "$\\rm log_{10}(\\rm dn/dM / Mpc^{-3} dex^{-1})$"

    xmin, xmax, ymin, ymax = 9, 12, -6, -1
    xleg = xmax - 0.3 * (xmax - xmin)
    yleg = ymax - 0.1 * (ymax - ymin)

    # all halos ##################################
    ax = fig.add_subplot(321)
    common.prepare_ax(ax, xmin, xmax, ymin, ymax, xtit=None, ytit=ytit)
    ax.tick_params(labelsize=13)
    ax.text(xleg, yleg, '$\\rm all\, halos$')

    #Predicted SMHM
    ind = np.where(hist_bmf[0, :] != 0)
    xplot = xmf[ind]
    yplot = hist_bmf[0, ind]
    ax.errorbar(xplot, yplot[0], color='k')

    ind = np.where(hist_bmf_sat[0, :] != 0)
    xplot = xmf[ind]
    yplot = hist_bmf_sat[0, ind]
    ax.errorbar(xplot, yplot[0], color='k', linestyle="dashed")

    #RESOLVE observations
    M, No, Nodn, Noup = load_resolve_mf_obs('bmassfunction_resolve.txt',
                                            [0, 1, 2, 3])
    resolve_mf_obs_as_errorbar(ax,
                               M,
                               No,
                               Nodn,
                               Noup,
                               'grey',
                               'o',
                               yerrdn_val=No)

    M, No, Nodn, Noup = load_resolve_mf_obs('bmassfunction_eco.txt',
                                            [0, 1, 2, 3])
    eco_mf_obs_as_errorbar(ax, M, No, Nodn, Noup, 'grey', 's', yerrdn_val=No)

    # low mass halos ##################################
    ax = fig.add_subplot(322)
    common.prepare_ax(ax, xmin, xmax, ymin, ymax, xtit=None, ytit=None)
    xleg = xmax - 0.63 * (xmax - xmin)
    yleg = ymax - 0.1 * (ymax - ymin)
    ax.text(xleg, yleg, '$11<\\rm log_{10}(M_{\\rm halo}/M_{\odot})<11.4$')

    #Predicted SMHM
    ind = np.where(hist_bmf[1, :] != 0)
    xplot = xmf[ind]
    yplot = hist_bmf[1, ind]
    ax.errorbar(xplot, yplot[0], color='b')

    ind = np.where(hist_bmf_sat[1, :] != 0)
    xplot = xmf[ind]
    yplot = hist_bmf_sat[1, ind]
    ax.errorbar(xplot, yplot[0], color='b', linestyle="dashed")

    #RESOLVE observations
    M, No, Nodn, Noup, Ns, Nsdn, Nsup = load_resolve_mf_obs(
        'bmassfunctionlowmasshalos_resolve.txt', [0, 1, 2, 3, 7, 8, 9])
    resolve_mf_obs_as_errorbar(ax, M, No, Nodn, Noup, 'b', 'o', yerrdn_val=0.1)
    resolve_mf_obs_as_errorbar(ax,
                               M,
                               Ns,
                               Nsdn,
                               Nsup,
                               'b',
                               'o',
                               yerrdn_val=0.1,
                               fillstyle='full',
                               markersize=3)

    M, No, Nodn, Noup, Ns, Nsdn, Nsup = load_resolve_mf_obs(
        'bmassfunctionlowmasshalos_eco.txt', [0, 1, 2, 3, 7, 8, 9])
    eco_mf_obs_as_errorbar(ax, M, No, Nodn, Noup, 'b', 's', yerrdn_val=0.1)
    eco_mf_obs_as_errorbar(ax,
                           M,
                           Ns,
                           Nsdn,
                           Nsup,
                           'b',
                           's',
                           fillstyle='full',
                           markersize=3)

    # medium mass halos ##################################
    ax = fig.add_subplot(323)
    common.prepare_ax(ax, xmin, xmax, ymin, ymax, xtit=None, ytit=ytit)
    ax.text(xleg, yleg, '$11.4<\\rm log_{10}(M_{\\rm halo}/M_{\odot})<12$')

    #Predicted SMHM
    ind = np.where(hist_bmf[2, :] != 0)
    xplot = xmf[ind]
    yplot = hist_bmf[2, ind]
    ax.errorbar(xplot, yplot[0], color='g')

    ind = np.where(hist_bmf_sat[2, :] != 0)
    xplot = xmf[ind]
    yplot = hist_bmf_sat[2, ind]
    ax.errorbar(xplot, yplot[0], color='g', linestyle="dashed")

    #RESOLVE observations
    M, No, Nodn, Noup, Ns, Nsdn, Nsup = load_resolve_mf_obs(
        'bmassfunctionmedmasshalos_resolve.txt', [0, 1, 2, 3, 7, 8, 9])
    resolve_mf_obs_as_errorbar(ax, M, No, Nodn, Noup, 'g', 'o', yerrdn_val=0.1)
    resolve_mf_obs_as_errorbar(ax,
                               M,
                               Ns,
                               Nsdn,
                               Nsup,
                               'g',
                               'o',
                               fillstyle='full',
                               markersize=3)

    M, No, Nodn, Noup, Ns, Nsdn, Nsup = load_resolve_mf_obs(
        'bmassfunctionmedmasshalos_eco.txt', [0, 1, 2, 3, 7, 8, 9])
    eco_mf_obs_as_errorbar(ax, M, No, Nodn, Noup, 'g', 's', yerrdn_val=0.1)
    eco_mf_obs_as_errorbar(ax,
                           M,
                           Ns,
                           Nsdn,
                           Nsup,
                           'g',
                           's',
                           fillstyle='full',
                           markersize=3)

    # medium high mass halos ##################################
    ax = fig.add_subplot(324)
    common.prepare_ax(ax, xmin, xmax, ymin, ymax, xtit=xtit, ytit=None)
    ax.text(xleg, yleg, '$12<\\rm log_{10}(M_{\\rm halo}/M_{\odot})<13.5$')

    #Predicted SMHM
    ind = np.where(hist_bmf[3, :] != 0)
    xplot = xmf[ind]
    yplot = hist_bmf[3, ind]
    ax.errorbar(xplot, yplot[0], color='r', label="all galaxies")

    ind = np.where(hist_bmf_sat[3, :] != 0)
    xplot = xmf[ind]
    yplot = hist_bmf_sat[3, ind]
    ax.errorbar(xplot,
                yplot[0],
                color='r',
                linestyle="dashed",
                label="satellites")

    #RESOLVE observations
    M, No, Nodn, Noup, Ns, Nsdn, Nsup = load_resolve_mf_obs(
        'bmassfunctionhighmasshalos_resolve.txt', [0, 1, 2, 3, 7, 8, 9])
    resolve_mf_obs_as_errorbar(ax,
                               M,
                               No,
                               Nodn,
                               Noup,
                               'r',
                               'o',
                               yerrdn_val=0.1,
                               label="RESOLVE all")
    resolve_mf_obs_as_errorbar(ax,
                               M,
                               Ns,
                               Nsdn,
                               Nsup,
                               'r',
                               'o',
                               fillstyle='full',
                               markersize=3,
                               label="RESOLVE satellites")

    M, No, Nodn, Noup, Ns, Nsdn, Nsup = load_resolve_mf_obs(
        'bmassfunctionhighmasshalos_eco.txt', [0, 1, 2, 3, 7, 8, 9])
    eco_mf_obs_as_errorbar(ax,
                           M,
                           No,
                           Nodn,
                           Noup,
                           'r',
                           's',
                           yerrdn_val=No,
                           label="ECO all")
    eco_mf_obs_as_errorbar(ax,
                           M,
                           Ns,
                           Nsdn,
                           Nsup,
                           'r',
                           's',
                           fillstyle='full',
                           markersize=3,
                           label="ECO satellites")

    common.prepare_legend(ax, ['k', 'k', 'k', 'k', 'k', 'k'],
                          loc=2,
                          bbox_to_anchor=(0.1, -0.4))

    # high mass halos ##################################
    ax = fig.add_subplot(325)
    common.prepare_ax(ax, xmin, xmax, ymin, ymax, xtit, ytit)
    ax.text(xleg, yleg, '$\\rm log_{10}(M_{\\rm halo}/M_{\odot})>13.5$')

    #Predicted SMHM
    ind = np.where(hist_bmf[4, :] != 0)
    xplot = xmf[ind]
    yplot = hist_bmf[4, ind]
    ax.errorbar(xplot, yplot[0], color='orange')

    ind = np.where(hist_bmf_sat[4, :] != 0)
    xplot = xmf[ind]
    yplot = hist_bmf_sat[4, ind]
    ax.errorbar(xplot, yplot[0], color='orange', linestyle="dashed")

    M, No, Nodn, Noup, Ns, Nsdn, Nsup = load_resolve_mf_obs(
        'bmassfunctionclusterhalos_eco.txt', [0, 1, 2, 3, 7, 8, 9])
    eco_mf_obs_as_errorbar(ax, M, No, Nodn, Noup, 'orange', 's', yerrdn_val=No)
    eco_mf_obs_as_errorbar(ax,
                           M,
                           Ns,
                           Nsdn,
                           Nsup,
                           'orange',
                           's',
                           fillstyle='full',
                           markersize=3,
                           label="ECO satellites")

    common.savefig(outdir, fig, 'bmf_resolve.pdf')
コード例 #27
0
ファイル: galaxy_analysis.py プロジェクト: pelahi/VR-Analysis
def plot_scaling_z(plt, outdir, snap, SFRMstar, R50Mstar, R50Mstar30, MBHMstar,
                   SigmaMstar30, ZstarMstar, ZSFMstar, AgeSMstar, SFRMstar30,
                   R50pMstar30, ZNSFMstar):

    bin_it = functools.partial(us.wmedians, xbins=xmf)

    ########################### will plot main sequence for all stellar particles in the subhalo
    xtit = "$\\rm log_{10} (\\rm M_{\\star, tot}/M_{\odot})$"
    ytit = "$\\rm log_{10}(\\rm SFR/M_{\odot} yr^{-1})$"
    xmin, xmax, ymin, ymax = 7, 12, -5, 1.5
    xleg = xmax - 0.2 * (xmax - xmin)
    yleg = ymax - 0.1 * (ymax - ymin)

    fig = plt.figure(figsize=(5, 10))

    idx = [0, 1, 2]

    zins = [0, 1, 2]
    subplots = [311, 312, 313]

    sn, mstot, sfr, r50, ms30, sfr30 = common.load_observation(
        '/fred/oz009/clagos/EAGLE/L0025N0376/REFERENCE/data/',
        'SUBFIND-EAGLE-DATABASE.data', [2, 29, 30, 26, 22, 24])

    for subplot, idx, z, s in zip(subplots, idx, zins, snap):
        ax = fig.add_subplot(subplot)
        if (idx == 2):
            xtitplot = xtit
        else:
            xtitplot = ' '
        common.prepare_ax(ax,
                          xmin,
                          xmax,
                          ymin,
                          ymax,
                          xtitplot,
                          ytit,
                          locators=(0.1, 1, 0.1))
        ax.text(xleg, yleg, 'z=%s' % (str(z)))

        #from SUBFIND
        ind = np.where((mstot > 0) & (sn == s) & (sfr > 0))
        rplot = bin_it(x=np.log10(mstot[ind]), y=np.log10(sfr[ind]))

        ind = np.where(rplot[0, :] != 0.)
        xplot = xmf[ind]
        yplot = rplot[0, ind]
        errdn = rplot[1, ind]
        errup = rplot[2, ind]

        if idx == 0:
            ax.plot(xplot,
                    yplot[0],
                    'b',
                    linestyle='dashed',
                    label='EAGLE L25')
        if idx > 0:
            ax.plot(xplot, yplot[0], 'b', linestyle='dashed')
        ax.fill_between(xplot,
                        yplot[0],
                        yplot[0] - errdn[0],
                        facecolor='b',
                        alpha=0.2,
                        interpolate=True)
        ax.fill_between(xplot,
                        yplot[0],
                        yplot[0] + errup[0],
                        facecolor='b',
                        alpha=0.2,
                        interpolate=True)

        #VR
        ind = np.where(SFRMstar[idx, 0, :] != 0.)
        xplot = xmf[ind]
        yplot = SFRMstar[idx, 0, ind]
        errdn = SFRMstar[idx, 1, ind]
        errup = SFRMstar[idx, 2, ind]

        if idx == 0:
            ax.plot(xplot, yplot[0], 'r', label='VR')
        if idx > 0:
            ax.plot(xplot, yplot[0], 'r')
        ax.fill_between(xplot,
                        yplot[0],
                        yplot[0] - errdn[0],
                        facecolor='r',
                        alpha=0.2,
                        interpolate=True)
        ax.fill_between(xplot,
                        yplot[0],
                        yplot[0] + errup[0],
                        facecolor='r',
                        alpha=0.2,
                        interpolate=True)

        if idx == 0:
            common.prepare_legend(ax, ['b', 'r'])

    common.savefig(outdir, fig, "main_sequence_z.pdf")

    ########################### will plot main sequence for 30kpc aperture
    xtit = "$\\rm log_{10} (\\rm M_{\\star, 30kpc}/M_{\odot})$"
    ytit = "$\\rm log_{10}(\\rm SFR_{\\rm 30kpc}/M_{\odot} yr^{-1})$"
    xmin, xmax, ymin, ymax = 7, 12, -5, 1.5
    xleg = xmax - 0.2 * (xmax - xmin)
    yleg = ymax - 0.1 * (ymax - ymin)

    fig = plt.figure(figsize=(5, 10))

    idx = [0, 1, 2]

    zins = [0, 1, 2]
    subplots = [311, 312, 313]

    for subplot, idx, z, s in zip(subplots, idx, zins, snap):
        ax = fig.add_subplot(subplot)
        if (idx == 2):
            xtitplot = xtit
        else:
            xtitplot = ' '
        common.prepare_ax(ax,
                          xmin,
                          xmax,
                          ymin,
                          ymax,
                          xtitplot,
                          ytit,
                          locators=(0.1, 1, 0.1))
        ax.text(xleg, yleg, 'z=%s' % (str(z)))

        #from SUBFIND
        ind = np.where((ms30 > 0) & (sn == s) & (sfr30 > 0))
        rplot = bin_it(x=np.log10(ms30[ind]), y=np.log10(sfr30[ind]))

        ind = np.where(rplot[0, :] != 0.)
        xplot = xmf[ind]
        yplot = rplot[0, ind]
        errdn = rplot[1, ind]
        errup = rplot[2, ind]

        if idx == 0:
            ax.plot(xplot,
                    yplot[0],
                    'b',
                    linestyle='dashed',
                    label='EAGLE L25')
        if idx > 0:
            ax.plot(xplot, yplot[0], 'b', linestyle='dashed')
        ax.fill_between(xplot,
                        yplot[0],
                        yplot[0] - errdn[0],
                        facecolor='b',
                        alpha=0.2,
                        interpolate=True)
        ax.fill_between(xplot,
                        yplot[0],
                        yplot[0] + errup[0],
                        facecolor='b',
                        alpha=0.2,
                        interpolate=True)

        #VR
        ind = np.where(SFRMstar30[idx, 0, :] != 0.)
        xplot = xmf[ind]
        yplot = SFRMstar30[idx, 0, ind]
        errdn = SFRMstar30[idx, 1, ind]
        errup = SFRMstar30[idx, 2, ind]

        if idx == 0:
            ax.plot(xplot, yplot[0], 'r', label='VR')
        if idx > 0:
            ax.plot(xplot, yplot[0], 'r')
        ax.fill_between(xplot,
                        yplot[0],
                        yplot[0] - errdn[0],
                        facecolor='r',
                        alpha=0.2,
                        interpolate=True)
        ax.fill_between(xplot,
                        yplot[0],
                        yplot[0] + errup[0],
                        facecolor='r',
                        alpha=0.2,
                        interpolate=True)

        if idx == 0:
            common.prepare_legend(ax, ['b', 'r'])

    common.savefig(outdir, fig, "main_sequence_30kpc_z.pdf")

    ########################### will plot r50 vs stellar mass for all stellar particles in the subhalo
    xtit = "$\\rm log_{10} (\\rm M_{\\star,tot}/M_{\odot})$"
    ytit = "$\\rm log_{10}(\\rm R_{\\rm 50}/pMpc)$"
    xmin, xmax, ymin, ymax = 7, 12, -3.3, -1
    xleg = xmax - 0.2 * (xmax - xmin)
    yleg = ymax - 0.1 * (ymax - ymin)

    fig = plt.figure(figsize=(5, 10))

    idx = [0, 1, 2]

    zins = [0, 1, 2]
    subplots = [311, 312, 313]

    for subplot, idx, z, s in zip(subplots, idx, zins, snap):
        ax = fig.add_subplot(subplot)

        if (idx == 2):
            xtitplot = xtit
        else:
            xtitplot = ' '
        common.prepare_ax(ax,
                          xmin,
                          xmax,
                          ymin,
                          ymax,
                          xtitplot,
                          ytit,
                          locators=(0.1, 1, 0.1))
        plt.subplots_adjust(left=0.2)

        ax.text(xleg, yleg, 'z=%s' % (str(z)))

        #from SUBFIND
        ind = np.where((mstot > 0) & (sn == s) & (r50 > 0))
        rplot = bin_it(x=np.log10(mstot[ind]), y=np.log10(r50[ind]) - 3.0)

        ind = np.where(rplot[0, :] != 0.)
        xplot = xmf[ind]
        yplot = rplot[0, ind]
        errdn = rplot[1, ind]
        errup = rplot[2, ind]

        if idx == 0:
            ax.plot(xplot,
                    yplot[0],
                    'b',
                    linestyle='dashed',
                    label='EAGLE L25')
        if idx > 0:
            ax.plot(xplot, yplot[0], 'b', linestyle='dashed')
        ax.fill_between(xplot,
                        yplot[0],
                        yplot[0] - errdn[0],
                        facecolor='b',
                        alpha=0.2,
                        interpolate=True)
        ax.fill_between(xplot,
                        yplot[0],
                        yplot[0] + errup[0],
                        facecolor='b',
                        alpha=0.2,
                        interpolate=True)

        #VR
        ind = np.where(R50Mstar[idx, 0, :] != 0.)
        xplot = xmf[ind]
        yplot = R50Mstar[idx, 0, ind]
        errdn = R50Mstar[idx, 1, ind]
        errup = R50Mstar[idx, 2, ind]

        if idx == 0:
            ax.plot(xplot, yplot[0], 'r', label='VR')
        if idx > 0:
            ax.plot(xplot, yplot[0], 'r')
        ax.fill_between(xplot,
                        yplot[0],
                        yplot[0] - errdn[0],
                        facecolor='r',
                        alpha=0.2,
                        interpolate=True)
        ax.fill_between(xplot,
                        yplot[0],
                        yplot[0] + errup[0],
                        facecolor='r',
                        alpha=0.2,
                        interpolate=True)

        if idx == 0:
            common.prepare_legend(ax, ['b', 'r'])

    common.savefig(outdir, fig, "r50_Mstar_z.pdf")

    ################## will plot r50 vs stellar mass for quantities measured within 30kpc
    sn, mstot, sfr, r50, r50p = common.load_observation(
        '/fred/oz009/clagos/EAGLE/L0025N0376/REFERENCE/data/',
        'SUBFIND-EAGLE-DATABASE-REF.data', [2, 22, 30, 33, 34])
    xtit = "$\\rm log_{10} (\\rm M_{\\star,30kpc}/M_{\odot})$"
    ytit = "$\\rm log_{10}(\\rm R_{\\rm 50,30kpc}/pMpc)$"
    xmin, xmax, ymin, ymax = 7, 12, -3.3, -1
    xleg = xmax - 0.2 * (xmax - xmin)
    yleg = ymax - 0.1 * (ymax - ymin)

    fig = plt.figure(figsize=(5, 10))

    idx = [0, 1, 2]

    zins = [0, 1, 2]
    subplots = [311, 312, 313]

    for subplot, idx, z, s in zip(subplots, idx, zins, snap):
        ax = fig.add_subplot(subplot)

        if (idx == 2):
            xtitplot = xtit
        else:
            xtitplot = ' '
        common.prepare_ax(ax,
                          xmin,
                          xmax,
                          ymin,
                          ymax,
                          xtitplot,
                          ytit,
                          locators=(0.1, 1, 0.1))
        plt.subplots_adjust(left=0.2)

        ax.text(xleg, yleg, 'z=%s' % (str(z)))

        #from SUBFIND
        ind = np.where((mstot > 0) & (sn == s) & (r50 > 0))
        rplot = bin_it(x=np.log10(mstot[ind]), y=np.log10(r50[ind]) - 3.0)

        ind = np.where(rplot[0, :] != 0.)
        xplot = xmf[ind]
        yplot = rplot[0, ind]
        errdn = rplot[1, ind]
        errup = rplot[2, ind]

        if idx == 0:
            ax.plot(xplot,
                    yplot[0],
                    'b',
                    linestyle='dashed',
                    label='EAGLE L25')
        if idx > 0:
            ax.plot(xplot, yplot[0], 'b', linestyle='dashed')
        ax.fill_between(xplot,
                        yplot[0],
                        yplot[0] - errdn[0],
                        facecolor='b',
                        alpha=0.2,
                        interpolate=True)
        ax.fill_between(xplot,
                        yplot[0],
                        yplot[0] + errup[0],
                        facecolor='b',
                        alpha=0.2,
                        interpolate=True)

        #VR
        ind = np.where(R50Mstar30[idx, 0, :] != 0.)
        xplot = xmf[ind]
        yplot = R50Mstar30[idx, 0, ind]
        errdn = R50Mstar30[idx, 1, ind]
        errup = R50Mstar30[idx, 2, ind]

        if idx == 0:
            ax.plot(xplot, yplot[0], 'r', label='VR')
        if idx > 0:
            ax.plot(xplot, yplot[0], 'r')
        ax.fill_between(xplot,
                        yplot[0],
                        yplot[0] - errdn[0],
                        facecolor='r',
                        alpha=0.2,
                        interpolate=True)
        ax.fill_between(xplot,
                        yplot[0],
                        yplot[0] + errup[0],
                        facecolor='r',
                        alpha=0.2,
                        interpolate=True)

        if idx == 0:
            common.prepare_legend(ax, ['b', 'r'])

    common.savefig(outdir, fig, "r50_Mstar_30kpc_z.pdf")

    ################## will plot r50 vs stellar mass for quantities measured within 30kpc, but in this case the r50 is projected
    xtit = "$\\rm log_{10} (\\rm M_{\\star,30kpc}/M_{\odot})$"
    ytit = "$\\rm log_{10}(\\rm R_{\\rm 50,30kpc,2D}/pMpc)$"
    xmin, xmax, ymin, ymax = 7, 12, -3.3, -1
    xleg = xmax - 0.2 * (xmax - xmin)
    yleg = ymax - 0.1 * (ymax - ymin)

    fig = plt.figure(figsize=(5, 10))

    idx = [0, 1, 2]

    zins = [0, 1, 2]
    subplots = [311, 312, 313]

    for subplot, idx, z, s in zip(subplots, idx, zins, snap):
        ax = fig.add_subplot(subplot)

        if (idx == 2):
            xtitplot = xtit
        else:
            xtitplot = ' '
        common.prepare_ax(ax,
                          xmin,
                          xmax,
                          ymin,
                          ymax,
                          xtitplot,
                          ytit,
                          locators=(0.1, 1, 0.1))
        plt.subplots_adjust(left=0.2)

        ax.text(xleg, yleg, 'z=%s' % (str(z)))

        #from SUBFIND
        ind = np.where((mstot > 0) & (sn == s) & (r50p > 0))
        rplot = bin_it(x=np.log10(mstot[ind]), y=np.log10(r50p[ind]) - 3.0)

        ind = np.where(rplot[0, :] != 0.)
        xplot = xmf[ind]
        yplot = rplot[0, ind]
        errdn = rplot[1, ind]
        errup = rplot[2, ind]

        if idx == 0:
            ax.plot(xplot,
                    yplot[0],
                    'b',
                    linestyle='dashed',
                    label='EAGLE L25')
        if idx > 0:
            ax.plot(xplot, yplot[0], 'b', linestyle='dashed')
        ax.fill_between(xplot,
                        yplot[0],
                        yplot[0] - errdn[0],
                        facecolor='b',
                        alpha=0.2,
                        interpolate=True)
        ax.fill_between(xplot,
                        yplot[0],
                        yplot[0] + errup[0],
                        facecolor='b',
                        alpha=0.2,
                        interpolate=True)

        #VR
        ind = np.where(R50pMstar30[idx, 0, :] != 0.)
        xplot = xmf[ind]
        yplot = R50pMstar30[idx, 0, ind]
        errdn = R50pMstar30[idx, 1, ind]
        errup = R50pMstar30[idx, 2, ind]

        if idx == 0:
            ax.plot(xplot, yplot[0], 'r', label='VR')
        if idx > 0:
            ax.plot(xplot, yplot[0], 'r')
        ax.fill_between(xplot,
                        yplot[0],
                        yplot[0] - errdn[0],
                        facecolor='r',
                        alpha=0.2,
                        interpolate=True)
        ax.fill_between(xplot,
                        yplot[0],
                        yplot[0] + errup[0],
                        facecolor='r',
                        alpha=0.2,
                        interpolate=True)

        if idx == 0:
            common.prepare_legend(ax, ['b', 'r'])

    common.savefig(outdir, fig, "r50_projected_Mstar_30kpc_z.pdf")

    ########################### will plot stellar velocity dispersion vs. stellar mass
    sn, mstot, sfr, r50, vs = common.load_observation(
        '/fred/oz009/clagos/EAGLE/L0025N0376/REFERENCE/data/',
        'SUBFIND-EAGLE-DATABASE-REF.data', [2, 22, 30, 33, 25])
    xtit = "$\\rm log_{10} (\\rm M_{\\star,30kpc}/M_{\odot})$"
    ytit = "$\\rm log_{10}(\\sigma_{\\star,30kpc}/km s^{-1})$"
    xmin, xmax, ymin, ymax = 7, 12, 1, 3
    xleg = xmax - 0.2 * (xmax - xmin)
    yleg = ymax - 0.1 * (ymax - ymin)

    fig = plt.figure(figsize=(5, 10))

    idx = [0, 1, 2]

    zins = [0, 1, 2]
    subplots = [311, 312, 313]

    for subplot, idx, z, s in zip(subplots, idx, zins, snap):
        ax = fig.add_subplot(subplot)

        if (idx == 2):
            xtitplot = xtit
        else:
            xtitplot = ' '
        common.prepare_ax(ax,
                          xmin,
                          xmax,
                          ymin,
                          ymax,
                          xtitplot,
                          ytit,
                          locators=(0.1, 1, 0.1))
        plt.subplots_adjust(left=0.2)

        ax.text(xleg, yleg, 'z=%s' % (str(z)))

        #from SUBFIND
        ind = np.where((mstot > 0) & (sn == s) & (vs > 0))
        rplot = bin_it(x=np.log10(mstot[ind]), y=np.log10(vs[ind]))

        ind = np.where(rplot[0, :] != 0.)
        xplot = xmf[ind]
        yplot = rplot[0, ind]
        errdn = rplot[1, ind]
        errup = rplot[2, ind]

        if idx == 0:
            ax.plot(xplot,
                    yplot[0],
                    'b',
                    linestyle='dashed',
                    label='EAGLE L25')
        if idx > 0:
            ax.plot(xplot, yplot[0], 'b', linestyle='dashed')
        ax.fill_between(xplot,
                        yplot[0],
                        yplot[0] - errdn[0],
                        facecolor='b',
                        alpha=0.2,
                        interpolate=True)
        ax.fill_between(xplot,
                        yplot[0],
                        yplot[0] + errup[0],
                        facecolor='b',
                        alpha=0.2,
                        interpolate=True)

        #VR
        ind = np.where(SigmaMstar30[idx, 0, :] != 0.)
        xplot = xmf[ind]
        yplot = SigmaMstar30[idx, 0, ind]
        errdn = SigmaMstar30[idx, 1, ind]
        errup = SigmaMstar30[idx, 2, ind]

        if idx == 0:
            ax.plot(xplot, yplot[0], 'r', label='VR')
        if idx > 0:
            ax.plot(xplot, yplot[0], 'r')
        ax.fill_between(xplot,
                        yplot[0],
                        yplot[0] - errdn[0],
                        facecolor='r',
                        alpha=0.2,
                        interpolate=True)
        ax.fill_between(xplot,
                        yplot[0],
                        yplot[0] + errup[0],
                        facecolor='r',
                        alpha=0.2,
                        interpolate=True)

        if idx == 0:
            common.prepare_legend(ax, ['b', 'r'])

    common.savefig(outdir, fig, "vdisp_Mstar_30kpc_z.pdf")

    ############ will plot stellar metallicity-stellar mass
    xtit = "$\\rm log_{10} (\\rm M_{\\star, tot}/M_{\odot})$"
    ytit = "$\\rm log_{10}(\\rm Z_{\star})$"
    xmin, xmax, ymin, ymax = 7, 12, -5, -1
    xleg = xmax - 0.2 * (xmax - xmin)
    yleg = ymax - 0.1 * (ymax - ymin)

    fig = plt.figure(figsize=(5, 10))

    idx = [0, 1, 2]

    zins = [0, 1, 2]
    subplots = [311, 312, 313]

    sn, mstot, zsf, zs, age, znsf = common.load_observation(
        '/fred/oz009/clagos/EAGLE/L0025N0376/REFERENCE/data/',
        'SUBFIND-EAGLE-DATABASE.data', [2, 29, 33, 34, 35, 36])

    for subplot, idx, z, s in zip(subplots, idx, zins, snap):
        ax = fig.add_subplot(subplot)
        if (idx == 2):
            xtitplot = xtit
        else:
            xtitplot = ' '
        common.prepare_ax(ax,
                          xmin,
                          xmax,
                          ymin,
                          ymax,
                          xtitplot,
                          ytit,
                          locators=(0.1, 1, 0.1))
        ax.text(xleg, yleg, 'z=%s' % (str(z)))

        #from SUBFIND
        ind = np.where((mstot > 0) & (sn == s) & (zs > 0))
        rplot = bin_it(x=np.log10(mstot[ind]), y=np.log10(zs[ind]))
        ind = np.where(rplot[0, :] != 0.)
        xplot = xmf[ind]
        yplot = rplot[0, ind]
        errdn = rplot[1, ind]
        errup = rplot[2, ind]

        if idx == 0:
            ax.plot(xplot,
                    yplot[0],
                    'b',
                    linestyle='dashed',
                    label='EAGLE L25')
        if idx > 0:
            ax.plot(xplot, yplot[0], 'b', linestyle='dashed')
        ax.fill_between(xplot,
                        yplot[0],
                        yplot[0] - errdn[0],
                        facecolor='b',
                        alpha=0.2,
                        interpolate=True)
        ax.fill_between(xplot,
                        yplot[0],
                        yplot[0] + errup[0],
                        facecolor='b',
                        alpha=0.2,
                        interpolate=True)

        #VR
        ind = np.where(ZstarMstar[idx, 0, :] != 0.)
        xplot = xmf[ind]
        yplot = ZstarMstar[idx, 0, ind]
        errdn = ZstarMstar[idx, 1, ind]
        errup = ZstarMstar[idx, 2, ind]

        if idx == 0:
            ax.plot(xplot, yplot[0], 'r', label='VR')
        if idx > 0:
            ax.plot(xplot, yplot[0], 'r')
        ax.fill_between(xplot,
                        yplot[0],
                        yplot[0] - errdn[0],
                        facecolor='r',
                        alpha=0.2,
                        interpolate=True)
        ax.fill_between(xplot,
                        yplot[0],
                        yplot[0] + errup[0],
                        facecolor='r',
                        alpha=0.2,
                        interpolate=True)

        if idx == 0:
            common.prepare_legend(ax, ['b', 'r'])

    common.savefig(outdir, fig, "zstar_mstar_z.pdf")

    ################ will plot star-forming gas metallicity vs. stellar mass
    xtit = "$\\rm log_{10} (\\rm M_{\\star, tot}/M_{\odot})$"
    ytit = "$\\rm log_{10}(\\rm Z_{\\rm SF,gas})$"
    xmin, xmax, ymin, ymax = 7, 12, -5, -1
    xleg = xmax - 0.2 * (xmax - xmin)
    yleg = ymax - 0.1 * (ymax - ymin)

    fig = plt.figure(figsize=(5, 10))

    idx = [0, 1, 2]

    zins = [0, 1, 2]
    subplots = [311, 312, 313]

    for subplot, idx, z, s in zip(subplots, idx, zins, snap):
        ax = fig.add_subplot(subplot)
        if (idx == 2):
            xtitplot = xtit
        else:
            xtitplot = ' '
        common.prepare_ax(ax,
                          xmin,
                          xmax,
                          ymin,
                          ymax,
                          xtitplot,
                          ytit,
                          locators=(0.1, 1, 0.1))
        ax.text(xleg, yleg, 'z=%s' % (str(z)))

        #from SUBFIND
        ind = np.where((mstot > 0) & (sn == s) & (zsf > 0))
        rplot = bin_it(x=np.log10(mstot[ind]), y=np.log10(zsf[ind]))
        ind = np.where(rplot[0, :] != 0.)
        xplot = xmf[ind]
        yplot = rplot[0, ind]
        errdn = rplot[1, ind]
        errup = rplot[2, ind]

        if idx == 0:
            ax.plot(xplot,
                    yplot[0],
                    'b',
                    linestyle='dashed',
                    label='EAGLE L25')
        if idx > 0:
            ax.plot(xplot, yplot[0], 'b', linestyle='dashed')
        ax.fill_between(xplot,
                        yplot[0],
                        yplot[0] - errdn[0],
                        facecolor='b',
                        alpha=0.2,
                        interpolate=True)
        ax.fill_between(xplot,
                        yplot[0],
                        yplot[0] + errup[0],
                        facecolor='b',
                        alpha=0.2,
                        interpolate=True)

        #VR
        ind = np.where(ZSFMstar[idx, 0, :] != 0.)
        xplot = xmf[ind]
        yplot = ZSFMstar[idx, 0, ind]
        errdn = ZSFMstar[idx, 1, ind]
        errup = ZSFMstar[idx, 2, ind]

        if idx == 0:
            ax.plot(xplot, yplot[0], 'r', label='VR')
        if idx > 0:
            ax.plot(xplot, yplot[0], 'r')
        ax.fill_between(xplot,
                        yplot[0],
                        yplot[0] - errdn[0],
                        facecolor='r',
                        alpha=0.2,
                        interpolate=True)
        ax.fill_between(xplot,
                        yplot[0],
                        yplot[0] + errup[0],
                        facecolor='r',
                        alpha=0.2,
                        interpolate=True)

        if idx == 0:
            common.prepare_legend(ax, ['b', 'r'])

    common.savefig(outdir, fig, "zsfgas_mstar_z.pdf")

    ################ will plot non-star-forming gas metallicity vs. stellar mass
    xtit = "$\\rm log_{10} (\\rm M_{\\star, tot}/M_{\odot})$"
    ytit = "$\\rm log_{10}(\\rm Z_{\\rm non-SF,gas})$"
    xmin, xmax, ymin, ymax = 7, 12, -5, -1
    xleg = xmax - 0.2 * (xmax - xmin)
    yleg = ymax - 0.1 * (ymax - ymin)

    fig = plt.figure(figsize=(5, 10))

    idx = [0, 1, 2]

    zins = [0, 1, 2]
    subplots = [311, 312, 313]

    for subplot, idx, z, s in zip(subplots, idx, zins, snap):
        ax = fig.add_subplot(subplot)
        if (idx == 2):
            xtitplot = xtit
        else:
            xtitplot = ' '
        common.prepare_ax(ax,
                          xmin,
                          xmax,
                          ymin,
                          ymax,
                          xtitplot,
                          ytit,
                          locators=(0.1, 1, 0.1))
        ax.text(xleg, yleg, 'z=%s' % (str(z)))

        #from SUBFIND
        ind = np.where((mstot > 0) & (sn == s) & (znsf > 0))
        rplot = bin_it(x=np.log10(mstot[ind]), y=np.log10(znsf[ind]))
        ind = np.where(rplot[0, :] != 0.)
        xplot = xmf[ind]
        yplot = rplot[0, ind]
        errdn = rplot[1, ind]
        errup = rplot[2, ind]

        if idx == 0:
            ax.plot(xplot,
                    yplot[0],
                    'b',
                    linestyle='dashed',
                    label='EAGLE L25')
        if idx > 0:
            ax.plot(xplot, yplot[0], 'b', linestyle='dashed')
        ax.fill_between(xplot,
                        yplot[0],
                        yplot[0] - errdn[0],
                        facecolor='b',
                        alpha=0.2,
                        interpolate=True)
        ax.fill_between(xplot,
                        yplot[0],
                        yplot[0] + errup[0],
                        facecolor='b',
                        alpha=0.2,
                        interpolate=True)

        #VR
        ind = np.where(ZNSFMstar[idx, 0, :] != 0.)
        xplot = xmf[ind]
        yplot = ZNSFMstar[idx, 0, ind]
        errdn = ZNSFMstar[idx, 1, ind]
        errup = ZNSFMstar[idx, 2, ind]

        if idx == 0:
            ax.plot(xplot, yplot[0], 'r', label='VR')
        if idx > 0:
            ax.plot(xplot, yplot[0], 'r')
        ax.fill_between(xplot,
                        yplot[0],
                        yplot[0] - errdn[0],
                        facecolor='r',
                        alpha=0.2,
                        interpolate=True)
        ax.fill_between(xplot,
                        yplot[0],
                        yplot[0] + errup[0],
                        facecolor='r',
                        alpha=0.2,
                        interpolate=True)

        if idx == 0:
            common.prepare_legend(ax, ['b', 'r'])

    common.savefig(outdir, fig, "znsfgas_mstar_z.pdf")

    ################ will plot stellar ages vs stellar mass
    xtit = "$\\rm log_{10} (\\rm M_{\\star, tot}/M_{\odot})$"
    ytit = "$\\rm log_{10}(\\rm age_{\\star}/Gyr)$"
    xmin, xmax, ymin, ymax = 7, 12, 0, 1.1
    xleg = xmax - 0.2 * (xmax - xmin)
    yleg = ymax - 0.1 * (ymax - ymin)

    fig = plt.figure(figsize=(5, 10))

    idx = [0, 1, 2]

    zins = [0, 1, 2]
    subplots = [311, 312, 313]

    for subplot, idx, z, s in zip(subplots, idx, zins, snap):
        ax = fig.add_subplot(subplot)
        if (idx == 2):
            xtitplot = xtit
        else:
            xtitplot = ' '
        common.prepare_ax(ax,
                          xmin,
                          xmax,
                          ymin,
                          ymax,
                          xtitplot,
                          ytit,
                          locators=(0.1, 1, 0.1))
        ax.text(xleg, yleg, 'z=%s' % (str(z)))

        #from SUBFIND
        ind = np.where((mstot > 0) & (sn == s) & (age > 0))
        rplot = bin_it(x=np.log10(mstot[ind]), y=np.log10(age[ind]))
        ind = np.where(rplot[0, :] != 0.)
        xplot = xmf[ind]
        yplot = rplot[0, ind]
        errdn = rplot[1, ind]
        errup = rplot[2, ind]

        if idx == 0:
            ax.plot(xplot,
                    yplot[0],
                    'b',
                    linestyle='dashed',
                    label='EAGLE L25')
        if idx > 0:
            ax.plot(xplot, yplot[0], 'b', linestyle='dashed')
        ax.fill_between(xplot,
                        yplot[0],
                        yplot[0] - errdn[0],
                        facecolor='b',
                        alpha=0.2,
                        interpolate=True)
        ax.fill_between(xplot,
                        yplot[0],
                        yplot[0] + errup[0],
                        facecolor='b',
                        alpha=0.2,
                        interpolate=True)

        #VR
        ind = np.where(AgeSMstar[idx, 0, :] != 0.)
        xplot = xmf[ind]
        yplot = AgeSMstar[idx, 0, ind]
        errdn = AgeSMstar[idx, 1, ind]
        errup = AgeSMstar[idx, 2, ind]

        if idx == 0:
            ax.plot(xplot, yplot[0], 'r', label='VR')
        if idx > 0:
            ax.plot(xplot, yplot[0], 'r')
        ax.fill_between(xplot,
                        yplot[0],
                        yplot[0] - errdn[0],
                        facecolor='r',
                        alpha=0.2,
                        interpolate=True)
        ax.fill_between(xplot,
                        yplot[0],
                        yplot[0] + errup[0],
                        facecolor='r',
                        alpha=0.2,
                        interpolate=True)

        if idx == 0:
            common.prepare_legend(ax, ['b', 'r'])

    common.savefig(outdir, fig, "starage_mstar_z.pdf")
コード例 #28
0
ファイル: resolve_comparison.py プロジェクト: viogp/shark
def plot_mHI_mhalo_resolve(plt, outdir, obsdir, mHImhalo, mHImhalo_true):

    resolve_obs_as_errorbars = functools.partial(_resolve_obs_as_errorbars,
                                                 obsdir)

    #   Plots gas metallicity vs. stellar mass
    fig = plt.figure(figsize=(5, 9))
    xtit = "$\\rm log_{10} (\\rm M_{\\rm halo}/M_{\odot})$"
    ytit = "$\\rm log_{10}(\\rm M_{\\rm HI}/M_{\odot})$"

    xmin, xmax, ymin, ymax = 10.5, 15.2, 7, 12
    xleg = xmin + 0.2 * (xmax - xmin)
    yleg = ymax - 0.1 * (ymax - ymin)

    # centrals
    ax = fig.add_subplot(211)
    common.prepare_ax(ax,
                      xmin,
                      xmax,
                      ymin,
                      ymax,
                      xtit,
                      ytit,
                      locators=(0.1, 1, 0.1))
    ax.text(xleg, yleg, 'centrals')

    #Predicted relation
    ind = np.where(mHImhalo[1, 0, :] != 0)
    yplot = (mHImhalo[1, 0, ind])
    errdn = (mHImhalo[1, 1, ind])
    errup = (mHImhalo[1, 2, ind])
    xplot = xmf[ind]

    ax.plot(xplot, yplot[0], color='k', label="G/S $>0.05$")
    ax.fill_between(xplot,
                    yplot[0],
                    yplot[0] - errdn[0],
                    facecolor='grey',
                    interpolate=True)
    ax.fill_between(xplot,
                    yplot[0],
                    yplot[0] + errup[0],
                    facecolor='grey',
                    interpolate=True)

    ind = np.where(mHImhalo_true[1, 0, :] != 0)
    yplot = (mHImhalo_true[1, 0, ind])
    xplot = xmf[ind]
    ax.errorbar(xplot,
                yplot[0],
                color='b',
                linestyle="dashed",
                label="true $M_{\\rm HI}$")

    #RESOLVE observations
    resolve_obs_as_errorbars(ax,
                             'himassvgroupmasscentral_resolve.txt',
                             [0, 4, 2, 6],
                             'orange',
                             'o',
                             label='RESOLVE')
    resolve_obs_as_errorbars(ax,
                             'himassvgroupmasscentral_eco.txt', [0, 4, 2, 6],
                             'orange',
                             'o',
                             label='ECO')

    common.prepare_legend(ax, ['k', 'b', 'orange', 'orange'], loc=4)

    # satellites
    ax = fig.add_subplot(212)
    common.prepare_ax(ax,
                      xmin,
                      xmax,
                      ymin,
                      ymax,
                      xtit,
                      ytit,
                      locators=(0.1, 1, 0.1))
    ax.text(xleg, yleg, 'satellites')

    #Predicted relation
    ind = np.where(mHImhalo[2, 0, :] != 0)
    yplot = (mHImhalo[2, 0, ind])
    errdn = (mHImhalo[2, 1, ind])
    errup = (mHImhalo[2, 2, ind])
    xplot = xmf[ind]

    ax.plot(xplot, yplot[0], color='k')
    ax.fill_between(xplot,
                    yplot[0],
                    yplot[0] - errdn[0],
                    facecolor='grey',
                    interpolate=True)
    ax.fill_between(xplot,
                    yplot[0],
                    yplot[0] + errup[0],
                    facecolor='grey',
                    interpolate=True)

    ind = np.where(mHImhalo_true[2, 0, :] != 0)
    yplot = (mHImhalo_true[2, 0, ind])
    xplot = xmf[ind]
    ax.errorbar(xplot, yplot[0], color='b', linestyle="dashed")

    #RESOLVE observations
    resolve_obs_as_errorbars(ax, 'himassvgroupmasssatellite_resolve.txt',
                             [0, 4, 2, 6], 'orange', 'o')
    resolve_obs_as_errorbars(ax, 'himassvgroupmasssatellite_eco.txt',
                             [0, 4, 2, 6], 'orange', 's')

    #Save figure
    common.savefig(outdir, fig, 'mHI-mhalo_resolve.pdf')
コード例 #29
0
ファイル: galaxy_analysis.py プロジェクト: pelahi/VR-Analysis
def plot_mf_z(plt, outdir, snap, vol_eagle, histmtot, histm30, histmgas,
              histmall):

    ########################### total stellar mass function
    xtit = "$\\rm log_{10} (\\rm M_{\\star,\\rm tot}/M_{\odot})$"
    ytit = "$\\rm log_{10}(\Phi/dlog{\\rm M_{\\star}}/{\\rm Mpc}^{-3} )$"
    xmin, xmax, ymin, ymax = 7, 12, -6, 1
    xleg = xmax - 0.2 * (xmax - xmin)
    yleg = ymax - 0.1 * (ymax - ymin)

    fig = plt.figure(figsize=(5, 10))

    idx = [0, 1, 2]

    zins = [0, 1, 2]
    subplots = [311, 312, 313]

    sn, subgn, mstot, ms30, mgas30, mdm30, mbh30 = common.load_observation(
        '/fred/oz009/clagos/EAGLE/L0025N0376/REFERENCE/data/',
        'SUBFIND-EAGLE-DATABASE.data', [2, 1, 29, 22, 23, 31, 32])
    mall = ms30 + mgas30 + mdm30 + mbh30

    for subplot, idx, z, s in zip(subplots, idx, zins, snap):
        ax = fig.add_subplot(subplot)
        if (idx == 2):
            xtitplot = xtit
        else:
            xtitplot = ' '
        common.prepare_ax(ax,
                          xmin,
                          xmax,
                          ymin,
                          ymax,
                          xtitplot,
                          ytit,
                          locators=(0.1, 1, 0.1))
        ax.text(xleg, yleg, 'z=%s' % (str(z)))

        #SMF from SUBFIND
        ind = np.where((mstot > 0) & (sn == s))
        H, bins_edges = np.histogram(np.log10(mstot[ind]),
                                     bins=np.append(mbins, mupp))
        histsfof = H

        y = histsfof[:]
        ind = np.where(y != 0.)
        if idx == 0:
            ax.plot(xmf[ind],
                    np.log10(y[ind] / vol_eagle / dm),
                    'b',
                    label='EAGLE L25')
        if idx > 0:
            ax.plot(xmf[ind], np.log10(y[ind] / vol_eagle / dm), 'b')

        #Predicted HMF
        y = histmtot[idx, :]
        ind = np.where(y != 0.)
        if idx == 0:
            ax.plot(xmf[ind], y[ind], 'r', linestyle='dashed', label='VR')
        if idx > 0:
            ax.plot(xmf[ind], y[ind], 'r', linestyle='dashed')
        if idx == 0:
            common.prepare_legend(ax, ['b', 'r'])

    common.savefig(outdir, fig, "smf_tot_z.pdf")

    ############################# stellar mass function (30kpc aperture)
    xtit = "$\\rm log_{10} (\\rm M_{\\star,\\rm 30kpc}/M_{\odot})$"
    ytit = "$\\rm log_{10}(\Phi/dlog{\\rm M_{\\star}}/{\\rm Mpc}^{-3} )$"
    xmin, xmax, ymin, ymax = 7, 12, -6, 1
    xleg = xmax - 0.2 * (xmax - xmin)
    yleg = ymax - 0.1 * (ymax - ymin)

    fig = plt.figure(figsize=(5, 10))

    idx = [0, 1, 2]

    zins = [0, 1, 2]
    subplots = [311, 312, 313]

    for subplot, idx, z, s in zip(subplots, idx, zins, snap):
        ax = fig.add_subplot(subplot)
        if (idx == 2):
            xtitplot = xtit
        else:
            xtitplot = ' '
        common.prepare_ax(ax,
                          xmin,
                          xmax,
                          ymin,
                          ymax,
                          xtitplot,
                          ytit,
                          locators=(0.1, 1, 0.1))
        ax.text(xleg, yleg, 'z=%s' % (str(z)))

        #SMF from SUBFIND
        ind = np.where((ms30 > 0) & (sn == s))
        H, bins_edges = np.histogram(np.log10(ms30[ind]),
                                     bins=np.append(mbins, mupp))
        histsfof = H

        y = histsfof[:]
        ind = np.where(y != 0.)
        if idx == 0:
            ax.plot(xmf[ind],
                    np.log10(y[ind] / vol_eagle / dm),
                    'b',
                    label='EAGLE L25')
        if idx > 0:
            ax.plot(xmf[ind], np.log10(y[ind] / vol_eagle / dm), 'b')

        #Predicted HMF
        y = histm30[idx, :]
        ind = np.where(y != 0.)
        if idx == 0:
            ax.plot(xmf[ind], y[ind], 'r', linestyle='dashed', label='VR')
        if idx > 0:
            ax.plot(xmf[ind], y[ind], 'r', linestyle='dashed')
        if idx == 0:
            common.prepare_legend(ax, ['b', 'r'])

    common.savefig(outdir, fig, "smf_30kpc_z.pdf")

    ############################# gas mass function (30kpc aperture)
    xtit = "$\\rm log_{10} (\\rm M_{\\rm gas, 30kpc}/M_{\odot})$"
    ytit = "$\\rm log_{10}(\Phi/dlog{\\rm M_{\\rm gas}}/{\\rm Mpc}^{-3} )$"
    xmin, xmax, ymin, ymax = 7, 12, -6, 1
    xleg = xmax - 0.2 * (xmax - xmin)
    yleg = ymax - 0.1 * (ymax - ymin)

    fig = plt.figure(figsize=(5, 10))

    idx = [0, 1, 2]

    zins = [0, 1, 2]
    subplots = [311, 312, 313]

    for subplot, idx, z, s in zip(subplots, idx, zins, snap):
        ax = fig.add_subplot(subplot)
        if (idx == 2):
            xtitplot = xtit
        else:
            xtitplot = ' '
        common.prepare_ax(ax,
                          xmin,
                          xmax,
                          ymin,
                          ymax,
                          xtitplot,
                          ytit,
                          locators=(0.1, 1, 0.1))
        ax.text(xleg, yleg, 'z=%s' % (str(z)))

        #SMF from SUBFIND
        ind = np.where((mgas30 > 0) & (sn == s))
        H, bins_edges = np.histogram(np.log10(mgas30[ind]),
                                     bins=np.append(mbins, mupp))
        histsfof = H

        y = histsfof[:]
        ind = np.where(y != 0.)
        if idx == 0:
            ax.plot(xmf[ind],
                    np.log10(y[ind] / vol_eagle / dm),
                    'b',
                    label='EAGLE L25')
        if idx > 0:
            ax.plot(xmf[ind], np.log10(y[ind] / vol_eagle / dm), 'b')

        #Predicted HMF
        y = histmgas[idx, :]
        ind = np.where(y != 0.)
        if idx == 0:
            ax.plot(xmf[ind], y[ind], 'r', linestyle='dashed', label='VR')
        if idx > 0:
            ax.plot(xmf[ind], y[ind], 'r', linestyle='dashed')
        if idx == 0:
            common.prepare_legend(ax, ['b', 'r'])

    common.savefig(outdir, fig, "gasmf_30kpc_z.pdf")

    ##################################### total mass function (30kpc aperture)
    xtit = "$\\rm log_{10} (\\rm M_{\\rm tot, 30kpc}/M_{\odot})$"
    ytit = "$\\rm log_{10}(\Phi/dlog{\\rm M_{\\rm ror}}/{\\rm Mpc}^{-3} )$"
    xmin, xmax, ymin, ymax = 7, 14, -6, 1
    xleg = xmax - 0.2 * (xmax - xmin)
    yleg = ymax - 0.1 * (ymax - ymin)

    fig = plt.figure(figsize=(5, 10))

    idx = [0, 1, 2]

    zins = [0, 1, 2]
    subplots = [311, 312, 313]

    for subplot, idx, z, s in zip(subplots, idx, zins, snap):
        ax = fig.add_subplot(subplot)
        if (idx == 2):
            xtitplot = xtit
        else:
            xtitplot = ' '
        common.prepare_ax(ax,
                          xmin,
                          xmax,
                          ymin,
                          ymax,
                          xtitplot,
                          ytit,
                          locators=(0.1, 1, 0.1))
        ax.text(xleg, yleg, 'z=%s' % (str(z)))

        #SMF from SUBFIND
        ind = np.where((mall > 0) & (sn == s))
        H, bins_edges = np.histogram(np.log10(mall[ind]),
                                     bins=np.append(mbins, mupp))
        histsfof = H

        y = histsfof[:]
        ind = np.where(y != 0.)
        if idx == 0:
            ax.plot(xmf[ind],
                    np.log10(y[ind] / vol_eagle / dm),
                    'b',
                    label='EAGLE L25')
        if idx > 0:
            ax.plot(xmf[ind], np.log10(y[ind] / vol_eagle / dm), 'b')

        #Predicted HMF
        y = histmall[idx, :]
        ind = np.where(y != 0.)
        if idx == 0:
            ax.plot(xmf[ind], y[ind], 'r', linestyle='dashed', label='VR')
        if idx > 0:
            ax.plot(xmf[ind], y[ind], 'r', linestyle='dashed')
        if idx == 0:
            common.prepare_legend(ax, ['b', 'r'])

    common.savefig(outdir, fig, "allmassmf_30kpc_z.pdf")
コード例 #30
0
def plot_scaling_z(plt, outdir, obsdir, snap, SFRMstar, R50Mstar, R50Mstar30,
                   MBHMstar, SigmaMstar30, ZstarMstar, ZSFMstar, AgeSMstar,
                   SFRMstar30, R50pMstar30):

    #define observaiton of the MS at z=0 to be plotted
    def obs_mainseq_z0():
        #best fit from Davies et al. (2016)
        xdataD16 = [9.3, 10.6]
        ydataD16 = [-0.39, 0.477]
        ax.plot(xdataD16,
                ydataD16,
                color='b',
                linestyle='dashdot',
                linewidth=4,
                label='Davies+16')
        #SDSS z=0 relation
        lm, SFR = common.load_observation(obsdir, 'SFR/Brinchmann04.dat',
                                          (0, 1))
        hobs = 0.7
        #add cosmology correction plus IMF correction that goes into the stellar mass.
        corr_cos = np.log10(pow(hobs, 2) / pow(h0, 2)) - 0.09
        # apply correction to both stellar mass and SFRs.
        ax.plot(lm[0:35] + corr_cos,
                SFR[0:35] + corr_cos,
                color='PaleVioletRed',
                linewidth=3,
                linestyle='dashed',
                label='Brinchmann+04')
        ax.plot(lm[36:70] + corr_cos,
                SFR[36:70] + corr_cos,
                color='PaleVioletRed',
                linewidth=5,
                linestyle='dotted')
        ax.plot(lm[71:len(SFR)] + corr_cos,
                SFR[71:len(SFR)] + corr_cos,
                color='PaleVioletRed',
                linewidth=5,
                linestyle='dotted')

    ########################### will plot main sequence for all stellar particles in the subhalo
    xtit = "$\\rm log_{10} (\\rm M_{\\star, tot}/M_{\odot})$"
    ytit = "$\\rm log_{10}(\\rm SFR/M_{\odot} yr^{-1})$"
    xmin, xmax, ymin, ymax = 7, 12, -5, 1.5
    xleg = xmax - 0.2 * (xmax - xmin)
    yleg = ymax - 0.1 * (ymax - ymin)

    fig = plt.figure(figsize=(5, 10))

    idx = [0, 1, 2]

    zins = [0, 1, 2]
    subplots = [311, 312, 313]

    for subplot, idx, z, s in zip(subplots, idx, zins, snap):
        ax = fig.add_subplot(subplot)
        if (idx == 2):
            xtitplot = xtit
        else:
            xtitplot = ' '
        common.prepare_ax(ax,
                          xmin,
                          xmax,
                          ymin,
                          ymax,
                          xtitplot,
                          ytit,
                          locators=(0.1, 1, 0.1))
        ax.text(xleg, yleg, 'z=%s' % (str(z)))

        #observations z=0
        if (z == 0):
            obs_mainseq_z0()

        #VR
        ind = np.where(SFRMstar[idx, 0, :] != 0.)
        xplot = xmf[ind]
        yplot = SFRMstar[idx, 0, ind]
        errdn = SFRMstar[idx, 1, ind]
        errup = SFRMstar[idx, 2, ind]

        if idx == 0:
            ax.plot(xplot, yplot[0], 'k', label='VR')
        if idx > 0:
            ax.plot(xplot, yplot[0], 'k')
        ax.fill_between(xplot,
                        yplot[0],
                        yplot[0] - errdn[0],
                        facecolor='k',
                        alpha=0.2,
                        interpolate=True)
        ax.fill_between(xplot,
                        yplot[0],
                        yplot[0] + errup[0],
                        facecolor='k',
                        alpha=0.2,
                        interpolate=True)

        if idx == 0:
            common.prepare_legend(ax, ['b', 'PaleVioletRed', 'k'])

    common.savefig(outdir, fig, "main_sequence_z_comp_obs.pdf")

    ########################### will plot main sequence for 30kpc aperture
    xtit = "$\\rm log_{10} (\\rm M_{\\star, 30kpc}/M_{\odot})$"
    ytit = "$\\rm log_{10}(\\rm SFR_{\\rm 30kpc}/M_{\odot} yr^{-1})$"
    xmin, xmax, ymin, ymax = 7, 12, -5, 1.5
    xleg = xmax - 0.2 * (xmax - xmin)
    yleg = ymax - 0.1 * (ymax - ymin)

    fig = plt.figure(figsize=(5, 10))

    idx = [0, 1, 2]

    zins = [0, 1, 2]
    subplots = [311, 312, 313]

    for subplot, idx, z, s in zip(subplots, idx, zins, snap):
        ax = fig.add_subplot(subplot)
        if (idx == 2):
            xtitplot = xtit
        else:
            xtitplot = ' '
        common.prepare_ax(ax,
                          xmin,
                          xmax,
                          ymin,
                          ymax,
                          xtitplot,
                          ytit,
                          locators=(0.1, 1, 0.1))
        ax.text(xleg, yleg, 'z=%s' % (str(z)))

        #observations z=0
        if (z == 0):
            obs_mainseq_z0()

        #VR
        ind = np.where(SFRMstar30[idx, 0, :] != 0.)
        xplot = xmf[ind]
        yplot = SFRMstar30[idx, 0, ind]
        errdn = SFRMstar30[idx, 1, ind]
        errup = SFRMstar30[idx, 2, ind]

        if idx == 0:
            ax.plot(xplot, yplot[0], 'k', label='VR')
        if idx > 0:
            ax.plot(xplot, yplot[0], 'k')
        ax.fill_between(xplot,
                        yplot[0],
                        yplot[0] - errdn[0],
                        facecolor='k',
                        alpha=0.2,
                        interpolate=True)
        ax.fill_between(xplot,
                        yplot[0],
                        yplot[0] + errup[0],
                        facecolor='k',
                        alpha=0.2,
                        interpolate=True)

        if idx == 0:
            common.prepare_legend(ax, ['b', 'PaleVioletRed', 'k'])

    common.savefig(outdir, fig, "main_sequence_30kpc_z_comp_obs.pdf")

    ########################### will plot r50 vs stellar mass for all stellar particles in the subhalo
    #define observations first
    def plot_gama_size_mass():
        m, r = common.load_observation(obsdir, 'SizesAndAM/rdisk_L16.dat',
                                       [0, 1])
        ax.plot(m[0:36],
                r[0:36],
                linestyle='dotted',
                color='b',
                label='L16 disks')
        ax.plot(m[38:83], r[38:83], linestyle='dotted', color='b')
        ax.plot(m[85:128], r[85:129], linestyle='dotted', color='b')
        m, r = common.load_observation(obsdir, 'SizesAndAM/rbulge_L16.dat',
                                       [0, 1])
        ax.plot(m[0:39],
                r[0:39],
                linestyle='dotted',
                color='darkgreen',
                label='L16 bulges')
        ax.plot(m[41:76], r[41:76], linestyle='dotted', color='darkgreen')
        ax.plot(m[78:115], r[78:115], linestyle='dotted', color='darkgreen')

    xtit = "$\\rm log_{10} (\\rm M_{\\star,tot}/M_{\odot})$"
    ytit = "$\\rm log_{10}(\\rm R_{\\rm 50,tot}/pkpc)$"
    xmin, xmax, ymin, ymax = 7, 12, -0.3, 2
    xleg = xmax - 0.2 * (xmax - xmin)
    yleg = ymax - 0.1 * (ymax - ymin)

    fig = plt.figure(figsize=(5, 10))

    idx = [0, 1, 2]

    zins = [0, 1, 2]
    subplots = [311, 312, 313]

    for subplot, idx, z, s in zip(subplots, idx, zins, snap):
        ax = fig.add_subplot(subplot)

        if (idx == 2):
            xtitplot = xtit
        else:
            xtitplot = ' '
        common.prepare_ax(ax,
                          xmin,
                          xmax,
                          ymin,
                          ymax,
                          xtitplot,
                          ytit,
                          locators=(0.1, 1, 0.1))
        plt.subplots_adjust(left=0.2)

        ax.text(xleg, yleg, 'z=%s' % (str(z)))
        if (z == 0):
            plot_gama_size_mass()

        #VR
        ind = np.where(R50Mstar[idx, 0, :] != 0.)
        xplot = xmf[ind]
        yplot = R50Mstar[idx, 0, ind] + 3.0
        errdn = R50Mstar[idx, 1, ind]
        errup = R50Mstar[idx, 2, ind]

        if idx == 0:
            ax.plot(xplot, yplot[0], 'k', label='VR')
        if idx > 0:
            ax.plot(xplot, yplot[0], 'k')
        ax.fill_between(xplot,
                        yplot[0],
                        yplot[0] - errdn[0],
                        facecolor='k',
                        alpha=0.2,
                        interpolate=True)
        ax.fill_between(xplot,
                        yplot[0],
                        yplot[0] + errup[0],
                        facecolor='k',
                        alpha=0.2,
                        interpolate=True)

        if idx == 0:
            common.prepare_legend(ax, ['b', 'darkgreen', 'k'],
                                  loc='upper left')

    common.savefig(outdir, fig, "r50_Mstar_z_comp_obs.pdf")

    ################## will plot r50 vs stellar mass for quantities measured within 30kpc
    xtit = "$\\rm log_{10} (\\rm M_{\\star,30kpc}/M_{\odot})$"
    ytit = "$\\rm log_{10}(\\rm R_{\\rm 50,30kpc}/pkpc)$"
    xmin, xmax, ymin, ymax = 7, 12, -0.3, 2
    xleg = xmax - 0.2 * (xmax - xmin)
    yleg = ymax - 0.1 * (ymax - ymin)

    fig = plt.figure(figsize=(5, 10))

    idx = [0, 1, 2]

    zins = [0, 1, 2]
    subplots = [311, 312, 313]

    for subplot, idx, z, s in zip(subplots, idx, zins, snap):
        ax = fig.add_subplot(subplot)

        if (idx == 2):
            xtitplot = xtit
        else:
            xtitplot = ' '
        common.prepare_ax(ax,
                          xmin,
                          xmax,
                          ymin,
                          ymax,
                          xtitplot,
                          ytit,
                          locators=(0.1, 1, 0.1))
        plt.subplots_adjust(left=0.2)

        ax.text(xleg, yleg, 'z=%s' % (str(z)))
        if (z == 0):
            plot_gama_size_mass()

        #VR
        ind = np.where(R50Mstar30[idx, 0, :] != 0.)
        xplot = xmf[ind]
        yplot = R50Mstar30[idx, 0, ind] + 3.0
        errdn = R50Mstar30[idx, 1, ind]
        errup = R50Mstar30[idx, 2, ind]

        if idx == 0:
            ax.plot(xplot, yplot[0], 'k', label='VR')
        if idx > 0:
            ax.plot(xplot, yplot[0], 'k')
        ax.fill_between(xplot,
                        yplot[0],
                        yplot[0] - errdn[0],
                        facecolor='k',
                        alpha=0.2,
                        interpolate=True)
        ax.fill_between(xplot,
                        yplot[0],
                        yplot[0] + errup[0],
                        facecolor='k',
                        alpha=0.2,
                        interpolate=True)

        if idx == 0:
            common.prepare_legend(ax, ['b', 'darkgreen', 'k'],
                                  loc='upper left')

    common.savefig(outdir, fig, "r50_Mstar_30kpc_z_comp_obs.pdf")

    ################## will plot r50 vs stellar mass for quantities measured within 30kpc, but in this case the r50 is projected
    xtit = "$\\rm log_{10} (\\rm M_{\\star,30kpc}/M_{\odot})$"
    ytit = "$\\rm log_{10}(\\rm R_{\\rm 50,30kpc,2D}/pkpc)$"
    xmin, xmax, ymin, ymax = 7, 12, -0.3, 2
    xleg = xmax - 0.2 * (xmax - xmin)
    yleg = ymax - 0.1 * (ymax - ymin)

    fig = plt.figure(figsize=(5, 10))

    idx = [0, 1, 2]

    zins = [0, 1, 2]
    subplots = [311, 312, 313]

    for subplot, idx, z, s in zip(subplots, idx, zins, snap):
        ax = fig.add_subplot(subplot)

        if (idx == 2):
            xtitplot = xtit
        else:
            xtitplot = ' '
        common.prepare_ax(ax,
                          xmin,
                          xmax,
                          ymin,
                          ymax,
                          xtitplot,
                          ytit,
                          locators=(0.1, 1, 0.1))
        plt.subplots_adjust(left=0.2)

        ax.text(xleg, yleg, 'z=%s' % (str(z)))
        if (z == 0):
            plot_gama_size_mass()

        #VR
        ind = np.where(R50pMstar30[idx, 0, :] != 0.)
        xplot = xmf[ind]
        yplot = R50pMstar30[idx, 0, ind] + 3.0
        errdn = R50pMstar30[idx, 1, ind]
        errup = R50pMstar30[idx, 2, ind]

        if idx == 0:
            ax.plot(xplot, yplot[0], 'k', label='VR')
        if idx > 0:
            ax.plot(xplot, yplot[0], 'k')
        ax.fill_between(xplot,
                        yplot[0],
                        yplot[0] - errdn[0],
                        facecolor='k',
                        alpha=0.2,
                        interpolate=True)
        ax.fill_between(xplot,
                        yplot[0],
                        yplot[0] + errup[0],
                        facecolor='k',
                        alpha=0.2,
                        interpolate=True)

        if idx == 0:
            common.prepare_legend(ax, ['b', 'darkgreen', 'k'],
                                  loc='upper left')

    common.savefig(outdir, fig, "r50_projected_Mstar_30kpc_z_comp_obs.pdf")

    ########################### will plot stellar velocity dispersion vs. stellar mass
    xtit = "$\\rm log_{10} (\\rm M_{\\star,30kpc}/M_{\odot})$"
    ytit = "$\\rm log_{10}(\\sigma_{\\star,30kpc}/km s^{-1})$"
    xmin, xmax, ymin, ymax = 7, 12, 1, 3
    xleg = xmax - 0.2 * (xmax - xmin)
    yleg = ymax - 0.1 * (ymax - ymin)

    fig = plt.figure(figsize=(5, 10))

    idx = [0, 1, 2]

    zins = [0, 1, 2]
    subplots = [311, 312, 313]

    for subplot, idx, z, s in zip(subplots, idx, zins, snap):
        ax = fig.add_subplot(subplot)

        if (idx == 2):
            xtitplot = xtit
        else:
            xtitplot = ' '
        common.prepare_ax(ax,
                          xmin,
                          xmax,
                          ymin,
                          ymax,
                          xtitplot,
                          ytit,
                          locators=(0.1, 1, 0.1))
        plt.subplots_adjust(left=0.2)

        ax.text(xleg, yleg, 'z=%s' % (str(z)))

        #VR
        ind = np.where(SigmaMstar30[idx, 0, :] != 0.)
        xplot = xmf[ind]
        yplot = SigmaMstar30[idx, 0, ind]
        errdn = SigmaMstar30[idx, 1, ind]
        errup = SigmaMstar30[idx, 2, ind]

        if idx == 0:
            ax.plot(xplot, yplot[0], 'k', label='VR')
        if idx > 0:
            ax.plot(xplot, yplot[0], 'k')
        ax.fill_between(xplot,
                        yplot[0],
                        yplot[0] - errdn[0],
                        facecolor='k',
                        alpha=0.2,
                        interpolate=True)
        ax.fill_between(xplot,
                        yplot[0],
                        yplot[0] + errup[0],
                        facecolor='k',
                        alpha=0.2,
                        interpolate=True)

        #observations
        if (z == 0):
            lm, sig, sigdn, sigup = common.load_observation(
                obsdir, 'StellarPops/vdS19-sigma.csv', [0, 1, 2, 3])
            sig = np.log10(sig)
            sigdn = np.log10(sigdn)
            sigup = np.log10(sigup)
            common.errorbars(ax,
                             lm,
                             sig,
                             sigdn,
                             sigup,
                             'b',
                             'D',
                             label='van de Sande+19')

        if idx == 0:
            common.prepare_legend(ax, ['k'], loc='upper left')

    common.savefig(outdir, fig, "vdisp_Mstar_30kpc_z_comp_obs.pdf")

    ############ will plot stellar metallicity-stellar mass
    xtit = "$\\rm log_{10} (\\rm M_{\\star, 30kpc}/M_{\odot})$"
    ytit = "$\\rm log_{10}(\\rm Z_{\star}/Z_{\\odot})$"
    xmin, xmax, ymin, ymax = 7, 12, -2, 1
    xleg = xmax - 0.2 * (xmax - xmin)
    yleg = ymax - 0.1 * (ymax - ymin)

    fig = plt.figure(figsize=(5, 10))

    idx = [0, 1, 2]

    zins = [0, 1, 2]
    subplots = [311, 312, 313]

    for subplot, idx, z, s in zip(subplots, idx, zins, snap):
        ax = fig.add_subplot(subplot)
        if (idx == 2):
            xtitplot = xtit
        else:
            xtitplot = ' '
        common.prepare_ax(ax,
                          xmin,
                          xmax,
                          ymin,
                          ymax,
                          xtitplot,
                          ytit,
                          locators=(0.1, 1, 0.1))
        ax.text(xleg, yleg, 'z=%s' % (str(z)))
        plt.subplots_adjust(left=0.2)

        #VR
        ind = np.where(ZstarMstar[idx, 0, :] != 0.)
        xplot = xmf[ind]
        yplot = ZstarMstar[idx, 0, ind] - log10zsun
        errdn = ZstarMstar[idx, 1, ind]
        errup = ZstarMstar[idx, 2, ind]

        if idx == 0:
            ax.plot(xplot, yplot[0], 'k', label='VR')
        if idx > 0:
            ax.plot(xplot, yplot[0], 'k')
        ax.fill_between(xplot,
                        yplot[0],
                        yplot[0] - errdn[0],
                        facecolor='k',
                        alpha=0.2,
                        interpolate=True)
        ax.fill_between(xplot,
                        yplot[0],
                        yplot[0] + errup[0],
                        facecolor='k',
                        alpha=0.2,
                        interpolate=True)

        #observations
        if (z == 0):
            lm, mz, mzdn, mzup = common.load_observation(
                obsdir, 'MZR/MSZR-Gallazzi05.dat', [0, 1, 2, 3])
            common.errorbars(ax,
                             lm[0:7],
                             mz[0:7],
                             mzdn[0:7],
                             mzup[0:7],
                             'b',
                             'D',
                             label='Kirby+13')
            common.errorbars(ax,
                             lm[7:22],
                             mz[7:22],
                             mzdn[7:22],
                             mzup[7:22],
                             'b',
                             'o',
                             label='Gallazzi+05')

        if idx == 0:
            common.prepare_legend(ax, ['k', 'b', 'b'], loc='lower right')

    common.savefig(outdir, fig, "zstar_mstar_30kpc_z_comp_obs.pdf")

    ################ will plot star-forming gas metallicity vs. stellar mass
    xtit = "$\\rm log_{10} (\\rm M_{\\star, 30kpc}/M_{\odot})$"
    ytit = "$\\rm log_{10}(\\rm Z_{\\rm SF,gas}/Z_{\\odot})$"
    xmin, xmax, ymin, ymax = 7, 12, -2, 1
    xleg = xmax - 0.2 * (xmax - xmin)
    yleg = ymax - 0.1 * (ymax - ymin)

    fig = plt.figure(figsize=(5, 10))

    idx = [0, 1, 2]

    zins = [0, 1, 2]
    subplots = [311, 312, 313]

    for subplot, idx, z, s in zip(subplots, idx, zins, snap):
        ax = fig.add_subplot(subplot)
        if (idx == 2):
            xtitplot = xtit
        else:
            xtitplot = ' '
        common.prepare_ax(ax,
                          xmin,
                          xmax,
                          ymin,
                          ymax,
                          xtitplot,
                          ytit,
                          locators=(0.1, 1, 0.1))
        ax.text(xleg, yleg, 'z=%s' % (str(z)))
        plt.subplots_adjust(left=0.2)

        if (z == 0):
            #MZR z=0
            corrzsun = 8.69  #solar oxygen abundance in units of 12 + log(O/H)
            hobs = 0.72
            #add cosmology correction plus IMF correction that goes into the stellar mass.
            corr_cos = np.log10(pow(hobs, 2) / pow(h0, 2)) - 0.09
            lm, mz, mzdn, mzup = common.load_observation(
                obsdir, 'MZR/MMAdrews13.dat', [0, 1, 2, 3])
            hobs = 0.7
            #add cosmology correction plus IMF correction that goes into the stellar mass.
            corr_cos = np.log10(pow(hobs, 2) / pow(h0, 2)) - 0.09
            common.errorbars(ax,
                             lm + corr_cos,
                             mz - corrzsun,
                             mzdn - corrzsun,
                             mzup - corrzsun,
                             'b',
                             's',
                             label='Andrews+13')
            #correction for Tremonti is the same.
            lm, mz, mzdn, mzup = common.load_observation(
                obsdir, 'MZR/Tremonti04.dat', [0, 1, 2, 3])
            common.errorbars(ax,
                             lm + corr_cos,
                             mz - corrzsun,
                             mzdn - corrzsun,
                             mzup - corrzsun,
                             'b',
                             'o',
                             label="Tremonti+04")

        #VR
        ind = np.where(ZSFMstar[idx, 0, :] != 0.)
        xplot = xmf[ind]
        yplot = ZSFMstar[idx, 0, ind] - log10zsun
        errdn = ZSFMstar[idx, 1, ind]
        errup = ZSFMstar[idx, 2, ind]

        if idx == 0:
            ax.plot(xplot, yplot[0], 'k', label='VR')
        if idx > 0:
            ax.plot(xplot, yplot[0], 'k')
        ax.fill_between(xplot,
                        yplot[0],
                        yplot[0] - errdn[0],
                        facecolor='k',
                        alpha=0.2,
                        interpolate=True)
        ax.fill_between(xplot,
                        yplot[0],
                        yplot[0] + errup[0],
                        facecolor='k',
                        alpha=0.2,
                        interpolate=True)

        if idx == 0:
            common.prepare_legend(ax, ['k', 'b', 'b'], loc='lower right')

    common.savefig(outdir, fig, "zsfgas_mstar_30kpc_z_comp_obs.pdf")

    ################ will plot stellar ages vs stellar mass
    xtit = "$\\rm log_{10} (\\rm M_{\\star, 30kpc}/M_{\odot})$"
    ytit = "$\\rm log_{10}(\\rm age_{\\star}/Gyr)$"
    xmin, xmax, ymin, ymax = 7, 12, 0, 1.1
    xleg = xmax - 0.2 * (xmax - xmin)
    yleg = ymax - 0.1 * (ymax - ymin)

    fig = plt.figure(figsize=(5, 10))

    idx = [0, 1, 2]

    zins = [0, 1, 2]
    subplots = [311, 312, 313]

    for subplot, idx, z, s in zip(subplots, idx, zins, snap):
        ax = fig.add_subplot(subplot)
        if (idx == 2):
            xtitplot = xtit
        else:
            xtitplot = ' '
        common.prepare_ax(ax,
                          xmin,
                          xmax,
                          ymin,
                          ymax,
                          xtitplot,
                          ytit,
                          locators=(0.1, 1, 0.1))
        ax.text(xleg, yleg, 'z=%s' % (str(z)))
        plt.subplots_adjust(left=0.2)

        #VR
        ind = np.where(AgeSMstar[idx, 0, :] != 0.)
        xplot = xmf[ind]
        yplot = AgeSMstar[idx, 0, ind]
        errdn = AgeSMstar[idx, 1, ind]
        errup = AgeSMstar[idx, 2, ind]

        if idx == 0:
            ax.plot(xplot, yplot[0], 'k', label='VR')
        if idx > 0:
            ax.plot(xplot, yplot[0], 'k')
        ax.fill_between(xplot,
                        yplot[0],
                        yplot[0] - errdn[0],
                        facecolor='k',
                        alpha=0.2,
                        interpolate=True)
        ax.fill_between(xplot,
                        yplot[0],
                        yplot[0] + errup[0],
                        facecolor='k',
                        alpha=0.2,
                        interpolate=True)

        #observations
        if (z == 0):
            lm, age, agedn, ageup = common.load_observation(
                obsdir, 'StellarPops/vdS19-age.csv', [0, 1, 2, 3])
            common.errorbars(ax,
                             lm,
                             age,
                             agedn,
                             ageup,
                             'b',
                             'D',
                             label='van de Sande+19')

        if idx == 0:
            common.prepare_legend(ax, ['k'])

    common.savefig(outdir, fig, "starage_mstar_z_comp_obs.pdf")

    ################ will plot black hole mass vs stellar mass
    xtit = "$\\rm log_{10} (\\rm M_{\\star, 30kpc}/M_{\odot})$"
    ytit = "$\\rm log_{10}(\\rm M_{\\rm BH}/M_{\odot})$"
    xmin, xmax, ymin, ymax = 7, 12, 6, 11
    xleg = xmax - 0.2 * (xmax - xmin)
    yleg = ymax - 0.1 * (ymax - ymin)

    fig = plt.figure(figsize=(5, 10))

    idx = [0, 1, 2]

    zins = [0, 1, 2]
    subplots = [311, 312, 313]

    for subplot, idx, z, s in zip(subplots, idx, zins, snap):
        ax = fig.add_subplot(subplot)
        if (idx == 2):
            xtitplot = xtit
        else:
            xtitplot = ' '
        common.prepare_ax(ax,
                          xmin,
                          xmax,
                          ymin,
                          ymax,
                          xtitplot,
                          ytit,
                          locators=(0.1, 1, 0.1))
        ax.text(xleg, yleg, 'z=%s' % (str(z)))
        plt.subplots_adjust(left=0.2)

        if (z == 0):
            #BH-bulge relation
            mBH_M13, errup_M13, errdn_M13, mBH_power, mbulge_M13 = common.load_observation(
                obsdir, 'BHs/MBH_sigma_Mbulge_McConnelMa2013.dat',
                [0, 1, 2, 3, 7])

            ind = np.where((mBH_M13 > 0) & (mbulge_M13 > 0))
            xobs = np.log10(mbulge_M13[ind])
            yobs = np.log10(mBH_M13[ind] * pow(10.0, mBH_power[ind]))
            lerr = np.log10(
                (mBH_M13[ind] - errdn_M13[ind]) * pow(10.0, mBH_power[ind]))
            herr = np.log10(
                (mBH_M13[ind] + errup_M13[ind]) * pow(10.0, mBH_power[ind]))
            ax.errorbar(xobs,
                        yobs,
                        yerr=[yobs - lerr, herr - yobs],
                        ls='None',
                        mfc='None',
                        ecolor='r',
                        mec='r',
                        marker='^',
                        label="McConnell & Ma 2013")

            #BH-bulge relation
            mBH_H04, errup_H04, errdn_H04, mbulge_H04 = common.load_observation(
                obsdir, 'BHs/MBH_sigma_Mbulge_HaeringRix2004.dat',
                [0, 1, 2, 4])

            xobs = np.log10(mbulge_H04)

            yobs = xobs * 0. - 999.
            indx = np.where(mBH_H04 > 0)
            yobs[indx] = np.log10(mBH_H04[indx])

            lerr = yobs * 0. - 999.
            indx = np.where((mBH_H04 - errdn_H04) > 0)
            lerr[indx] = np.log10(mBH_H04[indx] - errdn_H04[indx])

            herr = yobs * 0. + 999.
            indx = np.where((mBH_H04 + errup_H04) > 0)
            herr[indx] = np.log10(mBH_H04[indx] + errup_H04[indx])
            ax.errorbar(xobs,
                        yobs,
                        yerr=[yobs - lerr, herr - yobs],
                        ls='None',
                        mfc='None',
                        ecolor='maroon',
                        mec='maroon',
                        marker='s',
                        label="Haering+04")

        #VR
        ind = np.where(MBHMstar[idx, 0, :] != 0.)
        xplot = xmf[ind]
        yplot = MBHMstar[idx, 0, ind]
        errdn = MBHMstar[idx, 1, ind]
        errup = MBHMstar[idx, 2, ind]

        if idx == 0:
            ax.plot(xplot, yplot[0], 'k', label='VR')
        if idx > 0:
            ax.plot(xplot, yplot[0], 'k')
        ax.fill_between(xplot,
                        yplot[0],
                        yplot[0] - errdn[0],
                        facecolor='k',
                        alpha=0.2,
                        interpolate=True)
        ax.fill_between(xplot,
                        yplot[0],
                        yplot[0] + errup[0],
                        facecolor='k',
                        alpha=0.2,
                        interpolate=True)

        if idx == 0:
            common.prepare_legend(ax, ['k', 'r', 'maroon'], loc='upper left')

    common.savefig(outdir, fig, "blackhole_stellarmass_z_comp_obs.pdf")