Esempio n. 1
0
def line_ratios():
    """ 
    Get distribution of line ratios with respect to H-a to perhaps use as a prior
    in fitting codes.
    """
    import unicorn.paper1 as p1
    import unicorn
    import threedhst

    import numpy as np
    import matplotlib.pyplot as plt

    sel, NOBJ = p1.sdss_selection(zmax=0.2)

    plt.hist(np.log10(p1.sdss_line.NII_6584_FLUX[sel] /
                      p1.sdss_line.H_ALPHA_FLUX[sel]),
             bins=100,
             range=(-2, 2))
    plt.hist(np.log10(p1.sdss_line.H_BETA_FLUX[sel] /
                      p1.sdss_line.H_ALPHA_FLUX[sel]),
             bins=100,
             range=(-3, 3))
    plt.hist(np.log10(p1.sdss_line.H_BETA_FLUX[sel] /
                      p1.sdss_line.OIII_5007_FLUX[sel]),
             bins=100,
             range=(-3, 3))
Esempio n. 2
0
def line_ratios():
    """ 
    Get distribution of line ratios with respect to H-a to perhaps use as a prior
    in fitting codes.
    """
    import unicorn.paper1 as p1
    import unicorn
    import threedhst

    import numpy as np
    import matplotlib.pyplot as plt

    sel, NOBJ = p1.sdss_selection(zmax=0.2)

    plt.hist(np.log10(p1.sdss_line.NII_6584_FLUX[sel] / p1.sdss_line.H_ALPHA_FLUX[sel]), bins=100, range=(-2, 2))
    plt.hist(np.log10(p1.sdss_line.H_BETA_FLUX[sel] / p1.sdss_line.H_ALPHA_FLUX[sel]), bins=100, range=(-3, 3))
    plt.hist(np.log10(p1.sdss_line.H_BETA_FLUX[sel] / p1.sdss_line.OIII_5007_FLUX[sel]), bins=100, range=(-3, 3))
Esempio n. 3
0
def testing():
    """
    Make some simple plots like SSFR vs M
    """
    import unicorn.paper1 as p1

    sel, NOBJ = p1.sdss_selection(zmax=0.2)

    #### Mass vs. sSFR
    plt.plot(p1.sdss_logm.AVG[sel],
             p1.sdss_totspecsfr.AVG[sel],
             marker='.',
             color='red',
             alpha=0.01,
             linestyle='None')

    plt.xlim(9, 12)
    plt.ylim(-13, -8.5)

    #### Star-forming galaxies, S/N limit on line fluxes
    SN_line_limit = 3
    SN_lines = (
        p1.sdss_line.NII_6584_FLUX / p1.sdss_line.NII_6584_FLUX_ERR >
        SN_line_limit) & (
            p1.sdss_line.H_ALPHA_FLUX / p1.sdss_line.H_ALPHA_FLUX_ERR >
            SN_line_limit) & (
                p1.sdss_line.OIII_5007_FLUX / p1.sdss_line.OIII_5007_FLUX_ERR >
                SN_line_limit) & (p1.sdss_line.H_BETA_FLUX /
                                  p1.sdss_line.H_BETA_FLUX_ERR > SN_line_limit)

    gal_lines = sel & SN_lines  # & (p1.sdss_totspecsfr > -10.7)

    ### BPT diagram
    bptx = np.log10(p1.sdss_line.NII_6584_FLUX / p1.sdss_line.H_ALPHA_FLUX)
    bpty = np.log10(p1.sdss_line.OIII_5007_FLUX / p1.sdss_line.H_BETA_FLUX)
    bpty_doublet = np.log10(
        (p1.sdss_line.OIII_5007_FLUX + p1.sdss_line.OIII_4959_FLUX) /
        p1.sdss_line.H_BETA_FLUX)

    # plt.plot(bptx[gal_lines], bpty[gal_lines], marker='.', color='black', alpha=0.01, linestyle='None')

    hist, xedge, yedge = np.histogram2d(bptx[gal_lines],
                                        bpty[gal_lines],
                                        bins=100,
                                        range=[[-1.5, 0.8], [-1.2, 1.5]])

    # plt.imshow(hist.transpose(), interpolation='nearest')
    # plt.contour(xedge[1:], yedge[1:], hist.transpose(), [64,256,512], colors='red', alpha=1.0, linethick=2)

    Vbins = [2, 4, 8, 16, 32, 64, 128, 256, 512, 4096]
    values = 1. - np.arange(len(Vbins)) * 1. / len(Vbins)
    Vcolors = []
    for i in range(len(Vbins)):
        Vcolors.append('%f' % (values[i]))

    plt.gray()
    plt.contourf(xedge[1:],
                 yedge[1:],
                 hist.transpose(),
                 Vbins,
                 colors=Vcolors,
                 alpha=1.0,
                 linethick=2)
    plt.gray()
    plt.contourf(xedge[1:],
                 yedge[1:],
                 hist.transpose(),
                 Vbins,
                 colors=Vcolors,
                 alpha=1.0,
                 linethick=2)

    ### kauffman separation between SF galaxies and AGN
    xsf = np.arange(100) / 100. * 1.5 - 1.5
    ysf = 0.61 / (xsf - 0.05) + 1.3
    plt.plot(xsf, ysf, color='b', alpha=0.6, linewidth=2)

    #### star-forming galaxies
    ysf_int = np.interp(bptx, xsf, ysf, right=-10, left=-10)
    sfg = (bpty < ysf_int) & (bptx < -0.1) & gal_lines
    qui = ((bpty > ysf_int) | (bptx > -0.1)) & sel
    agn = (bpty > ysf_int) & gal_lines

    yy = bpty
    # yy = bpty_doublet

    plt.plot(bptx[sfg],
             yy[sfg],
             color='blue',
             alpha=0.01,
             marker='.',
             linestyle='None')
    plt.plot(bptx[agn],
             yy[agn],
             color='red',
             alpha=0.01,
             marker='.',
             linestyle='None')

    plt.xlim(-1.5, 0.8)
    plt.ylim(-1.2, 1.5)
    plt.xlabel('[NII]6584 / H' + r'$\alpha$')
    plt.ylabel('[OIII]5007 / H' + r'$\beta$')

    #### Mass vs. sSFR, for SFGs and AGN
    hist, xedge, yedge = np.histogram2d(p1.sdss_logm.AVG[sel],
                                        p1.sdss_totspecsfr.AVG[sel],
                                        bins=100,
                                        range=[[9, 12], [-13, -8.5]])
    plt.gray()
    plt.contourf(xedge[1:],
                 yedge[1:],
                 hist.transpose(),
                 Vbins,
                 colors=Vcolors,
                 alpha=1.0,
                 linethick=2)
    plt.gray()
    plt.contourf(xedge[1:],
                 yedge[1:],
                 hist.transpose(),
                 Vbins,
                 colors=Vcolors,
                 alpha=1.0,
                 linethick=2)

    plt.plot(p1.sdss_logm.AVG[sfg],
             p1.sdss_totspecsfr.AVG[sfg],
             marker='.',
             color='blue',
             alpha=0.01,
             linestyle='None')
    plt.plot(p1.sdss_logm.AVG[agn],
             p1.sdss_totspecsfr.AVG[agn],
             marker='.',
             color='red',
             alpha=0.01,
             linestyle='None')

    plt.xlim(9, 12)
    plt.ylim(-13, -8.5)
    plt.xlabel(r'$\log\ M/M_\odot$')
    plt.ylabel('sSFR')

    #### Mass vs. H-a eqw
    #plt.plot(p1.sdss_logm.AVG[sel], p1.sdss_line.H_ALPHA_EQW[sel], marker='.', color='black', alpha=0.01, linestyle='None')

    ### log
    hist, xedge, yedge = np.histogram2d(
        p1.sdss_logm.AVG[sel],
        np.log10(-p1.sdss_line.H_ALPHA_EQW[sel]),
        bins=100,
        range=[[9, 11.6], [-1, 2.7]])
    plt.contourf(xedge[1:],
                 10**yedge[1:],
                 hist.transpose(),
                 Vbins,
                 colors=Vcolors,
                 alpha=1.0,
                 linethick=2)
    plt.semilogy()

    hist, xedge, yedge = np.histogram2d(p1.sdss_logm.AVG[sel],
                                        -p1.sdss_line.H_ALPHA_EQW[sel],
                                        bins=100,
                                        range=[[9, 12], [-10, 80]])
    plt.gray()
    plt.contourf(xedge[1:],
                 yedge[1:],
                 hist.transpose(),
                 Vbins,
                 colors=Vcolors,
                 alpha=1.0,
                 linethick=2)
    plt.gray()
    plt.contourf(xedge[1:],
                 yedge[1:],
                 hist.transpose(),
                 Vbins,
                 colors=Vcolors,
                 alpha=1.0,
                 linethick=2)

    plt.plot(p1.sdss_logm.AVG[sfg],
             p1.sdss_line.H_ALPHA_EQW[sfg],
             marker='.',
             color='blue',
             alpha=0.01,
             linestyle='None')
    plt.plot(p1.sdss_logm.AVG[agn],
             p1.sdss_line.H_ALPHA_EQW[agn],
             marker='.',
             color='red',
             alpha=0.01,
             linestyle='None')

    plt.xlim(9, 12)
    plt.ylim(-80, 10)
    plt.xlabel(r'$\log\ M/M_\odot$')
    plt.ylabel(r'$\mathrm{EQW\ H}\alpha$')

    ### test colors
    hist, xedge, yedge = np.histogram2d(p1.sdss_logm.AVG[sel],
                                        p1.sdss_line.H_ALPHA_EQW[sel],
                                        bins=100,
                                        range=[[9, 12], [-80, 10]])
    plt.contourf(xedge[1:],
                 yedge[1:],
                 hist.transpose(),
                 Vbins,
                 colors=gen_rgb_colortable(Vbins=Vbins,
                                           rgb=(1, 1, 1),
                                           reverse=True),
                 alpha=1.0,
                 linethick=2)

    NBIN = 25
    Vbins = [2, 4, 8, 16, 32, 64, 128, 256, 512, 4096]
    Vbins = list(np.array(Vbins) * 100 / NBIN)

    hist, xedge, yedge = np.histogram2d(p1.sdss_logm.AVG[agn],
                                        p1.sdss_line.H_ALPHA_EQW[agn],
                                        bins=NBIN,
                                        range=[[9, 12], [-80, 10]])
    #plt.contourf(xedge[1:], yedge[1:], hist.transpose(), Vbins, colors=gen_rgb_colortable(Vbins=Vbins, rgb=(1,0,0), reverse=True), alpha=0.6, linethick=2)
    plt.contour(xedge[1:],
                yedge[1:],
                hist.transpose(),
                Vbins,
                colors='red',
                alpha=0.6,
                linethick=2)

    hist, xedge, yedge = np.histogram2d(p1.sdss_logm.AVG[sfg],
                                        p1.sdss_line.H_ALPHA_EQW[sfg],
                                        bins=NBIN,
                                        range=[[9, 12], [-80, 10]])
    #plt.contourf(xedge[1:], yedge[1:], hist.transpose(), Vbins, colors=gen_rgb_colortable(Vbins=Vbins, rgb=(0,0,1), reverse=True), alpha=0.6, linethick=2)
    plt.contour(xedge[1:],
                yedge[1:],
                hist.transpose(),
                Vbins,
                colors='blue',
                alpha=0.6,
                linethick=2)

    #### Eq-w vs sSFR
    plt.plot(p1.sdss_line.H_ALPHA_EQW[sel],
             p1.sdss_totspecsfr.AVG[sel],
             marker='.',
             color='black',
             alpha=0.01,
             linestyle='None')
    plt.xlim(-80, 10)
    plt.ylim(-13, -8.5)
    plt.ylabel(r'$\mathrm{EQW\ H}\alpha$')
    plt.xlabel(r'$\mathrm{sSFR}$')

    ##### Check OIII 4959/5007 line ratios for SF galaxies
    sfg_weak_oiii = sfg & (p1.sdss_line.OIII_4959_FLUX /
                           p1.sdss_line.OIII_4959_FLUX_ERR > SN_line_limit)
    plt.plot(np.log10(p1.sdss_line.OIII_5007_FLUX[sfg_weak_oiii]),
             (p1.sdss_line.OIII_4959_FLUX /
              p1.sdss_line.OIII_5007_FLUX)[sfg_weak_oiii],
             marker='.',
             linestyle='None',
             alpha=0.01,
             color='black')

    avg_ratio = threedhst.utils.biweight(
        (p1.sdss_line.OIII_4959_FLUX / p1.sdss_line.OIII_5007_FLUX
         )[sfg_weak_oiii & (np.log10(p1.sdss_line.OIII_5007_FLUX) > 1.5)],
        mean=True)
    plt.plot([0, 10], [1. / 2.98, 1. / 2.98], color='red', linewidth=2)

    plt.ylim(-0.1, 1)
    plt.xlim(0, 4)

    ##### Case B H-a/H-b
    plt.plot(np.log10(p1.sdss_line.H_ALPHA_FLUX[sfg]),
             (p1.sdss_line.H_BETA_FLUX / p1.sdss_line.H_ALPHA_FLUX)[sfg],
             marker='.',
             linestyle='None',
             alpha=0.01,
             color='black')
    plt.plot([0, 10], [1. / 2.86, 1. / 2.86], color='red', linewidth=2)

    plt.ylim(-0.1, 1)
    plt.xlim(0, 4)

    ##### Mass vs sersic n
    plt.plot(p1.sdss_logm.AVG[sfg],
             p1.sdss_sersic.SERSIC_N[sfg, 3],
             marker='.',
             color='blue',
             alpha=0.01,
             linestyle='None')
    plt.plot(p1.sdss_logm.AVG[qui],
             p1.sdss_sersic.SERSIC_N[qui, 3],
             marker='.',
             color='red',
             alpha=0.01,
             linestyle='None')

    hist, xedge, yedge = np.histogram2d(p1.sdss_logm.AVG[sel],
                                        p1.sdss_sersic.SERSIC_N[sel, 3],
                                        bins=100,
                                        range=[[9, 12], [0, 6]])
    plt.contourf(xedge[1:],
                 yedge[1:],
                 hist.transpose(),
                 Vbins,
                 colors=Vcolors,
                 alpha=1.0,
                 linethick=2)

    plt.xlabel(r'$\log\ M/M_\odot$')
    plt.ylabel(r'$\mathrm{Sersic}\ n$')

    plt.xlim(9, 12)
    plt.ylim(0, 6)

    ##### Mass vs size
    plt.plot(p1.sdss_logm.AVG[sfg], (p1.sdss_sersic.SERSIC_R50_i_KPC[sfg]),
             marker='.',
             color='blue',
             alpha=0.01,
             linestyle='None')
    plt.plot(p1.sdss_logm.AVG[qui], (p1.sdss_sersic.SERSIC_R50_i_KPC[qui]),
             marker='.',
             color='red',
             alpha=0.01,
             linestyle='None')

    hist, xedge, yedge = np.histogram2d(p1.sdss_logm.AVG[sel],
                                        np.log10(p1.sdss_sersic.SERSIC_R50[sel,
                                                                           3]),
                                        bins=100,
                                        range=[[9, 12], [-0.3, 1]])
    plt.contourf(xedge[1:],
                 yedge[1:],
                 hist.transpose(),
                 Vbins,
                 colors=Vcolors,
                 alpha=1.0,
                 linethick=2)

    plt.xlabel(r'$\log\ M/M_\odot$')
    plt.ylabel(r'$R_{50}$')

    plt.xlim(9, 12)
    plt.ylim(0, 6)
Esempio n. 4
0
def explore_em_lines():
    """
    Look at ratios of OIII4363, 5007, HB, NeIII 3869
    
    some of the selections come from unicorn.paper1
    
    """

    sel, NOBJ = p1.sdss_selection(zmax=0.2)
    SN_line_limit = 3
    SN_lines = (
        p1.sdss_line.NII_6584_FLUX / p1.sdss_line.NII_6584_FLUX_ERR >
        SN_line_limit) & (
            p1.sdss_line.H_ALPHA_FLUX / p1.sdss_line.H_ALPHA_FLUX_ERR >
            SN_line_limit) & (
                p1.sdss_line.OIII_5007_FLUX / p1.sdss_line.OIII_5007_FLUX_ERR >
                SN_line_limit) & (p1.sdss_line.H_BETA_FLUX /
                                  p1.sdss_line.H_BETA_FLUX_ERR > SN_line_limit)

    gal_lines = sel & SN_lines  # & (p1.sdss_totspecsfr > -10.7)

    ### BPT diagram
    bptx = np.log10(p1.sdss_line.NII_6584_FLUX / p1.sdss_line.H_ALPHA_FLUX)
    bpty = np.log10(p1.sdss_line.OIII_5007_FLUX / p1.sdss_line.H_BETA_FLUX)
    bpty_doublet = np.log10(
        (p1.sdss_line.OIII_5007_FLUX + p1.sdss_line.OIII_4959_FLUX) /
        p1.sdss_line.H_BETA_FLUX)

    ### kauffman separation between SF galaxies and AGN
    xsf = np.arange(100) / 100. * 1.5 - 1.5
    ysf = 0.61 / (xsf - 0.05) + 1.3

    #### star-forming galaxies
    ysf_int = np.interp(bptx, xsf, ysf, right=-10, left=-10)
    sfg = (bpty < ysf_int) & (bptx < -0.1) & gal_lines
    qui = ((bpty > ysf_int) | (bptx > -0.1)) & sel
    agn = (bpty > ysf_int) & gal_lines

    ######
    oiii_doublet = p1.sdss_line.OIII_5007_FLUX + p1.sdss_line.OIII_4959_FLUX
    x = np.log10(oiii_doublet / p1.sdss_line.H_GAMMA_FLUX)
    y = np.log10(p1.sdss_line.OIII_4363_FLUX / oiii_doublet)
    y = np.log10(p1.sdss_line.NEIII_3869_FLUX / oiii_doublet)

    y = np.log10(p1.sdss_line.NEIII_3869_FLUX / p1.sdss_line.H_GAMMA_FLUX)

    #### tail of objects in the plot, NeIII / H g
    yb = [-0.11, 0.64]
    xb = [0.81, 1.53]
    yi = np.interp(x, xb, yb)
    box = (y < (yi - 0.2)) & (x > 0.8)
    plt.plot(x[box], y[box], marker='.', alpha=0.05, color='green')

    plt.plot(x[sel], y[sel], marker='.', alpha=0.05)
    plt.plot(x[gal_lines], y[gal_lines], marker='.', alpha=0.05)

    plt.plot(x[agn], y[agn], marker='.', alpha=0.05, color='red')
    plt.plot(x[sfg], y[sfg], marker='.', alpha=0.05, color='blue')
    #plt.plot(x[qui], y[qui], ',', alpha=0.05, color='orange')
    #plt.plot(np.log10(4.125e-15/7.566e-16)*np.array([1,1]),[-2,2])
    plt.plot(np.log10(4.125e-15 / 3.342e-16) * np.array([1, 1]), [-2, 2],
             color='green')
    plt.plot([-2, 2],
             np.log10(2.818e-16 / 3.342e-16) * np.array([1, 1]),
             color='green')
    #plt.plot([-2,2], np.log10(2.818e-16/4.125e-15)*np.array([1,1]), color='green')

    yy = bpty_doublet
    plt.plot(bptx[sfg],
             yy[sfg],
             color='blue',
             alpha=0.05,
             marker='.',
             linestyle='None')
    plt.plot(bptx[agn],
             yy[agn],
             color='red',
             alpha=0.05,
             marker='.',
             linestyle='None')
    plt.plot(bptx[box],
             yy[box],
             color='green',
             alpha=0.05,
             marker='.',
             linestyle='None')
    plt.plot([-2, 2],
             np.log10(4.125e-15 / 7.566e-16) * np.array([1, 1]),
             color='green')
Esempio n. 5
0
def testing():
    """
    Make some simple plots like SSFR vs M
    """
    import unicorn.paper1 as p1

    sel, NOBJ = p1.sdss_selection(zmax=0.2)

    #### Mass vs. sSFR
    plt.plot(p1.sdss_logm.AVG[sel], p1.sdss_totspecsfr.AVG[sel], marker=".", color="red", alpha=0.01, linestyle="None")

    plt.xlim(9, 12)
    plt.ylim(-13, -8.5)

    #### Star-forming galaxies, S/N limit on line fluxes
    SN_line_limit = 3
    SN_lines = (
        (p1.sdss_line.NII_6584_FLUX / p1.sdss_line.NII_6584_FLUX_ERR > SN_line_limit)
        & (p1.sdss_line.H_ALPHA_FLUX / p1.sdss_line.H_ALPHA_FLUX_ERR > SN_line_limit)
        & (p1.sdss_line.OIII_5007_FLUX / p1.sdss_line.OIII_5007_FLUX_ERR > SN_line_limit)
        & (p1.sdss_line.H_BETA_FLUX / p1.sdss_line.H_BETA_FLUX_ERR > SN_line_limit)
    )

    gal_lines = sel & SN_lines  # & (p1.sdss_totspecsfr > -10.7)

    ### BPT diagram
    bptx = np.log10(p1.sdss_line.NII_6584_FLUX / p1.sdss_line.H_ALPHA_FLUX)
    bpty = np.log10(p1.sdss_line.OIII_5007_FLUX / p1.sdss_line.H_BETA_FLUX)
    bpty_doublet = np.log10((p1.sdss_line.OIII_5007_FLUX + p1.sdss_line.OIII_4959_FLUX) / p1.sdss_line.H_BETA_FLUX)

    # plt.plot(bptx[gal_lines], bpty[gal_lines], marker='.', color='black', alpha=0.01, linestyle='None')

    hist, xedge, yedge = np.histogram2d(bptx[gal_lines], bpty[gal_lines], bins=100, range=[[-1.5, 0.8], [-1.2, 1.5]])

    # plt.imshow(hist.transpose(), interpolation='nearest')
    # plt.contour(xedge[1:], yedge[1:], hist.transpose(), [64,256,512], colors='red', alpha=1.0, linethick=2)

    Vbins = [2, 4, 8, 16, 32, 64, 128, 256, 512, 4096]
    values = 1.0 - np.arange(len(Vbins)) * 1.0 / len(Vbins)
    Vcolors = []
    for i in range(len(Vbins)):
        Vcolors.append("%f" % (values[i]))

    plt.gray()
    plt.contourf(xedge[1:], yedge[1:], hist.transpose(), Vbins, colors=Vcolors, alpha=1.0, linethick=2)
    plt.gray()
    plt.contourf(xedge[1:], yedge[1:], hist.transpose(), Vbins, colors=Vcolors, alpha=1.0, linethick=2)

    ### kauffman separation between SF galaxies and AGN
    xsf = np.arange(100) / 100.0 * 1.5 - 1.5
    ysf = 0.61 / (xsf - 0.05) + 1.3
    plt.plot(xsf, ysf, color="b", alpha=0.6, linewidth=2)

    #### star-forming galaxies
    ysf_int = np.interp(bptx, xsf, ysf, right=-10, left=-10)
    sfg = (bpty < ysf_int) & (bptx < -0.1) & gal_lines
    qui = ((bpty > ysf_int) | (bptx > -0.1)) & sel
    agn = (bpty > ysf_int) & gal_lines

    yy = bpty
    # yy = bpty_doublet

    plt.plot(bptx[sfg], yy[sfg], color="blue", alpha=0.01, marker=".", linestyle="None")
    plt.plot(bptx[agn], yy[agn], color="red", alpha=0.01, marker=".", linestyle="None")

    plt.xlim(-1.5, 0.8)
    plt.ylim(-1.2, 1.5)
    plt.xlabel("[NII]6584 / H" + r"$\alpha$")
    plt.ylabel("[OIII]5007 / H" + r"$\beta$")

    #### Mass vs. sSFR, for SFGs and AGN
    hist, xedge, yedge = np.histogram2d(
        p1.sdss_logm.AVG[sel], p1.sdss_totspecsfr.AVG[sel], bins=100, range=[[9, 12], [-13, -8.5]]
    )
    plt.gray()
    plt.contourf(xedge[1:], yedge[1:], hist.transpose(), Vbins, colors=Vcolors, alpha=1.0, linethick=2)
    plt.gray()
    plt.contourf(xedge[1:], yedge[1:], hist.transpose(), Vbins, colors=Vcolors, alpha=1.0, linethick=2)

    plt.plot(p1.sdss_logm.AVG[sfg], p1.sdss_totspecsfr.AVG[sfg], marker=".", color="blue", alpha=0.01, linestyle="None")
    plt.plot(p1.sdss_logm.AVG[agn], p1.sdss_totspecsfr.AVG[agn], marker=".", color="red", alpha=0.01, linestyle="None")

    plt.xlim(9, 12)
    plt.ylim(-13, -8.5)
    plt.xlabel(r"$\log\ M/M_\odot$")
    plt.ylabel("sSFR")

    #### Mass vs. H-a eqw
    # plt.plot(p1.sdss_logm.AVG[sel], p1.sdss_line.H_ALPHA_EQW[sel], marker='.', color='black', alpha=0.01, linestyle='None')

    ### log
    hist, xedge, yedge = np.histogram2d(
        p1.sdss_logm.AVG[sel], np.log10(-p1.sdss_line.H_ALPHA_EQW[sel]), bins=100, range=[[9, 11.6], [-1, 2.7]]
    )
    plt.contourf(xedge[1:], 10 ** yedge[1:], hist.transpose(), Vbins, colors=Vcolors, alpha=1.0, linethick=2)
    plt.semilogy()

    hist, xedge, yedge = np.histogram2d(
        p1.sdss_logm.AVG[sel], -p1.sdss_line.H_ALPHA_EQW[sel], bins=100, range=[[9, 12], [-10, 80]]
    )
    plt.gray()
    plt.contourf(xedge[1:], yedge[1:], hist.transpose(), Vbins, colors=Vcolors, alpha=1.0, linethick=2)
    plt.gray()
    plt.contourf(xedge[1:], yedge[1:], hist.transpose(), Vbins, colors=Vcolors, alpha=1.0, linethick=2)

    plt.plot(
        p1.sdss_logm.AVG[sfg], p1.sdss_line.H_ALPHA_EQW[sfg], marker=".", color="blue", alpha=0.01, linestyle="None"
    )
    plt.plot(
        p1.sdss_logm.AVG[agn], p1.sdss_line.H_ALPHA_EQW[agn], marker=".", color="red", alpha=0.01, linestyle="None"
    )

    plt.xlim(9, 12)
    plt.ylim(-80, 10)
    plt.xlabel(r"$\log\ M/M_\odot$")
    plt.ylabel(r"$\mathrm{EQW\ H}\alpha$")

    ### test colors
    hist, xedge, yedge = np.histogram2d(
        p1.sdss_logm.AVG[sel], p1.sdss_line.H_ALPHA_EQW[sel], bins=100, range=[[9, 12], [-80, 10]]
    )
    plt.contourf(
        xedge[1:],
        yedge[1:],
        hist.transpose(),
        Vbins,
        colors=gen_rgb_colortable(Vbins=Vbins, rgb=(1, 1, 1), reverse=True),
        alpha=1.0,
        linethick=2,
    )

    NBIN = 25
    Vbins = [2, 4, 8, 16, 32, 64, 128, 256, 512, 4096]
    Vbins = list(np.array(Vbins) * 100 / NBIN)

    hist, xedge, yedge = np.histogram2d(
        p1.sdss_logm.AVG[agn], p1.sdss_line.H_ALPHA_EQW[agn], bins=NBIN, range=[[9, 12], [-80, 10]]
    )
    # plt.contourf(xedge[1:], yedge[1:], hist.transpose(), Vbins, colors=gen_rgb_colortable(Vbins=Vbins, rgb=(1,0,0), reverse=True), alpha=0.6, linethick=2)
    plt.contour(xedge[1:], yedge[1:], hist.transpose(), Vbins, colors="red", alpha=0.6, linethick=2)

    hist, xedge, yedge = np.histogram2d(
        p1.sdss_logm.AVG[sfg], p1.sdss_line.H_ALPHA_EQW[sfg], bins=NBIN, range=[[9, 12], [-80, 10]]
    )
    # plt.contourf(xedge[1:], yedge[1:], hist.transpose(), Vbins, colors=gen_rgb_colortable(Vbins=Vbins, rgb=(0,0,1), reverse=True), alpha=0.6, linethick=2)
    plt.contour(xedge[1:], yedge[1:], hist.transpose(), Vbins, colors="blue", alpha=0.6, linethick=2)

    #### Eq-w vs sSFR
    plt.plot(
        p1.sdss_line.H_ALPHA_EQW[sel],
        p1.sdss_totspecsfr.AVG[sel],
        marker=".",
        color="black",
        alpha=0.01,
        linestyle="None",
    )
    plt.xlim(-80, 10)
    plt.ylim(-13, -8.5)
    plt.ylabel(r"$\mathrm{EQW\ H}\alpha$")
    plt.xlabel(r"$\mathrm{sSFR}$")

    ##### Check OIII 4959/5007 line ratios for SF galaxies
    sfg_weak_oiii = sfg & (p1.sdss_line.OIII_4959_FLUX / p1.sdss_line.OIII_4959_FLUX_ERR > SN_line_limit)
    plt.plot(
        np.log10(p1.sdss_line.OIII_5007_FLUX[sfg_weak_oiii]),
        (p1.sdss_line.OIII_4959_FLUX / p1.sdss_line.OIII_5007_FLUX)[sfg_weak_oiii],
        marker=".",
        linestyle="None",
        alpha=0.01,
        color="black",
    )

    avg_ratio = threedhst.utils.biweight(
        (p1.sdss_line.OIII_4959_FLUX / p1.sdss_line.OIII_5007_FLUX)[
            sfg_weak_oiii & (np.log10(p1.sdss_line.OIII_5007_FLUX) > 1.5)
        ],
        mean=True,
    )
    plt.plot([0, 10], [1.0 / 2.98, 1.0 / 2.98], color="red", linewidth=2)

    plt.ylim(-0.1, 1)
    plt.xlim(0, 4)

    ##### Case B H-a/H-b
    plt.plot(
        np.log10(p1.sdss_line.H_ALPHA_FLUX[sfg]),
        (p1.sdss_line.H_BETA_FLUX / p1.sdss_line.H_ALPHA_FLUX)[sfg],
        marker=".",
        linestyle="None",
        alpha=0.01,
        color="black",
    )
    plt.plot([0, 10], [1.0 / 2.86, 1.0 / 2.86], color="red", linewidth=2)

    plt.ylim(-0.1, 1)
    plt.xlim(0, 4)

    ##### Mass vs sersic n
    plt.plot(
        p1.sdss_logm.AVG[sfg], p1.sdss_sersic.SERSIC_N[sfg, 3], marker=".", color="blue", alpha=0.01, linestyle="None"
    )
    plt.plot(
        p1.sdss_logm.AVG[qui], p1.sdss_sersic.SERSIC_N[qui, 3], marker=".", color="red", alpha=0.01, linestyle="None"
    )

    hist, xedge, yedge = np.histogram2d(
        p1.sdss_logm.AVG[sel], p1.sdss_sersic.SERSIC_N[sel, 3], bins=100, range=[[9, 12], [0, 6]]
    )
    plt.contourf(xedge[1:], yedge[1:], hist.transpose(), Vbins, colors=Vcolors, alpha=1.0, linethick=2)

    plt.xlabel(r"$\log\ M/M_\odot$")
    plt.ylabel(r"$\mathrm{Sersic}\ n$")

    plt.xlim(9, 12)
    plt.ylim(0, 6)

    ##### Mass vs size
    plt.plot(
        p1.sdss_logm.AVG[sfg],
        (p1.sdss_sersic.SERSIC_R50_i_KPC[sfg]),
        marker=".",
        color="blue",
        alpha=0.01,
        linestyle="None",
    )
    plt.plot(
        p1.sdss_logm.AVG[qui],
        (p1.sdss_sersic.SERSIC_R50_i_KPC[qui]),
        marker=".",
        color="red",
        alpha=0.01,
        linestyle="None",
    )

    hist, xedge, yedge = np.histogram2d(
        p1.sdss_logm.AVG[sel], np.log10(p1.sdss_sersic.SERSIC_R50[sel, 3]), bins=100, range=[[9, 12], [-0.3, 1]]
    )
    plt.contourf(xedge[1:], yedge[1:], hist.transpose(), Vbins, colors=Vcolors, alpha=1.0, linethick=2)

    plt.xlabel(r"$\log\ M/M_\odot$")
    plt.ylabel(r"$R_{50}$")

    plt.xlim(9, 12)
    plt.ylim(0, 6)
Esempio n. 6
0
def explore_em_lines():
    """
    Look at ratios of OIII4363, 5007, HB, NeIII 3869
    
    some of the selections come from unicorn.paper1
    
    """

    sel, NOBJ = p1.sdss_selection(zmax=0.2)
    SN_line_limit = 3
    SN_lines = (
        (p1.sdss_line.NII_6584_FLUX / p1.sdss_line.NII_6584_FLUX_ERR > SN_line_limit)
        & (p1.sdss_line.H_ALPHA_FLUX / p1.sdss_line.H_ALPHA_FLUX_ERR > SN_line_limit)
        & (p1.sdss_line.OIII_5007_FLUX / p1.sdss_line.OIII_5007_FLUX_ERR > SN_line_limit)
        & (p1.sdss_line.H_BETA_FLUX / p1.sdss_line.H_BETA_FLUX_ERR > SN_line_limit)
    )

    gal_lines = sel & SN_lines  # & (p1.sdss_totspecsfr > -10.7)

    ### BPT diagram
    bptx = np.log10(p1.sdss_line.NII_6584_FLUX / p1.sdss_line.H_ALPHA_FLUX)
    bpty = np.log10(p1.sdss_line.OIII_5007_FLUX / p1.sdss_line.H_BETA_FLUX)
    bpty_doublet = np.log10((p1.sdss_line.OIII_5007_FLUX + p1.sdss_line.OIII_4959_FLUX) / p1.sdss_line.H_BETA_FLUX)

    ### kauffman separation between SF galaxies and AGN
    xsf = np.arange(100) / 100.0 * 1.5 - 1.5
    ysf = 0.61 / (xsf - 0.05) + 1.3

    #### star-forming galaxies
    ysf_int = np.interp(bptx, xsf, ysf, right=-10, left=-10)
    sfg = (bpty < ysf_int) & (bptx < -0.1) & gal_lines
    qui = ((bpty > ysf_int) | (bptx > -0.1)) & sel
    agn = (bpty > ysf_int) & gal_lines

    ######
    oiii_doublet = p1.sdss_line.OIII_5007_FLUX + p1.sdss_line.OIII_4959_FLUX
    x = np.log10(oiii_doublet / p1.sdss_line.H_GAMMA_FLUX)
    y = np.log10(p1.sdss_line.OIII_4363_FLUX / oiii_doublet)
    y = np.log10(p1.sdss_line.NEIII_3869_FLUX / oiii_doublet)

    y = np.log10(p1.sdss_line.NEIII_3869_FLUX / p1.sdss_line.H_GAMMA_FLUX)

    #### tail of objects in the plot, NeIII / H g
    yb = [-0.11, 0.64]
    xb = [0.81, 1.53]
    yi = np.interp(x, xb, yb)
    box = (y < (yi - 0.2)) & (x > 0.8)
    plt.plot(x[box], y[box], marker=".", alpha=0.05, color="green")

    plt.plot(x[sel], y[sel], marker=".", alpha=0.05)
    plt.plot(x[gal_lines], y[gal_lines], marker=".", alpha=0.05)

    plt.plot(x[agn], y[agn], marker=".", alpha=0.05, color="red")
    plt.plot(x[sfg], y[sfg], marker=".", alpha=0.05, color="blue")
    # plt.plot(x[qui], y[qui], ',', alpha=0.05, color='orange')
    # plt.plot(np.log10(4.125e-15/7.566e-16)*np.array([1,1]),[-2,2])
    plt.plot(np.log10(4.125e-15 / 3.342e-16) * np.array([1, 1]), [-2, 2], color="green")
    plt.plot([-2, 2], np.log10(2.818e-16 / 3.342e-16) * np.array([1, 1]), color="green")
    # plt.plot([-2,2], np.log10(2.818e-16/4.125e-15)*np.array([1,1]), color='green')

    yy = bpty_doublet
    plt.plot(bptx[sfg], yy[sfg], color="blue", alpha=0.05, marker=".", linestyle="None")
    plt.plot(bptx[agn], yy[agn], color="red", alpha=0.05, marker=".", linestyle="None")
    plt.plot(bptx[box], yy[box], color="green", alpha=0.05, marker=".", linestyle="None")
    plt.plot([-2, 2], np.log10(4.125e-15 / 7.566e-16) * np.array([1, 1]), color="green")