Exemple #1
0
def plotMergerFractions3(query,
                         xlabel,
                         ylabel,
                         output,
                         out_folder,
                         mergetimelimit=0.25,
                         mstarmin=8.0,
                         mstarmax=11.5,
                         mbins=15,
                         ymin=0.0,
                         ymax=1.0,
                         logscale=False):
    #get data, all galaxies
    data = sq.get_data_sqliteSMNfunctions(path, db, query)
    tmp = data[:, 1]
    mstar = data[:, 0]
    mstar = N.log10(mstar / 10**tmp)
    print N.min(mstar), N.max(mstar)
    tmerge = data[:, 2]
    tmajor = data[:, 3]
    #masks
    nomergeMask = tmerge < 0.0
    majorsMask = (tmajor > 0.0) & (tmajor <= mergetimelimit)
    majorsMask2 = (tmajor > mergetimelimit)
    mergersMask = (tmerge > 0.0) & (tmerge <= mergetimelimit) &\
                  (majorsMask == False) & (majorsMask2 == False)
    mergersMask2 = (nomergeMask == False) & (majorsMask == False) &\
                   (mergersMask == False) & (majorsMask2 == False)
    #bin the data
    mids, numbs = dm.binAndReturnMergerFractions2(mstar, nomergeMask,
                                                  mergersMask, majorsMask,
                                                  mergersMask2, majorsMask2,
                                                  mstarmin, mstarmax, mbins,
                                                  logscale)
    #the fraction of mergers
    noMergerFraction = N.array([float(x[1]) / x[0] for x in numbs])
    mergerFraction = N.array([float(x[2]) / x[0] for x in numbs])
    majorMergerFraction = N.array([float(x[3]) / x[0] for x in numbs])
    mergerFraction2 = N.array([float(x[4]) / x[0] for x in numbs])
    majorMergerFraction2 = N.array([float(x[5]) / x[0] for x in numbs])

    #sanity check
    for a, b, c, d, e in zip(noMergerFraction, mergerFraction,
                             majorMergerFraction, mergerFraction2,
                             majorMergerFraction2):
        print a + b + c + d + e
        #make the figure
    #    fig = P.figure()
    fig = P.figure(figsize=(10, 10))
    fig.subplots_adjust(left=0.08, bottom=0.07, right=0.97, top=0.93)
    ax1 = fig.add_subplot(111)
    #calculate widths
    wd = (mids[1] - mids[0]) * 1.0
    #draw bars
    ax1.bar(mids,
            noMergerFraction,
            label='Never Merged',
            align='center',
            color='grey',
            width=wd,
            hatch='.')
    ax1.bar(mids,
            mergerFraction,
            bottom=noMergerFraction,
            align='center',
            label='Minor Merger: $T \leq %.0f$ Myr' % (mergetimelimit * 1000.),
            color='red',
            width=wd,
            hatch='/')
    ax1.bar(mids,
            mergerFraction2,
            align='center',
            bottom=noMergerFraction + mergerFraction,
            label='Minor Merger: $T > %.0f$ Myr' % (mergetimelimit * 1000.),
            color='blue',
            width=wd,
            hatch='|')
    ax1.bar(mids,
            majorMergerFraction,
            align='center',
            bottom=noMergerFraction + mergerFraction + mergerFraction2,
            label='Major Merger: $T \leq %.0f$ Myr' % (mergetimelimit * 1000.),
            color='magenta',
            width=wd,
            hatch='x')
    ax1.bar(mids,
            majorMergerFraction2,
            align='center',
            bottom=noMergerFraction + mergerFraction + mergerFraction2 +
            majorMergerFraction,
            label='Major Merger: $T > %.0f$ Myr' % (mergetimelimit * 1000.),
            color='green',
            width=wd,
            hatch='-')
    #labels
    ax1.set_xlabel(xlabel)
    ax1.set_ylabel(ylabel)
    #limits
    ax1.set_ylim(ymin, ymax)
    ax1.set_xlim(mids[0] - wd / 2., mids[-1] + wd / 2.)
    #add annotate
    P.text(0.5,
           1.05,
           'All galaxies in $2 \leq z < 4$',
           horizontalalignment='center',
           verticalalignment='center',
           transform=ax1.transAxes)
    #legend and save
    P.legend(loc='upper center')
    P.savefig(out_folder + output)
