Ejemplo n.º 1
0
def plot_HI_gas_fraction_groups(plt, output_dir, obs_dir, mHI_halos_stacking):

    ###################################
    #   Plots global mass densities
    fig = plt.figure(figsize=(5,4.5))

    xtit="$\\rm log_{10} (\\rm M_{\\rm halo}/M_{\odot}\,h^{-1})$"
    ytit="$\\rm log_{10}(M_{\\rm HI}/M_{\\rm halo})$"

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

    prepare_ax(ax, 10, 15, -5, -0.5, xtit, ytit)

    #Predicted SMHM
    ind = np.where((mHI_halos_stacking > 0) & (xmf > 10.3))
    xplot = xmf[ind]
    yplot = mHI_halos_stacking[ind]-xmf[ind]
    for i,j in zip (xplot,yplot):
    	print i,j

    ax.plot(xplot,yplot, color='k', linestyle='solid', label='Shark')


    common.prepare_legend(ax, ['k'])
    common.savefig(output_dir, fig, "HI_groups_stacking.pdf")
def conduct_bad_and_good(x, data, filename):
    """Study BadAndGoodLS algorithm."""
    r_1 = BadAndGoodLS(x, data, beta=0.01, gamma=40)
    r_1.fit()

    r_2 = BadAndGoodLS(x, data, beta=0.01, gamma=100)
    r_2.fit()

    r_3 = BadAndGoodLS(x, data, beta=0.01, gamma=200)
    r_3.fit()

    fig, ax = plt.subplots(1, 1, figsize=FIG_SIZE)
    ax.plot(x, data, 'o', label='Data')
    ax.plot(x, r_1.result, '-', label=r_1.name)
    ax.plot(x, r_2.result, '--', label=r_2.name)
    ax.plot(x, r_3.result, '-.', label=r_3.name)
    ax.legend(loc='best')
    ax.set_xlabel(r'$x$')
    ax.set_ylabel('Observations and fit')

    fig.tight_layout(pad=0.1)

    savefig(fig, filename)

    r_1.print_result()
    r_2.print_result()
    r_3.print_result()
Ejemplo n.º 3
0
def plot_cooling_rate(plt, outdir, med_tvir):

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

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

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

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

    common.prepare_legend(ax, ['r','k'], loc=2)
    common.savefig(outdir, fig, 'cooling_rate.pdf')
Ejemplo n.º 4
0
def plot_sft_efficiency(plt, outdir, redshifts, sfre, sfreH2, mhrat):

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

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

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

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

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

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

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

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

    common.savefig(outdir, fig, "cosmic_sfe.pdf")
Ejemplo n.º 5
0
def plot_baryon_fractions(plt, outdir, redshifts, mstar_dm, mcold_dm, mhot_dm,
                          meje_dm, mbar_dm):

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

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

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

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

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

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

    common.prepare_legend(ax, ['k', 'b', 'r', 'g', 'm', 'k'])
    common.savefig(outdir, fig, "baryon_frac.pdf")
Ejemplo n.º 6
0
def plot_caustic_halos(plt, outdir, sats_vproj, sats_rproj, sats_type):

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

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

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

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

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

    common.savefig(outdir, fig, 'caustic_groups.pdf')
Ejemplo n.º 7
0
def plot_curves(file_name, type_name, show_ylabel=True, show_legend=True):
    json_file = os.path.join(common.result_folder, file_name)
    xlabel = 'num_dexels'
    ylabel = 'time'
    with open(json_file, 'r') as f:
        database = json.load(f)
    # Get list of x entries
    x_array = set()
    for entries in database.values():
        x_array = x_array | set(entry[xlabel] for entry in entries)
    x_array = sorted(x_array)
    # Get list of y entries
    y_arrays = {}
    for i, entries in enumerate(database.values()):
        for entry in entries:
            key = (entry['operation'], entry['radius_relative'])
            if key not in y_arrays:
                y_arrays[key] = numpy.zeros(
                    (len(database.keys()), len(x_array)))
            j = x_array.index(entry[xlabel])
            y_arrays[key][i, j] = entry[ylabel] / 1000
    # Draw plot
    colors = itertools.cycle(('C0', 'C1', 'C2', 'C3'))
    markers = itertools.cycle(('o', '*', 'd', '^'))  # ',', +', '.', 'o', '*')
    linestyles = itertools.cycle(('-', '--', '-.', ':'))
    # plt.figure()
    fig, ax = common.newfig(1)
    show_conv = (type_name == 'loglog')
    for key, y_array in sorted(y_arrays.items()):
        r = key[1]
        c = next(colors)
        e = key[0].title()
        name = '{}, $r = {}$'.format(e, r)
        common.region_plot(x_array, y_array, c, c, name, next(linestyles),
                           next(markers), show_conv)
    if type_name == 'loglog':
        plt.loglog()
        ax.xaxis.set_major_formatter(plticker.LogFormatter(labelOnlyBase=True))
        ax.xaxis.set_minor_formatter(
            plticker.LogFormatter(labelOnlyBase=False,
                                  minor_thresholds=(4, 0.5)))
    plt.xlabel(common.legends[xlabel], fontsize='large')
    if show_ylabel:
        plt.ylabel(common.legends[ylabel], fontsize='large')
    # if show_legend:
    plt.legend(loc='upper left')
    result_plot = os.path.join(
        common.result_folder, ylabel + '_' + os.path.splitext(file_name)[0] +
        '_' + type_name + '.pdf')
    # plt.savefig(result_plot)
    common.savefig(result_plot)
Ejemplo n.º 8
0
    def myplot(tag3, ylabel):
        data = df[(df.tag1 != 'query') & (df.tag1 != 'ks') & (df.tag3 == tag3)]
        data = data.sort_values('var')

        for chain, group in data.groupby('tag1'):
            fig, ax = plt.subplots()

            for single, grp in group.groupby('tag2'):
                grp.plot(ax=ax, kind='line', x='var', y='value', label=single)

            ax.set_ylim((0, ax.yaxis.get_data_interval()[1]))
            ax.margins(y=0.1)
            ax.set_ylabel(ylabel)
            ax.set_xlabel(' ')
            cmn.savefig('top_' + chain + '_' + tag3, fig)
Ejemplo n.º 9
0
def plot_h1h2_gas_fraction(plt, output_dir, mhr_relation, mhr_relation_cen,
                           mhr_relation_sat):

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

    ax = fig.add_subplot(111)
    xtit = "$\\rm log_{10} (\\rm M_{\\star}/M_{\odot})$"
    ytit = "$\\rm log_{10}(M_{\\rm H_2}/M_{\\rm HI})$"
    prepare_ax(ax, 8, 12, -3, 1.0, xtit, ytit)

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

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

    ind = np.where(mhr_relation_cen[0, :] != 0)
    xplot = xmf[ind]
    yplot = mhr_relation_cen[0, ind]
    ax.errorbar(xplot,
                yplot[0],
                color='b',
                linestyle='dotted',
                label="centrals")

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

    common.prepare_legend(ax, ['k', 'b', 'r', 'grey', 'grey'])
    common.savefig(output_dir, fig, "HIH2_gas_fraction.pdf")
def conduct(x, data, noise, filename):
    """Conduct one experiment with data."""

    # Analyze the behavior of the non-normalized residuals first.
    lscf_def_noise = LSConservativeFormulation(x, data)
    lscf_def_noise.fit()

    fig, ax = plt.subplots(1, 2, figsize=FIG_SIZE)
    ax[0].bar(x, lscf_def_noise.residuals)
    ax[0].set_xlabel(r'$x$')
    ax[0].set_ylabel('Non-normalized residuals')

    kde = stats.gaussian_kde(lscf_def_noise.residuals)
    __, bins, __ = ax[1].hist(lscf_def_noise.residuals, density=True)
    xx = np.linspace(bins.min(), bins.max(), num=101)
    ax[1].plot(xx, kde(xx))
    ax[1].set_xlabel(r'$R$')
    ax[1].set_ylabel(r'Residuals PDF')

    fig.tight_layout(pad=0.1)
    savefig(fig, 'residuals-' + filename)

    # Now fit and plot the fitting results.
    ols = OLS(x, data, noise)
    ols.fit()

    lscf = LSConservativeFormulation(x, data, noise)
    lscf.fit()

    lsbag = BadAndGoodLS(x, data, noise=noise, beta=6/len(x), gamma=50)
    lsbag.fit()

    ols.print_result()
    lscf.print_result()
    lsbag.print_result()

    fig, ax = plt.subplots(1, 1, figsize=FIG_SIZE)
    ax.plot(x, data, 'o', label='Data')
    ax.plot(x, ols.result, '-', label='LS, ordinary')
    ax.plot(x, lscf.result, '--', label='LS, extension 1')
    ax.plot(x, lsbag.result, '-.', label='LS, extension 2')
    ax.legend(loc='best')
    ax.set_xlabel(r'$x$')
    ax.set_ylabel('Observations and fit')
    fig.tight_layout(pad=0.1)
    savefig(fig, filename)
