コード例 #1
0
def plot_icd_vs_mass():
    galaxies = pickle.load(open('galaxies.pickle', 'rb'))

    arrow_up = [[0, 0], [-1, -1], [0, 0], [0, -2], [0, 0], [1, -1], [0, 0]]

    # Make figure
    f1 = pyl.figure(1, figsize=(4, 6))
    f1s1 = f1.add_subplot(211)
    f1s2 = f1.add_subplot(212)

    for galaxy in galaxies:
        if galaxy.ston_I > 30. and galaxy.ICD_IH != None:
            f1s1.scatter(galaxy.z,
                         galaxy.ICD_IH * 100,
                         c='0.8',
                         marker='o',
                         s=25,
                         edgecolor='0.8')

        if galaxy.ston_V > 30. and galaxy.ICD_VJ != None:
            f1s2.scatter(galaxy.z,
                         galaxy.ICD_VJ * 100,
                         c='0.8',
                         marker='o',
                         s=25,
                         edgecolor='0.8')

    # Add the box and whiskers
    galaxies2 = filter(lambda galaxy: galaxy.ston_I > 30., galaxies)
    galaxies2 = pyl.asarray(galaxies2)
    x = [galaxy.z for galaxy in galaxies2]
    ll = 1.5
    ul = 4
    bins_x = pyl.arange(ll, ul, 0.5)
    grid = []

    for i in range(bins_x.size - 1):
        xmin = bins_x[i]
        xmax = bins_x[i + 1]
        cond = [cond1 and cond2 for cond1, cond2 in zip(x >= xmin, x < xmax)]

        grid.append(galaxies2.compress(cond))
    icd = []
    for i in range(len(grid)):
        icd.append([galaxy.ICD_IH * 100 for galaxy in grid[i]])
    from boxplot_percentile import percentile_box_plot as pbp
    pbp(f1s1,
        icd,
        indexer=list(pyl.delete(bins_x, -1) + 0.25),
        whisker_top=None,
        whisker_bottom=None)

    # Add the box and whiskers
    galaxies = pickle.load(open('galaxies.pickle', 'rb'))
    galaxies2 = filter(lambda galaxy: galaxy.ston_V > 30., galaxies)
    galaxies2 = pyl.asarray(galaxies2)
    x = [galaxy.z for galaxy in galaxies2]
    ll = 1.5
    ul = 4
    bins_x = pyl.arange(ll, ul, 0.5)
    grid = []

    for i in range(bins_x.size - 1):
        xmin = bins_x[i]
        xmax = bins_x[i + 1]
        cond = [cond1 and cond2 for cond1, cond2 in zip(x >= xmin, x < xmax)]

        grid.append(galaxies2.compress(cond))
    icd = []
    for i in range(len(grid)):
        icd.append([galaxy.ICD_VJ * 100 for galaxy in grid[i]])
    pbp(f1s2,
        icd,
        indexer=list(pyl.delete(bins_x, -1) + 0.25),
        whisker_top=None,
        whisker_bottom=None)

    f1s1.set_xlim(1.5, 3.5)
    f1s2.set_xlim(1.5, 3.5)

    f1s1.set_ylim(-1, 10)
    f1s2.set_ylim(-1, 10)

    f1s1.set_xticklabels([])
    f1s2.set_xticks([1.5, 2, 2.5, 3, 3.5])

    f1s1.set_ylabel(r"$\xi[i_{775},H_{160}]$ (%)")
    f1s2.set_xlabel("Redshift")
    f1s2.set_ylabel(r"$\xi[V_{606},J_{125}]$ (%)")

    import matplotlib.font_manager
    line1 = pyl.Line2D([], [],
                       marker='o',
                       mfc='0.8',
                       mec='0.8',
                       markersize=8,
                       linewidth=0)
    line2 = pyl.Line2D([], [],
                       marker='s',
                       mec='#348ABD',
                       mfc='None',
                       markersize=10,
                       linewidth=0,
                       markeredgewidth=2)
    line3 = pyl.Line2D([], [], color='#A60628', linewidth=2)
    prop = matplotlib.font_manager.FontProperties(size='small')
    pyl.figlegend((line1, line2, line3), ('Data', 'Quartiles', 'Medians'),
                  'lower center',
                  prop=prop,
                  ncol=3)

    pyl.show()
