Libraries


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

Dataset


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

In [3]:
print my_data.shape


(41573, 121)

In [4]:
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 [90]:
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)
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)

In [23]:
z_min=0.06
z_max=0.45

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

In [133]:
print fuv_band[index_uvup].size
print fuv_band[index_rsf].size
print fuv_band[index_uvweak].size
print fuv_band.size
print (fuv_band[[z_prob>0.85]].size)


1174
33168
2926
41572
38871

Sérsic Index Characterization


In [25]:
idx_si = indexes[(redshift>=z_min)*(redshift<=z_max)*(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_r>0)*(gal_index_h>0)*(z_prob>0.85)]
# cbar = plt.colorbar(mappable=redshift[idx_si])
plt.subplots(1,1, figsize=(10,7))
# plt.scatter(gal_index_r[idx_si], gal_index_h[idx_si], alpha=0.7, cmap=cbar)
plt.scatter(gal_index_r[idx_si], gal_index_h[idx_si], alpha=0.7, color = '#fdae6b')
plt.xlabel("Sersic Index r band", fontsize=15)
plt.ylabel("Sersic Index H band", fontsize=15)
plt.ylim(0,20)
plt.xlim(0,20)
plt.tick_params('both', labelsize='15')
plt.savefig('./Figs/sex_indexes_galfit.png', dpi=100)
plt.show()



In [26]:
idx_si = indexes[(redshift>z_min)*(redshift<=z_max)*(r_band>0)*(nuv_band>0)*(fuv_band>0)*((fuv_band-nuv_band)<50)*((fuv_band-nuv_band)>(-20))*(sex_index_r>0)*(sex_index_h>0)*(z_prob>0.85)]
plt.subplots(1,1, figsize=(10,7))
plt.plot(sex_index_r[idx_si], sex_index_h[idx_si], 'o', color = '#fdae6b', alpha=0.7)
plt.xlabel("Sersic Index r band", fontsize=15)
plt.ylabel("Sersic Index H band", fontsize=15)
plt.ylim(0,20)
plt.xlim(0,20)
plt.tick_params('both', labelsize='15')
plt.savefig('./Figs/sex_indexes_sextractor.png', dpi=100)
plt.show()



In [27]:
plt.scatter(redshift[idx_si], (sex_index_r[idx_si]-sex_index_h[idx_si]), color='#feb24c', alpha=0.7)
plt.ylabel("Sersic Index r band - Sersic Index H band \n (SEXTRACTOR)", fontsize=15)
plt.xlabel("Redshift", fontsize=15)
plt.axhline(y=0.0, color='black', linewidth=1.5)
plt.show()



In [31]:
plt.scatter(redshift[idx_si], (sex_index_r[idx_si]-sex_index_h[idx_si]), color='#feb24c', alpha=0.7)
plt.ylabel("Sersic Index r band - Sersic Index H band", fontsize=15)
plt.xlabel("Redshift", fontsize=15)
plt.axhline(y=0.0, color='black', linewidth=1.5)
plt.ylim(-20, 20)
# plt.xlim(-0.05, 0.5)
plt.title(r"Sersic Indexes Residuals - SEXTRACTOR")
plt.savefig('./Figs/res_sextractor.png')
plt.show()



In [33]:
plt.scatter(redshift[idx_si], (gal_index_r[idx_si]-gal_index_h[idx_si]), color='#feb24c', alpha=0.7)
plt.ylabel("Sersic Index r band - Sersic Index H band", fontsize=15)
plt.xlabel("Redshift", fontsize=15)
plt.axhline(y=0.0, color='black', linewidth=1.5)
plt.ylim(-20, 20)
# plt.xlim(-0.05, 0.5)
plt.title(r"Sersic Indexes Residuals - GALFIT")
plt.savefig('./Figs/res_galfit.png')
plt.show()



In [36]:
plt.scatter(redshift[idx_si], (gal_index_r[idx_si]-sex_index_r[idx_si]), color='#feb24c', alpha=0.7)
plt.ylabel("r diff - GALFIT-SEXTRACTOR", fontsize=15)
plt.xlabel("Redshift", fontsize=15)
plt.axhline(y=0.0, color='black', linewidth=1.5)
plt.ylim(-20, 20)
# plt.xlim(-0.05, 0.5)
# plt.title(r"Sersic Indexes Residuals - GALFIT")
# plt.savefig('./Figs/res_galfit.png')
plt.show()



In [37]:
plt.scatter(redshift[idx_si], (gal_index_h[idx_si]-sex_index_h[idx_si]), color='#feb24c', alpha=0.7)
plt.ylabel("r diff - GALFIT-SEXTRACTOR", fontsize=15)
plt.xlabel("Redshift", fontsize=15)
plt.axhline(y=0.0, color='black', linewidth=1.5)
plt.ylim(-20, 20)
# plt.xlim(-0.05, 0.5)
# plt.title(r"Sersic Indexes Residuals - GALFIT")
# plt.savefig('./Figs/res_galfit.png')
plt.show()



In [88]:
bins = np.arange(0, (gal_index_h[idx_si]).max(), 1)
plt.hist(gal_index_h[idx_si], color='#1b9e77', alpha=0.7, bins=bins, label='GALFIT')
plt.hist(sex_index_h[idx_si], color='#feb24c', alpha=0.7, bins=bins, label='SEXTRACTOR')
plt.xlim(0, (gal_index_h[idx_si]).max())
plt.xlabel("H band", fontsize=15)
plt.ylabel("Frequency", fontsize=15)
plt.legend(loc='best')
plt.savefig('./Figs/hband_dist.png')
plt.show()



In [86]:
plt.boxplot?

In [66]:
bins = np.arange(0, (redshift[idx_si]).max(), 0.05)
print bins

for i in range(bins.size):
    plt.boxplot((gal_index_h[idx_si]-sex_index_h[idx_si]), sym='o')
    plt.ylim(-5,5)
    plt.show()


[ 0.    0.05  0.1   0.15  0.2   0.25  0.3   0.35  0.4 ]

Caracterizing the UV emission of these galaxies


In [29]:
index_uvup        = np.where(((redshift>0.015)*(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)*(z_prob>0.85))
index_rsf         = np.where(((redshift>0.015)*(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)*(z_prob>0.85))
index_uvweak      = np.where(((redshift>0.015)*(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)*(z_prob>0.85))
index_redsequence = np.where(((redshift>0.015)*(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)*(z_prob>0.85))

In [30]:
print fuv_band[index_uvup].size
print fuv_band[index_rsf].size
print fuv_band[index_uvweak].size
print fuv_band.size
print (fuv_band[[z_prob>0.85]].size)


1174
33168
2926
41572
38871

Volume Limited Sample


In [96]:
index_vl_mag = indexes[(redshift>=z_min)*(redshift<=0.2)*(mag_abs_r<=(-21))*(r_band>0*(r_band<19.8)*(nuv_band>0)*(fuv_band>0)*((fuv_band-nuv_band)<50)*((fuv_band-nuv_band)>(-20)))]

In [99]:
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.axhline(y=3E10, color='black', linewidth=1.)
# plt.axvline(x=0.2, color='black', linewidth=1.)
# plt.axvline(x=0.015, color='black', linewidth=1.)
# 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.ylim(1E6, 1E12)
plt.grid(alpha=0.40)
plt.gca().invert_yaxis()
# plt.savefig('./Figs/mag_z_uvcategories_zoom.pdf')
# plt.savefig('./Figs/mag_z_uvcategories_zoom.png')
plt.show()



In [127]:
bins = np.arange(0, (redshift[index_clean]).max(), 0.05)
ratio_uvup_redseq = []
average_redshift = []
redshift_uvup = redshift[index_uvup]
# mag_abs_max = []
z_uv = []
z_rs = []
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:
#             mag_abs_max_i = mag_abs_r[index_redseq_i].max()
#             mag_abs_max.append(mag_abs_max_i)  
            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)        
z_uv = np.array(z_uv)
z_rs = np.array(z_rs)
ratio_uvup_redseq = np.array(ratio_uvup_redseq)
average_redshift  = np.array(average_redshift)
# mag_abs_max = np.array(mag_abs_max)
print ratio_uvup_redseq
print average_redshift, average_redshift.size
# print mag_abs_min, mag_abs_min.size


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
[  8.75        14.81103166  24.25629291  34.60648148  44.79166667
  50.75528701  59.25925926  31.03448276  20.           0.           0.           0.
   0.           0.           0.           0.           0.           0.           0.
   0.           0.           0.           0.           0.           0.           0.
   0.           0.           0.           0.           0.        ]
[ 0.025  0.075  0.125  0.175  0.225  0.275  0.325  0.375  0.425  0.625
  0.675] 11

In [124]:
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, width=1., alpha=0.7, color='#e6550d', edgecolor='#e6550d')
for i in range(9):
    plt.text(index[i]-.4, ratio_uvup_redseq[i]+1, r"%d/%d" % (z_uv[i], z_rs[i]))
plt.xticks(index, bins)
plt.ylabel("% of UV Upturn Galaxies", fontsize=15)
plt.xlabel("Redshift Ranges", fontsize=15)
plt.tick_params('both', labelsize='15')
plt.xlim(0, 10)
plt.ylim(0, 65)
# plt.grid(alpha=0.40)
plt.savefig('./Figs/percentageuvup_redseq.pdf')
plt.savefig('./Figs/percentageuvup_redseq.png')
plt.show()



In [128]:
redshift_bins = np.arange(0, (redshift[index_redsequence]).max(), 0.05)

In [129]:
print redshift_bins


[ 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]

In [132]:
mag_r_rs = mag_abs_r[index_redsequence]
print mag_r_rs.size
mag_abs_r_max = []
for i in range (redshift_bins.size):
    if i==0:
        continue
    else:
        index_i = np.where((redshift[index_redsequence]<=redshift_bins[i])*(redshift[index_redsequence]>=redshift_bins[i-1]))
        mag_abs_r_max_i = mag_r_rs[index_i].max()
    mag_abs_r_max.append(mag_abs_r_max_i)
mag_abs_r_max  = np.array(mag_abs_r_max)


4146
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-132-d71e00d84e5d> in <module>()
      7     else:
      8         index_i = np.where((redshift[index_redsequence]<=redshift_bins[i])*(redshift[index_redsequence]>=redshift_bins[i-1]))
----> 9         mag_abs_r_max_i = mag_r_rs[index_i].max()
     10     mag_abs_r_max.append(mag_abs_r_max_i)
     11 mag_abs_r_max  = np.array(mag_abs_r_max)

/usr/local/lib/python2.7/dist-packages/numpy/core/_methods.pyc in _amax(a, axis, out, keepdims)
     24 # small reductions
     25 def _amax(a, axis=None, out=None, keepdims=False):
---> 26     return umr_maximum(a, axis, None, out, keepdims)
     27 
     28 def _amin(a, axis=None, out=None, keepdims=False):

ValueError: zero-size array to reduction operation maximum which has no identity

In [ ]: