Пример #1
0
def plot(query, xlabel, ylabel, output, out_folder,
         bulge=0.4, xbin=10, ybin=10, xmin=-0.1, xmax=6):
    #get data
    data = N.array(sq.get_data_sqlitePowerTen(path, db, query))

    #sphericals
    mask = (data[:, 2] > bulge) & (data[:, 3] > 0.5)
    xe = data[:, 0][mask]
    ye = data[:, 1][mask]
    # disks
    disks = (data[:, 2] <= bulge) & (data[:, 3] > 0.5)
    xd = data[:, 0][disks]
    yd = data[:, 1][disks]
    #IR bright
    mask = data[:, 4] > 1e-3
    xir = data[:, 0][mask]
    yir = data[:, 1][mask]

    #calculate means and percentiles
    xmd, y50d, y16d, y84d = dm.average_bins(xd, yd, xmin, xmax, nxbins=20)
    xmt, y50t, y16t, y84t = dm.average_bins(data[:, 0], data[:, 1], xmin, xmax, nxbins=20)
    xme, y50e, y16e, y84e = dm.average_bins(xe, ye, xmin, xmax, nxbins=20)
    xmir, y50ir, y16ir, y84ir = dm.average_bins(xir, yir, xmin, xmax, nxbins=20)

    #figure
    fig = P.figure()
    ax1 = fig.add_subplot(111)
    #plots
    #    ax1.errorbar(xmt, y50t, yerr = [y50t, y84t], label = 'Total',
    #                 c = 'k')
    #    ax1.errorbar(xmd, y50d, yerr = [y50d, y84d], label = 'Late-types',
    #                 c = 'b', ls = '--')
    #    ax1.errorbar(xme, y50e, yerr = [y16e, y84e-y50e], label = 'Early-types',
    #                 c = 'r', ls = '-.')
    ax1.errorbar(xmir, y50ir, yerr=[y16ir, y84ir], label='$S_{250} > 1$ mJy',
                 c='m', ls=':')
    ax1.plot(xmt, y50t, 'k-', label='Total')
    ax1.plot(xmd, y50d, 'b--', label='Late-types')
    ax1.plot(xme, y50e, 'r-.', label='Early-types')
    #    ax1.fill_between(xmt, y16t, y50t, label = 'Total')
    #    ax1.fill_between(xmd, y16d, y50d, label = 'Late-type')
    #    ax1.fill_between(xme, y16e, y50e, label = 'Early-type')
    #    ax1.fill_between(xmir, y16ir, y50ir, label = '$S_{250} > 5$ mJy')

    #limits and labels
    ax1.set_xlim(0.0, xmax - .3)
    ax1.set_ylim(1e-3, 100.0)
    ax1.set_xlabel(xlabel)
    ax1.set_ylabel(ylabel)
    ax1.set_yscale('log')
    #legend
    ax1.legend(shadow=True, fancybox=True, loc='lower right')
    #save and close
    P.savefig(out_folder + output)
    P.close()