Ejemplo n.º 11
0
def plot_mass_cosmic_density(plt, outdir, redshifts, mcold, mHI, mH2):

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

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

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

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

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

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

    common.prepare_legend(ax, ['k', 'b', 'r'], loc=1)
    common.savefig(outdir, fig, "omega_neutral.pdf")
Ejemplo n.º 12
0
def plot_sizes_combined(plt, outdir, rcomb):

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

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

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

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

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

    common.prepare_legend(ax, ['k', 'k', 'k'], loc=2)
    common.savefig(outdir, fig, 'sizes_combined.pdf')
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")
Ejemplo n.º 14
0
Archivo: smhm.py Proyecto: viogp/shark
def plot_SMHM_z(plt, outdir, z, massgal):

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

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

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

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

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

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

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

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

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

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

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

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

        m = log_epsilon + M1 + fx - f

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

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

    common.savefig(outdir, fig, 'SMHM_z.pdf')
Ejemplo n.º 15
0
Archivo: smhm.py Proyecto: viogp/shark
def plot_BMHM_z(plt, outdir, massbar, massbar_inside):

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    common.savefig(outdir, fig, 'BMHM_z.pdf')
Ejemplo n.º 16
0
def plot_con_lambda(plt, outdir, con, lam, snap):

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

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

    idx = [0,1,2]

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    common.savefig(outdir, fig, "lambda_mtot_z.pdf")
Ejemplo n.º 17
0
def plot_halomf_z(plt, outdir, obs_dir, snap, vol_eagle, hist, histsh):

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

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

    idx = [0,1,2]

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

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

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

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

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

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

    common.savefig(outdir, fig, "halomf_z.pdf")
Ejemplo n.º 18
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")
Ejemplo n.º 19
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")
Ejemplo n.º 20
0
def plot_lambda(plt, outdir, obsdir, lambdaH,  lambda_jiang, lambda_mass, bt, ms, ssfr_z0):

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    common.savefig(outdir, fig, 'lambda_relation.pdf')
Ejemplo n.º 21
0
def plot_halomf_z(plt, outdir, obsdir, z, h0, hist, histsh, plotz):

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    common.savefig(outdir, fig, "halomf_z0.pdf")
Ejemplo n.º 22
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
Ejemplo n.º 23
0
def plot_specific_am_ratio(plt, outdir, obsdir, sam_ratio_halo_disk, sam_ratio_halo_gal, sam_ratio_halo_disk_gas, 
                           sam_vs_sam_halo_disk, sam_vs_sam_halo_gal, sam_vs_sam_halo_disk_gas):

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

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

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

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

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

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

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

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


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

    selec = 0 #disk-dominated galaxies

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

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

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

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

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

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

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

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

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

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

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

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

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

    common.savefig(outdir, fig, 'specific_am_halo_vs_galaxy_z0.pdf')
Ejemplo n.º 24
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')
Ejemplo n.º 25
0
def plot_bt_resolve(plt, outdir, obsdir, ETGsmhalo, LTGsmhalo):

    resolve_obs_as_errorbars = functools.partial(_resolve_obs_as_errorbars,
                                                 obsdir)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    common.savefig(outdir, fig, 'bt_resolve.pdf')
Ejemplo n.º 26
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")
Ejemplo n.º 27
0
def plot_bmf_resolve(plt, outdir, obsdir, hist_bmf, hist_bmf_sat):

    load_resolve_mf_obs = functools.partial(_load_resolve_mf_obs, obsdir)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    common.savefig(outdir, fig, 'bmf_resolve.pdf')
Ejemplo n.º 28
0
def plot_mHI_mhalo_resolve(plt, outdir, obsdir, mHImhalo, mHImhalo_true):

    resolve_obs_as_errorbars = functools.partial(_resolve_obs_as_errorbars,
                                                 obsdir)

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

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

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

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

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

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

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

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

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

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

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

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

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

    #Save figure
    common.savefig(outdir, fig, 'mHI-mhalo_resolve.pdf')
Ejemplo n.º 29
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")
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")