Packages


In [71]:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from mpl_toolkits.mplot3d import Axes3D

Loading Dataset


In [2]:
my_data = np.loadtxt('myGAMA_ALL_AB_ABSOL_MAGS_clean_plus_short.csv', delimiter=',', dtype=str)

In [3]:
my_dictionary = {}
for i in range(len(my_data[0, :])):                                         # Converting numpy array into dictionary
    my_dictionary[my_data[0, i]] = np.array(my_data[0 + 1:, i], dtype=str)

In [4]:
print my_data.shape
print my_data.size
print my_data[0,:]


(41573, 135)
5612355
['CATAID' 'OBJID_SDSSDR7' 'RA' 'DEC' 'MAG_AUTO_U' 'MAGERR_AUTO_U'
 'MAG_AUTO_G' 'MAGERR_AUTO_G' 'MAG_AUTO_R' 'MAGERR_AUTO_R' 'MAG_AUTO_I'
 'MAGERR_AUTO_I' 'MAG_AUTO_Z' 'MAGERR_AUTO_Z' 'MAG_AUTO_Y' 'MAGERR_AUTO_Y'
 'MAG_AUTO_J' 'MAGERR_AUTO_J' 'MAG_AUTO_H' 'MAGERR_AUTO_H' 'MAG_AUTO_K'
 'MAGERR_AUTO_K' 'BEST_MAG_NUV' 'BEST_MAGERR_NUV' 'BEST_MAG_FUV'
 'BEST_MAGERR_FUV' 'NMATCHUV' 'NMATCHOPT' 'NUVFLAG' 'FUVFLAG' 'SEX_INDEX_U'
 'SEX_INDEX_G' 'SEX_INDEX_R' 'SEX_INDEX_I' 'SEX_INDEX_Z' 'SEX_INDEX_Y'
 'SEX_INDEX_J' 'SEX_INDEX_H' 'SEX_INDEX_K' 'GAL_INDEX_U' 'GAL_INDEX_G'
 'GAL_INDEX_R' 'GAL_INDEX_I' 'GAL_INDEX_Z' 'GAL_INDEX_Y' 'GAL_INDEX_J'
 'GAL_INDEX_H' 'GAL_INDEX_K' 'U_MODEL' 'U_MODEL_ERR' 'G_MODEL'
 'G_MODEL_ERR' 'R_MODEL' 'R_MODEL_ERR' 'I_MODEL' 'I_MODEL_ERR' 'Z_MODEL'
 'Z_MODEL_ERR' 'KCORR_FUV_k0' 'KCORR_NUV_k0' 'KCORR_U_k0' 'KCORR_G_k0'
 'KCORR_R_k0' 'KCORR_I_k0' 'KCORR_Z_k0' 'KCORR_Y_k0' 'KCORR_J_k0'
 'KCORR_H_k0' 'KCORR_K_k0' 'CHI2_k0' 'MASS_k0' 'INTSFH_k0' 'METS_k0'
 'B300_k0' 'B1000_k0' 'EBV' 'SPECID_BEST' 'Z_HELIO' 'MAG_AB_FUV'
 'MAG_AB_NUV' 'MAG_AB_U' 'MAG_AB_G' 'MAG_AB_R' 'MAG_AB_I' 'MAG_AB_Z'
 'MAG_AB_Y' 'MAG_AB_J' 'MAG_AB_H' 'MAG_AB_K' 'MAG_ABSOLUTE_FUV'
 'MAG_ABSOLUTE_NUV' 'MAG_ABSOLUTE_U' 'MAG_ABSOLUTE_G' 'MAG_ABSOLUTE_R'
 'MAG_ABSOLUTE_I' 'MAG_ABSOLUTE_Z' 'MAG_ABSOLUTE_Y' 'MAG_ABSOLUTE_J'
 'MAG_ABSOLUTE_H' 'MAG_ABSOLUTE_K' 'UV_CLASS_YI2011' 'PROB' 'PETROMAG_R'
 'SN_CONT' 'SN_EMI' 'WARNING_FLAG' 'F_HALPHA' 'F_HBETA' 'OBJNAME'
 'EMLINE_CLASS' 'GAL_QFLAG_U' 'GAL_QFLAG_G' 'GAL_QFLAG_R' 'GAL_QFLAG_I'
 'GAL_QFLAG_Z' 'GAL_QFLAG_Y' 'GAL_QFLAG_J' 'GAL_QFLAG_H' 'SURVEY_BEST'
 'Z_HELIO_BEST' 'NQ_BEST' 'Z_TONRY' 'A_R' 'K_R' 'DM_70_30_70' 'AB_R'
 'SPECID' 'SURVEY' 'NQ' 'BALMER_DECREMENT' 'BALMERDEC_FLAG' 'L_APCOR'
 'L_APOBSCOR' 'SFR' 'EMLINE_METHOD']

