In [1]:
%pylab inline

from __future__ import division

import os
import copy
import argparse
import fnmatch
import numpy as np

import scipy
from scipy.interpolate import interp1d

# Astropy
from astropy.io import fits
from astropy    import units as u
from astropy.stats import sigma_clip
# AstroML
from astroML.plotting import hist

# Matplotlib related
# Matplotlib default settings
rcdef = plt.rcParams.copy()
pylab.rcParams['figure.figsize'] = 12, 10
pylab.rcParams['xtick.major.size'] = 8.0
pylab.rcParams['xtick.major.width'] = 2.5
pylab.rcParams['xtick.minor.size'] = 4.0
pylab.rcParams['xtick.minor.width'] = 2.5
pylab.rcParams['ytick.major.size'] = 8.0
pylab.rcParams['ytick.major.width'] = 2.5
pylab.rcParams['ytick.minor.size'] = 4.0
pylab.rcParams['ytick.minor.width'] = 2.5

import matplotlib.pyplot as plt
from matplotlib.patches import Ellipse
from matplotlib.ticker import NullFormatter
from matplotlib.ticker import MaxNLocator

# Personal
import hscUtils as hUtil
import galSBP

import cPickle as pickle

amag_sun_g = 5.33
amag_sun_r = 4.67
amag_sun_i = 4.48
amag_sun_z = 4.42


Populating the interactive namespace from numpy and matplotlib

In [ ]:
# Location of the cutouts 

""" On Astro3 / For MacOS"""
baseDir = '/Users/songhuang/astro3/hscs' 
redBCG = os.path.join(baseDir, 'redmapper')
nonBCG = os.path.join(baseDir, 'nonbcg')

A Few Useful Functions


In [2]:
def normProfile(rad, sbp, minRad, maxRad): 
    """
    Normalize the profile 
    """
    offset = np.nanmedian(sbp[(rad >= minRad) & (rad <= maxRad)])
    
    return (sbp-offset)

In [3]:
def logAdd(para1, para2):    
    """
    Doc
    """
    return np.log10((10.0 ** np.asarray(para1)) + (10.0 ** np.asarray(para2)))

In [4]:
def loadGalfitOutput(pklFile):     
    """
    Load a .pkl file for GALFIT model 
    Return the GalfitParser object 
    """
    if not os.path.isfile(pklFile): 
        raise Exception("XXX Can not find the .pkl file : %s") % pklFile 
    else: 
        return pickle.load(open(pklFile, 'rb'))

In [5]:
def findProfile(pattern, loc, verbose=False):
    """
    Find the prefix of the ellipse profiles 
    """
    result = []
    for root, dirs, files in os.walk(loc):
        for name in files:
            if fnmatch.fnmatch(name, pattern):
                result.append(os.path.join(root, name))
                
    if verbose: 
        print "### %d files found !" % len(result)
    
    return result

In [6]:
def readProfile(ellFile):
    """
    Load the pickle format 1-D profile
    """
    if os.path.isfile(ellFile):
        return pickle.load(open(ellFile, 'rb'))
    else:
        raise Exception("XXX Can not find the Ellipse file")

In [7]:
def getEllipProfile(objid, loc, stage='3', verbose=False):
    
    pattern = '*' + str(objid) + '*_img_ellip_' + stage + '.pkl'
    
    result = findProfile(pattern, loc)
    
    if len(result) == 0: 
        #raise Exception('XXX Can not find the Ellipse profile ! %s' % pattern)
        if verbose:
            print 'XXX Can not find the Ellipse profile ! %s' % pattern
            return None
    elif len(result) == 1: 
        ellProf = readProfile(result[0])
        return ellProf
    else: 
        if verbose:
            print "XXX Warning: More than 1 profiles found! Use the first one : %s" % result[0]
        ellProf = readProfile(result[0])
        return ellProf

In [1]:
def pixKpc(redshift, pix=0.168, show=True, npix=1.0):
    """
    The corresponding Kpc size of a pixel 
    """
    
    pixKpc = pix * npix * hUtil.cosmoScale(redshift)
    
    if show:
        print "# %d pixel(s) = %6.3f Kpc" % (npix, pixKpc)
        
    return pixKpc

In [9]:
def correctProf(ellProf, redshift, verbose=False, extinction=0.0, zp=27.0, 
                amag_sun=None, corCurve=False):
    
    """
    DOC
    """
    
    scale = hUtil.cosmoScale(redshift)
    distmod = hUtil.cosmoDistMod(redshift)
    
    if verbose: 
        print "### REDSHIFT : %6.4f" % redshift
        print "### SCALE : %7.4f kpc/arcsec" % scale 
        print "### DISTMOD : %7.4f mag" % distmod
    
    sma_kpc = ellProf['sma_asec'] * scale
    if not corCurve:
        abs_mag = -2.5 * np.log10(ellProf['growth_ori']) + zp - extinction - distmod
    else:
        abs_mag = -2.5 * np.log10(ellProf['growth_cor']) + zp - extinction - distmod

    if amag_sun is not None: 
        abs_sbp = (amag_sun + 21.572 - (ellProf['sbp'] - extinction))/2.5 + 6.0
    else:
        abs_sbp = ellProf['sbp'] - extinction

    return sma_kpc, abs_sbp, abs_mag

In [10]:
def photoCompare(sample, zp=27.0, prefix='hsc_xmm_log11.6', amag_sun=amag_sun_i, 
                 pix=0.168, absMag=True, aStr='extinction_i', verbose=False,
                 magStr='cModelAbsMag_i', stage='3', plot=True, color='b', 
                 radius=None, corCurve=False, idStr='objid_dr12', 
                 massStr='logMass', zStr='z', extCorrect=True, ax=None, 
                 marker='o'):
    
    """
    DOC
    """
    
    """ Read in the sample catalog """
    catFile = prefix + '_' + sample + '.fits' 
    catData = fits.open(catFile)[1].data
    
    """ Useful columns """
    gal_id   = catData[idStr]
    gal_z    = catData[zStr]
    
    if extCorrect:
        gal_alam = catData[aStr]
    else: 
        gal_alam = gal_z * 0.0
        
    gal_mag  = catData[magStr]
    gal_logm = catData[massStr]

    """ The "total" magnitude from SBP """
    mag_sbp = [] 
    mag_sdss = []
    
    for ii in range(len(catData)): 
        
        """ Get the Ellipse profile """
        ellProf = getEllipProfile(gal_id[ii], sample, stage=stage)
        
        if ellProf is not None:
            
            """ Get the radius in Kpc, luminosity profile, and growth curve for absolute magnitude """
            sma_kpc, abs_sbp, abs_cog = correctProf(ellProf, gal_z[ii], extinction=gal_alam[ii], 
                                                    zp=27.0, amag_sun=amag_sun, corCurve=corCurve)
            
            """ Distance module """
            distmod = hUtil.cosmoDistMod(gal_z[ii])
            
            if radius is None: 
                mag_use = ellProf['mag_tot'][0] - gal_alam[ii]
                if absMag:
                    mag_use = mag_use - distmod
            else: 
                rsma_use = radius ** 0.25
                rsma_common = np.arange(0, 4.5, 0.1)
                
                indexUse = np.isfinite(abs_cog)
                intrpFunc = interp1d(sma_kpc[indexUse]**0.25, abs_cog[indexUse], kind='linear')
                try:
                    mag_use = intrpFunc(rsma_use) - gal_alam[ii]
                    if not absMag:
                        mag_use = mag_use + distmod
                except Exception:
                    print "### Interpolation range is bad : %d" % gal_id[ii]
                    mag_use = ellProf['mag_tot'][0] - gal_alam[ii]
                    if absMag:
                        mag_use = mag_use - distmod
                
            mag_sbp.append(mag_use) 
            mag_sdss.append(gal_mag[ii])
            
            if verbose:
                print "### %22d -- %6.3f -- %6.3f -- %6.3f" % (gal_id[ii], gal_mag[ii], 
                                                               ellProf['mag_tot'][0], distmod)
    mag_sbp = np.asarray(mag_sbp)
    mag_sdss = np.asarray(mag_sdss)
    
    if plot:
        if ax is not None: 
            ax.scatter(mag_sbp, mag_sdss, marker=marker, color=color)
        else:
            scatter(mag_sbp, mag_sdss, marker=marker, color=color)
        
    return mag_sbp

In [33]:
def getStackProfile(sample, zp=27.0, prefix='hsc_xmm_log11.6', amag_sun=amag_sun_i, 
                    pix=0.168, absMag=True, aStr='extinction_i', verbose=False,
                    magStr='cModelAbsMag_i', stage='3', plot=True, plotAvg=True, 
                    color='b', width=0.9, singleColor='k', 
                    radius=None, corCurve=False, useMedian=True, alpha=0.1,
                    minRsma=0.3, maxRsma=3.5, extCorrect=True, idStr='objid_dr12', 
                    zStr='z', massStr='logMass', rsmaStep=0.1, ax=None, root=None, 
                    idSuffix=None, dirSuffix=None, catFile=None):
    
    """
    DOC
    """
    
    """ Read in the sample catalog """
    if catFile is None:
        catFile = prefix + '_' + sample + '.fits' 
        
    if root is not None: 
        catFile = os.path.join(root, catFile)
        
    if not os.path.isfile(catFile):
        raise Exception('XXX Can not find the input catalog : %s', catFile)
    else:
        catData = fits.open(catFile)[1].data
    
    """ Useful columns """
    gal_id   = catData[idStr]
    gal_z    = catData[zStr]
    print "### Median Redshift : %5.3f" % np.nanmedian(gal_z)
    
    if extCorrect:
        try:
            gal_alam = catData[aStr]
        except Exception: 
            print "### Can not find the column : %s" % aStr 
            gal_alam = gal_z * 0.0
    else:
        gal_alam = gal_z * 0.0
    
    if magStr is not None:
        try:
            gal_mag = catData[magStr]
            print " ## Median Magnitude : %5.2f" % np.nanmedian(gal_mag)
        except Exception:
            print "### Can not find the column : %s" % magStr 
            gal_mag = gal_z * 0.0
    else: 
        gal_mag = gal_z * 0.0 
        
    if massStr is not None:
        try:
            gal_mass = catData[massStr]
            print " ## Median Log Stellar Mass : %5.2f" % np.nanmedian(gal_mass)
        except Exception: 
            print "### Can not find the column : %s" % massStr 
            gal_mass = gal_z * 0.0            
    else: 
        gal_mass = gal_z * 0.0
    
    """ Plot """
    for ii in range(len(catData)): 
        
        if root is not None: 
            profDir = os.path.join(root, sample)
        else: 
            profDir = sample 
            
        if idSuffix is None: 
            pattern = str(gal_id[ii])
        else: 
            pattern = str(gal_id[ii]) + '*' + idSuffix 
            
        if dirSuffix is None: 
            location = profDir
        else: 
            location = profDir + '_' + dirSuffix
            
        ellProf = getEllipProfile(pattern, location, stage=stage)
    
        if ellProf is not None:
            sma_kpc, abs_sbp, abs_cog = correctProf(ellProf, gal_z[ii], 
                                                    extinction=gal_alam[ii], 
                                                    zp=27.0, verbose=False, 
                                                    amag_sun=amag_sun, 
                                                    corCurve=corCurve)
                    
            if plot:
                if ax is not None:
                    ax.plot(sma_kpc**0.25, abs_sbp, singleColor, alpha=alpha, linewidth=width)
                else: 
                    plot(sma_kpc**0.25, abs_sbp, singleColor, alpha=alpha, linewidth=width)  
                        
            intrpFunc = interp1d(sma_kpc**0.25, abs_sbp, 
                                 kind='linear')
            try:
                rsma_common = np.arange(minRsma, maxRsma, rsmaStep)
                asbp_intrp = intrpFunc(rsma_common)
                
                try: 
                    asbp_stack = np.vstack((asbp_stack, asbp_intrp))
                except NameError: 
                    asbp_stack = asbp_intrp
                        
            except Exception as errMsg:
                print errMsg
                print "### Bad interpolation range: %d " % gal_id[ii]
                print "    %5.2f -- %5.2f" % (np.nanmin(sma_kpc**0.25), 
                                              np.nanmax(sma_kpc**0.25))
    
    if useMedian:
        asbp_avg = np.nanmedian(asbp_stack, axis=0) 
    else:
        asbp_avg = np.nanmean(asbp_stack, axis=0) 

    if plotAvg:
        if ax is not None:
            print len(rsma_common)
            print len(asbp_avg)
            ax.plot(rsma_common, asbp_avg, color, linewidth=3.5)
        else:
            plot(rsma_common, asbp_avg, color, linewidth=3.5)
    
    return rsma_common, asbp_avg, asbp_stack

Playground


In [38]:
#def photoCompare(sample, zp=27.0, prefix='hsc_xmm_log11.6', amag_sun=amag_sun_i, 
#                 pix=0.168, absMag=True, aStr='extinction_i', verbose=False,
#                 magStr='cModelAbsMag_i', stage='3', plot=True, color='b', 
#                 radius=None, corCurve=False, idStr='objid_dr12', 
#                 massStr='logMass', zStr='z', extCorrect=True, ax=None, 
#                 marker='o'):

fig = plt.figure(figsize=(10, 10))
fig.subplots_adjust(left=0.1, right=0.95, bottom=0.15)
ax1 = fig.add_subplot(111)

maxR = 100.0

print "### Z1"
mag_sbp_z1 = photoCompare('z1', color='k', radius=maxR, ax=ax1)
print "### Z2"
mag_sbp_z2 = photoCompare('z2', color='r', radius=maxR, ax=ax1)
#mag_sbp_z2_b = photoCompare('z2', color='b', radius=100.0)
print "### Z3"
mag_sbp_z3 = photoCompare('z3', color='g', radius=maxR, ax=ax1)
print "### Z4"
mag_sbp_z4 = photoCompare('z4', color='b', radius=maxR, ax=ax1)

ax1.set_xlim(-21.5, -24.5)
ax1.set_ylim(-21.5, -24.5)
ax1.set_xlabel('Absolute Magnitude (HSC)',  size=16.0)
ax1.set_ylabel('Absolute Magnitude (SDSS)', size=16.0)

magRange = np.arange(-25.0, -20.0, 0.2)
ax1.plot(magRange, magRange, 'k')


### Z1
### Z2
### Z3
/usr/local/lib/python2.7/site-packages/IPython/kernel/__main__.py:17: RuntimeWarning: divide by zero encountered in log10
/usr/local/lib/python2.7/site-packages/IPython/kernel/__main__.py:17: RuntimeWarning: invalid value encountered in log10
### Z4
Out[38]:
[<matplotlib.lines.Line2D at 0x112375910>]

In [43]:
fig = plt.figure(figsize=(10, 6))
fig.subplots_adjust(left=0.1, right=0.95, bottom=0.15)
ax1 = fig.add_subplot(111)

hist(mag_sbp_z4, bins='knuth', histtype='stepfilled', alpha=0.5, 
     normed=True, color='b')
hist(mag_sbp_z3, bins='knuth', histtype='stepfilled', alpha=0.3, 
     normed=True, color='g')
hist(mag_sbp_z2, bins='knuth', histtype='step', alpha=0.8, 
     normed=True, color='r', linewidth=3.0)
hist(mag_sbp_z1, bins='knuth', histtype='step', alpha=0.8, 
     normed=True, color='k', linewidth=3.0)

ax1.set_xlabel('Absolute Magnitude', size=19.0)
ax1.set_ylabel('Fraction', size=19.0)
ax1.set_xlim(-21.5, -24.5)

for tick in ax1.xaxis.get_major_ticks():
    tick.label.set_fontsize(19) 
for tick in ax1.yaxis.get_major_ticks():
    tick.label.set_fontsize(19)


Out[43]:
(-21.5, -24.5)

In [544]:
#def photoCompare(sample, zp=27.0, prefix='hsc_xmm_log11.6', amag_sun=amag_sun_i, 
#                 pix=0.168, absMag=True, aStr='extinction_i', verbose=False,
#                 magStr='cModelAbsMag_i', stage='3', plot=True, color='b', 
#                 radius=None, corCurve=False, idStr='objid_dr12', 
#                 massStr='logMass', zStr='z', extCorrect=True, ax=None, 
#                 marker='o'):


R1 = 20.0
R2 = 50.0 
R3 = 100.0
R4 = 120.0

sample = 'z2'

print "### R1"
mag_sbp_r1 = photoCompare(sample, radius=R1, plot=None)
print "### R2"
mag_sbp_r2 = photoCompare(sample, radius=R2, plot=None)
print "### R3"
mag_sbp_r3 = photoCompare(sample, radius=R3, plot=None)
#print "### R4"
#mag_sbp_r4 = photoCompare(sample, radius=R4, plot=None)


### R1
### R2
### R3
/usr/local/lib/python2.7/site-packages/IPython/kernel/__main__.py:18: RuntimeWarning: divide by zero encountered in log10

In [555]:
fig = plt.figure(figsize=(10, 10))
fig.subplots_adjust(left=0.1, right=0.95, bottom=0.15)
ax1 = fig.add_subplot(111)

magRange = np.arange(-25.0, -20.0, 0.2)
ax1.plot(magRange, magRange, 'k', linestyle='--', linewidth=3.0, alpha=0.8)

ax1.scatter(mag_sbp_r1, mag_sbp_r2, marker='o', color='g', s=75, 
           alpha=0.7)
ax1.scatter(mag_sbp_r1, mag_sbp_r3, marker='o', color='r', s=75,
           alpha=0.5)
#ax1.scatter(mag_sbp_r1, mag_sbp_r4, marker='o', color='b')

ax1.set_xlim(-22.2, -24.3)
ax1.set_ylim(-22.2, -24.3)

ax1.set_xlabel('Absolute Magnitude (within 20 Kpc)',  size=25.0)
ax1.set_ylabel('Absolute Magnitude (within larger aperture)', size=25.0)

for tick in ax1.xaxis.get_major_ticks():
    tick.label.set_fontsize(20) 
for tick in ax1.yaxis.get_major_ticks():
    tick.label.set_fontsize(20) 
    
ax1.spines['top'].set_linewidth(3.5)
ax1.spines['right'].set_linewidth(3.5)
ax1.spines['bottom'].set_linewidth(3.5)
ax1.spines['left'].set_linewidth(3.5)

ax1.text(-23.45, -23.0, '$0.3<z<0.4$', size=32.0)
ax1.text(-23.25, -22.8, 'log $(M_{s}/M_{\odot})>11.6$', size=32.0)

ax1.text(-23.35, -22.55, 'within 50 Kpc', color='g', size=32.0)
ax1.text(-23.30, -22.35, 'within 100 Kpc', color='r', size=32.0)


Out[555]:
<matplotlib.text.Text at 0x114d52e50>

In [559]:
fig = plt.figure(figsize=(12, 7.5))
fig.subplots_adjust(left=0.1, right=0.95, bottom=0.15)
ax1 = fig.add_subplot(111)

hist(mag_sbp_r1, bins='knuth', histtype='stepfilled', alpha=0.5, 
     normed=True, color='b')
hist(mag_sbp_r2, bins='knuth', histtype='stepfilled', alpha=0.3, 
     normed=True, color='g')
hist(mag_sbp_r3, bins='knuth', histtype='stepfilled', alpha=0.6, 
     normed=True, color='r', linewidth=3.0)
#hist(mag_sbp_r4, bins='knuth', histtype='step', alpha=0.8, 
#     normed=True, color='k', linewidth=3.0)

ax1.set_xlabel('Magnitude', size=30.0)
ax1.set_ylabel('Fraction', size=30.0)
ax1.set_xlim(-22.01, -24.4)
ax1.set_ylim(0.01, 1.45)

for tick in ax1.xaxis.get_major_ticks():
    tick.label.set_fontsize(28) 
for tick in ax1.yaxis.get_major_ticks():
    tick.label.set_fontsize(28) 
    
ax1.spines['top'].set_linewidth(3.5)
ax1.spines['right'].set_linewidth(3.5)
ax1.spines['bottom'].set_linewidth(3.5)
ax1.spines['left'].set_linewidth(3.5)

ax1.text(-22.1, 1.2, '$<20$ Kpc', size=32, color='b')
ax1.text(-22.1, 1.0, '$<50$ Kpc', size=32, color='g')
ax1.text(-22.1, 0.8, '$<100$ Kpc', size=32, color='r')


Out[559]:
<matplotlib.text.Text at 0x1191abf90>

Average Profile


In [36]:
fig = plt.figure(figsize=(12, 12))
fig.subplots_adjust(left=0.1, right=0.95, bottom=0.15)
ax1 = fig.add_subplot(111)

rsma_common_z1, asbp_avg_z1, asbp_stack_z1 = getStackProfile('z1', minRsma=0.1, maxRsma=3.8,
                                                             ax=ax1, alpha=0.1)

rsma_common_z1m, asbp_avg_z1m, asbp_stack_z1m = getStackProfile('z1', prefix='hsc_xmm_mem', minRsma=0.1, 
                                                                maxRsma=3.8, ax=ax1, alpha=0.7, plotAvg=False,
                                                                width=3.0, singleColor='g')
rsma_common_z1b, asbp_avg_z1b, asbp_stack_z1b = getStackProfile('z1', prefix='hsc_xmm_bcg', minRsma=0.1, 
                                                                maxRsma=3.8, ax=ax1, alpha=0.95, plotAvg=False, 
                                                                width=3.0, singleColor='r')

print asbp_stack_z1.shape

std_stack_z1 = np.nanstd(asbp_stack_z1, axis=0)

#ax1.fill_between(rsma_common_z1, asbp_avg_z1+std_stack_z1, asbp_avg_z1-std_stack_z1,
#                 facecolor='b', alpha=0.2)

ax1.text(2.4, 8.6, '$0.15<z<0.30$', size=42)

ax1.set_xlabel('$R^{1/4}$ (Kpc)', size=32)
ax1.set_ylabel('log $(\mu/[L_{\odot} Kpc^{-2}])$', size=32)

ax1.set_xlim(0.0, 4.2)
ax1.set_ylim(3.2, 9.5)

for tick in ax1.xaxis.get_major_ticks():
    tick.label.set_fontsize(30) 
for tick in ax1.yaxis.get_major_ticks():
    tick.label.set_fontsize(30) 
    
ax1.spines['top'].set_linewidth(3.5)
ax1.spines['right'].set_linewidth(3.5)
ax1.spines['bottom'].set_linewidth(3.5)
ax1.spines['left'].set_linewidth(3.5)


### Median Redshift : 0.283
 ## Median Magnitude : -22.30
 ## Median Log Stellar Mass : 11.71
37
37
### Median Redshift : 0.290
 ## Median Magnitude : -22.62
 ## Median Log Stellar Mass : 11.75
### Median Redshift : 0.281
 ## Median Magnitude : -22.85
 ## Median Log Stellar Mass : 11.81
(68, 37)
/usr/local/lib/python2.7/site-packages/IPython/kernel/__main__.py:18: RuntimeWarning: divide by zero encountered in log10

In [30]:
fig = plt.figure(figsize=(12, 12))
fig.subplots_adjust(left=0.1, right=0.95, bottom=0.15)
ax1 = fig.add_subplot(111)

rsma_common_z2, asbp_avg_z2, asbp_stack_z2 = getStackProfile('z2', minRsma=0.1, maxRsma=3.8,
                                                             ax=ax1, alpha=0.1)
rsma_common_z2m, asbp_avg_z2m, asbp_stack_z2m = getStackProfile('z2', prefix='hsc_xmm_mem', minRsma=0.1, 
                                                                maxRsma=3.8, ax=ax1, alpha=0.5, plotAvg=False,
                                                                width=3.0, singleColor='g')
rsma_common_z2b, asbp_avg_z2b, asbp_stack_z2b = getStackProfile('z2', prefix='hsc_xmm_bcg', minRsma=0.1, 
                                                                maxRsma=3.8, ax=ax1, alpha=0.9, plotAvg=False,
                                                                width=3.0, singleColor='r')

print asbp_stack_z2.shape

std_stack_z2 = np.nanstd(asbp_stack_z2, axis=0)
#ax1.fill_between(rsma_common_z2, asbp_avg_z2+std_stack_z2, asbp_avg_z2-std_stack_z2,
#                 facecolor='b', alpha=0.2)

ax1.text(2.4, 8.6, '$0.30<z<0.40$', size=42)

ax1.set_xlabel('$R^{1/4}$ (Kpc)', size=32)
ax1.set_ylabel('log $(\mu/[L_{\odot} Kpc^{-2}])$', size=32)

ax1.set_xlim(0.0, 4.2)
ax1.set_ylim(3.2, 9.5)

for tick in ax1.xaxis.get_major_ticks():
    tick.label.set_fontsize(30) 
for tick in ax1.yaxis.get_major_ticks():
    tick.label.set_fontsize(30) 

ax1.spines['top'].set_linewidth(3.5)
ax1.spines['right'].set_linewidth(3.5)
ax1.spines['bottom'].set_linewidth(3.5)
ax1.spines['left'].set_linewidth(3.5)


### Median Redshift : 0.334
 ## Median Magnitude : -22.37
 ## Median Log Stellar Mass : 11.73
37
37
### Median Redshift : 0.333
 ## Median Magnitude : -22.35
 ## Median Log Stellar Mass : 11.72
### Median Redshift : 0.382
 ## Median Magnitude : -22.49
 ## Median Log Stellar Mass : 11.74
(89, 37)
/usr/local/lib/python2.7/site-packages/IPython/kernel/__main__.py:18: RuntimeWarning: divide by zero encountered in log10

In [34]:
fig = plt.figure(figsize=(12, 12))
fig.subplots_adjust(left=0.1, right=0.95, bottom=0.15)
ax1 = fig.add_subplot(111)

rsma_common_z3, asbp_avg_z3, asbp_stack_z3 = getStackProfile('z3', minRsma=0.1, maxRsma=3.8,
                                                             ax=ax1, alpha=0.03)
rsma_common_z3m, asbp_avg_z3m, asbp_stack_z3m = getStackProfile('z3', prefix='hsc_xmm_mem', minRsma=0.1, 
                                                                maxRsma=3.6, ax=ax1, alpha=0.5, plotAvg=False,
                                                                width=3.0, singleColor='g')
rsma_common_z3b, asbp_avg_z3b, asbp_stack_z3b = getStackProfile('z3', prefix='hsc_xmm_bcg', minRsma=0.1, 
                                                                maxRsma=3.6, ax=ax1, alpha=0.9, plotAvg=False,
                                                                width=3.0, singleColor='r')

print asbp_stack_z3.shape

std_stack_z3 = np.nanstd(asbp_stack_z3, axis=0)
#ax1.fill_between(rsma_common_z3, asbp_avg_z3+std_stack_z3, asbp_avg_z3-std_stack_z3,
#                 facecolor='b', alpha=0.2)

ax1.text(2.4, 8.6, '$0.40<z<0.50$', size=42)

ax1.set_xlabel('$R^{1/4}$ (Kpc)', size=32)
ax1.set_ylabel('log $(\mu/[L_{\odot} Kpc^{-2}])$', size=32)

ax1.set_xlim(0.0, 4.2)
ax1.set_ylim(3.2, 9.5)

for tick in ax1.xaxis.get_major_ticks():
    tick.label.set_fontsize(30) 
for tick in ax1.yaxis.get_major_ticks():
    tick.label.set_fontsize(30) 
    
ax1.spines['top'].set_linewidth(3.5)
ax1.spines['right'].set_linewidth(3.5)
ax1.spines['bottom'].set_linewidth(3.5)
ax1.spines['left'].set_linewidth(3.5)


/usr/local/lib/python2.7/site-packages/IPython/kernel/__main__.py:18: RuntimeWarning: divide by zero encountered in log10
/usr/local/lib/python2.7/site-packages/IPython/kernel/__main__.py:18: RuntimeWarning: invalid value encountered in log10
### Median Redshift : 0.458
 ## Median Magnitude : -22.50
 ## Median Log Stellar Mass : 11.76
37
37
### Median Redshift : 0.447
 ## Median Magnitude : -23.01
 ## Median Log Stellar Mass : 11.93
### Median Redshift : 0.446
 ## Median Magnitude : -23.09
 ## Median Log Stellar Mass : 11.97
(176, 37)

In [528]:
fig = plt.figure(figsize=(12, 12))
fig.subplots_adjust(left=0.1, right=0.95, bottom=0.15)
ax1 = fig.add_subplot(111)

rsma_common_z4, asbp_avg_z4, asbp_stack_z4 = getStackProfile('z4', minRsma=0.1, maxRsma=3.8,
                                                             ax=ax1, alpha=0.05)

print asbp_stack_z4.shape

std_stack_z4 = np.nanstd(asbp_stack_z4, axis=0)
ax1.fill_between(rsma_common_z4, asbp_avg_z4+std_stack_z4, asbp_avg_z4-std_stack_z4,
                 facecolor='b', alpha=0.2)

ax1.text(2.4, 8.6, '$0.50<z<0.60$', size=42)

ax1.set_xlabel('$R^{1/4}$ (Kpc)', size=32)
ax1.set_ylabel('log $(\mu/[L_{\odot} Kpc^{-2}])$', size=32)

ax1.set_xlim(0.0, 4.2)
ax1.set_ylim(3.2, 9.5)

for tick in ax1.xaxis.get_major_ticks():
    tick.label.set_fontsize(30) 
for tick in ax1.yaxis.get_major_ticks():
    tick.label.set_fontsize(30) 
    
ax1.spines['top'].set_linewidth(3.5)
ax1.spines['right'].set_linewidth(3.5)
ax1.spines['bottom'].set_linewidth(3.5)
ax1.spines['left'].set_linewidth(3.5)


/usr/local/lib/python2.7/site-packages/IPython/kernel/__main__.py:18: RuntimeWarning: divide by zero encountered in log10
/usr/local/lib/python2.7/site-packages/IPython/kernel/__main__.py:18: RuntimeWarning: invalid value encountered in log10
### Median Redshift : 0.555
 ## Median Magnitude : -22.66
 ## Median Log Stellar Mass : 11.75
(234, 37)

In [193]:
fig = plt.figure(figsize=(12, 12))
fig.subplots_adjust(left=0.1, right=0.95, bottom=0.15)
ax1 = fig.add_subplot(111)

ax1.plot(rsma_common_z1, asbp_avg_z1, 'k', linewidth=3.5)
ax1.fill_between(rsma_common_z1, asbp_avg_z1+std_stack_z1, asbp_avg_z1-std_stack_z1,
                 facecolor='k', alpha=0.08)

ax1.plot(rsma_common_z2, asbp_avg_z2, 'r', linewidth=3.5)
ax1.fill_between(rsma_common_z2, asbp_avg_z2+std_stack_z2, asbp_avg_z2-std_stack_z2,
                 facecolor='r', alpha=0.08)

ax1.plot(rsma_common_z3, asbp_avg_z3, 'g', linewidth=3.5)
ax1.fill_between(rsma_common_z3, asbp_avg_z3+std_stack_z3, asbp_avg_z3-std_stack_z3,
                 facecolor='g', alpha=0.06)

ax1.plot(rsma_common_z4, asbp_avg_z4, 'b', linewidth=3.5)
ax1.fill_between(rsma_common_z4, asbp_avg_z4+std_stack_z4, asbp_avg_z4-std_stack_z4,
                 facecolor='b', alpha=0.05)

ax1.set_xlabel('$R^{1/4}$ (Kpc)', size=24)
ax1.set_ylabel('log $(\mu/[L_{\odot} Kpc^{-2}])$', size=24)

ax1.set_xlim(0.0, 4.2)
ax1.set_ylim(3.2, 9.5)

for tick in ax1.xaxis.get_major_ticks():
    tick.label.set_fontsize(22) 
for tick in ax1.yaxis.get_major_ticks():
    tick.label.set_fontsize(22)



In [537]:
fig = plt.figure(figsize=(12, 12))
fig.subplots_adjust(left=0.1, right=0.95, bottom=0.15)
ax1 = fig.add_subplot(111)

asbp_avg_z1norm = normProfile(rsma_common_z1, asbp_avg_z1, 2.1, 2.2)
asbp_avg_z2norm = normProfile(rsma_common_z2, asbp_avg_z2, 2.1, 2.2) 
asbp_avg_z3norm = normProfile(rsma_common_z3, asbp_avg_z3, 2.1, 2.2) 
asbp_avg_z4norm = normProfile(rsma_common_z4, asbp_avg_z4, 2.1, 2.2) 

ax1.plot(rsma_common_z1, asbp_avg_z1norm, 'k', linewidth=3.5)
ax1.fill_between(rsma_common_z1, asbp_avg_z1norm+std_stack_z1, asbp_avg_z1norm-std_stack_z1,
                 facecolor='k', alpha=0.08)

ax1.plot(rsma_common_z2, asbp_avg_z2norm, 'r', linewidth=3.5)
ax1.fill_between(rsma_common_z2, asbp_avg_z2norm+std_stack_z2, asbp_avg_z2norm-std_stack_z2,
                 facecolor='r', alpha=0.08)

ax1.plot(rsma_common_z3, asbp_avg_z3norm, 'g', linewidth=3.5)
ax1.fill_between(rsma_common_z3, asbp_avg_z3norm+std_stack_z3, asbp_avg_z3norm-std_stack_z3,
                 facecolor='g', alpha=0.06)

ax1.plot(rsma_common_z4, asbp_avg_z4norm, 'b', linewidth=3.5)
ax1.fill_between(rsma_common_z4, asbp_avg_z4norm+std_stack_z4, asbp_avg_z4norm-std_stack_z4,
                 facecolor='b', alpha=0.05)

ax1.set_xlabel('$R^{1/4}$ (Kpc)', size=34)
ax1.set_ylabel('log $(\mu/[L_{\odot} Kpc^{-2}])$', size=34)

ax1.set_xlim(0.0, 4.2)
ax1.set_ylim(-3.9, 2.9)

for tick in ax1.xaxis.get_major_ticks():
    tick.label.set_fontsize(34) 
for tick in ax1.yaxis.get_major_ticks():
    tick.label.set_fontsize(34) 
    
ax1.spines['top'].set_linewidth(3.5)
ax1.spines['right'].set_linewidth(3.5)
ax1.spines['bottom'].set_linewidth(3.5)
ax1.spines['left'].set_linewidth(3.5)

ax1.text(0.3, -1.2, '$0.15<z<0.30$', size=42, color='k')
ax1.text(0.3, -1.7, '$0.30<z<0.40$', size=42, color='r')
ax1.text(0.3, -2.2, '$0.40<z<0.50$', size=42, color='g')
ax1.text(0.3, -2.7, '$0.50<z<0.60$', size=42, color='b')

ax1.text(0.3, -3.3, 'Normalized at 20 Kpc', size=32, color='k')

ax1.text(2.15, 2.0, 'log $(M_{s}/M_{\odot}) > 11.6$)', size=35, color='k')


Out[537]:
<matplotlib.text.Text at 0x1151e36d0>

In [65]:
for ii in range(len(catData)): 
    
    ellProf = getEllipProfile(gal_id[ii], loc, stage='3')
    
    if ellProf is not None:
        sma_kpc, asbp_i, amag_i = correctProf(ellProf, gal_z[ii], extinction=gal_ai[ii], zp=27.0, 
                                              verbose=False, amag_sun=amag_sun_i)
    
        plot(sma_kpc**0.25, amag_i, color='k', alpha=0.3)


/usr/local/lib/python2.7/site-packages/IPython/kernel/__main__.py:17: RuntimeWarning: divide by zero encountered in log10

XMM Good BCGs


In [561]:
#def getStackProfile(sample, zp=27.0, prefix='hsc_xmm_log11.6', amag_sun=amag_sun_i, 
#                    pix=0.168, absMag=True, aStr='extinction_i', verbose=False,
#                    magStr='cModelAbsMag_i', stage='3', plot=True, color='b', 
#                    radius=None, corCurve=False, useMedian=True, 
#                    minRsma=0.3, maxRsma=3.5, extCorrect=True, idStr='objid_dr12', 
#                    zStr='z', massStr='logMass', rsmaStep=0.1, ax=None, root=None, 
#                    idSuffix=None, dirSuffix=None, catFile=None)

clusterRoot = '/Users/songhuang/Downloads/hsc_cutout/xmm_cluster'
clusterCat = 'xmm_cluster_good.fits'
bandUse = 'r'

fig = plt.figure(figsize=(12, 12))
fig.subplots_adjust(left=0.1, right=0.95, bottom=0.15)
ax1 = fig.add_subplot(111)

rsma_common_bcg_r, asbp_avg_bcg_r, asbp_stack_bcg_r = getStackProfile('good', root=clusterRoot, catFile=clusterCat,
                                                                      dirSuffix=bandUse, minRsma=0.1, maxRsma=4.0,
                                                                      ax=ax1, idStr='ID', zStr='Z_LAMBDA', 
                                                                      magStr='IMAG')

print asbp_stack_bcg_r.shape

ax1.set_xlabel('$R^{1/4}$ (Kpc)', size=24)
ax1.set_ylabel('log $(\mu/[L_{\odot} Kpc^{-2}])$', size=24)

ax1.set_xlim(0.0, 4.2)
ax1.set_ylim(3.2, 9.5)

for tick in ax1.xaxis.get_major_ticks():
    tick.label.set_fontsize(22) 
for tick in ax1.yaxis.get_major_ticks():
    tick.label.set_fontsize(22)


### Median Redshift : 0.335
### Can not find the column : extinction_i
 ## Median Magnitude : 17.56
### Can not find the column : logMass
(40, 39)
/usr/local/lib/python2.7/site-packages/IPython/kernel/__main__.py:18: RuntimeWarning: divide by zero encountered in log10

In [196]:
#def getStackProfile(sample, zp=27.0, prefix='hsc_xmm_log11.6', amag_sun=amag_sun_i, 
#                    pix=0.168, absMag=True, aStr='extinction_i', verbose=False,
#                    magStr='cModelAbsMag_i', stage='3', plot=True, color='b', 
#                    radius=None, corCurve=False, useMedian=True, 
#                    minRsma=0.3, maxRsma=3.5, extCorrect=True, idStr='objid_dr12', 
#                    zStr='z', massStr='logMass', rsmaStep=0.1, ax=None, root=None, 
#                    idSuffix=None, dirSuffix=None, catFile=None)

clusterRoot = '/Users/songhuang/Downloads/hsc_cutout/xmm_cluster'
clusterCat = 'xmm_cluster_good.fits'
bandUse = 'z'


fig = plt.figure(figsize=(12, 12))
fig.subplots_adjust(left=0.1, right=0.95, bottom=0.15)
ax1 = fig.add_subplot(111)

