Esempio n. 1
0
def plot_starburst(path,
                   db,
                   reshifts,
                   out_folder,
                   xmin=0.0,
                   xmax=2.0,
                   fluxlimit=5):
    '''
    Plots 
    '''
    #figure
    fig = P.figure()
    ax = fig.add_subplot(111)

    for i, reds in enumerate(redshifts):
        query = '''select galprop.mstar_burst - galprop.mstar, FIR.pacs160_obs*1000
                from FIR, galprop where
                %s and
                FIR.gal_id = galprop.gal_id and
                FIR.halo_id = galprop.halo_id
                ''' % reds
        #tmp
        tmp = reds.split()
        zz = N.mean(N.array([float(tmp[2]), float(tmp[6])]))

        #get data
        data = N.array(sq.get_data_sqlitePowerTen(path, db, query))

        #set 1
        xd = N.log10(data[:, 1])
        yd = data[:, 0]

        #percentiles
        xmaxb = N.max(xd)
        nxbins = int(12 * (xmaxb - xmin))
        xbin_midd, y50d, y16d, y84d = dm.percentile_bins(xd,
                                                         yd,
                                                         xmin,
                                                         xmaxb,
                                                         nxbins=nxbins)
        msk = y50d > -10
        add = eval('0.0%s' % str(i))
        ax.errorbar(xbin_midd[msk] + add,
                    y50d[msk],
                    yerr=[y50d[msk] - y16d[msk], y84d[msk] - y50d[msk]],
                    label='$z = %.1f$' % zz)

    ax.axvline(N.log10(fluxlimit), ls=':', color='green')

    ax.set_xlabel('$\log_{10}(S_{160} \ [\mathrm{mJy}])$')
    ax.set_ylabel(
        r'$\log_{10} \left ( \frac{M_{starbust}}{M_{\star}} \right )$')

    ax.set_xlim(xmin, xmax)
    ax.set_ylim(-3.0, -0.5)

    P.legend(loc='lower right')
    P.savefig(out_folder + 'mburstratio.ps')
Esempio n. 2
0
def plot_DMmass(path,
                db,
                redshifts,
                out_folder,
                xmin=0.0,
                xmax=2.5,
                fluxlimit=5):
    """
    Generates a dark matter halo mass prediction plot.
    """
    lines = ["-", "--", "-.", ":"]
    linecycler = cycle(lines)
    colour = count(0.1, 0.1)

    #figure
    fig = P.figure()
    ax = fig.add_subplot(111)

    for i, reds in enumerate(redshifts):
        #query = '''select galprop.mhalo, FIR.spire250_obs*1000
        query = '''select galprop.mhalo, FIR.pacs160_obs*1000
                from FIR, galprop where
                %s and 
                FIR.gal_id = galprop.gal_id and
                FIR.halo_id = galprop.halo_id
                ''' % reds
        #tmp
        tmp = reds.split()
        zz = N.mean(N.array([float(tmp[2]), float(tmp[6])]))

        #get data
        data = N.array(sq.get_data_sqlitePowerTen(path, db, query))

        #set 1
        xd = N.log10(data[:, 1])
        yd = data[:, 0]

        #percentiles
        xmaxb = N.max(xd)
        nxbins = int(9 * (xmaxb - xmin))
        xbin_midd, y50d, y16d, y84d = dm.percentile_bins(xd,
                                                         yd,
                                                         xmin,
                                                         xmaxb,
                                                         nxbins=nxbins,
                                                         limit=9)
        msk = y50d > -10
        add = eval('0.0%s' % str(i))
        ax.errorbar(xbin_midd[msk] + add,
                    y50d[msk],
                    yerr=[y50d[msk] - y16d[msk], y84d[msk] - y50d[msk]],
                    ls=next(linecycler),
                    c=str(colour.next()),
                    label='$z = %.1f$' % zz)

    #ax.axvline(N.log10(fluxlimit), ls=':', color='green')
    #BW
    ax.axvline(N.log10(fluxlimit), ls=':', color='0.25')

    #ax.set_xlabel('$\log_{10}(S_{250} \ [\mathrm{mJy}])$')
    ax.set_xlabel('$\log_{10}(S_{160} \ [\mathrm{mJy}])$')
    ax.set_ylabel('$\log_{10}(M_{\mathrm{dm}} \ [M_{\odot}])$')

    ax.set_xlim(xmin, xmax)
    ax.set_ylim(10.98, 13.3)

    P.legend(loc='lower right')
    P.savefig(out_folder + 'DMmass2.ps')
