Beispiel #1
0
 def GetSourceSize(self,kpc=False):
     self.z=source_redshifts[self.name]
     self.Da = astCalc.da(self.z)
     self.scale = self.Da*1e3*np.pi/180./3600.
     if len(self.srcs) == 1 or self.name == 'J0837':
         self.Re_v = self.Ddic['Source 1 re']*0.05
         self.Re_i = self.Re_v.copy()
         self.Re_lower = self.Ldic['Source 1 re']*0.05
         self.Re_upper = self.Udic['Source 1 re']*0.05
     elif len(self.srcs) == 2 and self.name != 'J0837':
         print 'test this out...!'
         Xgrid = np.logspace(-4,5,1501)
         Res = []
         for i in range(len(self.imgs)):
             #if self.name == 'J1605':
             #    source = 
             source = self.fits[i][-3]*self.srcs[0].eval(Xgrid) + self.fits[i][-2]*self.srcs[1].eval(Xgrid)
             R = Xgrid.copy()
             light = source*2.*np.pi*R
             mod = splrep(R,light,t=np.logspace(-3.8,4.8,1301))
             intlight = np.zeros(len(R))
             for i in range(len(R)):
                 intlight[i] = splint(0,R[i],mod)
             model = splrep(intlight[:-300],R[:-300])
             
             if len(model[1][np.where(np.isnan(model[1])==True)]>0):
                 print "arrays need to be increasing monotonically! But don't worry about it"
                 model = splrep(intlight[:-450],R[:-450])
             reff = splev(0.5*intlight[-1],model)
             Res.append(reff*0.05)
         self.Re_v,self.Re_i = Res
     if kpc:
         return [self.Re_v*self.scale, self.Re_i*self.scale]
     return [self.Re_v, self.Re_i]
 def GetSourceSize(self,z):
     self.z=z
     self.Da = astCalc.da(self.z)
     self.scale = self.Da*np.pi/180./3600.
     if len(self.srcs) == 1:
         self.Re = self.Ddic['Source 1 re']*0.05
         self.Re_lower = self.Ldic['Source 1 re']*0.05
         self.Re_upper = self.Udic['Source 1 re']*0.05
         self.Re_kpc = self.Re*self.scale
         return self.Re
     elif len(self.srcs) == 2:
         print 'test this out...!'
         Xgrid = np.logspace(-4,5,1501)
         Ygrid = np.logspace(-4,5,1501)
         Res = []
         for i in range(len(self.imgs)):
             source = self.fits[i][-3]*self.srcs[0].eval(Xgrid) + self.fits[i][-2]*self.srcs[1].eval(Xgrid)
             R = Xgrid.copy()
             light = source*2.*np.pi*R
             mod = splrep(R,light,t=np.logspace(-3.8,4.8,1301))
             intlight = np.zeros(len(R))
             for i in range(len(R)):
                 intlight[i] = splint(0,R[i],mod)
             model = splrep(intlight[:-300],R[:-300])
             reff = splev(0.5*intlight[-1],model)
             Res.append(reff*0.05)
         self.Re_v,self.Re_i = Res
         return self.Re_v, self.Re_i
 def Arcsec2Kpc(self,z=None):
     self.z=z
     self.Da = astCalc.da(self.z)
     self.scale = self.Da*np.pi/180./3600.
     if len(self.srcs)==1:
         self.Re_kpc = self.Re*scale
     elif len(self.srcs)==2:
         self.Re_v_kpc = self.Re_v*scale
         self.Re_i_kpc = self.Re_i*scale
Beispiel #4
0
def findSeperationSpatial(data, center):
    ''' Finds the distance to all of the galaxies from the center of the
    cluster in the spatial plane. Returns values in Mpc.

    '''

    # Add a new column to the dataframe
    data['seperation'] = 0.0
    for row in data.iterrows():
        sepDeg = aco.calcAngSepDeg(center[0], center[1], row[1]['ra'],
                                   row[1]['dec'])
        sepMpc = sepDeg * aca.da(row[1]['redshift']) / 57.2957795131
        data['seperation'][row[0]] = sepMpc

    return data