rsma_common_bcg_z, asbp_avg_bcg_z, asbp_stack_bcg_z = getStackProfile('good', root=clusterRoot, catFile=clusterCat,
                                                                      dirSuffix=bandUse, minRsma=0.1, maxRsma=4.0,
                                                                      ax=ax1, idStr='ID', zStr='Z_LAMBDA', 
                                                                      magStr='IMAG')

ax1.set_xlabel('$R^{1/4}$ (Kpc)', size=24)
ax1.set_ylabel('log $(\mu/[L_{\odot} Kpc^{-2}])$', size=24)

ax1.set_xlim(0.0, 4.2)
ax1.set_ylim(3.2, 9.5)

for tick in ax1.xaxis.get_major_ticks():
    tick.label.set_fontsize(22) 
for tick in ax1.yaxis.get_major_ticks():
    tick.label.set_fontsize(22)


### Median Redshift : 0.335
### Can not find the column : extinction_i
 ## Median Magnitude : 17.56
### Can not find the column : logMass
/usr/local/lib/python2.7/site-packages/IPython/kernel/__main__.py:18: RuntimeWarning: divide by zero encountered in log10

In [590]:
fig = plt.figure(figsize=(12, 12))
fig.subplots_adjust(left=0.1, right=0.95, bottom=0.15)
ax1 = fig.add_subplot(111)

ax1.plot(rsma_common_z1, asbp_avg_z1, 'k', linewidth=4.0, alpha=0.85)
ax1.fill_between(rsma_common_z1, asbp_avg_z1+std_stack_z1, asbp_avg_z1-std_stack_z1,
                 facecolor='k', alpha=0.1)

ax1.plot(rsma_common_bcg_z, asbp_avg_bcg_z, color='b', linewidth=4.5)

ax1.set_xlabel('$R^{1/4}$ (Kpc)', size=35)
ax1.set_ylabel('log $(\mu/[L_{\odot} Kpc^{-2}])$', size=35)

ax1.set_xlim(0.0, 4.2)
ax1.set_ylim(3.2, 9.5)

for tick in ax1.xaxis.get_major_ticks():
    tick.label.set_fontsize(30) 
for tick in ax1.yaxis.get_major_ticks():
    tick.label.set_fontsize(30) 
    
ax1.spines['top'].set_linewidth(3.5)
ax1.spines['right'].set_linewidth(3.5)
ax1.spines['bottom'].set_linewidth(3.5)
ax1.spines['left'].set_linewidth(3.5)

ax1.text(1.90, 8.6, '40 redMapper BCGs', size=32, color='b')
ax1.text(2.40, 8.2, '$0.10<z<0.40$', size=30, color='b')
ax1.text(2.26, 7.8, '${\t{No\ Mass\ Limit}}$', size=30, color='b')

ax1.text(0.30, 5.7, '68 Massive Galaxies', size=32, color='k')
ax1.text(0.65, 5.3, '$0.15<z<0.30$', size=30, color='k')
ax1.text(0.45, 4.9, 'log $(M_{s}/M_{\odot})>11.6$', size=30, color='k')

ax1.text(0.46, 3.8, 'WIDE/XMM-LSS', size=40, color='k')


Out[590]:
<matplotlib.text.Text at 0x12160a350>

In [ ]:
fig = plt.figure(figsize=(12, 12))
fig.subplots_adjust(left=0.1, right=0.95, bottom=0.15)
ax1 = fig.add_subplot(111)

asbp_avg_z1norm = normProfile(rsma_common_z1, asbp_avg_z1, 2.2, 2.3)
asbp_avg_z2norm = normProfile(rsma_common_z2, asbp_avg_z2, 2.2, 2.3) 
asbp_avg_z3norm = normProfile(rsma_common_z3, asbp_avg_z3, 2.2, 2.3) 
asbp_avg_z4norm = normProfile(rsma_common_z4, asbp_avg_z4, 2.2, 2.3) 
asbp_avg_bcgNorm_z = normProfile(rsma_common_bcg_z, asbp_avg_bcg_z, 2.2, 2.3)


ax1.plot(rsma_common_z1, asbp_avg_z1norm, 'k', linewidth=3.5)
ax1.fill_between(rsma_common_z1, asbp_avg_z1norm+std_stack_z1, asbp_avg_z1norm-std_stack_z1,
                 facecolor='k', alpha=0.05)

ax1.plot(rsma_common_z2, asbp_avg_z2norm, 'r', linewidth=3.5)
ax1.fill_between(rsma_common_z2, asbp_avg_z2norm+std_stack_z2, asbp_avg_z2norm-std_stack_z2,
                 facecolor='r', alpha=0.05)

ax1.plot(rsma_common_bcg_z, asbp_avg_bcgNorm_z, color='b', linewidth=4.0)

ax1.set_xlabel('$R^{1/4}$ (Kpc)', size=24)
ax1.set_ylabel('log $(\mu/[L_{\odot} Kpc^{-2}])$', size=24)

ax1.set_xlim(0.0, 4.2)
#ax1.set_ylim(3.2, 9.5)

for tick in ax1.xaxis.get_major_ticks():
    tick.label.set_fontsize(22) 
for tick in ax1.yaxis.get_major_ticks():
    tick.label.set_fontsize(22)

COSMOS Massive


In [175]:
cosmosRoot = '/Users/songhuang/Downloads/hsc_cutout/cos_massive'
cosmosCat = 'cos_massive_sample.fits'

fig = plt.figure(figsize=(12, 12))
fig.subplots_adjust(left=0.1, right=0.95, bottom=0.15)
ax1 = fig.add_subplot(111)

rsma_common_cos, asbp_avg_cos, asbp_stack_cos = getStackProfile('prof', root=cosmosRoot, catFile=cosmosCat,
                                                                 minRsma=0.1, maxRsma=3.8, ax=ax1, 
                                                                 idStr='CATAID', zStr='z', 
                                                                 magStr='F814W_08', massStr='logm')

ax1.set_xlabel('$R^{1/4}$ (Kpc)', size=24)
ax1.set_ylabel('log $(\mu/[L_{\odot} Kpc^{-2}])$', size=24)

ax1.set_xlim(0.0, 4.2)
ax1.set_ylim(3.2, 9.5)

for tick in ax1.xaxis.get_major_ticks():
    tick.label.set_fontsize(22) 
for tick in ax1.yaxis.get_major_ticks():
    tick.label.set_fontsize(22)


/usr/local/lib/python2.7/site-packages/IPython/kernel/__main__.py:18: RuntimeWarning: divide by zero encountered in log10
/usr/local/lib/python2.7/site-packages/IPython/kernel/__main__.py:18: RuntimeWarning: invalid value encountered in log10
### Median Redshift : 0.529
### Can not find the column : extinction_i
 ## Median Magnitude : 20.98
 ## Median Log Stellar Mass : 10.70
/usr/local/lib/python2.7/site-packages/scipy/interpolate/interpolate.py:469: RuntimeWarning: invalid value encountered in add
  y_new = slope*(x_new - x_lo)[:, None] + y_lo

In [180]:
cosmosRoot = '/Users/songhuang/Downloads/hsc_cutout/cos_massive'
cosmosCat = 'cos_massive_csample1.fits'

fig = plt.figure(figsize=(12, 12))
fig.subplots_adjust(left=0.1, right=0.95, bottom=0.15)
ax1 = fig.add_subplot(111)

rsma_common_compact, asbp_avg_compact, asbp_stack_cospact = getStackProfile('prof', root=cosmosRoot, catFile=cosmosCat,
                                                                 minRsma=0.1, maxRsma=3.8, ax=ax1, 
                                                                 idStr='CATAID', zStr='z', 
                                                                 magStr='F814W_08', massStr='logm')

ax1.set_xlabel('$R^{1/4}$ (Kpc)', size=24)
ax1.set_ylabel('log $(\mu/[L_{\odot} Kpc^{-2}])$', size=24)

ax1.set_xlim(0.0, 4.2)
ax1.set_ylim(3.2, 9.5)

for tick in ax1.xaxis.get_major_ticks():
    tick.label.set_fontsize(22) 
for tick in ax1.yaxis.get_major_ticks():
    tick.label.set_fontsize(22)


### Median Redshift : 0.701
### Can not find the column : extinction_i
 ## Median Magnitude : 20.85
 ## Median Log Stellar Mass : 11.50
/usr/local/lib/python2.7/site-packages/IPython/kernel/__main__.py:18: RuntimeWarning: divide by zero encountered in log10

In [591]:
fig = plt.figure(figsize=(12, 12))
fig.subplots_adjust(left=0.1, right=0.95, bottom=0.15)
ax1 = fig.add_subplot(111)

cosmosRoot = '/Users/songhuang/Downloads/hsc_cutout/cos_massive'
cosmosCat = 'cos_massive_sample3.fits'

rsma_common_cos1, asbp_avg_cos1, asbp_stack_cos1 = getStackProfile('prof', root=cosmosRoot, catFile=cosmosCat,
                                                                 minRsma=0.1, maxRsma=3.8, ax=ax1, 
                                                                 idStr='CATAID', zStr='z', singleColor='b',
                                                                 magStr='F814W_08', massStr='logm')

cosmosCat = 'cos_massive_csample1.fits'

rsma_common_compact, asbp_avg_compact, asbp_stack_cospact = getStackProfile('prof', root=cosmosRoot, catFile=cosmosCat,
                                                                 minRsma=0.1, maxRsma=3.8, ax=ax1, color='r',
                                                                 idStr='CATAID', zStr='z', singleColor='r',
                                                                 magStr='F814W_08', massStr='logm')

ax1.set_xlabel('$R^{1/4}$ (Kpc)', size=35)
ax1.set_ylabel('log $(\mu/[L_{\odot} Kpc^{-2}])$', size=35)

ax1.set_xlim(0.0, 4.2)
ax1.set_ylim(3.1, 8.5)

for tick in ax1.xaxis.get_major_ticks():
    tick.label.set_fontsize(30) 
for tick in ax1.yaxis.get_major_ticks():
    tick.label.set_fontsize(30) 
    
ax1.spines['top'].set_linewidth(3.5)
ax1.spines['right'].set_linewidth(3.5)
ax1.spines['bottom'].set_linewidth(3.5)
ax1.spines['left'].set_linewidth(3.5)

ax1.text(2.20, 7.6, '30 "Normal" ETGs', size=32, color='b')
ax1.text(2.50, 7.2, '$0.60<z<0.80$', size=30, color='b')
ax1.text(2.36, 6.8, 'log $(M_{s}/M_{\odot})>11.3$', size=30, color='b')

ax1.text(0.30, 5.4, '12 "Compact" ETGs', size=32, color='r')
ax1.text(0.65, 5.0, '$0.60<z<0.80$', size=30, color='r')
ax1.text(0.45, 4.6, 'log $(M_{s}/M_{\odot})>11.3$', size=30, color='r')

ax1.text(0.32, 3.6, 'UDeep/COSMOS', size=40, color='k')


#ax1.plot(rsma_common_compact, asbp_avg_compact, color='r', linewidth=3.5)


### Median Redshift : 0.692
### Can not find the column : extinction_i
 ## Median Magnitude : 20.78
 ## Median Log Stellar Mass : 11.36
### Median Redshift : 0.701
### Can not find the column : extinction_i
 ## Median Magnitude : 20.85
 ## Median Log Stellar Mass : 11.50
/usr/local/lib/python2.7/site-packages/IPython/kernel/__main__.py:18: RuntimeWarning: divide by zero encountered in log10
Out[591]:
<matplotlib.text.Text at 0x121ef4910>

In [184]:
fig = plt.figure(figsize=(12, 12))
fig.subplots_adjust(left=0.1, right=0.95, bottom=0.15)
ax1 = fig.add_subplot(111)

asbp_avg_cos_norm_1 = normProfile(rsma_common_cos1, asbp_avg_cos1, 2.3, 2.5)
asbp_avg_cos_norm_2 = normProfile(rsma_common_cos2, asbp_avg_cos2, 2.3, 2.5) 
asbp_avg_cos_norm_c = normProfile(rsma_common_compact, asbp_avg_compact, 2.3, 2.5) 

ax1.plot(rsma_common_cos1, asbp_avg_cos_norm_1, 'k', linewidth=3.5)

ax1.plot(rsma_common_cos2, asbp_avg_cos_norm_2, 'b', linewidth=3.5)

ax1.plot(rsma_common_compact, asbp_avg_cos_norm_c, 'r', linewidth=3.5)

ax1.set_xlabel('$R^{1/4}$ (Kpc)', size=24)
ax1.set_ylabel('log $(\mu/[L_{\odot} Kpc^{-2}])$', size=24)

ax1.set_xlim(0.0, 4.2)
#ax1.set_ylim(3.2, 9.5)

for tick in ax1.xaxis.get_major_ticks():
    tick.label.set_fontsize(22) 
for tick in ax1.yaxis.get_major_ticks():
    tick.label.set_fontsize(22)