Exemple #2
0
def plotMergerFractions(query,
                        xlabel, ylabel,
                        output, out_folder,
                        mergetimelimit=0.25,
                        mstarmin=8.0,
                        mstarmax=11.5,
                        mbins=15,
                        ymin=-0.01,
                        ymax=1.01,
                        logscale=False):
    #get data, all galaxies
    data = sq.get_data_sqliteSMNfunctions(path, db, query)
    if logscale:
        mstar = N.log10(data[:, 0])
        logscale = False
    else:
        mstar = data[:, 0]
    print N.min(mstar), N.max(mstar)
    tmerge = data[:, 1]
    tmajor = data[:, 2]
    #masks
    nomergeMask = tmerge < 0.0
    majorsMask = (tmajor > 0.0) & (tmajor <= mergetimelimit)
    majorsMask2 = (tmajor > mergetimelimit)
    mergersMask = (tmerge > 0.0) & (tmerge <= mergetimelimit) &\
                  (majorsMask == False) & (majorsMask2 == False)
    mergersMask2 = (nomergeMask == False) & (majorsMask == False) &\
                   (mergersMask == False) & (majorsMask2 == False)
    #bin the data
    mids, numbs = dm.binAndReturnMergerFractions2(mstar,
                                                  nomergeMask,
                                                  mergersMask,
                                                  majorsMask,
                                                  mergersMask2,
                                                  majorsMask2,
                                                  mstarmin,
                                                  mstarmax,
                                                  mbins,
                                                  logscale)
    #the fraction of mergers
    noMergerFraction = N.array([float(x[1]) / x[0] for x in numbs])
    mergerFraction = N.array([float(x[2]) / x[0] for x in numbs])
    majorMergerFraction = N.array([float(x[3]) / x[0] for x in numbs])
    mergerFraction2 = N.array([float(x[4]) / x[0] for x in numbs])
    majorMergerFraction2 = N.array([float(x[5]) / x[0] for x in numbs])

    #sanity check
    for a, b, c, d, e in zip(noMergerFraction, mergerFraction, majorMergerFraction,
                             mergerFraction2, majorMergerFraction2):
        print a + b + c + d + e

        #make the figure
    #    fig = P.figure()
    fig = P.figure(figsize=(10, 10))
    fig.subplots_adjust(left=0.08, bottom=0.07,
                        right=0.97, top=0.93)
    ax1 = fig.add_subplot(111)
    #draw lines
    ax1.plot(mids, noMergerFraction, 'k-', lw=2.6,
             label='Never Merged')
    ax1.plot(mids, mergerFraction, ls='--', lw=2.6,
             label='Minor Merger: $T \leq 250$ Myr')
    ax1.plot(mids, mergerFraction2, ls='-.', lw=2.6,
             label='Minor Merger: $T > 250$ Myr')
    ax1.plot(mids, majorMergerFraction, ls='--', lw=2.6,
             label='Major Merger: $T \leq 250$ Myr')
    ax1.plot(mids, majorMergerFraction2, ls='-.', lw=2.6,
             label='Major Merger: $T > 250$ Myr')
    #labels
    ax1.set_xlabel(xlabel)
    ax1.set_ylabel(ylabel)
    #limits
    ax1.set_ylim(ymin, ymax)
    #add annotate
    P.text(0.5, 0.93, 'All galaxies\n$2 \leq z < 4$',
           horizontalalignment='center',
           verticalalignment='center',
           transform=ax1.transAxes)
    #make grid
    ax1.grid()
    #legend and save
    P.legend(loc='upper right')
    P.savefig(out_folder + output)