def findseparationSpatial(data, center):
    ''' Finds the distance to all of the galaxies from the center of the
    cluster in the spatial plane. Returns values in Mpc.

    '''

    # Add a new column to the dataframe
    sepDeg = np.array(aco.calcAngSepDeg(center[0], center[1], data.ra.values,
                                        data.dec.values))
    da = np.array([aca.da(z) / 57.2957795131 for z in data.redshift.values])

    sepMpc = da * sepDeg
    data.loc[:, 'separation'] = sepMpc

    return data
from astLib import astStats
from scipy.stats import scoreatpercentile
galaxies = pickle.load(open('galaxies.pickle', 'rb'))
galaxies = filter(lambda galaxy: galaxy.ston_I > 10., galaxies)
#galaxies = filter(lambda galaxy: 10<galaxy.Mass <11 and galaxy.ston_I > 10. , 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]]

f1 = pyl.figure(1, figsize=(6, 4))
f1s1 = f1.add_subplot(111)

for galaxy in galaxies:
    re = 0.06 * galaxy.halflight * astCalc.da(galaxy.z) * 1000 / 206265.
    if galaxy.ICD_IH * 100 < 50:
        f1s1.scatter(re, galaxy.ICD_IH * 100, c='0.8', edgecolor='0.8', s=20)
    else:
        f1s1.scatter(re, 50, s=100, marker=None, verts=arrowup_verts)

x = [
    round(0.06 * galaxy.halflight * astCalc.da(galaxy.z) * 1000 / 206265.)
    for galaxy in galaxies
]
y = [galaxy.ICD_IH * 100. for galaxy in galaxies]

x_, y_median = zip(*sorted(
    (xVal, pyl.median([yVal for a, yVal in zip(x, y) if xVal == a]))
    for xVal in set(x)))
Beispiel #7
0
omegaMs = [1.0, 0.2, 0.05]
omegaLs = [0.0, 0.8, 0.0]
styles = ['r-', 'b--', 'g:']
z = numpy.arange(0, 6, 0.1)

# da
pylab.clf()
for m, l, s in zip(omegaMs, omegaLs, styles):
    astCalc.OMEGA_M0 = m
    astCalc.OMEGA_L = l
    label = "$\Omega_{m0}$ = %.2f $\Omega_\Lambda$ = %.2f" % (m, l)
    dH = astCalc.C_LIGHT/astCalc.H0
    plotData = []
    for i in z:
        plotData.append(astCalc.da(i)/dH)
    pylab.plot(z, plotData, s, label=label)
pylab.ylim(0, 0.5)
pylab.xlim(0, 5)
pylab.xlabel("$z$")
pylab.ylabel("$D_A/D_H$")
pylab.legend(loc='lower right')

# dV/dz
pylab.clf()
for m, l, s in zip(omegaMs, omegaLs, styles):
    astCalc.OMEGA_M0 = m
    astCalc.OMEGA_L = l
    label = "$\Omega_{m0}$ = %.2f $\Omega_\Lambda$ = %.2f" % (m, l)
    dH = astCalc.C_LIGHT/astCalc.H0
    plotData = []