Esempio n. 3
0
def plot_sfrs(path,
              db,
              redshifts,
              out_folder,
              xmin=0.0,
              xmax=2.3,
              fluxlimit=5,
              obs=True):
    '''
    Plots SFR
    '''
    lines = ["-", "--", "-.", ":"]
    linecycler = cycle(lines)
    colour = count(0.1, 0.1)

    #figure
    fig = P.figure()
    ax = fig.add_subplot(111)

    for reds in redshifts:
        #query = '''select galprop.mstardot, FIR.pacs160_obs*1000
        query = '''select galprop.mstardot, FIR.spire250_obs*1000
                from FIR, galprop where
                %s and
                FIR.gal_id = galprop.gal_id and
                FIR.halo_id = galprop.halo_id
                ''' % reds
        #tmp
        tmp = reds.split()
        zz = N.mean(N.array([float(tmp[2]), float(tmp[6])]))

        #get data
        data = sq.get_data_sqlitePowerTen(path, db, query)

        #set 1
        xd = N.log10(data[:, 1])
        yd = N.log10(data[:, 0])

        #percentiles
        xmaxb = N.max(xd)
        nxbins = int(11 * (xmaxb - xmin))
        xbin_midd, y50d, y16d, y84d = dm.percentile_bins(xd,
                                                         yd,
                                                         xmin,
                                                         xmaxb,
                                                         nxbins=nxbins)

        msk = y50d > -10
        ax.errorbar(xbin_midd[msk],
                    y50d[msk],
                    yerr=[y50d[msk] - y16d[msk], y84d[msk] - y50d[msk]],
                    ls=next(linecycler),
                    c=str(colour.next()),
                    label='$z = %.1f$' % zz)

        print '\nStraight line fit for z = %.1f' % zz
        tmp = fit.linearregression(xbin_midd[msk], y50d[msk], report=True)
        #tmp = fit.linearregression(xd, yd,
        #                           report = True)

    #ax.axvline(N.log10(fluxlimit), ls=':', color='green')
    ax.axvline(N.log10(fluxlimit), ls=':', color='0.25')

    if obs:
        data = N.loadtxt('/Users/sammy/Research/Herschel/LaceySFRs.txt')
        data[:, 2] = N.log10(10**data[:, 2] / (1. / (1. / 0.7)))
        msk1 = data[:, 0] < 15
        msk2 = (data[:, 0] > 15) & (data[:, 0] < 35)
        msk3 = (data[:, 0] > 35) & (data[:, 0] < 55)
        msk4 = (data[:, 0] > 55) & (data[:, 0] < 70)
        msk5 = (data[:, 0] > 70) & (data[:, 0] < 80)
        ax.plot(data[msk1][:, 1],
                data[msk1][:, 2],
                c='0.1',
                ls='--',
                label='$\mathrm{L10:}\ z = 0.25$')
        ax.plot(data[msk2][:, 1],
                data[msk2][:, 2],
                c='0.2',
                ls='--',
                label='$\mathrm{L10:}\ z = 1.0$')
        ax.plot(data[msk3][:, 1],
                data[msk3][:, 2],
                c='0.3',
                ls='--',
                label='$\mathrm{L10:}\ z = 2.0$')
        ax.plot(data[msk4][:, 1],
                data[msk4][:, 2],
                c='0.4',
                ls='--',
                label='$\mathrm{L10:}\ z = 3.0$')
        ax.plot(data[msk5][:, 1],
                data[msk5][:, 2],
                c='0.5',
                ls='--',
                label='$\mathrm{L10:}\ z = 4.0$')

    #ax.set_xlabel('$\log_{10}(S_{160} \ [\mathrm{mJy}])$')
    ax.set_xlabel('$\log_{10}(S_{250} \ [\mathrm{mJy}])$')
    ax.set_ylabel('$\log_{10}(\dot{M}_{\star} \ [M_{\odot}\mathrm{yr}^{-1}])$')

    ax.set_xlim(xmin, xmax)
    ax.set_ylim(-1.2, 3)

    P.legend(loc='lower right')
    if obs:
        P.savefig(out_folder + 'sfrOBSBW.ps')
    else:
        P.savefig(out_folder + 'sfrBW.ps')
Esempio n. 4
0
def plot_ssfr(path,
              db,
              redshifts,
              out_folder,
              xmin=0.0,
              xmax=2.3,
              fluxlimit=5):
    """
    Plots SSFR. 
    """
    lines = ["-", "--", "-.", ":"]
    linecycler = cycle(lines)
    colour = count(0.1, 0.1)

    #figure
    fig = P.figure()
    ax = fig.add_subplot(111)

    for reds in redshifts:
        query = '''select galprop.mstardot, galprop.mstar, FIR.pacs160_obs
                from FIR, galprop where
                %s and
                FIR.gal_id = galprop.gal_id and
                FIR.halo_id = galprop.halo_id
                ''' % reds
        #tmp
        tmp = reds.split()
        zz = N.mean(N.array([float(tmp[2]), float(tmp[6])]))

        #get data
        data = sq.get_data_sqlitePowerTen(path, db, query)

        #set 1
        xd = N.log10(data[:, 2] * 1e3)
        yd = N.log10(data[:, 0] / 10**data[:, 1])

        #percentiles
        xmaxb = N.max(xd)
        nxbins = int(9 * (xmaxb - xmin))
        xbin_midd, y50d, y16d, y84d = dm.percentile_bins(xd,
                                                         yd,
                                                         xmin,
                                                         xmaxb,
                                                         nxbins=nxbins)

        msk = y50d > -20
        ax.errorbar(xbin_midd[msk],
                    y50d[msk],
                    yerr=[y50d[msk] - y16d[msk], y84d[msk] - y50d[msk]],
                    ls=next(linecycler),
                    c=str(colour.next()),
                    label='$z = %.1f$' % zz)

    #ax.axvline(N.log10(fluxlimit), ls=':', color='green')
    ax.axvline(N.log10(fluxlimit), ls=':', color='0.25')

    ax.set_xlabel('$\log_{10}(S_{160} \ [\mathrm{mJy}])$')
    ax.set_ylabel(
        r'$\log_{10} \left (\frac{\dot{M}_{\star}}{M_{\star}} \ [\mathrm{yr}^{-1}] \right )$'
    )

    ax.set_xlim(xmin, xmax)
    ax.set_ylim(-11.1, -7.8)

    P.legend()  #loc = 'lower right')
    P.savefig(out_folder + 'ssfr.ps')