Exemple #3
0
def plotMergerFractions(query,
                        xlabel,
                        ylabel,
                        output,
                        out_folder,
                        mergetimelimit=0.25,
                        mstarmin=8.0,
                        mstarmax=11.5,
                        mbins=15,
                        ymin=-0.01,
                        ymax=1.01,
                        logscale=False):
    #get data, all galaxies
    data = sq.get_data_sqliteSMNfunctions(path, db, query)
    if logscale:
        mstar = N.log10(data[:, 0])
        logscale = False
    else:
        mstar = data[:, 0]
    print N.min(mstar), N.max(mstar)
    tmerge = data[:, 1]
    tmajor = data[:, 2]
    #masks
    nomergeMask = tmerge < 0.0
    majorsMask = (tmajor > 0.0) & (tmajor <= mergetimelimit)
    majorsMask2 = (tmajor > mergetimelimit)
    mergersMask = (tmerge > 0.0) & (tmerge <= mergetimelimit) &\
                  (majorsMask == False) & (majorsMask2 == False)
    mergersMask2 = (nomergeMask == False) & (majorsMask == False) &\
                   (mergersMask == False) & (majorsMask2 == False)
    #bin the data
    mids, numbs = dm.binAndReturnMergerFractions2(mstar, nomergeMask,
                                                  mergersMask, majorsMask,
                                                  mergersMask2, majorsMask2,
                                                  mstarmin, mstarmax, mbins,
                                                  logscale)
    #the fraction of mergers
    noMergerFraction = N.array([float(x[1]) / x[0] for x in numbs])
    mergerFraction = N.array([float(x[2]) / x[0] for x in numbs])
    majorMergerFraction = N.array([float(x[3]) / x[0] for x in numbs])
    mergerFraction2 = N.array([float(x[4]) / x[0] for x in numbs])
    majorMergerFraction2 = N.array([float(x[5]) / x[0] for x in numbs])

    #sanity check
    for a, b, c, d, e in zip(noMergerFraction, mergerFraction,
                             majorMergerFraction, mergerFraction2,
                             majorMergerFraction2):
        print a + b + c + d + e

        #make the figure
    #    fig = P.figure()
    fig = P.figure(figsize=(10, 10))
    fig.subplots_adjust(left=0.08, bottom=0.07, right=0.97, top=0.93)
    ax1 = fig.add_subplot(111)
    #draw lines
    ax1.plot(mids, noMergerFraction, 'k-', lw=2.6, label='Never Merged')
    ax1.plot(mids,
             mergerFraction,
             ls='--',
             lw=2.6,
             label='Minor Merger: $T \leq 250$ Myr')
    ax1.plot(mids,
             mergerFraction2,
             ls='-.',
             lw=2.6,
             label='Minor Merger: $T > 250$ Myr')
    ax1.plot(mids,
             majorMergerFraction,
             ls='--',
             lw=2.6,
             label='Major Merger: $T \leq 250$ Myr')
    ax1.plot(mids,
             majorMergerFraction2,
             ls='-.',
             lw=2.6,
             label='Major Merger: $T > 250$ Myr')
    #labels
    ax1.set_xlabel(xlabel)
    ax1.set_ylabel(ylabel)
    #limits
    ax1.set_ylim(ymin, ymax)
    #add annotate
    P.text(0.5,
           0.93,
           'All galaxies\n$2 \leq z < 4$',
           horizontalalignment='center',
           verticalalignment='center',
           transform=ax1.transAxes)
    #make grid
    ax1.grid()
    #legend and save
    P.legend(loc='upper right')
    P.savefig(out_folder + output)