Beispiel #8
0
def plot_icd_vs_mass():
    galaxies = pickle.load(open('galaxies.pickle', 'rb'))
    galaxies = filter(lambda galaxy: 0.06 * galaxy.halflight *\
            astCalc.da(galaxy.z)*1000/206265. > 2, galaxies)

    # Make figure
    f1 = pyl.figure(1, figsize=(6, 4))
    f1s1 = f1.add_subplot(121)
    f1s2 = f1.add_subplot(122)
    #    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_width import percentile_box_plot as pbp
    #bp1 = f1s1.boxplot(icd, positions=pyl.delete(bins_x,-1)+0.25, sym='')
    width = pyl.diff(bins_x)
    index = pyl.delete(bins_x, -1) + 0.25
    index[-1] = index[-1] + 0.25
    pbp(f1s1, icd, indexer=list(index), width=width)
    pbp(f1s2, icd, indexer=list(index), width=width)
    '''
    # 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='')
    width = pyl.diff(bins_x)
    index = pyl.delete(bins_x,-1) + 0.25
    index[-1] = index[-1] + 0.25
    pbp(f1s3, icd, indexer=list(index), width=width)
    pbp(f1s4, icd, indexer=list(index), width=width)

    '''
    # 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])

    f1s1.set_ylabel(r"$\xi[i_{775},H_{160}]$ (%)")
    f1s1.set_xlabel(r"Log Mass ($M_{\odot})$")
    f1s2.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='#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)

    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()
Beispiel #9
0
import matplotlib.ticker


galaxies = pickle.load(open('galaxies.pickle','rb'))
galaxies = filter(lambda galaxy: galaxy.ston_I >30., galaxies)

f1 = pyl.figure(1, figsize=(6,4))
f1s1 = f1.add_subplot(111)

#x = [0.06 * galaxy.halflight * astCalc.da(galaxy.z) * 1000./206265
#    for galaxy in galaxies]

galaxies = pyl.asarray(galaxies)

for galaxy in galaxies:
    re = 0.06* galaxy.halflight * astCalc.da(galaxy.z)*1000/206265.
    f1s1.scatter(re, galaxy.ICD_IH*100, c='0.8', edgecolor='0.8', s=20)

bins_x = pyl.arange(1, 20, 2)
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)]
    bunch = galaxies.compress(cond)

    icds = [galaxy.ICD_IH*100 for galaxy in bunch]
    if len(icds) >= 1:
        med = pyl.median(icds)
        f1s1.scatter((xmax-xmin)/2. + xmin, med, s=50, c='r')
Beispiel #10
0
 def Arcsec2Kpc(self,z=None):
     self.z=z
     self.Da = astCalc.da(self.z)
     self.scale = self.Da*1e3*np.pi/180./3600.
     self.Re_v_kpc = self.Re_v*scale
     self.Re_i_kpc = self.Re_i*scale
Beispiel #11
0
from scipy.stats import scoreatpercentile

galaxies = pickle.load(open("galaxies.pickle", "rb"))
galaxies = filter(lambda galaxy: galaxy.ston_I > 10.0, galaxies)
# galaxies = filter(lambda galaxy: 10<galaxy.Mass <11 and galaxy.ston_I > 10. , 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]]

f1 = pyl.figure(1, figsize=(6, 4))
f1s1 = f1.add_subplot(111)

for galaxy in galaxies:
    re = 0.06 * galaxy.halflight * astCalc.da(galaxy.z) * 1000 / 206265.0
    if galaxy.ICD_IH * 100 < 50:
        f1s1.scatter(re, galaxy.ICD_IH * 100, c="0.8", edgecolor="0.8", s=20)
    else:
        f1s1.scatter(re, 50, s=100, marker=None, verts=arrowup_verts)

x = [round(0.06 * galaxy.halflight * astCalc.da(galaxy.z) * 1000 / 206265.0) for galaxy in galaxies]
y = [galaxy.ICD_IH * 100.0 for galaxy in galaxies]

x_, y_median = zip(*sorted((xVal, pyl.median([yVal for a, yVal in zip(x, y) if xVal == a])) for xVal in set(x)))

x_, y_upper = zip(
    *sorted((xVal, scoreatpercentile([yVal for a, yVal in zip(x, y) if xVal == a], 75)) for xVal in set(x))
)
x_, y_low = zip(*sorted((xVal, scoreatpercentile([yVal for a, yVal in zip(x, y) if xVal == a], 25)) for xVal in set(x)))
Beispiel #12
0
    gc = aplpy.FITSFigure(fits)
    try:
        gc.show_rgb(png)
    except FileNotFoundError:
        gc.show_grayscale(stretch='arcsinh', pmin=1, pmax=98)
        gc.set_theme('publication')

    gc.set_tick_labels_format(xformat='hh:mm:ss', yformat='dd:mm')
    gc.set_tick_labels_size('small')

    ###
    # move things around and draw the labels
    ###

    # recenter
    window = 206265. / astCalc.da(confirmed.iloc[i]['z_cl_boada'])
    gc.recenter(confirmed.iloc[i]['RA BCG'], confirmed.iloc[i]['DEC BCG'],
                window / 3600)

    # add the circles
    gc.show_circles(confirmed.iloc[i]['RA'],
                    confirmed.iloc[i]['DEC'],
                    2 / 60,
                    linestyle='--',
                    edgecolor='#e24a33',
                    facecolor='none',
                    path_effects=[
                        pe.Stroke(linewidth=1.2, foreground='white'),
                        pe.Normal()
                    ])
    gc.show_circles(confirmed.iloc[i]['RA'],
Beispiel #13
0
                dataframeIndex = list(LOSVsorted.index[list(indices[0])])
                LOSVsorted = LOSVsorted.drop(dataframeIndex)
                interlopers += dataframeIndex
            else:
                rejected = False
    print 'interlopers',interlopers
    return data.drop(interlopers)

def rejectInterlopers_group(data, sigmav=500)

    deltaZmax = 2 * simgav / c
    avgz = findClusterCenterRedshift(data)

    deltaRmax = (c * deltaZmax)/(10*(1 + avgz)*aca.H0*aca.Ez(avgz)) # 1/Mpc

    deltaThetamax = 206265 * deltaRmax * aca.da(avgz) # arcseconds


catalog = '/Users/steven/Projects/cluster/data/boada/may_2013/catalogs/XMMXCSJ124425.9+164758.0_complete.csv'


files = glob.glob('*.results')
center = 191.1050125, 16.7966666667

results = parseResults(files)
matched = matchToCatalog(results, catalog)
seperated = findSeperationSpatial(matched, center)



Beispiel #14
0
 def testda(self):
     """ astLib.da should give known result with known input """
     for z, result in self.da:
         answer = astCalc.da(z)
         self.assertAlmostEqual(result, answer)
Beispiel #15
0
def plot_icd_vs_mass():
    galaxies = pickle.load(open('galaxies.pickle','rb'))
    galaxies = filter(lambda galaxy: 0.06 * galaxy.halflight *\
            astCalc.da(galaxy.z)*1000/206265. > 2, galaxies)

    # Make figure
    f1 = pyl.figure(1, figsize=(6,4))
    f1s1 = f1.add_subplot(121)
    f1s2 = f1.add_subplot(122)
#    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_width import percentile_box_plot as pbp
    #bp1 = f1s1.boxplot(icd, positions=pyl.delete(bins_x,-1)+0.25, sym='')
    width = pyl.diff(bins_x)
    index = pyl.delete(bins_x,-1) + 0.25
    index[-1] = index[-1] + 0.25
    pbp(f1s1, icd, indexer=list(index), width=width)
    pbp(f1s2, icd, indexer=list(index), width=width)

    '''
    # 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='')
    width = pyl.diff(bins_x)
    index = pyl.delete(bins_x,-1) + 0.25
    index[-1] = index[-1] + 0.25
    pbp(f1s3, icd, indexer=list(index), width=width)
    pbp(f1s4, icd, indexer=list(index), width=width)

    '''
    # 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])

    f1s1.set_ylabel(r"$\xi[i_{775},H_{160}]$ (%)")
    f1s1.set_xlabel(r"Log Mass ($M_{\odot})$")
    f1s2.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='#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)

    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()