コード例 #2
0
def plot_icd_vs_mass():
    galaxies = pickle.load(open('galaxies.pickle','rb'))

    # Make figure
    f1 = pyl.figure(1, figsize=(6,4))
    f1s1 = f1.add_subplot(221)
    f1s2 = f1.add_subplot(222)
    f1s3 = f1.add_subplot(223)
    f1s4 = f1.add_subplot(224)

    #Upper and Lower limit arrow verts
    arrowup_verts = [[0.,0.], [-1., -1], [0.,0.],
        [0.,-2.], [0.,0.], [1,-1], [0,0]]
    #arrowdown_verts = [[0.,0.], [-1., 1], [0.,0.],
    #    [0.,2.], [0.,0.], [1, 1]]

    for galaxy in galaxies:
        if galaxy.ston_I > 30. and galaxy.ICD_IH != None:
            # Add arrows first
            if galaxy.ICD_IH > 0.5:
                f1s1.scatter(galaxy.Mass, 0.5*100, s=100, marker=None,
                    verts=arrowup_verts)
            else:
                f1s1.scatter(galaxy.Mass, galaxy.ICD_IH * 100, c='0.8',
                    marker='o', s=25, edgecolor='0.8')
                f1s2.scatter(galaxy.Mass, galaxy.ICD_IH * 100, c='0.8',
                    marker='o', s=25, edgecolor='0.8')

        if galaxy.ston_J > 30. and galaxy.ICD_JH != None:
            # Add arrows first
            if galaxy.ICD_JH > 0.12:
                f1s3.scatter(galaxy.Mass, 12, s=100, marker=None,
                    verts=arrowup_verts)
            else:
                f1s3.scatter(galaxy.Mass, galaxy.ICD_JH * 100, c='0.8',
                    marker='o', s=25, edgecolor='0.8')
                f1s4.scatter(galaxy.Mass, galaxy.ICD_JH * 100, c='0.8',
                    marker='o', s=25, edgecolor='0.8')

    # Add the box and whiskers
    galaxies2 = filter(lambda galaxy: galaxy.ston_I > 30., galaxies)
    galaxies2 = pyl.asarray(galaxies2)
    x = [galaxy.Mass for galaxy in galaxies2]
    ll = 8.5
    ul= 12
    #bins_x =pyl.arange(8.5, 12.5, 0.5)
    bins_x =pyl.array([8.5, 9., 9.5, 10., 10.5, 11., 12.])
    grid = []

    for i in range(bins_x.size-1):
        xmin = bins_x[i]
        xmax = bins_x[i+1]
        cond=[cond1 and cond2 for cond1, cond2 in zip(x>=xmin, x<xmax)]

        grid.append(galaxies2.compress(cond))
    icd = []
    for i in range(len(grid)):
        icd.append([galaxy.ICD_IH*100 for galaxy in grid[i]])

    from boxplot_percentile import percentile_box_plot as pbp
    #bp1 = f1s1.boxplot(icd, positions=pyl.delete(bins_x,-1)+0.25, sym='')
    pbp(f1s1, icd, indexer=list(pyl.delete(bins_x,-1)+0.25))
    pbp(f1s2, icd, indexer=list(pyl.delete(bins_x,-1)+0.25))


    # Add the box and whiskers
    galaxies2 = filter(lambda galaxy: galaxy.ston_J > 30., galaxies)
    galaxies2 = pyl.asarray(galaxies2)
    x = [galaxy.Mass for galaxy in galaxies2]
    ll = 8.5
    ul= 12
    #bins_x =pyl.linspace(ll, ul, 7)
    #bins_x =pyl.arange(8.5, 12.5, 0.5)
    bins_x =pyl.array([8.5, 9., 9.5, 10., 10.5, 11., 12.])
    grid = []

    for i in range(bins_x.size-1):
        xmin = bins_x[i]
        xmax = bins_x[i+1]
        cond=[cond1 and cond2 for cond1, cond2 in zip(x>=xmin, x<xmax)]

        grid.append(galaxies2.compress(cond))
    icd = []
    for i in range(len(grid)):
        icd.append([galaxy.ICD_JH*100 for galaxy in grid[i]])
    #bp2 = f1s2.boxplot(icd, positions=pyl.delete(bins_x,-1)+0.25, sym='')
    pbp(f1s3, icd, indexer=list(pyl.delete(bins_x,-1)+0.25))
    pbp(f1s4, icd, indexer=list(pyl.delete(bins_x,-1)+0.25))

    # Finish Plot
    # Tweak colors on the boxplot
    #pyl.setp(bp1['boxes'], lw=2)
    #pyl.setp(bp1['whiskers'], lw=2)
    #pyl.setp(bp1['medians'], lw=2)
    #pyl.setp(bp2['boxes'], lw=2)
    #pyl.setp(bp2['whiskers'], lw=2)
    #pyl.setp(bp2['medians'], lw=2)
    #pyl.setp(bp['fliers'], color='#8CFF6F', marker='+')

    #f1s1.axvspan(7.477, 9, facecolor='#FFFDD0', ec='None', zorder=0)
    #f1s1.axvspan(11, 12, facecolor='#FFFDD0', ec='None', zorder=0)
    #f1s2.axvspan(7.477, 9, facecolor='#FFFDD0', ec='None', zorder=0)
    #f1s2.axvspan(11, 12, facecolor='#FFFDD0', ec='None', zorder=0)

    f1s1.set_xlim(8,12)
    f1s2.set_xlim(8,12)
    f1s3.set_xlim(8,12)
    f1s4.set_xlim(8,12)

    f1s1.set_ylim(-10,50)
    f1s2.set_ylim(0,15)
    f1s3.set_ylim(-5,12)
    f1s4.set_ylim(-1,3)

    f1s1.set_xticks([8,9,10,11,12])
    f1s1.set_xticklabels([])
    f1s2.set_xticks([8,9,10,11,12])
    f1s2.set_xticklabels([])
    f1s3.set_xticks([8,9,10,11,12])
    f1s4.set_xticks([8,9,10,11,12])

    f1s4.set_yticks([-1, 0, 1, 2, 3])

    f1s3.set_xlabel(r"Log Mass ($M_{\odot})$")
    f1s1.set_ylabel(r"$\xi[i_{775},H_{160}]$ (%)")
    f1s4.set_xlabel(r"Log Mass ($M_{\odot})$")
    f1s3.set_ylabel(r"$\xi[J_{125},H_{160}]$ (%)")

    import matplotlib.font_manager
    line1 = pyl.Line2D([], [], marker='o', mfc='0.8', mec='0.8', markersize=8,
        linewidth=0)
    line2 = pyl.Line2D([], [], marker='s', mec='blue', mfc='None',
        markersize=10, linewidth=0, markeredgewidth=2)
    line3 = pyl.Line2D([], [], color='r', linewidth=2)
    prop = matplotlib.font_manager.FontProperties(size='small')
    pyl.figlegend((line1, line2, line3), ('Data', 'Quartiles',
        'Medians'), 'lower center', prop=prop, ncol=3)

    from matplotlib.patches import ConnectionPatch
    xy = (12, 15)
    xy2 = (8, 15)
    con = ConnectionPatch(xyA=xy, xyB=xy2, coordsA='data', coordsB='data',
        axesA=f1s1, axesB=f1s2)
    xy = (12, 0)
    xy2 = (8, 0)
    con2 = ConnectionPatch(xyA=xy, xyB=xy2, coordsA='data', coordsB='data',
        axesA=f1s1, axesB=f1s2)
    f1s1.add_artist(con)
    f1s1.add_artist(con2)

    xy = (12, 3)
    xy2 = (8, 3)
    con = ConnectionPatch(xyA=xy, xyB=xy2, coordsA='data', coordsB='data',
        axesA=f1s3, axesB=f1s4)
    xy = (12, -1)
    xy2 = (8, -1)
    con2 = ConnectionPatch(xyA=xy, xyB=xy2, coordsA='data', coordsB='data',
        axesA=f1s3, axesB=f1s4)
    f1s3.add_artist(con)
    f1s3.add_artist(con2)

    pyl.draw()
    pyl.show()