Test of .pkl file


In [208]:
loc = '/Users/songhuang/Downloads/hsc_cutout/cos_massive/galfit'
pklFile = 'cosmos_6006354_HSC-I_full_1ser.pkl'

obj1Ser = loadGalfitOutput(os.path.join(loc, pklFile))

In [211]:
print obj1Ser.reduced_chisq


1.048929

In [212]:
obj1Ser.component_1.re * obj1Ser.component_1.ar


Out[212]:
1.7477975300000002

In [274]:
obj1Ser.component_1.n


Out[274]:
6.9677

In [216]:
import coaddCutoutGalfitSimple as gSimple 

aic, bic, hq = gSimple.galfitAIC(obj1Ser)
print aic, bic, hq


132882.56314 132980.054414 132887.199341

In [228]:
cosmosDir = '/Users/songhuang/Downloads/hsc_cutout/cos_massive'
cosmosPklDir = os.path.join(cosmosDir, 'galfit')

cosmosCat = os.path.join(cosmosDir, 'cos_massive_sample.fits')

cosmosData = fits.open(cosmosCat)[1].data

In [301]:
pix = 0.168
chisqThr = 4.0

galZ   = []
galMs  = []
galRe  = []
galEll = []
galMag = []
galNs  = []
gal814 = []

galReHSC  = []
galEllHSC = []
galMagHSC = []
galNsHSC = []

chi1Ser = []
aic1Ser = []
bic1Ser = []

for galaxy in cosmosData: 
    
    galId = galaxy['CATAID']
    pattern1Ser = '*' + str(galId) + '*1ser.pkl'
    
    pklFound = findProfile(pattern1Ser, cosmosPklDir)
    
    if len(pklFound) == 1:
        
        pklFile = pklFound[0]
        obj1Ser = loadGalfitOutput(pklFile)
        
        nser = obj1Ser.component_1.n
        chisq = obj1Ser.reduced_chisq
        
        if (chisq <= chisqThr) and (nser < 8.0):
    
            scale = galaxy['scale']
            distmod = hUtil.cosmoDistMod(galaxy['z'])
            
            galZ.append(galaxy['z'])
            galMs.append(galaxy['logm'])
            galRe.append(galaxy['re'])
            galEll.append(galaxy['ell'])
            galMag.append(galaxy['Imag3'] - distmod)
            gal814.append(-2.5 * np.log10(galaxy['FLUX_GIM2D']) + 27.0 - distmod)
            galNs.append(galaxy['SERSIC_N_GIM2D'])
        
            aic, bic, hq = gSimple.galfitAIC(obj1Ser)
        
            chi1Ser.append(chisq)
            aic1Ser.append(aic)
            bic1Ser.append(bic)
        
            galReHSC.append(obj1Ser.component_1.re * 0.168 * scale)
            galEllHSC.append(1.0 - obj1Ser.component_1.ar)
            galMagHSC.append(obj1Ser.component_1.mag - 0.03 - distmod)
            galNsHSC.append(obj1Ser.component_1.n)

            
print "### Number of models : %d" % len(galRe)
        
galZ   = np.asarray(galZ)
galMs  = np.asarray(galMs)
galRe  = np.asarray(galRe)
galEll = np.asarray(galEll)

galReHSC  = np.asarray(galReHSC)
galEllHSC = np.asarray(galEllHSC)
galNsHSC = np.asarray(galNsHSC)

chi1Ser = np.asarray(chi1Ser)
aic1Ser = np.asarray(aic1Ser)
bic1Ser = np.asarray(bic1Ser)


### Number of models : 1030

In [594]:
fig = plt.figure(figsize=(13, 13))
fig.subplots_adjust(left=0.1, right=0.95, bottom=0.15)
ax1 = fig.add_subplot(111)

ax1.plot([0.0,0.5,1.1], [0.0,0.5,1.1], 'k--', alpha=0.6,
        linewidth=3.5)

sca = ax1.scatter(galEll, galEllHSC, alpha=0.5, c=galZ, s=(galMs-9.8)*80.0)

ax1.set_xlabel('Ellipticity (HST/ACS F814W)', size=32)
ax1.set_ylabel('Ellipticity (HSC/$i$-band)', size=32)

ax1.set_xlim(0.01, 0.899)
ax1.set_ylim(0.01, 0.899)

cbar = fig.colorbar(sca)
cbar.set_label('Redshift', size=20)

for tick in ax1.xaxis.get_major_ticks():
    tick.label.set_fontsize(26) 
for tick in ax1.yaxis.get_major_ticks():
    tick.label.set_fontsize(26) 
    
ax1.spines['top'].set_linewidth(3.5)
ax1.spines['right'].set_linewidth(3.5)
ax1.spines['bottom'].set_linewidth(3.5)
ax1.spines['left'].set_linewidth(3.5)



In [597]:
fig = plt.figure(figsize=(13, 13))
fig.subplots_adjust(left=0.1, right=0.95, bottom=0.15)
ax1 = fig.add_subplot(111)

ax1.plot([-3.0,105.1], [-3.0, 105.1], 'k--', alpha=0.6, linewidth=3.5)

sca = ax1.scatter(np.log10(galRe), np.log10(galReHSC), alpha=0.5, 
                  c=galZ, s=(galMs-9.8)*80.0)

ax1.set_xlabel('log ($R_e$/Kpc) (HST/ACS F814W)', size=32)
ax1.set_ylabel('log ($R_e$/Kpc) (HSC/$i$-band)', size=32)

ax1.set_xlim(-0.49, 1.89)
ax1.set_ylim(-0.49, 1.89)

cbar = fig.colorbar(sca)
cbar.set_label('Redshift', size=20)

for tick in ax1.xaxis.get_major_ticks():
    tick.label.set_fontsize(26) 
for tick in ax1.yaxis.get_major_ticks():
    tick.label.set_fontsize(26) 
    
ax1.spines['top'].set_linewidth(3.5)
ax1.spines['right'].set_linewidth(3.5)
ax1.spines['bottom'].set_linewidth(3.5)
ax1.spines['left'].set_linewidth(3.5)



In [596]:
fig = plt.figure(figsize=(13, 13))
fig.subplots_adjust(left=0.1, right=0.95, bottom=0.15)
ax1 = fig.add_subplot(111)

ax1.plot([-3.0,105.1], [-3.0, 105.1], 'k--', alpha=0.6, linewidth=3.5)

sca = ax1.scatter(np.log10(galRe), np.log10(galReHSC), alpha=0.5, 
                  c=galNsHSC, s=(galMs-9.8)*80.0)

ax1.set_xlabel('log ($R_e$/Kpc) (HST/ACS F814W)', size=32)
ax1.set_ylabel('log ($R_e$/Kpc) (HSC/$i$-band)', size=32)

ax1.set_xlim(-0.49, 1.89)
ax1.set_ylim(-0.49, 1.89)

cbar = fig.colorbar(sca)
cbar.set_label('Sersic Index', size=20)

for tick in ax1.xaxis.get_major_ticks():
    tick.label.set_fontsize(26) 
for tick in ax1.yaxis.get_major_ticks():
    tick.label.set_fontsize(26) 
    
ax1.spines['top'].set_linewidth(3.5)
ax1.spines['right'].set_linewidth(3.5)
ax1.spines['bottom'].set_linewidth(3.5)
ax1.spines['left'].set_linewidth(3.5)



In [302]:
fig = plt.figure(figsize=(13.5, 12))
fig.subplots_adjust(left=0.1, right=0.95, bottom=0.15)
ax1 = fig.add_subplot(111)

ax1.plot([-25.0,-10.1], [-25.0, -10.1], 'k--', alpha=0.6, 
         linewidth=3.5)

sca = ax1.scatter(galMag, galMagHSC, c=galZ, alpha=0.5, 
                  s=(galMs-9.8)*80.0)

ax1.set_xlabel('Magnitude (Suprime-Cam i-band)', size=24)
ax1.set_ylabel('Magnitude (HSC/$i$-band)', size=24)

ax1.set_xlim(-19.0, -25.5)
ax1.set_ylim(-19.0, -25.5)

cbar = fig.colorbar(sca)
cbar.set_label('Redshift', size=20)

for tick in ax1.xaxis.get_major_ticks():
    tick.label.set_fontsize(24) 
for tick in ax1.yaxis.get_major_ticks():
    tick.label.set_fontsize(24)



In [303]:
fig = plt.figure(figsize=(13.5, 12))
fig.subplots_adjust(left=0.1, right=0.95, bottom=0.15)
ax1 = fig.add_subplot(111)

ax1.plot([-25.0,-10.1], [-25.0, -10.1], 'k--', alpha=0.6, 
         linewidth=3.5)

sca = ax1.scatter(galMag, galMagHSC, c=galNsHSC, alpha=0.5, 
                  s=(galMs-9.8)*80.0)

ax1.set_xlabel('Magnitude (Suprime-Cam i-band)', size=24)
ax1.set_ylabel('Magnitude (HSC/$i$-band)', size=24)

ax1.set_xlim(-19.0, -25.5)
ax1.set_ylim(-19.0, -25.5)

cbar = fig.colorbar(sca)
cbar.set_label('Sersic Index', size=20)

for tick in ax1.xaxis.get_major_ticks():
    tick.label.set_fontsize(24) 
for tick in ax1.yaxis.get_major_ticks():
    tick.label.set_fontsize(24)



In [595]:
fig = plt.figure(figsize=(13, 13))
fig.subplots_adjust(left=0.1, right=0.95, bottom=0.15)
ax1 = fig.add_subplot(111)

ax1.plot([-25.9,-10.1], [-25.9, -10.1], 'k--', alpha=0.6, 
         linewidth=3.5)

sca = ax1.scatter(np.asarray(gal814)+7.2, galMagHSC, c=galNsHSC, alpha=0.5, 
                  s=(galMs-9.8)*80.0)

ax1.set_xlabel('Magnitude (HST/ACS F814W)', size=32)
ax1.set_ylabel('Magnitude (HSC/$i$-band)', size=32)

ax1.set_xlim(-19.0, -25.5)
ax1.set_ylim(-19.0, -25.5)

cbar = fig.colorbar(sca)
cbar.set_label('Sersic Index', size=20)

for tick in ax1.xaxis.get_major_ticks():
    tick.label.set_fontsize(26) 
for tick in ax1.yaxis.get_major_ticks():
    tick.label.set_fontsize(26) 
    
ax1.spines['top'].set_linewidth(3.5)
ax1.spines['right'].set_linewidth(3.5)
ax1.spines['bottom'].set_linewidth(3.5)
ax1.spines['left'].set_linewidth(3.5)



In [322]:
fig = plt.figure(figsize=(13.5, 12))
fig.subplots_adjust(left=0.1, right=0.95, bottom=0.15)
ax1 = fig.add_subplot(111)

ax1.plot([0.0, 8.5], [0.0, 8.5], 'k--', alpha=0.6, 
         linewidth=3.5)

sca = ax1.scatter(galNs, galNsHSC, c=galZ, alpha=0.5, 
                  s=(galMs-9.8)*80.0)

ax1.set_xlabel('Sersic Index (GIM2D - HST/F814W)', size=24)
ax1.set_ylabel('Sersic Index (GALFIT - HSC/$i$-band)', size=24)

ax1.set_xlim(0.1, 8.4)
ax1.set_ylim(0.1, 8.4)

cbar = fig.colorbar(sca)
cbar.set_label('Redshift', size=20)

for tick in ax1.xaxis.get_major_ticks():
    tick.label.set_fontsize(24) 
for tick in ax1.yaxis.get_major_ticks():
    tick.label.set_fontsize(24)


XMM_ETG & XMM_Massive


In [412]:
xmmEtgDir = '/Users/songhuang/Downloads/hsc_cutout/xmm_etg/'

xmmEtg2PklDir = os.path.join(xmmEtgDir, 'xmm_ell_2_galfit')
xmmEtg3PklDir = os.path.join(xmmEtgDir, 'xmm_ell_3_galfit')

xmmEtg2Cat = os.path.join(xmmEtgDir, 'hsc_sdss_xmm_nearby_ell_z0.05_0.13.fits')
xmmEtg3Cat = os.path.join(xmmEtgDir, 'hsc_sdss_xmm_nearby_ell_z0.16_0.24.fits')

xmmEtg2Data = fits.open(xmmEtg2Cat)[1].data
xmmEtg3Data = fits.open(xmmEtg3Cat)[1].data

In [413]:
xmassDir = '/Users/songhuang/Downloads/hsc_cutout/xmm_massive/'

xmassZ1PklDir = os.path.join(xmassDir, 'galfit/z1_i')
xmassZ2PklDir = os.path.join(xmassDir, 'galfit/z2_i')
xmassZ3PklDir = os.path.join(xmassDir, 'galfit/z3_i')
xmassZ4PklDir = os.path.join(xmassDir, 'galfit/z4_i')

xmassZ1Cat = os.path.join(xmassDir, 'hsc_xmm_log11.6_z1.fits')
xmassZ2Cat = os.path.join(xmassDir, 'hsc_xmm_log11.6_z2.fits')
xmassZ3Cat = os.path.join(xmassDir, 'hsc_xmm_log11.6_z3.fits')
xmassZ4Cat = os.path.join(xmassDir, 'hsc_xmm_log11.6_z4.fits')

xmassZ1Data = fits.open(xmassZ1Cat)[1].data
xmassZ2Data = fits.open(xmassZ2Cat)[1].data
xmassZ3Data = fits.open(xmassZ3Cat)[1].data
xmassZ4Data = fits.open(xmassZ4Cat)[1].data

In [414]:
def get1SerSize(cat, pklDir, zStr='z', idStr='objid_dr12', pix=0.168, 
                chisqThr=4.0, nSerThr=8.0, extinctionStr='extinction_i'):
    
    galUse = np.empty(len(cat), dtype=bool)
    galUse[:] = False
    
    galRe1Ser = []
    galAr1Ser = []
    galMag1Ser = []
    galNs1Ser = []

    chi1Ser = []
    aic1Ser = []
    bic1Ser = []

    for ii, galaxy in enumerate(cat): 
                
        galId = galaxy[idStr]
        pattern1Ser = '*' + str(galId) + '*1ser.pkl'
        pattern2Ser = '*' + str(galId) + '*2ser.pkl'
        
        pkl1SerFound = findProfile(pattern1Ser, pklDir)
        pkl1SerFound = findProfile(pattern1Ser, pklDir)

        if len(pkl1SerFound) == 1:
            
            pkl1SerFile = pkl1SerFound[0]
            obj1Ser = loadGalfitOutput(pkl1SerFile)
            
            if type(obj1Ser) is not numpy.core.records.recarray:
            
                nser1Ser  = obj1Ser.component_1.n
                chisq1Ser = obj1Ser.reduced_chisq
            
                try: 
                    ai = galaxy[extinctionStr]
                except Exception:
                    ai = 0.05
            
                if (chisq1Ser <= chisqThr) and (nser1Ser < nSerThr):
                
                    scale = pixKpc(galaxy[zStr], show=False)
                    distmod = hUtil.cosmoDistMod(galaxy[zStr])
                
                    aic1, bic1, hq1 = gSimple.galfitAIC(obj1Ser)
                
                    chi1Ser.append(chisq1Ser)
                    aic1Ser.append(aic1)
                    bic1Ser.append(bic1)
        
                    galRe1Ser.append(obj1Ser.component_1.re * scale)
                    galAr1Ser.append(obj1Ser.component_1.ar)
                    galMag1Ser.append(obj1Ser.component_1.mag - ai - distmod)
                    galNs1Ser.append(obj1Ser.component_1.n)
                    
                    galUse[ii] = True
                    
    print "### Number of models : %d" % len(galRe1Ser)
    
    return galUse, galRe1Ser, galAr1Ser, galMag1Ser, galNs1Ser, chi1Ser, bic1Ser

In [415]:
xEtg2Use, xEtg2Re, xEtg2Ar, xEtg2Mag, xEtg2Ns, xEtg2Chi, xEtg2Bic = get1SerSize(xmmEtg2Data, xmmEtg2PklDir, 
                                                                                zStr='z', idStr='id', pix=0.168, 
                                                                                chisqThr=10.0, nSerThr=8.0, 
                                                                                extinctionStr='extinction_i')
xEtg3Use, xEtg3Re, xEtg3Ar, xEtg3Mag, xEtg3Ns, xEtg3Chi, xEtg3Bic = get1SerSize(xmmEtg3Data, xmmEtg3PklDir, 
                                                                                zStr='z', idStr='id', pix=0.168, 
                                                                                chisqThr=10.0, nSerThr=8.0, 
                                                                                extinctionStr='extinction_i')


### Number of models : 19
### Number of models : 156

In [418]:
xMass1Use, xMass1Re, xMass1Ar, xMass1Mag, xMass1Ns, xMass1Chi, xMass1Bic = get1SerSize(xmassZ1Data, xmassZ1PklDir, 
                                                                                       zStr='z', idStr='objid_dr12', 
                                                                                       pix=0.168, chisqThr=10.0, 
                                                                                       nSerThr=8.0, 
                                                                                       extinctionStr='extinction_i')
xMass2Use, xMass2Re, xMass2Ar, xMass2Mag, xMass2Ns, xMass2Chi, xMass2Bic = get1SerSize(xmassZ2Data, xmassZ2PklDir, 
                                                                                       zStr='z', idStr='objid_dr12', 
                                                                                       pix=0.168, chisqThr=10.0, 
                                                                                       nSerThr=8.0, 
                                                                                       extinctionStr='extinction_i')
xMass3Use, xMass3Re, xMass3Ar, xMass3Mag, xMass3Ns, xMass3Chi, xMass3Bic = get1SerSize(xmassZ3Data, xmassZ3PklDir, 
                                                                                       zStr='z', idStr='objid_dr12', 
                                                                                       pix=0.168, chisqThr=10.0, 
                                                                                       nSerThr=8.0, 
                                                                                       extinctionStr='extinction_i')
xMass4Use, xMass4Re, xMass4Ar, xMass4Mag, xMass4Ns, xMass4Chi, xMass4Bic = get1SerSize(xmassZ4Data, xmassZ4PklDir, 
                                                                                       zStr='z', idStr='objid_dr12', 
                                                                                       pix=0.168, chisqThr=10.0, 
                                                                                       nSerThr=8.0, 
                                                                                       extinctionStr='extinction_i')


### Number of models : 32
### Number of models : 72
### Number of models : 144
### Number of models : 189

In [467]:
xEtg2logm = xmmEtg2Data[xEtg2Use]['logms_pca']
xEtg3logm = xmmEtg3Data[xEtg3Use]['logms_pca']
scatter(xEtg2logm, np.log10(np.asarray(xEtg2Re)*np.asarray(xEtg2Ar)))
scatter(xEtg3logm, np.log10(np.asarray(xEtg3Re)*np.asarray(xEtg3Ar)))

xMass1logm = xmassZ1Data[xMass1Use]['logms_pca_bc03']
xMass2logm = xmassZ2Data[xMass2Use]['logms_pca_bc03']
xMass3logm = xmassZ3Data[xMass3Use]['logms_pca_bc03']
xMass4logm = xmassZ4Data[xMass4Use]['logms_pca_bc03']

scatter(xMass1logm, np.log10(np.asarray(xMass1Re)*np.asarray(xMass1Ar)))
scatter(xMass2logm, np.log10(np.asarray(xMass2Re)*np.asarray(xMass2Ar)))
#scatter(xMass3logm, np.log10(np.asarray(xMass3Re)*np.asarray(xMass3Ar)))
#scatter(xMass4logm, np.log10(np.asarray(xMass4Re)*np.asarray(xMass4Ar)))


Out[467]:
<matplotlib.collections.PathCollection at 0x1155a6190>

In [508]:
def get2SerSize(cat, pklDir, zStr='z', idStr='objid_dr12', pix=0.168, 
                chisqThr=4.0, nSerThr=8.0, extinctionStr='extinction_i', 
                factor=0.95, massStr='logms_pca'):
    
    galUse = np.empty(len(cat), dtype=bool)
    galUse[:] = False
    
    galRe1Ser = []
    galAr1Ser = []
    galMag1Ser = []
    galNs1Ser = []

    chi1Ser = []
    aic1Ser = []
    bic1Ser = []
    
    galRe2SerI = []
    galAr2SerI = []
    galMag2SerI = []
    galNs2SerI = []
    
    galRe2SerO = []
    galAr2SerO = []
    galMag2SerO = []
    galNs2SerO = []
    
    innerFrac = []
    
    chi2Ser = []
    aic2Ser = []
    bic2Ser = []
    
    logmI = []
    logmO = []
    
    for ii, galaxy in enumerate(cat): 
                
        galId = galaxy[idStr]
        pattern1Ser = '*' + str(galId) + '*1ser.pkl'
        pattern2Ser = '*' + str(galId) + '*2ser.pkl'
        
        pkl1SerFound = findProfile(pattern1Ser, pklDir)
        pkl2SerFound = findProfile(pattern2Ser, pklDir)

        if (len(pkl1SerFound) == 1) and (len(pkl2SerFound) == 1):
            
            pkl1SerFile = pkl1SerFound[0]
            obj1Ser = loadGalfitOutput(pkl1SerFile)
            
            pkl2SerFile = pkl2SerFound[0]
            obj2Ser = loadGalfitOutput(pkl2SerFile)
            
            if (type(obj1Ser) is not numpy.core.records.recarray) and (
                type(obj2Ser) is not numpy.core.records.recarray):
            
                nser2A = obj1Ser.component_1.n
                nser2B = obj2Ser.component_2.n
                
                chisq1 = obj1Ser.reduced_chisq
                aic1, bic1, hq1 = gSimple.galfitAIC(obj1Ser)
                
                chisq2 = obj1Ser.reduced_chisq
                aic2, bic2, hq2 = gSimple.galfitAIC(obj2Ser)
            
                try: 
                    ai = galaxy[extinctionStr]
                except Exception:
                    ai = 0.05
            
                logmT = galaxy[massStr]

                if (logmT >= 11.2) and (bic2 < bic1) and (aic2 < aic1) and (
                    nser2A <= nSerThr) and (nser2B <= nSerThr):
                
                    scale = pixKpc(galaxy[zStr], show=False)
                    distmod = hUtil.cosmoDistMod(galaxy[zStr])
                
                    chi1Ser.append(chisq1)
                    aic1Ser.append(aic1)
                    bic1Ser.append(bic1)
        
                    galRe1Ser.append(obj1Ser.component_1.re * np.sqrt(obj1Ser.component_1.ar) * scale)
                    galAr1Ser.append(obj1Ser.component_1.ar)
                    galMag1Ser.append(obj1Ser.component_1.mag - ai - distmod)
                    galNs1Ser.append(obj1Ser.component_1.n)
                    
                    """ 2 Sersic part """
                    chi2Ser.append(chisq2)
                    aic2Ser.append(aic2)
                    bic2Ser.append(bic2)
                    
                    if (obj2Ser.component_1.re <= obj2Ser.component_2.re): 
                        compInner = obj2Ser.component_1
                        compOuter = obj2Ser.component_2
                    else: 
                        compInner = obj2Ser.component_2 
                        compOuter = obj2Ser.component_1

                    galRe2SerI.append(compInner.re * scale * np.sqrt(compInner.ar))
                    galAr2SerI.append(compInner.ar)
                    galMag2SerI.append(compInner.mag)
                    galNs2SerI.append(compInner.n)

                    galRe2SerO.append(compOuter.re * scale * np.sqrt(compOuter.ar))
                    galAr2SerO.append(compOuter.ar)
                    galMag2SerO.append(compOuter.mag)
                    galNs2SerO.append(compOuter.n)  
                                        
                    fluxI = 10.0 ** ((27.0 - compInner.mag) / 2.5)
                    fluxO = 10.0 ** ((27.0 - compOuter.mag) / 2.5)
                    innerFrac.append(fluxI / (fluxI + fluxO))
                    
                    logmI.append(logmT + np.log10(fluxI / (fluxI + fluxO)))
                    logmO.append(logmT + np.log10(fluxO / (fluxI + fluxO)))

                    galUse[ii] = True
                    
    print "### Number of models : %d" % len(galRe1Ser)
    
    return galRe2SerI, galRe2SerO, logmI, logmO

In [509]:
xEtg3ReI, xEtg3ReO, xEtg3logmI, xEtg3logmO = get2SerSize(xmmEtg3Data, xmmEtg3PklDir, zStr='z', idStr='id', 
                                                         chisqThr=5.0, nSerThr=6.0, massStr='logms_pca')

xEtg2ReI, xEtg2ReO, xEtg2logmI, xEtg2logmO = get2SerSize(xmmEtg2Data, xmmEtg2PklDir, zStr='z', idStr='id', 
                                                         chisqThr=5.0, nSerThr=6.0, massStr='logms_pca')


### Number of models : 89
### Number of models : 6

In [510]:
xMass1ReI, xMass1ReO, xMass1logmI, xMass1logmO = get2SerSize(xmassZ1Data, xmassZ1PklDir, zStr='z', 
                                                             idStr='objid_dr12', chisqThr=5.0, nSerThr=6.0, 
                                                             massStr='logms_pca_bc03')
xMass2ReI, xMass2ReO, xMass2logmI, xMass2logmO = get2SerSize(xmassZ2Data, xmassZ2PklDir, zStr='z', 
                                                             idStr='objid_dr12', chisqThr=5.0, nSerThr=6.0, 
                                                             massStr='logms_pca_bc03')
xMass3ReI, xMass3ReO, xMass3logmI, xMass3logmO = get2SerSize(xmassZ3Data, xmassZ3PklDir, zStr='z', 
                                                             idStr='objid_dr12', chisqThr=5.0, nSerThr=6.0, 
                                                             massStr='logms_pca_bc03')
xMass4ReI, xMass4ReO, xMass4logmI, xMass4logmO = get2SerSize(xmassZ4Data, xmassZ4PklDir, zStr='z', 
                                                             idStr='objid_dr12', chisqThr=5.0, nSerThr=6.0, 
                                                             massStr='logms_pca_bc03')


### Number of models : 24
### Number of models : 47
### Number of models : 77
### Number of models : 91

In [505]:
cgsInner = fits.open('cgs_inner.fits')[1].data
cgsOuter = fits.open('cgs_outer.fits')[1].data
cgsMass = fits.open('cgs_massive.fits')[1].data

In [611]:
fig = plt.figure(figsize=(11.0, 11.0))
fig.subplots_adjust(left=0.1, right=0.95, bottom=0.15)
ax1 = fig.add_subplot(111)

#ax1.plot([-25.9,-10.1], [-25.9, -10.1], 'k--', alpha=0.6, 
#         linewidth=3.5)

""" CGS """

ax1.scatter(cgsMass['logm_inner']+0.15, np.log10(cgsMass['re_inner']),
            s=90, color='r', linewidth=3.0,
            facecolor='none', alpha=0.2)

ax1.scatter(cgsMass['logm_outer']+0.15, np.log10(cgsMass['re_outer']), 
            s=90, color='b', linewidth=3.0,
            facecolor='none', alpha=0.2)

""" 1 Sersic """
#xEtg2logm = xmmEtg2Data[xEtg2Use]['logms_pca']
#xEtg3logm = xmmEtg3Data[xEtg3Use]['logms_pca']

#ax1.scatter(xEtg2logm, np.log10(np.asarray(xEtg2Re)*np.asarray(xEtg2Ar)), 
#            color='k', alpha=0.6)
#ax1.scatter(xEtg3logm, np.log10(np.asarray(xEtg3Re)*np.asarray(xEtg3Ar)), 
#            color='k', alpha=0.6)

#xMass1logm = xmassZ1Data[xMass1Use]['logms_pca_bc03']
#xMass2logm = xmassZ2Data[xMass2Use]['logms_pca_bc03']
#xMass3logm = xmassZ3Data[xMass3Use]['logms_pca_bc03']
#xMass4logm = xmassZ4Data[xMass4Use]['logms_pca_bc03']

#ax1.scatter(xMass1logm, np.log10(np.asarray(xMass1Re)*np.asarray(xMass1Ar)), 
#            color='k', alpha=0.6)
#ax1.scatter(xMass2logm, np.log10(np.asarray(xMass2Re)*np.asarray(xMass2Ar)), 
#            color='k', alpha=0.6)
#ax1.scatter(xMass3logm, np.log10(np.asarray(xMass3Re)*np.asarray(xMass3Ar)), 
#            color='k', alpha=0.6)
#ax1.scatter(xMass4logm, np.log10(np.asarray(xMass4Re)*np.asarray(xMass4Ar)), 
#            color='k', alpha=0.6)

""" 2 Sersic """

xEtg3logmT = logAdd(xEtg3logmI, xEtg3logmO)
ax1.scatter(xEtg3logmI, np.log10(np.asarray(xEtg3ReI)), s=(xEtg3logmT-10.5)*80, 
            c='r', alpha=0.7, marker='s')
ax1.scatter(xEtg3logmO, np.log10(np.asarray(xEtg3ReO)), s=(xEtg3logmT-10.5)*80, 
            c='b', alpha=0.6)

xEtg2logmT = logAdd(xEtg2logmI, xEtg2logmO)
ax1.scatter(xEtg2logmI, np.log10(np.asarray(xEtg2ReI)), s=(xEtg2logmT-10.5)*80, 
            c='r', alpha=0.7, marker='s')
ax1.scatter(xEtg2logmO, np.log10(np.asarray(xEtg2ReO)), s=(xEtg2logmT-10.5)*80, 
            c='b', alpha=0.6)

xMass1logmT = logAdd(xMass1logmI, xMass1logmO)
ax1.scatter(xMass1logmI, np.log10(np.asarray(xMass1ReI)), s=(xMass1logmT-10.5)*80, 
            c='r', alpha=0.7, marker='s')
ax1.scatter(xMass1logmO, np.log10(np.asarray(xMass1ReO)), s=(xMass1logmT-10.5)*80, 
            c='b', alpha=0.6)

xMass2logmT = logAdd(xMass2logmI, xMass2logmO)
ax1.scatter(xMass2logmI, np.log10(np.asarray(xMass2ReI)), s=(xMass2logmT-10.5)*80, 
            c='r', alpha=0.7, marker='s')
ax1.scatter(xMass2logmO, np.log10(np.asarray(xMass2ReO)), s=(xMass2logmT-10.5)*80, 
            c='b', alpha=0.6)

xMass3logmT = logAdd(xMass3logmI, xMass3logmO)
#ax1.scatter(xMass3logmI, np.log10(np.asarray(xMass3ReI)), s=(xMass3logmT-10.5)*80, 
#            c='r', alpha=0.7, marker='s')
#ax1.scatter(xMass3logmO, np.log10(np.asarray(xMass3ReO)), s=(xMass3logmT-10.5)*80, 
#            c='b', alpha=0.6)

xMass4logmT = logAdd(xMass4logmI, xMass4logmO)
#ax1.scatter(xMass4logmI, np.log10(np.asarray(xMass4ReI)), s=(xMass4logmT-10.0)*80, 
#            c='r', alpha=0.9, marker='s')
#ax1.scatter(xMass4logmO, np.log10(np.asarray(xMass4ReO)), s=(xMass4logmT-10.0)*80, 
#            c='b', alpha=0.8)

ax1.set_xlabel('log ($M_{s}/M_{\odot}$)', size=33)
ax1.set_ylabel('log ($R_{e}$/Kpc)', size=33)

ax1.set_xlim(10.0, 12.2)
ax1.set_ylim(-0.9, 2.4)

#cbar = fig.colorbar(sca)
#cbar.set_label('Sersic Index', size=20)

for tick in ax1.xaxis.get_major_ticks():
    tick.label.set_fontsize(28) 
for tick in ax1.yaxis.get_major_ticks():
    tick.label.set_fontsize(28)
    
ax1.spines['top'].set_linewidth(4.0)
ax1.spines['right'].set_linewidth(4.0)
ax1.spines['bottom'].set_linewidth(4.0)
ax1.spines['left'].set_linewidth(4.0)

ax1.text(10.2, 2.0, '~200 Ellipticals in HSC/XMM', size=36)
ax1.text(10.2, 1.7, 'log $(M_{s}/M_{\odot})>11.2$', size=26)
ax1.text(10.2, 1.3, '$0.1<z<0.3$', size=26)

ax1.text(11.52, -0.2, 'Inner', color='r', size=36)
ax1.text(11.5, -0.5, 'Outer', color='b', size=36)


Out[611]:
<matplotlib.text.Text at 0x1159df250>

In [609]:
fig = plt.figure(figsize=(11.0, 11.0))
fig.subplots_adjust(left=0.1, right=0.95, bottom=0.15)
ax1 = fig.add_subplot(111)

#ax1.plot([-25.9,-10.1], [-25.9, -10.1], 'k--', alpha=0.6, 
#         linewidth=3.5)

""" CGS """

ax1.scatter(cgsMass['logm_inner']+0.15, np.log10(cgsMass['re_inner']),
            s=90, color='r', linewidth=3.0, marker='s',
            facecolor='none', alpha=0.5)

ax1.scatter(cgsMass['logm_outer']+0.15, np.log10(cgsMass['re_outer']), 
            s=98, color='b', linewidth=3.0, marker='o',
            facecolor='none', alpha=0.5)

ax1.set_xlabel('log ($M_{s}/M_{\odot}$)', size=33)
ax1.set_ylabel('log ($R_{e}$/Kpc)', size=33)

ax1.set_xlim(10.0, 12.2)
ax1.set_ylim(-0.9, 2.4)

#cbar = fig.colorbar(sca)
#cbar.set_label('Sersic Index', size=20)

for tick in ax1.xaxis.get_major_ticks():
    tick.label.set_fontsize(28) 
for tick in ax1.yaxis.get_major_ticks():
    tick.label.set_fontsize(28)
    
ax1.text(10.2, 2.0, '40 Ellipticals in CGS', size=36)
ax1.text(10.2, 1.7, 'log $(M_{s}/M_{\odot})>11.2$', size=26)

ax1.text(11.52, -0.2, 'Inner', color='r', size=36)
ax1.text(11.5, -0.5, 'Outer', color='b', size=36)
    
ax1.spines['top'].set_linewidth(4.0)
ax1.spines['right'].set_linewidth(4.0)
ax1.spines['bottom'].set_linewidth(4.0)
ax1.spines['left'].set_linewidth(4.0)


Test using z1


In [26]:
loc = 'z2'
zp = 27.0

amag_sun_g = 5.33
amag_sun_r = 4.67
amag_sun_i = 4.48
amag_sun_z = 4.42

In [27]:
catFile = 'hsc_xmm_log11.6_' + loc + '.fits' 
catData = fits.open(catFile)[1].data

gal_id = catData['objid_dr12']
gal_z  = catData['z']
gal_ai = catData['extinction_i']
gal_amagi = catData['cModelAbsMag_i']
gal_logm = catData['logMass']

ii = 2

ellProf = getEllipProfile(gal_id[ii], loc, stage='3')
sma_kpc, asbp_i, amag_i = correctProf(ellProf, gal_z[ii], extinction=gal_ai[ii], 
                                      zp=27.0, amag_sun=amag_sun_i, corCurve=True)
print gal_id[ii]

plot(sma_kpc**0.25, amag_i)


1237679253597913345
/usr/local/lib/python2.7/site-packages/IPython/kernel/__main__.py:19: RuntimeWarning: divide by zero encountered in log10
Out[27]:
[<matplotlib.lines.Line2D at 0x1116c9210>]

In [29]:
catData.columns


Out[29]:
ColDefs(
    name = 'objid_dr12'; format = 'K'; null = -9223372036854775808
    name = 'specobjid_dr12'; format = 'K'; null = -9223372036854775808
    name = 'bestobjid'; format = 'K'; null = -9223372036854775808
    name = 'fluxobjid'; format = 'K'; null = -9223372036854775808
    name = 'plateid'; format = 'K'; null = -9223372036854775808
    name = 'firstRelease'; format = '32A'
    name = 'plate'; format = 'I'; null = -32768
    name = 'mjd'; format = 'J'; null = -2147483648
    name = 'fiberid'; format = 'I'; null = -32768
    name = 'ra_fib'; format = 'D'
    name = 'dec_fib'; format = 'D'
    name = 'ra_pho'; format = 'D'
    name = 'dec_pho'; format = 'D'
    name = 'raerr'; format = 'D'
    name = 'decerr'; format = 'D'
    name = 'z'; format = 'E'
    name = 'zerr'; format = 'E'
    name = 'vdisp_sdss'; format = 'E'
    name = 'vdisperr_sdss'; format = 'E'
    name = 'nchild'; format = 'I'; null = -32768
    name = 'photo_type'; format = 'I'; null = -32768
    name = 'extinction_u'; format = 'E'
    name = 'extinction_g'; format = 'E'
    name = 'extinction_r'; format = 'E'
    name = 'extinction_i'; format = 'E'
    name = 'extinction_z'; format = 'E'
    name = 'logms_pca_bc03'; format = 'D'
    name = 'logms_err_pca_bc03'; format = 'D'
    name = 'vdisp_pca_bc03'; format = 'D'
    name = 'vdisperr_pca_bc03'; format = 'D'
    name = 'cModelAbsMag_u'; format = 'D'
    name = 'cModelAbsMag_g'; format = 'D'
    name = 'cModelAbsMag_r'; format = 'D'
    name = 'cModelAbsMag_i'; format = 'D'
    name = 'cModelAbsMag_z'; format = 'D'
    name = 'logMass'; format = 'D'
    name = 'logMass_median'; format = 'D'
    name = 'logMass_err'; format = 'D'
    name = 'tau'; format = 'D'
    name = 'tau_err'; format = 'D'
    name = 'tau_mean'; format = 'D'
    name = 'age'; format = 'D'
    name = 'age_mean'; format = 'D'
    name = 'age_min'; format = 'D'
    name = 'age_max'; format = 'D'
    name = 'ssfr'; format = 'D'
    name = 'ssfr_mean'; format = 'D'
    name = 'ssfr_min'; format = 'D'
    name = 'ssfr_max'; format = 'D'
)

In [123]:
ellProf


Out[123]:
<Table masked=False length=76>
smaintensint_errpix_varrmsellell_errpapa_errx0x0_erry0y0_errgradgrad_errgrad_r_errrsmamagmag_lerrmag_uerrtflux_etflux_ctmag_etmag_cnpix_enpix_ca3a3_errb3b3_erra4a4_errb4b4_errndatanflagniterstopa_bigsareaa1a1_errb1b1_erra2a2_errb2b2_errpa_normsbpsbp_lowsbp_uppsma_asecrsma_asecavg_x0avg_y0avg_qavg_pagrowth_oriavg_bkggrowth_corrad_outermag_tot
float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64int64int64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64float64
0.045.5986121708nannannannannannannan502.0nan500.0nan-5.822931nannan0.049.85254nannannannannannannannannannannannannannannannan10nannannannannannannannannannannannannan18.9790831117nannan0.00.0502.0500.00.777823218.480340.00.003537829250.0183.93378705618.2148556008
0.549820242.39705217080.29316441.4948511.0570190.22217680.0604475518.480349.068295502.00.01763681500.00.02099757-5.6775717.9063831.3925640.861103149.931570.007533220.00748086845.6021545.6021549.8525449.852541.01.00.011399150.038545050.021895450.04549393-0.1017490.14210530.024746310.035975871301.00.0nan2.00.00032430680.03301069-0.018158420.031909670.00039427680.03252446-0.017806230.0313822718.4803419.058116659119.0506355419.06559777820.09236979360.551293019301502.0500.00.777823218.480340.00.003537829250.0183.93378705618.2148556008
0.604802242.08488217070.32097741.636671.15730.22217680.0598653418.480348.980952502.00.01921364500.00.02287486-5.6508787.8671631.3922020.881867549.939590.0083108680.00824961345.6021545.6021549.8525449.852541.01.00.010639990.037852480.021260340.044691-0.10080790.14075970.024661240.035845181301.00.0nan2.00.0003405610.03604436-0.019675560.034842160.0004046950.03552199-0.019297590.0342745418.4803419.06613985219.057891154719.07438854940.10160676960.564586723095502.0500.00.777823218.480346.52910871660.003537829256.52855989885183.93378705618.2148556008
0.665282441.74312217070.35123571.7909581.2663980.22217680.059274218.480348.892269502.00.0209263500.00.02491388-5.6193877.8239711.3923180.903132649.948450.0091728910.00909716745.6021545.6021549.8525449.852541.01.00.0098641410.037170540.020558760.04383769-0.099841290.13942740.024611190.03577381301.00.0nan2.00.00035610790.0393402-0.021289260.038028070.00041206650.03878044-0.020884780.0374185518.4803419.074992071519.065895439219.08408870370.11176744320.578200987452502.0500.00.777823218.4803414.3651798370.0035378292514.3639669498183.93378705618.2148556008
0.731810741.36927217080.38414771.9587761.3850640.22217680.0585850118.480348.788877502.00.02275128500.00.02708662-5.5864847.7769581.3921020.924910449.958210.010128730.0100340345.6021545.6021549.8525449.852541.01.00.0089595430.036397730.019763140.04286409-0.098706140.13782780.024544860.03567061301.00.0nan2.00.00036889220.0428923-0.022986870.04146170.00041265970.04229444-0.022555430.0408091618.4803419.084758861819.074724284619.09479343890.12294419760.592143558429502.0500.00.777823218.4803423.76192735390.0035378292523.7599109417183.93378705618.2148556008
0.804991840.96045217080.41992272.1411941.5140530.22217680.0578404318.480348.677176502.00.02470835500.00.02941661-5.5492327.7258871.3922440.947213549.968990.011187670.0110728745.6021545.6021549.8525449.852541.01.00.007951070.035583450.018897680.04182085-0.097473470.13612810.024456810.035546741301.00.0nan2.00.00037773290.04672648-0.024764630.0451680.00040393230.04609037-0.024306570.0444717818.4803419.0955407819.084467535519.10661402450.13523862240.60642232974502.0500.00.777823218.4803435.01963609150.0035378292535.0166474144183.93378705618.2148556008
0.88549140.51374217070.45875792.3392151.6540750.22217680.0570074718.480348.552217502.00.02678777500.00.03189227-5.5088157.6703271.3923730.970054349.98090.012363010.0122246745.6021545.6021549.8525449.852541.01.00.0068329370.034721810.017918370.04065501-0.096079110.13420190.024365160.035416121301.00.0nan2.00.0003819330.0508447-0.026607990.049148850.00038430210.05017089-0.026124050.04840918.4803419.107445701919.095221501619.11966990230.1487624880.62104541276502.0500.00.777823218.4803448.49291712760.0035378292548.48875201183.93378705618.2148556008
0.974040140.02594217070.50085392.5538641.8058540.22217680.0522075118.480347.832129502.00.0269855500.00.03212769-5.8722777.5983011.2939270.993445949.994050.013669840.0135013545.6021545.6021549.8525449.852541.01.00.0052014210.0313720.015663870.03575424-0.087987040.11427640.022574510.030691481301.00.0nan2.00.00037904920.05526703-0.028509110.053423690.00034937890.05455668-0.028000980.0526407718.4803419.120596537519.107095954619.13409712030.16363873680.63602110875502.0500.00.777823218.4803464.59931085590.0035378292564.5937222457183.93378705618.2148556008
1.07144439.45395217080.54488612.7783841.9646150.22217680.0384059518.480345.76163502.00.02183679500.00.02599786-6.8445257.4879411.0940041.01740250.009680.015098250.01489057126.5437206.623548.744448.212053.05.00.006341280.02348460.01242040.02549096-0.06686950.073378380.013225020.015461091301.00.0nan2.00.00018109410.04072266-0.025681830.03936443-2.360399e-050.039914-0.025270880.0385123218.4803419.136222770819.121331936819.15111360490.1800025920.6513579073502.0500.00.777823218.4803483.80954572010.0035378292583.8022346857183.93378705618.2148556008
1.17858938.72060217070.5888723.002672.1232080.22217680.0276341718.480344.145657502.00.01728341500.00.02057682-7.4559187.3630170.987541.04193550.030050.01663650.01638724126.5437206.623548.744448.212053.05.00.0040503680.016883860.0020996110.01590358-0.049227630.04889908-0.0057370360.0075743771301.00.0nan2.0-0.0015016480.04584903-0.0091436680.04431981-0.003291380.04577971-0.0094866610.0441720218.4803419.156591954719.140205611319.17297829810.1980029520.667064634257502.0500.00.777823218.48034106.6220699870.00353782925106.612674806183.93378705618.2148556008
.............................................................................................................................................................................................
269.6161-0.002294072250.00097078530.16435950.010041880.2221768nan18.48034nan502.0nan500.0nan-0.0001068721nannan4.05215961.263161.6465460.62637059313.35411929.6544.0772343.80843177629.0228373.0-0.057207360.05885445-0.014201040.03990409-0.10453560.09089732-0.078554180.07218049107191.04.0nan267.89170.0025249380.0010194820.0013065650.0009568091-0.00082480380.0010072030.00040107990.000960958418.4803430.389707563629.763336458231.01607866945.29550482.59426165195502.0500.00.777823218.480343700.355905090.003537829253071.92509047183.93378705618.2148556008
296.57770.001702861750.0012222350.23184240.012877040.2221768nan18.48034nan502.0nan500.0nan-5.769885e-055.321355e-050.92226374.14987159.701530.28832140.227603311131.9212876.5143.8835743.7255214939.0276349.0-0.0081580270.07248045-0.088857380.1082324-0.13905710.1456371-0.054410030.08679032111151.04.0nan324.15570.0048883650.0011249220.0020642410.0010655180.0014608990.001073107-0.0018156650.00106599618.4803428.828075024328.600473450329.055676598349.82505362.65681884843502.0500.00.777823218.480343895.848400220.003537829253135.446617183.93378705618.2148556008
326.2354-8.35725e-060.00099842010.20453590.010327740.2221768nan18.48034nan502.0nan500.0nan-5.719997e-053.568318e-050.62383214.2499460.130730.36102160.27046614163.3115534.1743.6220943.52178260063.0334401.00.035612730.06120889-0.12718760.09903508-0.083667530.075767040.16401290.1163901107191.04.0nan392.21930.0037714170.0009755543-0.0014924850.0009277947-0.00057113080.0009239655-0.0019176570.000931587718.4803429.257272056428.98680623629.527737876754.80754722.72088440614502.0500.00.777823218.480344055.155713320.003537829253135.06940164183.93378705618.2148556008
358.859-0.001874423250.00059859320.13425940.0061628940.2221768nan18.48034nan502.0nan500.0nan-4.575998e-05nannan4.35242260.947510.48431090.33373715206.3216220.7543.5449443.47482314693.0404549.00.063402370.06776278-0.045415070.058030230.020069760.047525510.054569560.06248949106201.04.0nan474.5916-0.0002858560.0007420002-0.00089405220.00071620920.00036585380.00073750892.451674e-050.00071803218.4803430.074050749429.740315291130.407786207760.2883122.78649508322502.0500.00.777823218.480344146.002868060.003537829253032.69750984183.93378705618.2148556008
394.7449-0.000849035250.00068618750.17009410.0070979780.2221768nan18.48034nan502.0nan500.0nan-3.660798e-05nannan4.45737560.426110.31990550.24678415885.917874.9943.4974743.36938380737.0489565.00.033026580.063772820.033400590.06606904-0.0084039080.058019270.096901920.09768435107191.04.0nan574.2605-0.00027464530.00084209690.00014091870.00084613220.00089163750.00082118680.00063699270.000853418918.4803429.552652582829.305867917229.799437248466.31714322.85368775929502.0500.00.777823218.480344323.689712840.003537829252976.58968058183.93378705618.2148556008
434.2194-0.000135743250.00083756440.23260670.0088242890.2221768nan18.48034nan502.0nan500.0nan-2.928639e-05nannan4.56485860.170640.30684890.238960417213.1519675.5443.4103543.26518460741.0592333.00.18080120.16012080.11353160.1158382-0.031365840.07323290.11106280.1131265111151.04.0nan694.8404-0.0026311870.00082020180.001528780.00084097110.00029402070.0008161382-0.0003998180.000840611618.4803429.297183189229.058221292929.536145085572.94885922.92250071549502.0500.00.777823218.480344595.727052190.003537829252965.73538925183.93378705618.2148556008
477.64130.001851738750.00085674410.25816850.0089035460.2221768nan18.48034nan502.0nan500.0nan-4.143658e-052.426579e-050.58561284.67493459.671120.1879620.160175123346.6333068.1143.0794442.70148557479.0716761.00.17665280.11263750.066288690.058865390.0067032640.043185740.022862480.0477745108181.04.0nan840.7764-0.0004902030.0008519073-0.00072775340.00089804710.0018834320.00082166120.0012083680.000870813618.4803428.797661519228.637487208228.957835830280.24373842.99297292643502.0500.00.777823218.480345117.188303590.003537829253144.89817295183.93378705618.2148556008
525.4055-0.000127444250.00078060920.22408160.0070254830.2221768nan18.48034nan502.0nan500.0nan-3.314927e-05nannan4.78766460.167990.28221140.223784326819.0636173.3142.9288942.60403670805.0845889.00.090021780.087837280.086453180.084781670.087998580.085882890.02309340.0516037381451.04.0nan1017.326-0.001729110.0007081591-0.0012659210.00094134270.0014506040.00071361990.0016362920.000823217918.4803429.294537884929.070753759129.518322010888.2681243.06514464711502.0500.00.777823218.480345516.450213290.003537829253129.9779705183.93378705618.2148556008
577.9460.003155436750.0015974660.48860990.013926380.2221768nan18.48034nan502.0nan500.0nan-5.998454e-053.480823e-050.58028674.90311259.435910.29606360.232387735200.7946664.1442.6336242.32754778019.0928285.00.19869220.12455090.023297510.044776920.017556630.04431974-0.071516870.0610383276501.04.0nan1230.971-0.00030148060.001290697-0.0017995610.0019662910.0042615980.0012699870.0035750820.00145595218.4803428.562451196528.330064216928.794838176297.0949283.13905652423502.0500.00.777823218.480346464.599977420.003537829253576.96851447183.93378705618.2148556008
635.7407-0.000311346250.0012227640.26695220.0069170.22217680.115422118.4803415.87183502.021.76365500.029.5061-4.798763e-05nannan5.02134460.228180.51723210.348892543552.9648425.6342.4024642.28731884124.0980361.00.097334040.084954020.038808660.04471033-0.061727580.05675741-0.017301180.0345055432941.01.0nan1489.469-0.0017989380.0007341676-0.003550720.0013298960.0014616130.001065375-0.00072538140.00104258618.4803429.354722955629.005830117929.7036157933106.80443763.2147508837502.0500.00.777823218.480347017.6376970.003537829253523.6019788183.93378705618.2148556008

In [217]:
index = np.isfinite(amag_i)
intrpFunc = interp1d(sma_kpc[index]**0.25, amag_i[index], kind='linear')

sma_common = np.arange(0.9, 4.0, 0.1)

sbp_intrp = intrpFunc(sma_common)

plot(sma_kpc**0.25, amag_i, 'r', linewidth=2.0, alpha=0.8)
plot(sma_common, sbp_intrp)

print pixKpc(gal_z[ii])**0.25
print np.min(sma_kpc**0.25)

temp = intrpFunc(1.5)


# 1 pixel(s) =  0.764 Kpc
0.934972199355
0.0