In [5]:
redshift     = my_dictionary['Z_HELIO'].astype(float)
fuv_band     = my_dictionary['MAG_AB_FUV'].astype(float)   
nuv_band     = my_dictionary['MAG_AB_NUV'].astype(float)
u_band       = my_dictionary['MAG_AB_U'].astype(float)
g_band       = my_dictionary['MAG_AB_G'].astype(float)
r_band       = my_dictionary['MAG_AB_R'].astype(float)
mag_abs_r    = my_dictionary['MAG_ABSOLUTE_R'].astype(float)
stellar_mass = my_dictionary['MASS_k0'].astype(float)
sex_index_r  = my_dictionary['SEX_INDEX_R'].astype(float)  #SEx Sérsic Index
sex_index_h  = my_dictionary['SEX_INDEX_H'].astype(float)  #SEx Sérsic Index
gal_index_r  = my_dictionary['GAL_INDEX_R'].astype(float)  #Galfit Sérsic Index
gal_index_h  = my_dictionary['GAL_INDEX_H'].astype(float)  #Galfit Sérsic Index
z_prob       = my_dictionary['PROB'].astype(float)
sfr          = my_dictionary['SFR'].astype(float)
b300         = my_dictionary['B300_k0'].astype(float)
b1000        = my_dictionary['B1000_k0'].astype(float)
balmer_dec   = my_dictionary['BALMER_DECREMENT'].astype(float)
uv_class     = my_dictionary['UV_CLASS_YI2011'].astype(str)

Volume Selection


In [6]:
z_min=0.06
z_max=0.40

Cleaning the overall sample


In [7]:
indexes = np.arange(redshift.size)
index_clean = indexes[(r_band>0)*(r_band<19.8)*(nuv_band>0)*(fuv_band>0)*((fuv_band-nuv_band)<50)
                      *((fuv_band-nuv_band)>(-20))*(gal_index_h>0)]

Selecting the sample


In [8]:
index_all = indexes[(r_band>0)*(r_band<19.8)*(nuv_band>0)*(fuv_band>0)*((fuv_band-nuv_band)<50)
                      *((fuv_band-nuv_band)>(-20))*(gal_index_h>0)*(z_prob>0.85)*(redshift>=z_min)]

Characterizing the UV emission of the Galaxies


In [9]:
index_uvup = np.where(((r_band>0)*(r_band<19.8)*(nuv_band>0)*(fuv_band>0)*(nuv_band-r_band)>5.4)
                      *(fuv_band-nuv_band<0.9)*(fuv_band-r_band<6.6)*(fuv_band-nuv_band<50)*(fuv_band-nuv_band>-20)
                      *(gal_index_h>0)*(z_prob>0.85)*(redshift>=z_min))

In [10]:
index_rsf = np.where(((r_band>0)*(r_band<19.8)*(nuv_band>0)*(fuv_band>0)*(nuv_band - r_band)<5.4)
                     *(fuv_band-nuv_band<50)*(fuv_band-nuv_band>-20)*(gal_index_h>0)*(z_prob>0.85)*(redshift>=z_min))

In [11]:
index_uvweak = np.where(((r_band>0)*(r_band<19.8)*(nuv_band>0)*(fuv_band>0)*(nuv_band - r_band) > 5.4)
                        *((fuv_band-r_band)>6.6)*(fuv_band-nuv_band<50)*(fuv_band-nuv_band>-20)*(gal_index_h>0)
                        *(z_prob>0.85)*(redshift>=z_min))

In [12]:
index_redsequence = np.where(((r_band>0)*(r_band<19.8)*(nuv_band>0)*(fuv_band>0)*(nuv_band-r_band)>5.4)
                             *(fuv_band-nuv_band<50)*(fuv_band-nuv_band>-20)*(gal_index_h>0)*(z_prob>0.85)
                             *(redshift>=z_min))

Plot 01: Yi et al. (2011) UV diagnosis plot


In [106]:
sns.set_style("whitegrid")
plt.subplots(1,1, figsize=(10,7))
plot01, = plt.plot((nuv_band - r_band)[index_all], (fuv_band - nuv_band)[index_all], 'o', color = '#fec44f', 
                   alpha=0.7, label="RSF")
plot02, = plt.plot((nuv_band - r_band)[index_redsequence], (fuv_band - nuv_band)[index_redsequence], 'o', 
                   color = '#feb24c', alpha=0.7, label="UV Weak")
plot03, = plt.plot((nuv_band - r_band)[index_uvup], (fuv_band - nuv_band)[index_uvup], 'o', color = '#f03b20', 
                   alpha=0.7, label="UV upturn")
plt.legend(numpoints=10, loc='best', fontsize=18)
plt.text(-4.5, 8, r"RSF", fontsize=18)
plt.text(-4.5, -3, r"RSF", fontsize=18)
plt.text(6.5, 8, r"UV Weak", fontsize=18)
plt.text(6.5, -3, r"UV upturn", fontsize=20)
plt.axvline(x=5.4, color='black', linewidth=2.)
plt.axhline(y=0.9, color='black', linewidth=2.)
plt.xlabel("NUV-r", fontsize=20)
plt.ylabel("FUV-NUV", fontsize=20)
plt.tick_params('both', labelsize='18')
plt.grid(alpha=0.40)
plt.savefig('./Figs/maglim_yi_diagram.pdf')
plt.savefig('./Figs/maglim_yi_diagram.png')
plt.show()


Plot 02: Redshift x Magnitude


In [14]:
sns.set_style("whitegrid")
plt.subplots(1,1, figsize=(10,7))
plt.plot(redshift[index_redsequence], mag_abs_r[index_redsequence], 'o', alpha=0.7, color='#7570b3', label='Red Sequence (UV weak+upturn)')
plt.plot(redshift[index_uvup], mag_abs_r[index_uvup], 'o', alpha=0.7, color='#d95f02', label='UV Upturn')
plt.xlabel("Redshift", fontsize=15)
plt.ylabel("M$_r$", fontsize=15)
plt.legend(loc='best', numpoints=1, fontsize=20, frameon=False)
plt.axvline(x=z_max, color='black', linewidth=1.)
plt.axvline(x=z_min, color='black', linewidth=1.)
plt.tick_params('both', labelsize='15')
plt.xlim(0,0.5)
plt.grid(alpha=0.40)
plt.gca().invert_yaxis()
plt.savefig('./Figs/maglim_mag_z_uvcategories_zoom.pdf')
plt.savefig('./Figs/maglim_mag_z_uvcategories_zoom.png')
plt.show()


UV Fraction


In [15]:
bins = np.arange(0, (redshift[index_clean]).max(), 0.05)
ratio_uvup_redseq = []
average_redshift = []
z_uv = []
z_rs = []
redshift_uvup = redshift[index_uvup]

for i in range(bins.size):
    if i==0:
        continue
    else:
        index_redseq_i = np.where((bins[i-1] <= redshift[index_redsequence]) * (redshift[index_redsequence] <= bins[i]))
        index_uvup_i = np.where((bins[i-1] <= redshift_uvup) * (redshift_uvup <= bins[i]))
        redshift_bin_redseq = redshift[index_redseq_i]
        redshift_bin_uvup   = redshift_uvup[index_uvup_i]
        if (redshift_bin_redseq.size==0):
            ratio_uvup_i = 0
            print "There are no UV Upturn galaxies in this range of redshift: %.2f and %.2f" % (bins[i-1], bins[i])
        else:
            ratio_uvup_i = (np.float(redshift_bin_uvup.size) / np.float(redshift_bin_redseq.size)) *100
            average_redshift_i = np.average((bins[i], bins[i-1]))
            average_redshift.append(average_redshift_i)
        z_uv.append(redshift_bin_uvup.size)
        z_rs.append(redshift_bin_redseq.size)
        ratio_uvup_redseq.append(ratio_uvup_i)
ratio_uvup_redseq = np.array(ratio_uvup_redseq)
z_uv = np.array(z_uv)
z_rs = np.array(z_rs)
average_redshift  = np.array(average_redshift)


There are no UV Upturn galaxies in this range of redshift: 0.00 and 0.05
There are no UV Upturn galaxies in this range of redshift: 0.45 and 0.50
There are no UV Upturn galaxies in this range of redshift: 0.50 and 0.55
There are no UV Upturn galaxies in this range of redshift: 0.55 and 0.60
There are no UV Upturn galaxies in this range of redshift: 0.70 and 0.75
There are no UV Upturn galaxies in this range of redshift: 0.75 and 0.80
There are no UV Upturn galaxies in this range of redshift: 0.80 and 0.85
There are no UV Upturn galaxies in this range of redshift: 0.85 and 0.90
There are no UV Upturn galaxies in this range of redshift: 0.90 and 0.95
There are no UV Upturn galaxies in this range of redshift: 0.95 and 1.00
There are no UV Upturn galaxies in this range of redshift: 1.00 and 1.05
There are no UV Upturn galaxies in this range of redshift: 1.05 and 1.10
There are no UV Upturn galaxies in this range of redshift: 1.10 and 1.15
There are no UV Upturn galaxies in this range of redshift: 1.15 and 1.20
There are no UV Upturn galaxies in this range of redshift: 1.20 and 1.25
There are no UV Upturn galaxies in this range of redshift: 1.25 and 1.30
There are no UV Upturn galaxies in this range of redshift: 1.30 and 1.35
There are no UV Upturn galaxies in this range of redshift: 1.35 and 1.40
There are no UV Upturn galaxies in this range of redshift: 1.40 and 1.45
There are no UV Upturn galaxies in this range of redshift: 1.45 and 1.50
There are no UV Upturn galaxies in this range of redshift: 1.50 and 1.55

Plot 03 - UV fraction


In [95]:
n_groups = bins.size
index = np.arange(1,n_groups,1)
sns.set_style('white')
plt.subplots(1,1, figsize=(10,7))
plt.bar(index[[ratio_uvup_redseq!=0]], ratio_uvup_redseq[[ratio_uvup_redseq!=0]], width=1., alpha=0.65, color='#e6550d', edgecolor='#e6550d')
for i in range(bins[[ratio_uvup_redseq!=0]].size +1):
    plt.text(index[i]+0.2, ratio_uvup_redseq[i]+1.6, r"$\mathbf{\frac{%4d}{%4d}}$" % (z_uv[i], z_rs[i]), fontsize=20)
plt.xticks(index, bins)
plt.ylabel("% of UV Upturn Galaxies", fontsize=20)
plt.xlabel("Redshift", fontsize=20)
plt.tick_params('both', labelsize='18')
plt.xlim(0.5, bins[[ratio_uvup_redseq!=0]].size +3)
plt.ylim(0, 65)
plt.rcParams['mathtext.fontset'] = u'stixsans'
plt.savefig('./Figs/maglim_percentageuvup_redseq.pdf')
plt.savefig('./Figs/maglim_percentageuvup_redseq.png')
plt.show()