コード例 #3
0
ファイル: plot_icd_z_box.py プロジェクト: boada/ICD
def plot_icd_vs_mass():
    galaxies = pickle.load(open('galaxies.pickle','rb'))

    arrow_up = [[0,0], [-1,-1], [0,0], [0,-2], [0,0], [1,-1], [0,0]]

    # Make figure
    f1 = pyl.figure(1, figsize=(6,4))
    f1s1 = f1.add_subplot(221)
    f1s2 = f1.add_subplot(222)
    f1s3 = f1.add_subplot(223)
    f1s4 = f1.add_subplot(224)

    for galaxy in galaxies:
        if galaxy.ston_I > 30. and galaxy.ICD_IH != None:
            if galaxy.ICD_IH*100 < 50:
                f1s1.scatter(galaxy.z, galaxy.ICD_IH * 100, c='0.8',
                    marker='o', s=25, edgecolor='0.8')
            else:
                f1s1.scatter(galaxy.z, 50, s=100, marker=None, verts=arrow_up)

            f1s2.scatter(galaxy.z, galaxy.ICD_IH * 100, c='0.8',
                marker='o', s=25, edgecolor='0.8')

        if galaxy.ston_V > 30. and galaxy.ICD_VJ != None:
            f1s3.scatter(galaxy.z, galaxy.ICD_VJ * 100, c='0.8',
                marker='o', s=25, edgecolor='0.8')
            f1s4.scatter(galaxy.z, galaxy.ICD_VJ * 100, c='0.8',
                marker='o', s=25, edgecolor='0.8')

    # Add the box and whiskers
    galaxies2 = filter(lambda galaxy: galaxy.ston_I > 30., galaxies)
    galaxies2 = pyl.asarray(galaxies2)
    x = [galaxy.z for galaxy in galaxies2]
    ll = 1.5
    ul= 4
    bins_x =pyl.arange(ll, ul, 0.5)
    grid = []

    for i in range(bins_x.size-1):
        xmin = bins_x[i]
        xmax = bins_x[i+1]
        cond=[cond1 and cond2 for cond1, cond2 in zip(x>=xmin, x<xmax)]

        grid.append(galaxies2.compress(cond))
    icd = []
    for i in range(len(grid)):
        icd.append([galaxy.ICD_IH*100 for galaxy in grid[i]])
    from boxplot_percentile import percentile_box_plot as pbp
    pbp(f1s1, icd, indexer=list(pyl.delete(bins_x,-1)+0.25))
    pbp(f1s2, icd, indexer=list(pyl.delete(bins_x,-1)+0.25))

    # Add the box and whiskers
    galaxies = pickle.load(open('galaxies.pickle','rb'))
    galaxies2 = filter(lambda galaxy: galaxy.ston_V > 30., galaxies)
    galaxies2 = pyl.asarray(galaxies2)
    x = [galaxy.z for galaxy in galaxies2]
    ll = 1.5
    ul= 4
    bins_x =pyl.arange(ll, ul, 0.5)
    grid = []

    for i in range(bins_x.size-1):
        xmin = bins_x[i]
        xmax = bins_x[i+1]
        cond=[cond1 and cond2 for cond1, cond2 in zip(x>=xmin, x<xmax)]

        grid.append(galaxies2.compress(cond))
    icd = []
    for i in range(len(grid)):
        icd.append([galaxy.ICD_VJ*100 for galaxy in grid[i]])
    pbp(f1s3, icd, indexer=list(pyl.delete(bins_x,-1)+0.25))
    pbp(f1s4, icd, indexer=list(pyl.delete(bins_x,-1)+0.25))

    f1s1.set_xlim(1.5, 3.5)
    f1s2.set_xlim(1.5, 3.5)
    f1s3.set_xlim(1.5, 3.5)
    f1s4.set_xlim(1.5, 3.5)

    f1s1.set_ylim(-5, 50)
    f1s2.set_ylim(-1, 10)
    f1s3.set_ylim(-5, 50)
    f1s4.set_ylim(-1, 10)

    f1s1.set_xticks([1.5,2,2.5,3,3.5])
    f1s2.set_xticks([1.5,2,2.5,3,3.5])
    f1s1.set_xticklabels([])
    f1s2.set_xticklabels([])
    f1s3.set_xticks([1.5,2,2.5,3,3.5])
    f1s4.set_xticks([1.5,2,2.5,3,3.5])

    f1s1.axhline(0.0, lw=2, c='b', zorder=0)
    f1s2.axhline(0.0, lw=2, c='b', zorder=0)
    f1s3.axhline(0.0, lw=2, c='b', zorder=0)
    f1s4.axhline(0.0, lw=2, c='b', zorder=0)

    f1s3.set_xlabel("Redshift")
    f1s1.set_ylabel(r"$\xi[i_{775},H_{160}]$ (%)")
    f1s4.set_xlabel("Redshift")
    f1s3.set_ylabel(r"$\xi[V_{606},J_{125}]$ (%)")

    import matplotlib.font_manager
    line1 = pyl.Line2D([], [], marker='o', mfc='0.8', mec='0.8', markersize=8,
        linewidth=0)
    line2 = pyl.Line2D([], [], marker='s', mec='blue', mfc='None',
        markersize=10, linewidth=0, markeredgewidth=2)
    line3 = pyl.Line2D([], [], color='r', linewidth=2)
    prop = matplotlib.font_manager.FontProperties(size='small')
    pyl.figlegend((line1, line2, line3), ('Data', 'Quartiles',
        'Medians'), 'lower center', prop=prop, ncol=3)

    from matplotlib.patches import ConnectionPatch
    xy = (3.5, 10)
    xy2 = (1.5, 10)
    con = ConnectionPatch(xyA=xy, xyB=xy2, coordsA='data', coordsB='data',
            axesA=f1s1, axesB=f1s2)
    xy = (3.5, -1)
    xy2 = (1.5, -1)
    con2 = ConnectionPatch(xyA=xy, xyB=xy2, coordsA='data', coordsB='data',
            axesA=f1s1, axesB=f1s2)
    f1s1.add_artist(con)
    f1s1.add_artist(con2)

    xy = (3.5, 10)
    xy2 = (1.5, 10)
    con = ConnectionPatch(xyA=xy, xyB=xy2, coordsA='data', coordsB='data',
            axesA=f1s3, axesB=f1s4)
    xy = (3.5, -1)
    xy2 = (1.5, -1)
    con2 = ConnectionPatch(xyA=xy, xyB=xy2, coordsA='data', coordsB='data',
            axesA=f1s3, axesB=f1s4)
    f1s3.add_artist(con)
    f1s3.add_artist(con2)

    pyl.draw()
    pyl.show()
コード例 #4
0
ファイル: plot_z_box_zooms.py プロジェクト: boada/ICD
def plot_icd_vs_mass():
    galaxies = pickle.load(open('galaxies.pickle','rb'))

    arrow_up = [[0,0], [-1,-1], [0,0], [0,-2], [0,0], [1,-1], [0,0]]

    # Make figure
    f1 = pyl.figure(1, figsize=(4,6))
    f1s1 = f1.add_subplot(211)
    f1s2 = f1.add_subplot(212)

    for galaxy in galaxies:
        if galaxy.ston_I > 30. and galaxy.ICD_IH != None:
            f1s1.scatter(galaxy.z, galaxy.ICD_IH * 100, c='0.8',
                marker='o', s=25, edgecolor='0.8')

        if galaxy.ston_V > 30. and galaxy.ICD_VJ != None:
            f1s2.scatter(galaxy.z, galaxy.ICD_VJ * 100, c='0.8',
                marker='o', s=25, edgecolor='0.8')

    # Add the box and whiskers
    galaxies2 = filter(lambda galaxy: galaxy.ston_I > 30., galaxies)
    galaxies2 = pyl.asarray(galaxies2)
    x = [galaxy.z for galaxy in galaxies2]
    ll = 1.5
    ul= 4
    bins_x =pyl.arange(ll, ul, 0.5)
    grid = []

    for i in range(bins_x.size-1):
        xmin = bins_x[i]
        xmax = bins_x[i+1]
        cond=[cond1 and cond2 for cond1, cond2 in zip(x>=xmin, x<xmax)]

        grid.append(galaxies2.compress(cond))
    icd = []
    for i in range(len(grid)):
        icd.append([galaxy.ICD_IH*100 for galaxy in grid[i]])
    from boxplot_percentile import percentile_box_plot as pbp
    pbp(f1s1, icd, indexer=list(pyl.delete(bins_x,-1)+0.25), whisker_top=None,
            whisker_bottom=None)

    # Add the box and whiskers
    galaxies = pickle.load(open('galaxies.pickle','rb'))
    galaxies2 = filter(lambda galaxy: galaxy.ston_V > 30., galaxies)
    galaxies2 = pyl.asarray(galaxies2)
    x = [galaxy.z for galaxy in galaxies2]
    ll = 1.5
    ul= 4
    bins_x =pyl.arange(ll, ul, 0.5)
    grid = []

    for i in range(bins_x.size-1):
        xmin = bins_x[i]
        xmax = bins_x[i+1]
        cond=[cond1 and cond2 for cond1, cond2 in zip(x>=xmin, x<xmax)]

        grid.append(galaxies2.compress(cond))
    icd = []
    for i in range(len(grid)):
        icd.append([galaxy.ICD_VJ*100 for galaxy in grid[i]])
    pbp(f1s2, icd, indexer=list(pyl.delete(bins_x,-1)+0.25), whisker_top=None,
            whisker_bottom=None)

    f1s1.set_xlim(1.5, 3.5)
    f1s2.set_xlim(1.5, 3.5)

    f1s1.set_ylim(-1, 10)
    f1s2.set_ylim(-1, 10)

    f1s1.set_xticklabels([])
    f1s2.set_xticks([1.5,2,2.5,3,3.5])

    f1s1.set_ylabel(r"$\xi[i_{775},H_{160}]$ (%)")
    f1s2.set_xlabel("Redshift")
    f1s2.set_ylabel(r"$\xi[V_{606},J_{125}]$ (%)")

    import matplotlib.font_manager
    line1 = pyl.Line2D([], [], marker='o', mfc='0.8', mec='0.8', markersize=8,
        linewidth=0)
    line2 = pyl.Line2D([], [], marker='s', mec='#348ABD', mfc='None',
        markersize=10, linewidth=0, markeredgewidth=2)
    line3 = pyl.Line2D([], [], color='#A60628', linewidth=2)
    prop = matplotlib.font_manager.FontProperties(size='small')
    pyl.figlegend((line1, line2, line3), ('Data', 'Quartiles',
        'Medians'), 'lower center', prop=prop, ncol=3)

    pyl.show()
コード例 #5
0
ファイル: test.py プロジェクト: boada/ICD
def plot_uvj_vs_icd():
    galaxies = pickle.load(open('galaxies.pickle', 'rb'))
    galaxies = filter(lambda galaxy: galaxy.ICD_IH != None, galaxies)
    galaxies = filter(lambda galaxy: galaxy.sersic != None and \
            galaxy.ston_I > 30, galaxies)

    #Upper and Lower limit arrow verts
    arrowup_verts = [[0., 0.], [-1., -1], [0., 0.], [0., -2.], [0., 0.],
                     [1, -1]]
    #arrowdown_verts = [[0.,0.], [-1., 1], [0.,0.],
    #    [0.,2.], [0.,0.], [1, 1]]

    F = pyl.figure(1, figsize=(8, 3))
    grid = AxesGrid(F,
                    111,
                    nrows_ncols=(1, 4),
                    axes_pad=0.1,
                    add_all=True,
                    aspect=False,
                    share_all=True)

    ax1 = grid[0]
    ax2 = grid[1]
    ax3 = grid[2]
    ax4 = grid[3]

    for galaxy in galaxies:
        if galaxy.sersic < 1.:
            col1 = ax1.scatter(galaxy.Mass,
                               galaxy.Color_grad,
                               s=25,
                               c='0.8',
                               edgecolor='0.8')
        if 1. < galaxy.sersic < 2.:
            col2 = ax2.scatter(galaxy.Mass,
                               galaxy.Color_grad,
                               s=25,
                               c='0.8',
                               edgecolor='0.8')
        if 2. < galaxy.sersic < 3.:
            col3 = ax3.scatter(galaxy.Mass,
                               galaxy.Color_grad,
                               s=25,
                               c='0.8',
                               edgecolor='0.8')
        if 3. < galaxy.sersic:
            if galaxy.Color_grad < 50:
                col4 = ax4.scatter(galaxy.Mass,
                                   galaxy.Color_grad,
                                   s=25,
                                   c='0.8',
                                   edgecolor='0.8')
            else:
                col4 = ax4.scatter(galaxy.Mass,
                                   50,
                                   marker=None,
                                   s=100,
                                   verts=arrowup_verts)

    # Add the box and whiskers
    galaxies1 = filter(lambda galaxy: galaxy.ston_I > 30. and \
        galaxy.sersic < 1, galaxies)
    galaxies1 = pyl.asarray(galaxies1)
    galaxies2 = filter(lambda galaxy: galaxy.ston_I > 30. and \
        1 < galaxy.sersic < 2, galaxies)
    galaxies2 = pyl.asarray(galaxies2)
    galaxies3 = filter(lambda galaxy: galaxy.ston_I > 30. and \
        2 < galaxy.sersic < 3, galaxies)
    galaxies3 = pyl.asarray(galaxies3)
    galaxies4 = filter(lambda galaxy: galaxy.ston_I > 30. and \
        3 < galaxy.sersic, galaxies)
    galaxies4 = pyl.asarray(galaxies4)

    x1 = [galaxy.Mass for galaxy in galaxies1]
    x2 = [galaxy.Mass for galaxy in galaxies2]
    x3 = [galaxy.Mass for galaxy in galaxies3]
    x4 = [galaxy.Mass for galaxy in galaxies4]

    ll = 8.5
    ul = 12
    bins_x = pyl.arange(8.5, 12.5, 0.5)
    grid1 = []
    grid2 = []
    grid3 = []
    grid4 = []

    for i in range(bins_x.size - 1):
        xmin = bins_x[i]
        xmax = bins_x[i + 1]
        cond = [cond1 and cond2 for cond1, cond2 in zip(x1 >= xmin, x1 < xmax)]
        grid1.append(galaxies1.compress(cond))
        cond = [cond1 and cond2 for cond1, cond2 in zip(x2 >= xmin, x2 < xmax)]
        grid2.append(galaxies2.compress(cond))
        cond = [cond1 and cond2 for cond1, cond2 in zip(x3 >= xmin, x3 < xmax)]
        grid3.append(galaxies3.compress(cond))
        cond = [cond1 and cond2 for cond1, cond2 in zip(x4 >= xmin, x4 < xmax)]
        grid4.append(galaxies4.compress(cond))

    icd1 = []
    icd2 = []
    icd3 = []
    icd4 = []

    for i in range(len(grid1)):
        icd1.append([galaxy.Color_grad for galaxy in grid1[i]])
        icd2.append([galaxy.Color_grad for galaxy in grid2[i]])
        icd3.append([galaxy.Color_grad for galaxy in grid3[i]])
        icd4.append([galaxy.Color_grad for galaxy in grid4[i]])

    from boxplot_percentile import percentile_box_plot as pbp

    bp1 = pbp(ax1, icd1, indexer=list(pyl.delete(bins_x, -1) + 0.25))
    bp2 = pbp(ax2, icd2, indexer=list(pyl.delete(bins_x, -1) + 0.25))
    bp3 = pbp(ax3, icd3, indexer=list(pyl.delete(bins_x, -1) + 0.25))
    bp4 = pbp(ax4, icd4, indexer=list(pyl.delete(bins_x, -1) + 0.25))

    ax1.set_xticks([8, 9, 10, 11])
    ax2.set_xticks([8, 9, 10, 11])
    ax3.set_xticks([8, 9, 10, 11])
    ax4.set_xticks([8, 9, 10, 11])

    #    ax1.set_xlim(8, 12)
    #    ax2.set_xlim(8, 12)
    #    ax3.set_xlim(8, 12)
    #    ax4.set_xlim(8, 12)

    #    ax1.set_ylim(0, 50)
    #    ax2.set_ylim(0, 50)
    #    ax3.set_ylim(0, 50)
    #    ax4.set_ylim(0, 50)

    ax1.set_ylabel(r'$\xi[i_{775},H_{160}]$ (%)')
    ax1.set_title('n < 1')
    ax2.set_title('1 < n < 2')
    ax3.set_title('2 < n < 3')
    ax4.set_title('3 < n')

    pyl.figtext(.5,
                .05,
                r'Log Mass $(M_{\odot})$',
                fontsize=18,
                horizontalalignment='center')
    ax1.axhline(0, lw=2, zorder=0)
    ax2.axhline(0, lw=2, zorder=0)
    ax3.axhline(0, lw=2, zorder=0)
    ax4.axhline(0, lw=2, zorder=0)

    import matplotlib.font_manager
    line1 = pyl.Line2D([], [],
                       marker='o',
                       mfc='0.8',
                       mec='0.8',
                       markersize=8,
                       linewidth=0)
    line2 = pyl.Line2D([], [],
                       marker='s',
                       mec='blue',
                       mfc='None',
                       markersize=10,
                       linewidth=0,
                       markeredgewidth=2)
    line3 = pyl.Line2D([], [], color='r', linewidth=2)
    prop = matplotlib.font_manager.FontProperties(size='small')
    ax3.legend((line1, line2, line3), ('Data', 'Quartiles', 'Medians'),
               'upper center',
               prop=prop,
               ncol=1)

    pyl.tight_layout()
    pyl.subplots_adjust(bottom=0.21, left=0.11)
    pyl.show()