Пример #2
0
def plot_properties(query,
                    xlabel,
                    ylabel,
                    output,
                    out_folder,
                    flux=5,
                    band=250,
                    pmin=0.1,
                    pmax=1.0,
                    xbin=15,
                    ybin=11,
                    xmin=7.9,
                    xmax=11.7,
                    ymin=0,
                    ymax=50):
    '''
    Plots 
    '''

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

    #set 1: all galaxies
    xd = data[:, 0]
    yd = data[:, 1]

    #set 2
    mask = data[:, 1] > flux
    xe = data[:, 0][mask]
    ye = data[:, 1][mask]
    #x limits for the right hand (scatter) plot
    secxmin, secxmax = 0.99 * N.min(xe), 1.005 * N.max(xe)
    if 'mstardot' in query:
        secxmax = 1200.
    if 'burst' in query:
        secxmax = 1500.

    #hess
    sd, sdmin, sdmax = h.hess_plot(xd,
                                   yd,
                                   N.ones(len(xd)),
                                   xmin,
                                   xmax,
                                   xbin,
                                   ymin,
                                   ymax,
                                   ybin,
                                   pmax=pmax,
                                   pmin=pmin)
    se, semin, semax = h.hess_plot(xe,
                                   ye,
                                   N.ones(len(xe)),
                                   secxmin,
                                   secxmax,
                                   xbin - 4,
                                   flux,
                                   ymax,
                                   ybin - 1,
                                   pmax=pmax,
                                   pmin=pmin)

    #figure
    #    f, (ax1, ax2) = P.subplots(1, 2, sharey=True)
    #    f, (ax1, ax2) = P.subplots(1, 2, figsize=(10,10))
    f, (ax1, ax2) = P.subplots(1, 2)
    f.subplots_adjust(wspace=0.0,
                      hspace=0.01,
                      left=0.08,
                      bottom=0.07,
                      right=0.97,
                      top=0.93)

    #hess plots
    ims = ax1.imshow(sd,
                     vmin=sdmin,
                     vmax=sdmax,
                     origin='lower',
                     cmap=cm.gray,
                     interpolation=None,
                     extent=[xmin, xmax, ymin, ymax],
                     aspect='auto',
                     alpha=1)
    ims = ax2.imshow(se,
                     vmin=semin,
                     vmax=semax,
                     origin='lower',
                     cmap=cm.gray,
                     interpolation=None,
                     extent=[secxmin, secxmax, flux, ymax],
                     aspect='auto',
                     alpha=1)
    #flux limit lines
    ax1.axhline(flux, color='green', ls='--')
    ax2.axhline(flux, color='green', ls='--')
    #scatter to the second plot
    ax2.scatter(xe, ye, s=6, color='b')
    #percentiles
    xbin_midd, y50d, y16d, y84d = dm.percentile_bins(xd, yd, xmin, xmax)
    md = (y50d > 0) | (y16d > 0) | (y84d > 0)
    xbin_mide, y50e, y16e, y84e = dm.percentile_bins(xe, ye, secxmin, secxmax)
    me = (y50e > 0) | (y16e > 0) | (y84e > 0)
    ax1.plot(xbin_midd[md], y50d[md], 'r-')
    ax1.plot(xbin_midd[md], y16d[md], 'r--')
    ax1.plot(xbin_midd[md], y84d[md], 'r--')
    ax2.plot(xbin_mide[me], y50e[me], 'r-')
    ax2.plot(xbin_mide[me], y16e[me], 'r--')
    ax2.plot(xbin_mide[me], y84e[me], 'r--')

    #add text
    P.text(0.5,
           0.95,
           'All galaxies',
           horizontalalignment='center',
           verticalalignment='center',
           transform=ax1.transAxes)
    P.text(0.5,
           0.95,
           r'%s > %.1f $ mJy' % (ylabel.split()[0], flux),
           horizontalalignment='center',
           verticalalignment='center',
           transform=ax2.transAxes)

    #labels
    ax1.set_xlabel(xlabel)
    ax2.set_xlabel(xlabel)
    ax1.set_ylabel(ylabel)
    #y tick positions
    #    ax1.set_yticks(yticks)
    #ax2.set_yticks(yticks[1:-2])

    #limits
    ax1.set_xlim(xmin, xmax)
    ax2.set_xlim(secxmin, secxmax)

    ax1.set_ylim(ymin, ymax)
    ax2.set_ylim(ymin, ymax)

    ax2.set_yticks(ax2.get_yticks()[1:-1])
    #    ax2.set_xticks(ax2.get_xticks()[1:])

    #make grid
    ax1.grid()
    ax2.grid()

    P.savefig(out_folder + output)
Пример #3
0
def plot_ages(query,
              xlabel,
              ylabel,
              output,
              out_folder,
              flux=5,
              band=250,
              title='$2.0 < z < 4.0$',
              pmin=0.05,
              pmax=1.0,
              xbin=10,
              ybin=15,
              xmin=7.9,
              xmax=11.7,
              ymin=-1.5,
              ymax=1.8,
              scatters=False,
              mean=False):
    '''
    Plots age versus a given quantity.
    '''
    #get data
    data = N.array(sq.get_data_sqlitePowerTen(path, db, query))

    #observable galaxies
    mask = data[:, 1] > flux
    xe = data[:, 0][mask]
    ye = N.log10(data[:, 1][mask])
    #all galaxies
    xd = data[:, 0]
    yd = N.log10(data[:, 1])
    mask = yd != N.nan
    xd = xd[mask]
    yd = yd[mask]

    #hess
    sd, sdmin, sdmax = h.hess_plot(xd,
                                   yd,
                                   N.ones(len(xd)),
                                   xmin,
                                   xmax,
                                   xbin,
                                   ymin,
                                   ymax,
                                   ybin,
                                   pmax=pmax,
                                   pmin=pmin)
    se, semin, semax = h.hess_plot(xe,
                                   ye,
                                   N.ones(len(xe)),
                                   xmin,
                                   xmax,
                                   xbin,
                                   N.log10(flux),
                                   ymax,
                                   ybin,
                                   pmax=pmax,
                                   pmin=pmin)

    #figure
    fig = P.figure()
    fig.suptitle(title)
    f, (ax1, ax2) = P.subplots(1, 2, sharey=True)
    f.subplots_adjust(wspace=0.0,
                      hspace=0.01,
                      left=0.08,
                      bottom=0.07,
                      right=0.97,
                      top=0.93)

    #contours
    ims = ax1.imshow(sd,
                     vmin=sdmin,
                     vmax=sdmax,
                     origin='lower',
                     cmap=cm.gray,
                     interpolation=None,
                     extent=[xmin, xmax, ymin, ymax],
                     aspect='auto',
                     alpha=1)
    ims = ax2.imshow(se,
                     vmin=semin,
                     vmax=semax,
                     origin='lower',
                     cmap=cm.gray,
                     interpolation=None,
                     extent=[xmin, xmax, N.log10(flux), ymax],
                     aspect='auto',
                     alpha=1)

    #percentiles
    xbin_midd, y50d, y16d, y84d = dm.percentile_bins(xd, yd, xmin, xmax)
    md = (y50d > 0) & (y16d > 0) & (y84d > 0)
    xbin_mide, y50e, y16e, y84e = dm.percentile_bins(xe, ye, xmin, xmax)
    me = (y50e > 0) & (y16e > 0) & (y84e > 0)
    ax1.plot(xbin_midd[md], y50d[md], 'r-')
    ax1.plot(xbin_midd[md], y16d[md], 'r--')
    ax1.plot(xbin_midd[md], y84d[md], 'r--')
    ax2.plot(xbin_mide[me], y50e[me], 'r-')
    ax2.plot(xbin_mide[me], y16e[me], 'r--')
    ax2.plot(xbin_mide[me], y84e[me], 'r--')

    #dots
    if scatters:
        ax1.scatter(xd, yd, c='b', s=10, marker='h', label='All galaxies')
        ax2.scatter(xe,
                    ye,
                    c='r',
                    s=10,
                    marker='o',
                    label=r'$S_{%i} > %.1f$ mJy' % (band, flux))

    #hlines
    if mean:
        #mean size
        mean_disk = N.mean(yd)
        mean_early = N.mean(ye)
        ax1.axhline(mean_disk, c='b', label='Mean')
        ax2.axhline(mean_early, c='r', label='Mean')

    #add text
    P.text(0.5,
           0.95,
           'All galaxies',
           horizontalalignment='center',
           verticalalignment='center',
           transform=ax1.transAxes)
    P.text(0.5,
           0.95,
           r'$S_{%i} > %.1f$ mJy' % (band, flux),
           horizontalalignment='center',
           verticalalignment='center',
           transform=ax2.transAxes)

    #labels
    ax1.set_xlabel(xlabel)
    ax2.set_xlabel(xlabel)
    ax1.set_ylabel(ylabel)
    #ax2.set_yticks([])

    #limits
    #ax1.set_ylim(ymin, ymax)
    #ax2.set_ylim(ymin, ymax)
    ax1.set_xlim(xmin, xmax)
    ax2.set_xlim(xmin, xmax)

    #yticks
    #ax1.set_yticks(y1ticks)
    #ax2.set_yticks(y2ticks)

    #make grid
    ax1.grid()
    ax2.grid()

    #write a legend
    ax1.legend(shadow=True,
               fancybox=True,
               numpoints=1,
               loc='upper left',
               scatterpoints=1)
    ax2.legend(shadow=True,
               fancybox=True,
               numpoints=1,
               loc='upper left',
               scatterpoints=1)
    P.savefig(out_folder + output)
Пример #4
0
    xmax1 = 11.7
    ymin = 0.1;
    ymax = 10

    query1 = """select galprop.mstar, galprop.r_disk, Pow10(galprop.mbulge - galprop.mstar)
                from FIR, galprop where
                FIR.z >= 2.0 and
                FIR.z < 4.0 and
                FIR.gal_id = galprop.gal_id and
                FIR.halo_id = galprop.halo_id and
                galprop.tmerge > 0.5 and
                FIR.spire250_obs > 1e-15 and
                FIR.spire250_obs < 1e6
                """
    #get data
    data = N.array(sq.get_data_sqlitePowerTen(path, db, query1))
    #slice the data
    disks = data[:, 2] <= bulge
    xd1 = data[:, 0][disks]
    yd1 = data[:, 1][disks]
    #old algorithm
    so1, somin1, somax1 = hess_plot_old(xd1, yd1, N.ones(len(xd1)),
                                        xmin1, xmax1, xbin1,
                                        ymin, ymax, ybin1,
                                        pmax=pmax, pmin=pmin)

    #new algorithm
    sn1, snmin1, snmax1 = hess_plot(xd1, yd1, N.ones(len(xd1)),
                                    xmin1, xmax1, xbin1,
                                    ymin, ymax, ybin1,
                                    pmax=pmax, pmin=pmin)
Пример #5
0
def plot_size(query,
              xlabel,
              ylabel,
              output,
              out_folder,
              bulge=0.4,
              title='$2.0 < z < 4.0$',
              pmin=0.05,
              pmax=1.0,
              xbin=15,
              ybin=15,
              y1ticks=[1, 3, 5, 7, 10],
              y2ticks=[1, 3, 5, 7],
              xmin=7.9,
              xmax=11.7,
              ymin=0.1,
              ymax=10,
              scatters=False,
              mean=False):
    '''
    Plots size versus a given quantity.
    '''
    #get data
    data = sq.get_data_sqlitePowerTen(path, db, query)

    #sphericals
    mask = data[:, 2] > bulge
    xe = data[:, 0][mask]
    ye = data[:, 1][mask]
    # disks
    disks = data[:, 2] <= bulge
    xd = data[:, 0][disks]
    yd = data[:, 1][disks]

    #hess
    sd, sdmin, sdmax = h.hess_plot(xd,
                                   yd,
                                   N.ones(len(xd)),
                                   xmin,
                                   xmax,
                                   xbin,
                                   ymin,
                                   ymax,
                                   ybin,
                                   pmax=pmax,
                                   pmin=pmin)
    se, semin, semax = h.hess_plot(xe,
                                   ye,
                                   N.ones(len(xe)),
                                   xmin,
                                   xmax,
                                   xbin,
                                   ymin,
                                   ymax,
                                   ybin,
                                   pmax=pmax,
                                   pmin=pmin)

    #figure
    #    fig = P.figure(figsize = (12, 12))
    fig = P.figure()
    fig.suptitle(title)
    fig.subplots_adjust(wspace=0.0,
                        hspace=0.01,
                        left=0.08,
                        bottom=0.07,
                        right=0.97,
                        top=0.93)
    ax1 = fig.add_subplot(121)
    ax2 = fig.add_subplot(122)

    #contours
    #    ax1.contourf(sd, origin = 'lower', colors = 'b',
    #                 linewidths = 0.8, linestyles = '-',
    #                 extent = [xmin, xmax, ymin, ymax],
    #                 rightside_up = True, alpha = 0.7)#,
    #                 #levels = [0.01, 0.3, 0.6, 0.9])
    #    ax2.contourf(se, origin = 'lower', colors = 'r',
    #                 linewidths = 0.8, linestyles = '-',
    #                 extent = [xmin, xmax, ymin, ymax],
    #                 rightside_up = True, alpha = 0.7)
    ims = ax1.imshow(sd,
                     vmin=sdmin,
                     vmax=sdmax,
                     origin='lower',
                     cmap=cm.gray,
                     interpolation=None,
                     extent=[xmin, xmax, ymin, ymax],
                     aspect='auto',
                     alpha=1)
    ims = ax2.imshow(se,
                     vmin=semin,
                     vmax=semax,
                     origin='lower',
                     cmap=cm.gray,
                     interpolation=None,
                     extent=[xmin, xmax, ymin, ymax],
                     aspect='auto',
                     alpha=1)

    #percentiles
    xbin_midd, y50d, y16d, y84d = dm.percentile_bins(xd, yd, xmin, xmax)
    md = (y50d > 0) & (y16d > 0) & (y84d > 0)
    xbin_mide, y50e, y16e, y84e = dm.percentile_bins(xe, ye, xmin, xmax)
    me = (y50e > 0) & (y16e > 0) & (y84e > 0)
    ax1.plot(xbin_midd[md], y50d[md], 'r-')
    ax1.plot(xbin_midd[md], y16d[md], 'r--')
    ax1.plot(xbin_midd[md], y84d[md], 'r--')
    ax2.plot(xbin_mide[me], y50e[me], 'r-')
    ax2.plot(xbin_mide[me], y16e[me], 'r--')
    ax2.plot(xbin_mide[me], y84e[me], 'r--')

    #dots
    if scatters:
        ax1.scatter(xd, yd, c='b', s=10, marker='h', label='Late-type')
        ax2.scatter(xe, ye, c='r', s=10, marker='o', label='Early-type')

    #hlines
    if mean:
        #mean size
        mean_disk = N.mean(yd)
        mean_early = N.mean(ye)
        ax1.axhline(mean_disk, c='b', label='Mean')
        ax2.axhline(mean_early, c='r', label='Mean')

    #add text
    P.text(0.5,
           0.95,
           'Late-type galaxies',
           horizontalalignment='center',
           verticalalignment='center',
           transform=ax1.transAxes)
    P.text(0.5,
           0.95,
           'Early-type galaxies',
           horizontalalignment='center',
           verticalalignment='center',
           transform=ax2.transAxes)

    #labels
    ax1.set_xlabel(xlabel)
    ax2.set_xlabel(xlabel)
    ax1.set_ylabel(ylabel)
    ax2.set_yticks([])

    #limits
    ax1.set_ylim(ymin, ymax)
    ax2.set_ylim(ymin, ymax)
    ax1.set_xlim(xmin, xmax)
    ax2.set_xlim(xmin, xmax)

    #yticks
    ax1.set_yticks(y1ticks)
    ax2.set_yticks(y2ticks)

    #make grid
    #ax1.grid()
    #ax2.grid()

    #write a legend
    ax1.legend(shadow=True,
               fancybox=True,
               numpoints=1,
               loc='upper left',
               scatterpoints=1)
    ax2.legend(shadow=True,
               fancybox=True,
               numpoints=1,
               loc='upper left',
               scatterpoints=1)
    P.savefig(out_folder + output)
Пример #6
0
def plot_size2(query,
               xlabel,
               ylabel,
               output,
               out_folder,
               bulge=0.4,
               title='$2.0 < z < 4.0$',
               pmin=0.05,
               pmax=1.0,
               xbin=15,
               ybin=15,
               xmin=7.9,
               xmax=11.7,
               ymin=0.1,
               ymax=10):
    '''
    Plots size versus a given quantity.
    '''
    #get data
    data = N.array(sq.get_data_sqlitePowerTen(path, db, query))

    # disks
    disks = data[:, 2] <= bulge
    xd = data[:, 0][disks]
    yd = data[:, 1][disks]

    #hess
    sd, sdmin, sdmax = h.hess_plot(xd,
                                   yd,
                                   N.ones(len(xd)),
                                   xmin,
                                   xmax,
                                   xbin,
                                   ymin,
                                   ymax,
                                   ybin,
                                   pmax=pmax,
                                   pmin=pmin)

    #figure
    fig = P.figure()
    fig.suptitle(title)
    ax1 = fig.add_subplot(111)

    ims = ax1.imshow(sd,
                     vmin=sdmin,
                     vmax=sdmax,
                     origin='lower',
                     cmap=cm.gray,
                     interpolation=None,
                     extent=[xmin, xmax, ymin, ymax],
                     aspect='auto',
                     alpha=1)

    #percentiles
    xbin_midd, y50d, y16d, y84d = dm.percentile_bins(xd, yd, xmin, xmax)
    md = (y50d > 0) & (y16d > 0) & (y84d > 0)
    ax1.plot(xbin_midd[md], y50d[md], 'r-')
    ax1.plot(xbin_midd[md], y16d[md], 'r--')
    ax1.plot(xbin_midd[md], y84d[md], 'r--')

    #add text
    P.text(0.5,
           0.95,
           'Late-type galaxies',
           horizontalalignment='center',
           verticalalignment='center',
           transform=ax1.transAxes)

    #labels
    ax1.set_xlabel(xlabel)
    ax1.set_ylabel(ylabel)

    #limits
    ax1.set_ylim(ymin, ymax)
    ax1.set_xlim(xmin, xmax)

    #yticks
    #ax1.set_yticks(y1ticks)

    #make grid
    #ax1.grid()

    #write a legend
    ax1.legend(shadow=True,
               fancybox=True,
               numpoints=1,
               loc='upper left',
               scatterpoints=1)
    P.savefig(out_folder + output)
Пример #7
0
             FIR.spire250_obs < 1e6 and
             FIR.gal_id = galprop.gal_id and
             FIR.halo_id = galprop.halo_id
             '''
 query2 = '''select galprop.mstar, galprop.r_disk, Pow10(galprop.mbulge - galprop.mstar)
             from FIR, galprop where
             galprop.tmerge > 0.5 and
             FIR.z >= 2.0 and
             FIR.z < 4.0 and
             FIR.spire250_obs > 5e-3 and
             FIR.spire250_obs < 1e6 and
             FIR.gal_id = galprop.gal_id and
             FIR.halo_id = galprop.halo_id
             '''
 #get data query1
 data = sq.get_data_sqlitePowerTen(path, db, query1)
 # disks
 disks = data[:, 2] <= bulge
 xd1 = data[:, 0][disks]
 yd1 = data[:, 1][disks]
 #get data query1
 data = sq.get_data_sqlitePowerTen(path, db, query2)
 # disks
 disks = data[:, 2] <= bulge
 xd2 = data[:, 0][disks]
 yd2 = data[:, 1][disks]
 #find all galaxies in similar Mstellar range as SPIRE bright
 yd2min = N.min(yd2)
 yd2max = N.max(yd2)
 msk = (yd1 >= yd2min) & (yd1 <= yd2max)
 #print out some info
Пример #8
0
def plot_ages(query, xlabel, ylabel, output, out_folder,
              flux = 5, band = 250, title = '$2.0 < z < 4.0$',
              pmin = 0.05, pmax = 1.0,
              xbin = 10, ybin = 15,
              xmin = 7.9, xmax = 11.7, ymin = -1.5, ymax = 1.8,
              scatters = False, mean = False):
    '''
    Plots age versus a given quantity.
    '''
    #get data
    data = N.array(sq.get_data_sqlitePowerTen(path, db, query))

    #observable galaxies
    mask = data[:,1] > flux
    xe = data[:,0][mask]
    ye = N.log10(data[:,1][mask])
    #all galaxies
    xd = data[:,0]
    yd = N.log10(data[:,1])
    mask = yd != N.nan
    xd = xd[mask]
    yd = yd[mask]

    #hess
    sd, sdmin, sdmax = h.hess_plot(xd, yd, N.ones(len(xd)), 
                                   xmin, xmax, xbin, 
                                   ymin, ymax, ybin,
                                   pmax = pmax, pmin = pmin)
    se, semin, semax = h.hess_plot(xe, ye, N.ones(len(xe)), 
                                   xmin, xmax, xbin, 
                                   N.log10(flux), ymax, ybin,
                                   pmax = pmax, pmin = pmin)
    
    #figure
    fig = P.figure()
    fig.suptitle(title)
    f, (ax1, ax2) = P.subplots(1, 2, sharey=True) 
    f.subplots_adjust(wspace = 0.0, hspace = 0.01, left = 0.08, bottom = 0.07,
                      right = 0.97, top = 0.93)

    #contours
    ims = ax1.imshow(sd, vmin = sdmin, vmax = sdmax,
                     origin = 'lower', cmap = cm.gray,
                     interpolation = None,
                     extent = [xmin, xmax, ymin, ymax],
                     aspect = 'auto', alpha = 1)
    ims = ax2.imshow(se, vmin = semin, vmax = semax,
                     origin = 'lower', cmap = cm.gray,
                     interpolation = None,
                     extent = [xmin, xmax, N.log10(flux), ymax],
                     aspect = 'auto', alpha = 1)

    #percentiles
    xbin_midd, y50d, y16d, y84d = dm.percentile_bins(xd, yd, xmin, xmax)
    md = (y50d > 0) & (y16d > 0) & (y84d > 0)
    xbin_mide, y50e, y16e, y84e = dm.percentile_bins(xe, ye, xmin, xmax)
    me = (y50e > 0) & (y16e > 0) & (y84e > 0)
    ax1.plot(xbin_midd[md], y50d[md], 'r-')
    ax1.plot(xbin_midd[md], y16d[md], 'r--')
    ax1.plot(xbin_midd[md], y84d[md], 'r--')
    ax2.plot(xbin_mide[me], y50e[me], 'r-')
    ax2.plot(xbin_mide[me], y16e[me], 'r--')
    ax2.plot(xbin_mide[me], y84e[me], 'r--')

    #dots
    if scatters:
        ax1.scatter(xd, yd, c='b', s = 10,
                    marker = 'h', label = 'All galaxies')
        ax2.scatter(xe, ye, c='r', s = 10,
                    marker = 'o', label = r'$S_{%i} > %.1f$ mJy' % (band, flux))

    #hlines
    if mean:
        #mean size
        mean_disk = N.mean(yd)
        mean_early = N.mean(ye)
        ax1.axhline(mean_disk, c = 'b', label = 'Mean')
        ax2.axhline(mean_early, c = 'r', label = 'Mean')

    #add text
    P.text(0.5, 0.95, 'All galaxies',
           horizontalalignment='center',
           verticalalignment='center',
           transform = ax1.transAxes)
    P.text(0.5, 0.95, r'$S_{%i} > %.1f$ mJy' % (band, flux),
           horizontalalignment='center',
           verticalalignment='center',
           transform = ax2.transAxes)


    #labels
    ax1.set_xlabel(xlabel)
    ax2.set_xlabel(xlabel)
    ax1.set_ylabel(ylabel)
    #ax2.set_yticks([])

    #limits
    #ax1.set_ylim(ymin, ymax)
    #ax2.set_ylim(ymin, ymax)
    ax1.set_xlim(xmin, xmax)
    ax2.set_xlim(xmin, xmax)

    #yticks
    #ax1.set_yticks(y1ticks)
    #ax2.set_yticks(y2ticks)

    #make grid
    ax1.grid()
    ax2.grid()
    
    #write a legend
    ax1.legend(shadow = True, fancybox = True, 
               numpoints = 1, loc = 'upper left',
               scatterpoints = 1)
    ax2.legend(shadow = True, fancybox = True, 
               numpoints = 1, loc = 'upper left',
               scatterpoints = 1)
    P.savefig(out_folder + output)
Пример #9
0
    xmax1 = 11.7
    ymin = 0.1
    ymax = 10

    query1 = """select galprop.mstar, galprop.r_disk, Pow10(galprop.mbulge - galprop.mstar)
                from FIR, galprop where
                FIR.z >= 2.0 and
                FIR.z < 4.0 and
                FIR.gal_id = galprop.gal_id and
                FIR.halo_id = galprop.halo_id and
                galprop.tmerge > 0.5 and
                FIR.spire250_obs > 1e-15 and
                FIR.spire250_obs < 1e6
                """
    #get data
    data = N.array(sq.get_data_sqlitePowerTen(path, db, query1))
    #slice the data
    disks = data[:, 2] <= bulge
    xd1 = data[:, 0][disks]
    yd1 = data[:, 1][disks]
    #old algorithm
    so1, somin1, somax1 = hess_plot_old(xd1,
                                        yd1,
                                        N.ones(len(xd1)),
                                        xmin1,
                                        xmax1,
                                        xbin1,
                                        ymin,
                                        ymax,
                                        ybin1,
                                        pmax=pmax,