Exemple #4
0
def plotMergerFractions3(query,
                         xlabel, ylabel,
                         output, out_folder,
                         mergetimelimit=0.25,
                         mstarmin=8.0,
                         mstarmax=11.5,
                         mbins=15,
                         ymin=0.0,
                         ymax=1.0,
                         logscale=False):
    #get data, all galaxies
    data = sq.get_data_sqliteSMNfunctions(path, db, query)
    tmp = data[:, 1]
    mstar = data[:, 0]
    mstar = N.log10(mstar / 10 ** tmp)
    print N.min(mstar), N.max(mstar)
    tmerge = data[:, 2]
    tmajor = data[:, 3]
    #masks
    nomergeMask = tmerge < 0.0
    majorsMask = (tmajor > 0.0) & (tmajor <= mergetimelimit)
    majorsMask2 = (tmajor > mergetimelimit)
    mergersMask = (tmerge > 0.0) & (tmerge <= mergetimelimit) &\
                  (majorsMask == False) & (majorsMask2 == False)
    mergersMask2 = (nomergeMask == False) & (majorsMask == False) &\
                   (mergersMask == False) & (majorsMask2 == False)
    #bin the data
    mids, numbs = dm.binAndReturnMergerFractions2(mstar,
                                                  nomergeMask,
                                                  mergersMask,
                                                  majorsMask,
                                                  mergersMask2,
                                                  majorsMask2,
                                                  mstarmin,
                                                  mstarmax,
                                                  mbins,
                                                  logscale)
    #the fraction of mergers
    noMergerFraction = N.array([float(x[1]) / x[0] for x in numbs])
    mergerFraction = N.array([float(x[2]) / x[0] for x in numbs])
    majorMergerFraction = N.array([float(x[3]) / x[0] for x in numbs])
    mergerFraction2 = N.array([float(x[4]) / x[0] for x in numbs])
    majorMergerFraction2 = N.array([float(x[5]) / x[0] for x in numbs])

    #sanity check
    for a, b, c, d, e in zip(noMergerFraction, mergerFraction, majorMergerFraction,
                             mergerFraction2, majorMergerFraction2):
        print a + b + c + d + e
        #make the figure
    #    fig = P.figure()
    fig = P.figure(figsize=(10, 10))
    fig.subplots_adjust(left=0.08, bottom=0.07,
                        right=0.97, top=0.93)
    ax1 = fig.add_subplot(111)
    #calculate widths
    wd = (mids[1] - mids[0]) * 1.0
    #draw bars
    ax1.bar(mids, noMergerFraction,
            label='Never Merged', align='center',
            color='grey', width=wd, hatch='.')
    ax1.bar(mids, mergerFraction,
            bottom=noMergerFraction, align='center',
            label='Minor Merger: $T \leq %.0f$ Myr' % (mergetimelimit * 1000.),
            color='red', width=wd, hatch='/')
    ax1.bar(mids, mergerFraction2, align='center',
            bottom=noMergerFraction + mergerFraction,
            label='Minor Merger: $T > %.0f$ Myr' % (mergetimelimit * 1000.),
            color='blue', width=wd, hatch='|')
    ax1.bar(mids, majorMergerFraction, align='center',
            bottom=noMergerFraction + mergerFraction + mergerFraction2,
            label='Major Merger: $T \leq %.0f$ Myr' % (mergetimelimit * 1000.),
            color='magenta', width=wd, hatch='x')
    ax1.bar(mids, majorMergerFraction2, align='center',
            bottom=noMergerFraction + mergerFraction + mergerFraction2 + majorMergerFraction,
            label='Major Merger: $T > %.0f$ Myr' % (mergetimelimit * 1000.),
            color='green', width=wd, hatch='-')
    #labels
    ax1.set_xlabel(xlabel)
    ax1.set_ylabel(ylabel)
    #limits
    ax1.set_ylim(ymin, ymax)
    ax1.set_xlim(mids[0] - wd / 2., mids[-1] + wd / 2.)
    #add annotate
    P.text(0.5, 1.05, 'All galaxies in $2 \leq z < 4$',
           horizontalalignment='center',
           verticalalignment='center',
           transform=ax1.transAxes)
    #legend and save
    P.legend(loc='upper center')
    P.savefig(out_folder + output)