コード例 #6
0
ファイル: test.py プロジェクト: boada/ICD
def plot_uvj_vs_icd():
    galaxies = pickle.load(open("galaxies.pickle", "rb"))
    galaxies = filter(lambda galaxy: galaxy.ICD_IH != None, galaxies)
    galaxies = filter(lambda galaxy: galaxy.sersic != None and galaxy.ston_I > 30, galaxies)

    # Upper and Lower limit arrow verts
    arrowup_verts = [[0.0, 0.0], [-1.0, -1], [0.0, 0.0], [0.0, -2.0], [0.0, 0.0], [1, -1]]
    # arrowdown_verts = [[0.,0.], [-1., 1], [0.,0.],
    #    [0.,2.], [0.,0.], [1, 1]]

    F = pyl.figure(1, figsize=(8, 3))
    grid = AxesGrid(F, 111, nrows_ncols=(1, 4), axes_pad=0.1, add_all=True, aspect=False, share_all=True)

    ax1 = grid[0]
    ax2 = grid[1]
    ax3 = grid[2]
    ax4 = grid[3]

    for galaxy in galaxies:
        if galaxy.sersic < 1.0:
            col1 = ax1.scatter(galaxy.Mass, galaxy.Color_grad, s=25, c="0.8", edgecolor="0.8")
        if 1.0 < galaxy.sersic < 2.0:
            col2 = ax2.scatter(galaxy.Mass, galaxy.Color_grad, s=25, c="0.8", edgecolor="0.8")
        if 2.0 < galaxy.sersic < 3.0:
            col3 = ax3.scatter(galaxy.Mass, galaxy.Color_grad, s=25, c="0.8", edgecolor="0.8")
        if 3.0 < galaxy.sersic:
            if galaxy.Color_grad < 50:
                col4 = ax4.scatter(galaxy.Mass, galaxy.Color_grad, s=25, c="0.8", edgecolor="0.8")
            else:
                col4 = ax4.scatter(galaxy.Mass, 50, marker=None, s=100, verts=arrowup_verts)

    # Add the box and whiskers
    galaxies1 = filter(lambda galaxy: galaxy.ston_I > 30.0 and galaxy.sersic < 1, galaxies)
    galaxies1 = pyl.asarray(galaxies1)
    galaxies2 = filter(lambda galaxy: galaxy.ston_I > 30.0 and 1 < galaxy.sersic < 2, galaxies)
    galaxies2 = pyl.asarray(galaxies2)
    galaxies3 = filter(lambda galaxy: galaxy.ston_I > 30.0 and 2 < galaxy.sersic < 3, galaxies)
    galaxies3 = pyl.asarray(galaxies3)
    galaxies4 = filter(lambda galaxy: galaxy.ston_I > 30.0 and 3 < galaxy.sersic, galaxies)
    galaxies4 = pyl.asarray(galaxies4)

    x1 = [galaxy.Mass for galaxy in galaxies1]
    x2 = [galaxy.Mass for galaxy in galaxies2]
    x3 = [galaxy.Mass for galaxy in galaxies3]
    x4 = [galaxy.Mass for galaxy in galaxies4]

    ll = 8.5
    ul = 12
    bins_x = pyl.arange(8.5, 12.5, 0.5)
    grid1 = []
    grid2 = []
    grid3 = []
    grid4 = []

    for i in range(bins_x.size - 1):
        xmin = bins_x[i]
        xmax = bins_x[i + 1]
        cond = [cond1 and cond2 for cond1, cond2 in zip(x1 >= xmin, x1 < xmax)]
        grid1.append(galaxies1.compress(cond))
        cond = [cond1 and cond2 for cond1, cond2 in zip(x2 >= xmin, x2 < xmax)]
        grid2.append(galaxies2.compress(cond))
        cond = [cond1 and cond2 for cond1, cond2 in zip(x3 >= xmin, x3 < xmax)]
        grid3.append(galaxies3.compress(cond))
        cond = [cond1 and cond2 for cond1, cond2 in zip(x4 >= xmin, x4 < xmax)]
        grid4.append(galaxies4.compress(cond))

    icd1 = []
    icd2 = []
    icd3 = []
    icd4 = []

    for i in range(len(grid1)):
        icd1.append([galaxy.Color_grad for galaxy in grid1[i]])
        icd2.append([galaxy.Color_grad for galaxy in grid2[i]])
        icd3.append([galaxy.Color_grad for galaxy in grid3[i]])
        icd4.append([galaxy.Color_grad for galaxy in grid4[i]])

    from boxplot_percentile import percentile_box_plot as pbp

    bp1 = pbp(ax1, icd1, indexer=list(pyl.delete(bins_x, -1) + 0.25))
    bp2 = pbp(ax2, icd2, indexer=list(pyl.delete(bins_x, -1) + 0.25))
    bp3 = pbp(ax3, icd3, indexer=list(pyl.delete(bins_x, -1) + 0.25))
    bp4 = pbp(ax4, icd4, indexer=list(pyl.delete(bins_x, -1) + 0.25))

    ax1.set_xticks([8, 9, 10, 11])
    ax2.set_xticks([8, 9, 10, 11])
    ax3.set_xticks([8, 9, 10, 11])
    ax4.set_xticks([8, 9, 10, 11])

    #    ax1.set_xlim(8, 12)
    #    ax2.set_xlim(8, 12)
    #    ax3.set_xlim(8, 12)
    #    ax4.set_xlim(8, 12)

    #    ax1.set_ylim(0, 50)
    #    ax2.set_ylim(0, 50)
    #    ax3.set_ylim(0, 50)
    #    ax4.set_ylim(0, 50)

    ax1.set_ylabel(r"$\xi[i_{775},H_{160}]$ (%)")
    ax1.set_title("n < 1")
    ax2.set_title("1 < n < 2")
    ax3.set_title("2 < n < 3")
    ax4.set_title("3 < n")

    pyl.figtext(0.5, 0.05, r"Log Mass $(M_{\odot})$", fontsize=18, horizontalalignment="center")
    ax1.axhline(0, lw=2, zorder=0)
    ax2.axhline(0, lw=2, zorder=0)
    ax3.axhline(0, lw=2, zorder=0)
    ax4.axhline(0, lw=2, zorder=0)

    import matplotlib.font_manager

    line1 = pyl.Line2D([], [], marker="o", mfc="0.8", mec="0.8", markersize=8, linewidth=0)
    line2 = pyl.Line2D([], [], marker="s", mec="blue", mfc="None", markersize=10, linewidth=0, markeredgewidth=2)
    line3 = pyl.Line2D([], [], color="r", linewidth=2)
    prop = matplotlib.font_manager.FontProperties(size="small")
    ax3.legend((line1, line2, line3), ("Data", "Quartiles", "Medians"), "upper center", prop=prop, ncol=1)

    pyl.tight_layout()
    pyl.subplots_adjust(bottom=0.21, left=0.11)
    pyl.show()
コード例 #7
0
ファイル: plot_icd_vs_z_box.py プロジェクト: boada/ICD
ll = 1.5
ul = 4
bins_x = pyl.arange(ll, ul, 0.5)
grid = []

for i in range(bins_x.size - 1):
    xmin = bins_x[i]
    xmax = bins_x[i + 1]
    cond = [cond1 and cond2 for cond1, cond2 in zip(x >= xmin, x < xmax)]

    grid.append(galaxies2.compress(cond))
icd = []
for i in range(len(grid)):
    icd.append([galaxy.ICD_IH * 100 for galaxy in grid[i]])
from boxplot_percentile import percentile_box_plot as pbp
pbp(f1s1, icd, indexer=list(pyl.delete(bins_x, -1) + 0.25))
pbp(f1s2, icd, indexer=list(pyl.delete(bins_x, -1) + 0.25))

# Add the box and whiskers
galaxies = pickle.load(open('galaxies.pickle', 'rb'))
galaxies2 = filter(lambda galaxy: galaxy.ston_V > 30., galaxies)
galaxies2 = pyl.asarray(galaxies2)
x = [galaxy.z for galaxy in galaxies2]
ll = 1.5
ul = 4
bins_x = pyl.arange(ll, ul, 0.5)
grid = []

for i in range(bins_x.size - 1):
    xmin = bins_x[i]
    xmax = bins_x[i + 1]
コード例 #8
0
ファイル: plot_icd_vs_z_box.py プロジェクト: boada/ICD
ll = 1.5
ul= 4
bins_x =pyl.arange(ll, ul, 0.5)
grid = []

for i in range(bins_x.size-1):
    xmin = bins_x[i]
    xmax = bins_x[i+1]
    cond=[cond1 and cond2 for cond1, cond2 in zip(x>=xmin, x<xmax)]

    grid.append(galaxies2.compress(cond))
icd = []
for i in range(len(grid)):
    icd.append([galaxy.ICD_IH*100 for galaxy in grid[i]])
from boxplot_percentile import percentile_box_plot as pbp
pbp(f1s1, icd, indexer=list(pyl.delete(bins_x,-1)+0.25))
pbp(f1s2, icd, indexer=list(pyl.delete(bins_x,-1)+0.25))

# Add the box and whiskers
galaxies = pickle.load(open('galaxies.pickle','rb'))
galaxies2 = filter(lambda galaxy: galaxy.ston_V > 30., galaxies)
galaxies2 = pyl.asarray(galaxies2)
x = [galaxy.z for galaxy in galaxies2]
ll = 1.5
ul= 4
bins_x =pyl.arange(ll, ul, 0.5)
grid = []

for i in range(bins_x.size-1):
    xmin = bins_x[i]
    xmax = bins_x[i+1]