/home/mldantas/miniconda2/lib/python2.7/site-packages/ipykernel/__main__.py:6: VisibleDeprecationWarning: boolean index did not match indexed array along dimension 0; dimension is 32 but corresponding boolean dimension is 31
/home/mldantas/miniconda2/lib/python2.7/site-packages/ipykernel/__main__.py:12: VisibleDeprecationWarning: boolean index did not match indexed array along dimension 0; dimension is 32 but corresponding boolean dimension is 31

Plot 04: Absolute Magnitude r band x NUV-r


In [17]:
with plt.style.context("seaborn-whitegrid"):
    plt.rcParams["axes.edgecolor"] = "0.15"
    plt.rcParams["axes.linewidth"]  = 1.25
    
    plt.subplots(1,1, figsize=(10,7))
    plt.plot(mag_abs_r[index_all], (nuv_band[index_all]- r_band[index_all]), 'o', color='gray', alpha=0.05, label='All galaxies')
    plt.plot(mag_abs_r[index_uvup], (nuv_band[index_uvup] - r_band[index_uvup]), 'o', color='#e6550d', alpha=0.2, label='UV Upturn')
    sns.kdeplot(mag_abs_r[index_all], (nuv_band[index_all]- r_band[index_all]), n_levels=50, shade=False, 
                cmap="Purples_d", cbar=True)
    plt.xlabel("M$_r$", fontsize=15)
    plt.ylabel("NUV-r", fontsize=15)
    plt.tick_params('both', labelsize='15')
    plt.legend(loc='best', numpoints=100, fontsize=20, frameon=False)
      
    plt.savefig('./Figs/maglim_color_mag01.pdf')
    plt.savefig('./Figs/maglim_color_mag01.png')
    plt.show()


Plot 05: Absolute Magnitude r band x g-r


In [18]:
with plt.style.context("seaborn-whitegrid"):
    plt.rcParams["axes.edgecolor"] = "0.15"
    plt.rcParams["axes.linewidth"]  = 1.25
    
    plt.subplots(1,1, figsize=(10,7))    
    plt.plot(mag_abs_r[index_all], (g_band - r_band)[index_all], 'o', color='gray', alpha=0.05, label='All galaxies')
    plt.plot(mag_abs_r[index_uvup], (g_band - r_band)[index_uvup], 'o', color='#e6550d', alpha=0.2, label='UV Upturn')
    sns.kdeplot(mag_abs_r[index_all], (g_band - r_band)[index_all], n_levels=50, shade=False, 
                        cmap="Purples_d", cbar=True)
    plt.ylim(-1., 4.)
    plt.xlim()
    plt.xlabel("M$_r$", fontsize=15)
    plt.ylabel("g-r", fontsize=15)
    plt.tick_params('both', labelsize='15')
    plt.legend(loc='best', numpoints=100, fontsize=20, frameon=False)
    plt.savefig('./Figs/maglim_color_mag02.pdf')
    plt.savefig('./Figs/maglim_color_mag02.png')
    plt.show()


Plot 06: Analysing the Sersic Index


In [19]:
bins_sersic = np.arange(0, gal_index_h.max(), 0.5)
sns.set_style("white")
plt.subplots(1,1, figsize=(10,7))
plt.hist(gal_index_h[index_rsf][[gal_index_r[index_rsf]<=10]], color='#fec44f', alpha=0.4, bins=bins_sersic, log=True, label='RSF Objects')
plt.hist(gal_index_h[index_redsequence][[gal_index_r[index_redsequence]<=10]], color='#feb24c', alpha=0.8, bins=bins_sersic, log=True, label='Red Sequence objects')
plt.hist(gal_index_h[index_uvup][[gal_index_r[index_uvup]<=10]], color='#f03b20', alpha=0.8, bins=bins_sersic, log=True, label='UV Upturn')
plt.xlabel("Sersic Index (UKIDSS H band)", fontsize=20)
plt.ylabel("Frequency", fontsize=20)
plt.tick_params('both', labelsize='15')
# plt.xlim(0,11)
plt.legend(loc='best', numpoints=1, fontsize=20, frameon=False)
plt.savefig('./Figs/maglim_sersic_dist.pdf')
plt.show()


