Exemplo n.º 1
0
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")
Exemplo n.º 2
0
 def load_observation(self, *args, **kwargs):
     obsdir = os.path.normpath(
         os.path.abspath(os.path.join(__file__, '..', '..', 'data')))
     return common.load_observation(obsdir, *args, **kwargs)
Exemplo n.º 3
0
def plot_bulge_BH(plt, outdir, obsdir, BH):

    fig = plt.figure(figsize=(5, 4.5))
    xtit = "$\\rm log_{10} (\\rm M_{\\rm bulge}/M_{\odot})$"
    ytit = "$\\rm log_{10} (\\rm M_{\\rm BH}/M_{\odot})$"

    xmin, xmax, ymin, ymax = 8, 13, 5, 11
    xleg = xmax - 0.2 * (xmax - xmin)
    yleg = ymax - 0.1 * (ymax - ymin)

    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))
    ax.text(xleg, yleg, 'z=0')

    #Predicted SMHM
    ind = np.where(BH[0, 0, :] != 0)
    if (len(xmf[ind]) > 0):
        xplot = xmf[ind]
        yplot = BH[0, 0, ind]
        errdn = BH[0, 1, ind]
        errup = BH[0, 2, ind]
        ax.plot(xplot, yplot[0], color='k', label="Shark")
        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)

    MBH_othermodels = common.load_observation(
        obsdir, 'Models/SharkVariations/BHBulgeRelation_OtherModels.dat', [0])
    MBH_f_smbh0p008 = MBH_othermodels[0:29]
    MBH_f_smbh0p00008 = MBH_othermodels[30:60]
    ind = np.where(MBH_f_smbh0p008 != 0)
    xplot = xmf[ind]
    yplot = MBH_f_smbh0p008[ind]
    ax.plot(xplot,
            yplot,
            color='Goldenrod',
            linestyle='dashed',
            label='$f_{\\rm smbh}=8 \\times 10^{-3}$')
    ind = np.where(MBH_f_smbh0p00008 != 0)
    xplot = xmf[ind]
    yplot = MBH_f_smbh0p00008[ind]
    ax.plot(xplot,
            yplot,
            color='Orange',
            linestyle='dotted',
            label='$f_{\\rm smbh}=8 \\times 10^{-5}$')

    #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")

    common.prepare_legend(ax, ['k', 'Goldenrod', 'Orange', 'r', 'maroon'],
                          loc=2)
    common.savefig(outdir, fig, 'bulge-BH.pdf')
Exemplo n.º 4
0
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")
Exemplo n.º 5
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
Exemplo n.º 6
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")
Exemplo n.º 7
0
def plot_mass_densities(plt, outdir, obsdir, h0, redshifts, mstar, mcold, mhot,
                        meje, mstarden, mcoldden, mhotden, mejeden):

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

    xtit = "$\\rm Lookback\, time/Gyr$"
    ytit = "$\\rm log_{10}(\\rho/\\rho_{\\rm bar,halos})$"

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

    common.prepare_ax(ax,
                      0,
                      13.5,
                      -5,
                      0.1,
                      xtit,
                      ytit,
                      locators=(0.1, 1, 0.1, 1),
                      fontsize=10)
    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)

    ax.plot(us.look_back_time(redshifts), mstar, 'k', label='stars')
    ax.plot(us.look_back_time(redshifts), mcold, 'b', label='ISM gas')
    ax.plot(us.look_back_time(redshifts), mhot, 'r', label='halo gas')
    ax.plot(us.look_back_time(redshifts), meje, 'g', label='ejected gas')

    common.prepare_legend(ax, ['k', 'b', 'r', 'g'], fontsize=10)

    xtit = "$\\rm Lookback\, time/Gyr$"
    ytit = "$\\rm log_{10}(\\rho_{\\rm bar} /\\rm M_{\odot} \\rm Mpc^{-3})$"

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

    common.prepare_ax(ax,
                      0,
                      13.5,
                      6,
                      10,
                      xtit,
                      ytit,
                      locators=(0.1, 1, 0.1, 1),
                      fontsize=10)

    msharktot = mstarden + mcoldden + mhotden + mejeden
    ind = np.where(mstarden > 0)
    ax.plot(us.look_back_time(redshifts),
            np.log10(mstarden[ind] * pow(h0, 2.0)),
            'k',
            label='Shark')
    ind = np.where(mcoldden > 0)
    ax.plot(us.look_back_time(redshifts),
            np.log10(mcoldden[ind] * pow(h0, 2.0)), 'b')
    ind = np.where(mhotden > 0)
    ax.plot(us.look_back_time(redshifts),
            np.log10(mhotden[ind] * pow(h0, 2.0)), 'r')
    ind = np.where(mejeden > 0)
    ax.plot(us.look_back_time(redshifts),
            np.log10(mejeden[ind] * pow(h0, 2.0)), 'g')
    ind = np.where(msharktot > 0)
    ax.plot(us.look_back_time(redshifts),
            np.log10(msharktot[ind] * pow(h0, 2.0)), 'DarkMagenta')

    lbt, eaglesm, eaglesmout, eagleism, eaglehg, eagleejec = common.load_observation(
        obsdir, 'Models/OtherModels/EAGLE_BaryonGrowthTotal.dat',
        [0, 2, 3, 4, 5, 6])
    eaglesm = np.log10(pow(10.0, eaglesm) + pow(10.0, eaglesmout))
    eagletot = np.log10(
        pow(10.0, eaglesm) + pow(10.0, eagleism) + pow(10.0, eaglehg) +
        pow(10.0, eagleejec))
    ind = np.where(eaglesm > 0)
    ax.plot(lbt[ind],
            eaglesm[ind] - 6.0,
            'k',
            linestyle='dotted',
            label='EAGLE')
    ind = np.where(eagleism > 0)
    ax.plot(lbt[ind], eagleism[ind] - 6.0, 'b', linestyle='dotted')
    ind = np.where(eaglehg > 0)
    ax.plot(lbt[ind], eaglehg[ind] - 6.0, 'r', linestyle='dotted')
    ind = np.where(eagleejec > 0)
    ax.plot(lbt[ind], eagleejec[ind] - 6.0, 'g', linestyle='dotted')
    ind = np.where(eagletot > 0)
    ax.plot(lbt[ind], eagletot[ind] - 6.0, 'DarkMagenta', linestyle='dotted')

    common.prepare_legend(ax, ['k', 'k', 'k'], fontsize=10)

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

    common.prepare_ax(ax,
                      0,
                      13.5,
                      6,
                      10,
                      xtit,
                      ytit,
                      locators=(0.1, 1, 0.1, 1),
                      fontsize=10)

    ind = np.where(mstarden > 0)
    ax.plot(us.look_back_time(redshifts),
            np.log10(mstarden[ind] * pow(h0, 2.0)),
            'k',
            label='Shark')
    ind = np.where(mcoldden > 0)
    ax.plot(us.look_back_time(redshifts),
            np.log10(mcoldden[ind] * pow(h0, 2.0)), 'b')
    ind = np.where(mhotden > 0)
    ax.plot(us.look_back_time(redshifts),
            np.log10(mhotden[ind] * pow(h0, 2.0)), 'r')
    ind = np.where(mejeden > 0)
    ax.plot(us.look_back_time(redshifts),
            np.log10(mejeden[ind] * pow(h0, 2.0)), 'g')
    ind = np.where(msharktot > 0)
    ax.plot(us.look_back_time(redshifts),
            np.log10(msharktot[ind] * pow(h0, 2.0)), 'DarkMagenta')

    lbt, galsm, galism, galhg, galejec = common.load_observation(
        obsdir, 'Models/OtherModels/global_Mitchell18.dat', [0, 2, 3, 4, 5])
    galtot = np.log10(
        pow(10.0, galsm) + pow(10.0, galism) + pow(10.0, galhg) +
        pow(10.0, galejec))
    galsm = (galsm)
    galism = (galism)
    galhg = (galhg)
    galejec = (galejec)

    h = 0.704
    vol = 6.0  #np.log10(1953125.0/pow(h,3.0))
    ind = np.where(galsm > 0)
    ax.plot(lbt[ind],
            galsm[ind] - vol,
            'k',
            linestyle='dashed',
            label='GALFORM M18',
            linewidth=1)
    ind = np.where(galism > 0)
    ax.plot(lbt[ind], galism[ind] - vol, 'b', linestyle='dashed', linewidth=1)
    ind = np.where(galhg > 0)
    ax.plot(lbt[ind], galhg[ind] - vol, 'r', linestyle='dashed', linewidth=1)
    ind = np.where(galejec > 0)
    ax.plot(lbt[ind], galejec[ind] - vol, 'g', linestyle='dashed', linewidth=1)
    ind = np.where(galtot > 0)
    ax.plot(lbt[ind],
            galtot[ind] - vol,
            'DarkMagenta',
            linestyle='dashed',
            linewidth=1)

    common.prepare_legend(ax, ['k', 'k', 'k'], fontsize=10)

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

    common.prepare_ax(ax,
                      0,
                      13.5,
                      6,
                      10,
                      xtit,
                      ytit,
                      locators=(0.1, 1, 0.1, 1),
                      fontsize=10)

    ind = np.where(mstarden > 0)
    ax.plot(us.look_back_time(redshifts),
            np.log10(mstarden[ind] * pow(h0, 2.0)),
            'k',
            label='Shark')
    ind = np.where(mcoldden > 0)
    ax.plot(us.look_back_time(redshifts),
            np.log10(mcoldden[ind] * pow(h0, 2.0)), 'b')
    ind = np.where(mhotden > 0)
    ax.plot(us.look_back_time(redshifts),
            np.log10(mhotden[ind] * pow(h0, 2.0)), 'r')
    ind = np.where(mejeden > 0)
    ax.plot(us.look_back_time(redshifts),
            np.log10(mejeden[ind] * pow(h0, 2.0)), 'g')
    ind = np.where(msharktot > 0)
    ax.plot(us.look_back_time(redshifts),
            np.log10(msharktot[ind] * pow(h0, 2.0)), 'DarkMagenta')

    zbt, galism, galsm, galhg, galejec = common.load_observation(
        obsdir, 'Models/OtherModels/BaryonBudgetLgalaxies.dat',
        [1, 2, 3, 4, 5])
    lbt = us.look_back_time(zbt)
    galtot = np.log10(galsm + galism + galhg + galejec) + 10.0
    galsm = np.log10(galsm) + 10.0
    galism = np.log10(galism) + 10.0
    galhg = np.log10(galhg) + 10.0
    galejec = np.log10(galejec) + 10.0

    h = 0.673
    vol = np.log10(125000000.0 / pow(h, 3.0))
    ind = np.where(galsm > 0)
    ax.plot(lbt[ind],
            galsm[ind] - vol - np.log10(h),
            'k',
            linestyle='dashdot',
            label='L-galaxies H15',
            linewidth=1)
    ind = np.where(galism > 0)
    ax.plot(lbt[ind],
            galism[ind] - vol - np.log10(h),
            'b',
            linestyle='dashdot',
            linewidth=1)
    ind = np.where(galhg > 0)
    ax.plot(lbt[ind],
            galhg[ind] - vol - np.log10(h),
            'r',
            linestyle='dashdot',
            linewidth=1)
    ind = np.where(galejec > 0)
    ax.plot(lbt[ind],
            galejec[ind] - vol - np.log10(h),
            'g',
            linestyle='dashdot',
            linewidth=1)
    ind = np.where(galtot > 0)
    ax.plot(lbt[ind],
            galtot[ind] - vol - np.log10(h),
            'DarkMagenta',
            linestyle='dashdot',
            linewidth=1)

    common.prepare_legend(ax, ['k', 'k', 'k'], fontsize=10)

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

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

    xtit = "$\\rm Lookback\, time/Gyr$"
    ytit = "$\\rm log_{10}(\\rho_{\\rm gas, halo} /\\rm M_{\odot} \\rm Mpc^{-3})$"

    ax = fig.add_subplot(111)
    plt.subplots_adjust(bottom=0.15, left=0.15)
    common.prepare_ax(ax,
                      0,
                      13.5,
                      5,
                      10,
                      xtit,
                      ytit,
                      locators=(0.1, 1, 0.1, 1),
                      fontsize=10)

    ind = np.where(mhotden > 0)
    ax.plot(us.look_back_time(redshifts),
            np.log10(mhotden[ind] * pow(h0, 2.0)),
            'r',
            label='Shark')

    lbt, eaglesm, eaglesmout, eagleism, eaglehg, eagleejec = common.load_observation(
        obsdir, 'Models/OtherModels/EAGLE_BaryonGrowthTotal.dat',
        [0, 2, 3, 4, 5, 6])
    eaglesm = np.log10(pow(10.0, eaglesm) + pow(10.0, eaglesmout))
    eagletot = np.log10(
        pow(10.0, eaglesm) + pow(10.0, eagleism) + pow(10.0, eaglehg) +
        pow(10.0, eagleejec))
    ind = np.where(eaglehg > 0)
    ax.plot(lbt[ind],
            eaglehg[ind] - 6.0,
            'r',
            linestyle='dotted',
            label='EAGLE')

    lbt, galsm, galism, galhg, galejec = common.load_observation(
        obsdir, 'Models/OtherModels/global_Mitchell18.dat', [0, 2, 3, 4, 5])
    galtot = np.log10(
        pow(10.0, galsm) + pow(10.0, galism) + pow(10.0, galhg) +
        pow(10.0, galejec))
    galhg = (galhg)

    h = 0.704
    vol = 6.0  #np.log10(1953125.0/pow(h,3.0))
    ind = np.where(galhg > 0)
    ax.plot(lbt[ind],
            galhg[ind] - vol,
            'r',
            linestyle='dashed',
            linewidth=1,
            label='GALFORM M18')
    ind = np.where(galejec > 0)

    zbt, galism, galsm, galhg, galejec = common.load_observation(
        obsdir, 'Models/OtherModels/BaryonBudgetLgalaxies.dat',
        [1, 2, 3, 4, 5])
    lbt = us.look_back_time(zbt)
    galhg = np.log10(galhg) + 10.0

    h = 0.673
    vol = np.log10(125000000.0 / pow(h, 3.0))
    ind = np.where(galhg > 0)
    ax.plot(lbt[ind],
            galhg[ind] - vol - np.log10(h),
            'r',
            linestyle='dashdot',
            linewidth=1,
            label='L-galaxies H15')

    common.prepare_legend(ax, ['k', 'k', 'k', 'k'], fontsize=10)

    common.savefig(outdir, fig, "global_hotgas.pdf")
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")
Exemplo n.º 9
0
def plot_cosmic_dust(plt, outdir, obsdir, redshifts, h0, mdustden,
                     mdustden_mol):

    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 dust}/ M_{\odot}\,cMpc^{-3})$"
    common.prepare_ax(ax,
                      0,
                      13.5,
                      4,
                      6.3,
                      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(mdustden > 0)
    ax.plot(us.look_back_time(redshifts[ind]),
            np.log10(mdustden[ind] * pow(h0, 2.0)),
            'r',
            label='Shark all metals')

    ind = np.where(mdustden_mol > 0)
    ax.plot(us.look_back_time(redshifts[ind]),
            np.log10(mdustden_mol[ind] * pow(h0, 2.0)),
            'r',
            linestyle='dashed',
            label='Shark metals in molecular gas')

    #Baldry (Chabrier IMF), ['Baldry+2012, z<0.06']
    redD17d, redD17u, smdD17, err1, err2, err3, err4 = common.load_observation(
        obsdir, 'Global/Driver18_dust.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(us.look_back_time(xobs),
                yobs,
                yerr=[err, err],
                ls='None',
                mfc='None',
                ecolor='grey',
                mec='grey',
                marker='o',
                label="Driver+18")

    common.prepare_legend(ax, ['r', 'r', 'grey'])
    common.savefig(outdir, fig, "cosmic_dust.pdf")
Exemplo n.º 10
0
def plot_omega_HI(plt, outdir, obsdir, redshifts, h0, omegaHI):

    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 H_I})$"
    common.prepare_ax(ax,
                      0,
                      13.5,
                      -5,
                      -2,
                      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(omegaHI > 0)
    ax.plot(us.look_back_time(redshifts[ind]),
            np.log10(omegaHI[ind] * pow(h0, 2.0)) + np.log10(XH),
            'r',
            label='Shark')

    z, hi_modelvar = common.load_observation(
        obsdir, 'Models/SharkVariations/Global_OtherModels.dat', [0, 1])
    hi_modelvar_burst3 = hi_modelvar[0:179]
    hi_modelvar_nu0p5 = hi_modelvar[181:360]
    hi_modelvar_burst20 = hi_modelvar[360:539]

    ind = np.where(hi_modelvar_burst20 > -10)
    ax.plot(us.look_back_time(z[ind]),
            hi_modelvar_burst20[ind],
            'Sienna',
            linestyle='dotted',
            label='$\\eta_{\\rm burst}=20$')
    ind = np.where(hi_modelvar_burst3 > -10)
    ax.plot(us.look_back_time(z[ind]),
            hi_modelvar_burst3[ind],
            'Crimson',
            linestyle='dashdot',
            label='$\\eta_{\\rm burst}=3$')
    ind = np.where(hi_modelvar_nu0p5 > -10)
    ax.plot(us.look_back_time(z[ind]),
            hi_modelvar_nu0p5[ind],
            'Salmon',
            linestyle='dotted',
            label='$\\nu_{\\rm SF}=0.5 \\rm Gyr^{-1}$')

    xcgm = np.zeros(shape=2)
    ycgm = np.zeros(shape=2)

    xcgm[:] = 2.0
    ycgm[0] = -5.0
    ycgm[1] = -2.0
    ax.plot(us.look_back_time(xcgm),
            ycgm,
            'k',
            linestyle='dotted',
            linewidth=0.85)
    ax.arrow(us.look_back_time(2.0),
             -2.5,
             0.75,
             0,
             head_width=0.05,
             head_length=0.1,
             fc='k',
             ec='k')
    ax.text(10.55, -2.4, 'CGM?', fontsize=12)

    # Rhee+18 compilation
    redR18, reddR18, reduR18, omegaR18, errdnR18, errupR18 = common.load_observation(
        obsdir, 'Global/HI_density_Rhee18.dat', [1, 2, 3, 7, 8, 9])

    ax.errorbar(us.look_back_time(redR18),
                np.log10(omegaR18 * 1e-3),
                xerr=[reddR18, reduR18],
                yerr=[errdnR18, errupR18],
                ls='None',
                mfc='None',
                ecolor='grey',
                mec='grey',
                marker='o',
                label="Rhee+18 (comp)")

    common.prepare_legend(ax, ['r', 'Sienna', 'Crimson', 'Salmon', 'grey'])
    common.savefig(outdir, fig, "omega_HI.pdf")
Exemplo n.º 11
0
def plot_sfr_mstars_z0(plt, outdir, obsdir, h0, sfr_seq, mainseqsf,
                       sigmamainseqsf, slope_ms_z0, offset_ms_z0):

    fig = plt.figure(figsize=(5, 5))
    xtit = "$\\rm log_{10} (\\rm M_{\\star}/M_{\odot})$"
    ytit = "$\\rm log_{10}(\\rm SFR/M_{\odot} yr^{-1})$"

    xmin, xmax, ymin, ymax = 8, 12, -5, 3
    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, 1))

    #predicted relation
    ind = np.where((sfr_seq[0, :] > 0) & (sfr_seq[1, :] != 0))
    xdata = sfr_seq[0, ind]
    ydata = sfr_seq[1, ind]
    us.density_contour(ax, xdata[0], ydata[0], 30, 30)  #, **contour_kwargs)

    ind = np.where(mainseqsf[0, 0, :] != 0)
    xplot = xmf[ind]
    yplot = mainseqsf[0, 0, ind]
    ax.plot(xplot,
            yplot[0],
            color='k',
            linestyle='solid',
            linewidth=1,
            label="Shark all galaxies")

    #SFR relation z=0
    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')

    xdataD16 = [9.3, 10.6]
    ydataD16 = [-0.39, 0.477]
    ax.plot(xdataD16,
            ydataD16,
            color='b',
            linestyle='dashdot',
            linewidth=4,
            label='Davies+16')

    ax.plot(xmf, (slope_ms_z0 * xmf + offset_ms_z0) + xmf - 9.0,
            linewidth=3,
            linestyle='solid',
            color='grey',
            label='MS fit Shark')
    # Legend
    common.prepare_legend(ax, ['k', 'PaleVioletRed', 'b', 'grey'], loc=2)
    common.savefig(outdir, fig, 'SFR_Mstars_z0_MSShark.pdf')

    #plot scatter of the MS for all different definitions.
    fig = plt.figure(figsize=(5, 5))
    ytit = "$\\rm \\sigma_{\\rm SSFR}$"
    xtit = "$\\rm log_{10}(\\rm M_{\\star}/M_{\odot})$"

    xmin, xmax, ymin, ymax = 7, 11, 0, 1.4
    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, 1))
    ax.text(7.2, 1.3, '$\\rm SSFR>\\alpha MS(M_{\\star},fit)$')

    #predicted relation
    inputs = [0, 1, 2, 3, 4, 5]
    labels = [
        '$\\rm all$', '$\\rm log_{10}(SSFR/Gyr^{-1})>-2$', '$\\alpha=0.1$',
        '$\\alpha=0.12$', '$\\alpha=0.158$', '$\\alpha=0.25$'
    ]
    colors = ['k', 'b', 'LightSteelBlue', 'Orange', 'Red', 'DarkSalmon']
    lines = ['solid', 'dashed', 'dotted', 'dashdot', 'solid', 'dotted']
    for j in zip(inputs[:]):
        i = j[0]
        ind = np.where(sigmamainseqsf[0, i, :] != 0)
        yplot = sigmamainseqsf[0, i, ind]
        ax.plot(xmf[ind],
                yplot[0],
                color=colors[i],
                linestyle=lines[i],
                linewidth=1,
                label=labels[i])

    common.prepare_legend(ax, colors, bbox_to_anchor=(0.1, 0.45))
    common.savefig(outdir, fig, 'Scatter_mainsquence_z0.pdf')

    #plot scatter of the MS across redshifts.
    fig = plt.figure(figsize=(5, 5))
    ytit = "$\\rm \\sigma_{\\rm SSFR}$"
    xtit = "$\\rm log_{10}(\\rm M_{\\star}/M_{\odot})$"

    xmin, xmax, ymin, ymax = 7, 11, 0, 1.4
    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, 1))

    #predicted relation
    inputs = [0, 1, 2, 3, 4, 5]
    labels = ['z=0', 'z=0.5', 'z=1', 'z=2', 'z=3', 'z=4']
    colors = ['k', 'b', 'DarkTurquoise', 'YellowGreen', 'Gold', 'red']
    lines = ['solid', 'dashed', 'dotted', 'dashdot', 'solid', 'dotted']
    for j in zip(inputs[:]):
        i = j[0]
        ind = np.where(sigmamainseqsf[i, 4, :] != 0)
        yplot = sigmamainseqsf[i, 4, ind]
        ax.plot(xmf[ind],
                yplot[0],
                color=colors[i],
                linestyle=lines[i],
                linewidth=1,
                label=labels[i])

    common.prepare_legend(ax, colors, bbox_to_anchor=(0.1, 0.45))
    common.savefig(outdir, fig, 'Scatter_mainsquence_z_evolution.pdf')
Exemplo n.º 12
0
def plot_passive_fraction(plt, outdir, obsdir, passive_fractions, hist_ssfr,
                          passive_fractions_cens_sats):

    fig = plt.figure(figsize=(5, 4.5))
    xtit = "$\\rm log_{10} (\\rm M_{\\star}/M_{\odot})$"
    ytit = "$\\rm passive\,fraction$"

    xmin, xmax, ymin, ymax = 8, 12, 0, 1
    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, 1))

    ind = np.where(passive_fractions[0, 0, :] >= 0)
    xplot = xmf2[ind]
    yplot = passive_fractions[0, 0, ind]
    ax.plot(xplot,
            yplot[0],
            color='k',
            linestyle='solid',
            linewidth=1,
            label="Shark all galaxies")
    ind = np.where(passive_fractions[0, 1, :] >= 0)
    xplot = xmf2[ind]
    yplot = passive_fractions[0, 1, ind]
    ax.plot(xplot,
            yplot[0],
            color='b',
            linestyle='solid',
            linewidth=1,
            label="$\\rm M_{\\rm halo}<10^{12}\,M_{\odot}$")
    ind = np.where(passive_fractions[0, 2, :] >= 0)
    xplot = xmf2[ind]
    yplot = passive_fractions[0, 2, ind]
    ax.plot(xplot,
            yplot[0],
            color='r',
            linestyle='solid',
            linewidth=1,
            label="$\\rm M_{\\rm halo}> 10^{12}\,M_{\odot}$")

    #passive fraction z=0
    lm, frac = common.load_observation(
        obsdir, 'SFR/PassiveFraction_Halpha_Davies16.dat', (0, 1))
    ax.plot(lm[0:6],
            frac[0:6],
            color='k',
            linewidth=2,
            linestyle='dotted',
            label='Davies+16 all galaxies')
    ax.plot(lm[8:14],
            frac[8:14],
            color='b',
            linewidth=2,
            linestyle='dotted',
            label='Davies+16 isolated')
    ax.plot(lm[16:20],
            frac[16:20],
            color='r',
            linewidth=2,
            linestyle='dotted',
            label='Davies+16 groups')

    # Legend
    common.prepare_legend(ax, ['k', 'b', 'r', 'k', 'b', 'r'], loc=2)
    common.savefig(outdir, fig, 'passive_fraction_z0.pdf')

    #plot passive fraction for satellites/centrals in bins of stellar mass and halo mass
    fig = plt.figure(figsize=(12, 9))
    xtit = "$\\rm log_{10} (\\rm M_{\\rm halo}/M_{\odot})$"
    ytit = "$\\rm passive\,fraction$"

    subplots = (231, 232, 233, 234, 235, 236)
    titles = ('$\\rm 9<log_{10} (\\rm M_{\\star}/M_{\odot})<9.4$',
              '$\\rm 9.4<log_{10} (\\rm M_{\\star}/M_{\odot})<9.8$',
              '$\\rm 9.8<log_{10} (\\rm M_{\\star}/M_{\odot})<10.2$',
              '$\\rm 10.2<log_{10} (\\rm M_{\\star}/M_{\odot})<10.6$',
              '$\\rm 10.6<log_{10} (\\rm M_{\\star}/M_{\odot})<11$',
              '$\\rm 11<log_{10} (\\rm M_{\\star}/M_{\odot})<11.4$')
    xmin, xmax, ymin, ymax = 11, 14.5, 0, 1

    for j in range(0, 6):
        ax = fig.add_subplot(subplots[j])
        plt.subplots_adjust(bottom=0.15, left=0.15)

        xtitin = xtit
        if (j < 3):
            xtitin = ""
        common.prepare_ax(ax,
                          xmin,
                          xmax,
                          ymin,
                          ymax,
                          xtitin,
                          ytit,
                          locators=(0.1, 1, 0.1, 1))
        ax.text(11.1, 1.03, titles[j])

        ind = np.where(passive_fractions_cens_sats[0, 0, j, :] != 0)
        xplot = xmf2[ind]
        yplot = passive_fractions_cens_sats[0, 0, j, ind]
        ax.plot(xplot,
                yplot[0],
                color='b',
                linestyle='solid',
                linewidth=1,
                label="centrals")

        ind = np.where(passive_fractions_cens_sats[0, 1, j, :] != 0)
        xplot = xmf2[ind]
        yplot = passive_fractions_cens_sats[0, 1, j, ind]
        ax.plot(xplot,
                yplot[0],
                color='r',
                linestyle='dashed',
                linewidth=1,
                label="satellites")

        if (j == 0):
            # Legend
            common.prepare_legend(ax, ['b', 'r'], loc=2)

    common.savefig(outdir, fig, 'passive_fraction_z0_mhalo-mstars.pdf')
Exemplo n.º 13
0
def plot_bt_fractions(plt, outdir, obsdir, BT_fractions,
                      BT_fractions_nodiskins, BT_fractions_centrals,
                      BT_fractions_satellites):

    fig = plt.figure(figsize=(5, 4.5))
    xtit = "$\\rm log_{10} (\\rm M_{\\star}/M_{\odot})$"
    ytit = "$\\rm f_{\\rm bulge}$"
    xmin, xmax, ymin, ymax = 8, 12, -0.1, 1.05

    # LTG ##################################
    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, 1))

    #Predicted size-mass for disks
    ind = np.where(BT_fractions[0, :] >= 0)
    if (len(xmf[ind]) > 0):
        xplot = xmf[ind]
        yplot = BT_fractions[0, ind]
        ax.plot(xplot, yplot[0], 'k', label='bulges built by all processes')
        #for i in zip(BT_fractions[0,:]):
        #    print i

    ind = np.where(BT_fractions_nodiskins[0, :] >= 0)
    if (len(xmf[ind]) > 0):
        xplot = xmf[ind]
        yplot = BT_fractions_nodiskins[0, ind]
        ax.plot(xplot,
                yplot[0],
                'r',
                linestyle='dashed',
                label='only by mergers')

    #ind = np.where(BT_fractions_centrals[0,:] >= 0)
    #if(len(xmf[ind]) > 0):
    #    xplot = xmf[ind]
    #    yplot = BT_fractions_centrals[0,ind]
    #    ax.plot(xplot,yplot[0],'k', linestyle = 'dotted', label ='centrals')
    #ind = np.where(BT_fractions_satellites[0,:] >= 0)
    #if(len(xmf[ind]) > 0):
    #    xplot = xmf[ind]
    #    yplot = BT_fractions_satellites[0,ind]
    #    ax.plot(xplot,yplot[0],'k', linestyle = 'dashed', label ='satellites')

    BT_othermodels = common.load_observation(
        obsdir, 'Models/SharkVariations/BTFractions_OtherModels.dat', [0])
    BT_stable0 = BT_othermodels[0:29]
    BT_stable0p5 = BT_othermodels[30:60]
    BT_stable1 = BT_othermodels[91:120]

    ind = np.where(BT_stable0 >= 0)
    xplot = xmf[ind]
    yplot = BT_stable0[ind]
    ax.plot(xplot,
            yplot,
            color='Goldenrod',
            linestyle='dashdot',
            label='$\\epsilon_{\\rm disk}=0$')
    ind = np.where(BT_stable1 >= 0)
    xplot = xmf[ind]
    yplot = BT_stable1[ind]
    ax.plot(xplot,
            yplot,
            color='Orange',
            linestyle='dotted',
            label='$\\epsilon_{\\rm disk}=1$')

    #Baldry (Chabrier IMF), ['Baldry+2012, z<0.06']
    mM16, fM16, errdnfM16, errupfM16 = common.load_observation(
        obsdir, 'Morph/Moffet16.dat', [0, 1, 2, 3])
    errdnfM16 = np.abs(errdnfM16 - fM16)
    errupfM16 = np.abs(errupfM16 - fM16)
    ax.errorbar(mM16,
                fM16,
                yerr=[errdnfM16, errupfM16],
                ls='None',
                mfc='None',
                ecolor='grey',
                mec='grey',
                marker='^',
                label="Moffett+16")

    common.prepare_legend(ax, ['k', 'r', 'Goldenrod', 'Orange', 'grey'], loc=2)
    common.savefig(outdir, fig, 'BTfractions.pdf')
Exemplo n.º 14
0
def _load_resolve_mf_obs(obsdir, fname, cols):
    return common.load_observation(obsdir, 'RESOLVE/massfuncs/' + fname, cols)
Exemplo n.º 15
0
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")
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")
Exemplo n.º 17
0
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")
Exemplo n.º 18
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')
Exemplo n.º 19
0
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")
Exemplo n.º 20
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")
Exemplo n.º 21
0
def plot_molecular_gas_fraction(
        plt, output_dir, obs_dir, mgas_gals, mgas_relation, mh1_gals,
        mh1_relation, mh2_gals, mh2_relation, mgas_relation_ltg,
        mh2_relation_ltg, mh1_relation_ltg, mgas_relation_etg,
        mh2_relation_etg, mh1_relation_etg, mgas_ms_relation_ltg,
        mh2_ms_relation_ltg, mh1_ms_relation_ltg, mgas_ms_relation_etg,
        mh2_ms_relation_etg, mh1_ms_relation_etg):

    xmin, xmax, ymin, ymax = 9, 12, -3, 1
    fig = plt.figure(figsize=(11, 11))

    # First subplot
    ax = fig.add_subplot(321)
    plt.subplots_adjust(left=0.15)

    xtit = "$\\rm log_{10} (\\rm M_{\\star}/M_{\odot})$"
    ytit = "$\\rm log_{10}(M_{\\rm HI+H_2}/M_{\\star})$"
    prepare_ax(ax, xmin, xmax, ymin, ymax, xtit, ytit)

    #Predicted relation for all galaxies
    ind = np.where((mgas_gals[0, :] > 0) & (mgas_gals[1, :] != 0))
    xdata = mgas_gals[0, ind]
    ydata = mgas_gals[1, ind]
    us.density_contour(ax, xdata[0], ydata[0], 30, 30)  #, **contour_kwargs)

    def plot_mrelation(mrelation, color, label=None, linestyle=None):
        ind = np.where(mrelation[0, :] != 0)
        xplot = xmf[ind]
        yplot = mrelation[0, ind]
        linestyle = linestyle or ''
        ax.plot(xplot, yplot[0], color=color, label=label, linestyle=linestyle)

    def plot_mrelation_fill(mrelation,
                            color,
                            colorfill,
                            label=None,
                            linestyle=None):
        ind = np.where(mrelation[0, :] != 0)
        xplot = xmf[ind]
        yplot = mrelation[0, ind]
        errdn = mrelation[1, ind]
        errup = mrelation[2, ind]

        ax.plot(xplot, yplot[0], color=color, label=label, linestyle=linestyle)
        ax.fill_between(xplot,
                        yplot[0],
                        yplot[0] - errdn[0],
                        facecolor=colorfill,
                        alpha=0.2,
                        interpolate=True)
        ax.fill_between(xplot,
                        yplot[0],
                        yplot[0] + errup[0],
                        facecolor=colorfill,
                        alpha=0.2,
                        interpolate=True)

    plot_mrelation(mgas_relation,
                   'k',
                   linestyle='solid',
                   label="Shark all galaxies")

    #Baldry (Chabrier IMF), ['Baldry+2012, z<0.06']
    add_observations_to_plot(obs_dir,
                             'NeutralGasRatio_NonDetEQZero.dat',
                             ax,
                             '^',
                             "xCOLDGAS+xGASS(0)",
                             color='grey')
    add_observations_to_plot(obs_dir,
                             'NeutralGasRatio_NonDetEQUpperLimits.dat', ax,
                             'v', "xCOLDGAS+xGASS(UL)")

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

    # Second subplot
    ax = fig.add_subplot(322)
    xmin, xmax, ymin, ymax = 9, 12, -4.5, 1

    prepare_ax(ax, xmin, xmax, ymin, ymax, xtit, ytit)

    plot_mrelation_fill(mgas_relation_ltg,
                        'b',
                        'b',
                        label="Shark LTGs $(\\rm B/T)_{\\rm bar}$",
                        linestyle='solid')
    plot_mrelation_fill(mgas_relation_etg,
                        'r',
                        'r',
                        label="Shark ETGs $(\\rm B/T)_{\\rm bar}$",
                        linestyle='solid')
    plot_mrelation(mgas_ms_relation_ltg,
                   'b',
                   label="Shark LTGs $(\\rm B/T)_{\star}$",
                   linestyle='dotted')
    plot_mrelation(mgas_ms_relation_etg,
                   'r',
                   label="Shark ETGs $(\\rm B/T)_{\star}$",
                   linestyle='dotted')

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

    # Third subplot
    ax = fig.add_subplot(323)
    plt.subplots_adjust(left=0.15)

    xtit = "$\\rm log_{10} (\\rm M_{\\star}/M_{\odot})$"
    ytit = "$\\rm log_{10}(M_{\\rm HI}/M_{\\star})$"
    xmin, xmax, ymin, ymax = 9, 12, -3, 1
    prepare_ax(ax, xmin, xmax, ymin, ymax, xtit, ytit)

    #Predicted relation
    ind = np.where((mh1_gals[0, :] > 0) & (mh1_gals[1, :] != 0))
    xdata = mh1_gals[0, ind]
    ydata = mh1_gals[1, ind]
    us.density_contour(ax, xdata[0], ydata[0], 30, 30)  #, **contour_kwargs)
    plot_mrelation(mh1_relation, 'k', linestyle='solid')

    #Baldry (Chabrier IMF), ['Baldry+2012, z<0.06']
    add_observations_to_plot(obs_dir,
                             'HIGasRatio_NonDetEQZero.dat',
                             ax,
                             '^',
                             "xGASS(0)",
                             color='grey')
    add_observations_to_plot(obs_dir, 'HIGasRatio_NonDetEQUpperLimits.dat', ax,
                             'v', "xGASS(UL)")

    x, y, yerr_down, yerr_up = common.load_observation(obs_dir,
                                                       'Gas/Parkash18.dat',
                                                       (0, 1, 2, 3))
    ax.errorbar(x,
                y - x,
                yerr=[(y - x) - (yerr_down - x), (yerr_up - x) - (y - x)],
                ls='None',
                mfc='r',
                fillstyle='full',
                ecolor='r',
                mec='r',
                marker='s',
                markersize=7,
                label="Parkash+18")

    m, mrat, merr = common.load_observation(obs_dir,
                                            'Gas/RHI-Mstars_Brown15.dat',
                                            [0, 1, 2])
    errdn = np.log10(mrat) - np.log10(mrat - merr)
    errup = np.log10(mrat + merr) - np.log10(mrat)
    ax.errorbar(m,
                np.log10(mrat),
                yerr=[errdn, errup],
                ls='None',
                mfc='Salmon',
                fillstyle='full',
                ecolor='Salmon',
                mec='Salmon',
                marker='o',
                markersize=7,
                label="Brown+15")

    # Legend
    common.prepare_legend(ax, ['k', 'k', 'r', 'Salmon'], loc=1)

    # Fourth subplot
    ax = fig.add_subplot(324)
    xmin, xmax, ymin, ymax = 9, 12, -4.5, 1
    prepare_ax(ax, xmin, xmax, ymin, ymax, xtit, ytit)

    plot_mrelation_fill(mh1_relation_ltg, 'b', 'b', linestyle='solid')
    plot_mrelation_fill(mh1_relation_etg, 'r', 'r', linestyle='solid')
    plot_mrelation(mh1_ms_relation_ltg, 'b', linestyle='dotted')
    plot_mrelation(mh1_ms_relation_etg, 'r', linestyle='dotted')

    add_observations_to_plot(obs_dir,
                             'RHI-Mstars_Callette18-LTGs.dat',
                             ax,
                             's',
                             "Calette+18 LTGs",
                             color='grey',
                             err_absolute=True)
    add_observations_to_plot(obs_dir,
                             'RHI-Mstars_Callette18-ETGs.dat',
                             ax,
                             'o',
                             "Calette+18 ETGs",
                             color='grey',
                             err_absolute=True)

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

    # Fifth subplot
    ax = fig.add_subplot(325)
    plt.subplots_adjust(left=0.15)

    xtit = "$\\rm log_{10} (\\rm M_{\\star}/M_{\odot})$"
    ytit = "$\\rm log_{10}(M_{\\rm H_2}/M_{\\star})$"
    xmin, xmax, ymin, ymax = 9, 12, -3, 1
    prepare_ax(ax, xmin, xmax, ymin, ymax, xtit, ytit)

    #Predicted relation
    ind = np.where((mh2_gals[0, :] > 0) & (mh2_gals[1, :] != 0))
    xdata = mh2_gals[0, ind]
    ydata = mh2_gals[1, ind]
    us.density_contour(ax, xdata[0], ydata[0], 30, 30)  #, **contour_kwargs)
    plot_mrelation(mh2_relation, 'k', linestyle='solid')

    #Baldry (Chabrier IMF), ['Baldry+2012, z<0.06']
    add_observations_to_plot(obs_dir,
                             'MolecularGasRatio_NonDetEQZero.dat',
                             ax,
                             '^',
                             "xCOLDGASS(0)",
                             color='grey')
    add_observations_to_plot(obs_dir,
                             'MolecularGasRatio_NonDetEQUpperLimits.dat', ax,
                             'v', "xCOLDGASS(UL)")

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

    # Fourth subplot
    ax = fig.add_subplot(326)
    xmin, xmax, ymin, ymax = 9, 12, -4.5, 1
    prepare_ax(ax, xmin, xmax, ymin, ymax, xtit, ytit)

    plot_mrelation_fill(mh2_relation_ltg, 'b', 'b', linestyle='solid')
    plot_mrelation_fill(mh2_relation_etg, 'r', 'r', linestyle='solid')
    plot_mrelation(mh2_ms_relation_ltg, 'b', linestyle='dotted')
    plot_mrelation(mh2_ms_relation_etg, 'r', linestyle='dotted')

    add_observations_to_plot(obs_dir,
                             'RH2-Mstars_Callette18-LTGs.dat',
                             ax,
                             's',
                             "Calette+18 LTGs",
                             color='grey',
                             err_absolute=True)
    add_observations_to_plot(obs_dir,
                             'RH2-Mstars_Callette18-ETGs.dat',
                             ax,
                             'o',
                             "Calette+18 ETGs",
                             color='grey',
                             err_absolute=True)

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

    common.savefig(output_dir, fig, "molecular_gas_fraction.pdf")
Exemplo n.º 22
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")
Exemplo n.º 23
0
def plot_sizes(plt, outdir, obsdir, disk_size_cen, disk_size_sat, bulge_size,
               bulge_size_mergers, bulge_size_diskins):

    fig = plt.figure(figsize=(5, 9.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(211)
    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(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.errorbar(xplot,
                yplot[0],
                yerr=[errdn[0], errup[0]],
                ls='None',
                mfc='None',
                ecolor='k',
                mec='k',
                marker='o',
                label="Shark centrals")

    #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.errorbar(xplot,
                yplot[0],
                yerr=[errdn[0], errup[0]],
                ls='None',
                mfc='None',
                ecolor='r',
                mec='r',
                marker='v',
                markersize=5,
                label="Shark satellites")

    #Lange et al. (2016)
    a = 5.56
    aerr = 1.745
    b = 0.274
    ind = np.where(xmf < 10.3)
    rL16 = np.log10(a * pow((pow(10.0, xmf) / 1e10), b))

    ax.plot(xmf[ind], rL16[ind], 'b', linestyle='solid', label='L16 disks')

    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="50th, 68th, 90th")
    ax.plot(m[38:83], r[38:83], linestyle='dotted', color='b')
    ax.plot(m[85:128], r[85:129], linestyle='dotted', color='b')

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

    # 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(212)
    common.prepare_ax(ax,
                      xmin,
                      xmax,
                      ymin,
                      ymax,
                      xtit,
                      ytit,
                      locators=(0.1, 1, 0.1, 1))

    #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.errorbar(xplot,
                    yplot[0],
                    yerr=[errdn[0], errup[0]],
                    ls='None',
                    mfc='None',
                    ecolor='k',
                    mec='k',
                    marker='o',
                    label="Shark bulges")
        #for i in zip(bulge_size[0,0,:]):
        #    print i

    ind = np.where((bulge_size_diskins[0, 0, :] != 0) & (xmf > 10.2))
    if (len(xmf[ind]) > 0):
        xplot = xmf[ind]
        yplot = bulge_size_diskins[0, 0, ind]
        err = bulge_size[0, 1, ind]
        err[:] = 0
        ax.errorbar(xplot,
                    yplot[0],
                    yerr=[err[0], err[0]],
                    ls='None',
                    mfc='None',
                    ecolor='Orange',
                    mec='Orange',
                    marker='s',
                    markersize=4,
                    label="disk instability driven")

    ind = np.where((bulge_size_mergers[0, 0, :] != 0) & (xmf > 10.2))
    if (len(xmf[ind]) > 0):
        xplot = xmf[ind]
        yplot = bulge_size_mergers[0, 0, ind]
        err = bulge_size[0, 1, ind]
        err[:] = 0
        ax.errorbar(xplot,
                    yplot[0],
                    yerr=[err[0], err[0]],
                    ls='None',
                    mfc='None',
                    ecolor='DarkCyan',
                    mec='DarkCyan',
                    marker='D',
                    markersize=4,
                    label="merger driven")

    rb_nodissipation = common.load_observation(
        obsdir, 'Models/SharkVariations/SizeBulges_OtherModels.dat', [0])
    ind = np.where(rb_nodissipation != 0)
    xplot = xmf[ind]
    yplot = rb_nodissipation[ind]
    err = xmf[ind]
    err[:] = 0
    ax.errorbar(xplot,
                yplot,
                yerr=[err, err],
                ls='None',
                mfc='None',
                ecolor='LightSlateGray',
                mec='LightSlateGray',
                marker='x',
                markersize=6,
                label="no dissipation")

    #Lange et al. (2016)
    a = 2.319
    aerr = 1.186
    b = 0.19565217391
    a2 = 1.390
    aerr2 = 0.9
    b2 = 0.624

    ind = np.where(xmf <= 10.3)

    rL16 = np.log10(a * pow((pow(10.0, xmf[ind]) / 1e10), b))
    ax.plot(xmf[ind],
            rL16,
            'r',
            linestyle='solid',
            label='L16 $M_{\\star}<2\\times 10^{10}\\rm M_{\odot}$')

    ind = np.where((xmf >= 10.3) & (xmf < 11.5))
    rL16_2 = np.log10(a2 * pow((pow(10.0, xmf[ind]) / 1e10), b2))

    ax.plot(xmf[ind],
            rL16_2,
            'm',
            linestyle='solid',
            label='L16 $M_{\\star}>2\\times 10^{10}\\rm M_{\odot}$')

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

    common.prepare_legend(
        ax, ['r', 'm', 'k', 'Orange', 'DarkCyan', 'LightSlateGray'], loc=2)
    common.savefig(outdir, fig, 'sizes.pdf')