Plots 07 & 08: SFR and AGE


In [20]:
# bins_sfr = np.arange(0, sfr[index_redsequence].max(), 1E17)
plt.subplots(1,1, figsize=(10,7))
plt.semilogy(redshift[index_redsequence], sfr[index_redsequence], 'o', color='#feb24c', alpha=0.8, label='Red-Sequence')
plt.semilogy(redshift[index_uvup], sfr[index_uvup], 'o', color='#f03b20', alpha=0.6, label='UV Upturn')
plt.legend(loc='best', fontsize=15)
plt.ylabel("SFR", fontsize=20)
plt.xlabel("Redshift", fontsize=20)
plt.tick_params('both', labelsize='15')
plt.xlim(0, 0.45)
plt.ylim(0, 1E8)
plt.show()



In [21]:
print sfr[index_redsequence].max()
print np.average(sfr[index_redsequence])


7.73516e+18
2.15279103771e+15

Magnitudes Distribution


In [22]:
bxplt = {}
bxplt['UV_class']  = uv_class[index_redsequence]
bxplt['MAG_ABS_R'] = mag_abs_r[index_redsequence]
bxplt['redshift'] = redshift[index_redsequence]
bxplt = pd.DataFrame(bxplt)

In [23]:
bins = np.arange(0, (redshift[index_clean]).max(), 0.05)

In [24]:
print bins
bins_average = []
for i in range(bins.size-1):
    bins_average.append(np.average([bins[i+1], bins[i]]))
bins_average = np.array(bins_average)

print bins_average


[ 0.    0.05  0.1   0.15  0.2   0.25  0.3   0.35  0.4   0.45  0.5   0.55
  0.6   0.65  0.7   0.75  0.8   0.85  0.9   0.95  1.    1.05  1.1   1.15
  1.2   1.25  1.3   1.35  1.4   1.45  1.5   1.55]
[ 0.025  0.075  0.125  0.175  0.225  0.275  0.325  0.375  0.425  0.475
  0.525  0.575  0.625  0.675  0.725  0.775  0.825  0.875  0.925  0.975
  1.025  1.075  1.125  1.175  1.225  1.275  1.325  1.375  1.425  1.475
  1.525]

In [90]:
z_cut = pd.cut(bxplt['redshift'], bins = np.array(bins), labels=list(bins[0:-1]))
palette = ['#feb24c', '#f03b20']
plt.subplots(1,1, figsize=(10,7))
plot01 = sns.boxplot(x=z_cut, y='MAG_ABS_R', hue='UV_class', notch=True, palette=palette, data=bxplt, fliersize=4)
plt.setp(plot01.artists, alpha=.8)
handles, _ = plot01.get_legend_handles_labels()
plt.legend(handles, ["UV Weak", "UV Upturn"], fontsize=20)
plt.xlim(0,bins[[ratio_uvup_redseq!=0]].size+1)
plt.ylabel("M$_r$", fontsize=20)
plt.xlabel("Redshift", fontsize=20)
plt.tick_params('both', labelsize='18')
plt.gca().invert_yaxis()
plt.savefig('./Figs/boxplots_legend.png')
plt.savefig('./Figs/boxplots_legend.pdf')
plt.show()


/home/mldantas/miniconda2/lib/python2.7/site-packages/ipykernel/__main__.py:8: VisibleDeprecationWarning: boolean index did not match indexed array along dimension 0; dimension is 32 but corresponding boolean dimension is 31

In [26]:
plt.subplots(1,1, figsize=(10,7))
plt.hist((u_band[index_redsequence]-r_band[index_redsequence]), bins=10, log=True, color='#feb24c', alpha=0.6)
plt.hist((u_band[index_uvup]-r_band[index_uvup]), bins=10, log=True, color='#f03b20', alpha=0.6)
plt.ylabel("Freqency", fontsize=20)
plt.xlabel("u-r", fontsize=20)
plt.tick_params('both', labelsize='15')
plt.show()



In [ ]: