In [1]:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
In [2]:
# %matplotlib notebook
In [3]:
my_data = np.loadtxt('../Catalogue/Match07_smalldoubleclean_emlines.csv', delimiter=',', dtype=str)
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 [5]:
print my_data.shape
print my_data.size
print my_data[0,:]
In [6]:
redshift = my_dictionary['Z'].astype(float)
cataid = my_dictionary['CATAID'].astype(str)
z_prob = my_dictionary['PROB'].astype(float)
z_quality = my_dictionary['NQ'].astype(int)
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['logmstar'].astype(float) # stellar mass from sed fitting - log scale
stellar_age = my_dictionary['logage'].astype(float) # stellar age - log scale
stellar_met = my_dictionary['metal'].astype(float) # stellar metallicity
dn4000 = my_dictionary['D4000N'].astype(float)
h_alpha_flux = my_dictionary['HA_FLUX_COMP'].astype(float)
h_alpha_ew = my_dictionary['HA_EW_COMP'].astype(float)
h_beta_flux = my_dictionary['HB_FLUX_COMP'].astype(float)
h_beta_ew = my_dictionary['HB_EW_COMP'].astype(float)
nii_flux = my_dictionary['NIIR_FLUX_COMP'].astype(float) # R for red or 6583A -- see http://www.gama-survey.org/dr3/schema/dmu.php?id=8
oiii_flux = my_dictionary['OIIIR_EW_COMP'].astype(float) # R for red or 5007A -- see http://www.gama-survey.org/dr3/schema/dmu.php?id=8
uv_class = my_dictionary['UV_CLASS_YI2011'].astype(str)
whan_class = my_dictionary['WHAN_CLASS'].astype(str)
In [7]:
print np.unique(uv_class)
print np.unique(whan_class)
In [8]:
print my_data[:,0].shape
In [9]:
idx_uvup = np.where(uv_class=='UV_UPTURN')
idx_uvwk = np.where(uv_class=='UV_WEAK')
idx_redseq = list(idx_uvup[0]) + list(idx_uvwk[0])
In [10]:
bins = np.arange(0, (redshift[idx_uvup]).max(), 0.05)
average_redshift = []
z_uvup_all = []
z_sf = []
z_sa = []
z_wa = []
z_rp = []
z_na = []
ratio_sf = []
ratio_wa = []
ratio_sa = []
ratio_rp = []
ratio_na = []
z_uvup = redshift[idx_uvup]
z_sf = z_uvup[np.where(whan_class[idx_uvup]=='SF')]
z_sa = z_uvup[np.where(whan_class[idx_uvup]=='sAGN')]
z_wa = z_uvup[np.where(whan_class[idx_uvup]=='wAGN')]
z_rp = z_uvup[np.where(whan_class[idx_uvup]=='Retired/Passive')]
z_na = z_uvup[np.where(whan_class[idx_uvup]=='NA')]
In [11]:
for i in range(bins.size):
if i==0:
continue
else:
index_uvup_i = np.where((bins[i-1]<=z_uvup)*(z_uvup<=bins[i]))
index_sf_i = np.where((bins[i-1]<=z_sf)*(z_sf<=bins[i]))
index_sa_i = np.where((bins[i-1]<=z_sa)*(z_sa<=bins[i]))
index_wa_i = np.where((bins[i-1]<=z_wa)*(z_wa<=bins[i]))
index_rp_i = np.where((bins[i-1]<=z_rp)*(z_rp<=bins[i]))
index_na_i = np.where((bins[i-1]<=z_na)*(z_na<=bins[i]))
z_bin_uvup = z_uvup[index_uvup_i]
z_bin_sf = z_sf[index_sf_i]
z_bin_sa = z_sa[index_sa_i]
z_bin_wa = z_wa[index_wa_i]
z_bin_rp = z_rp[index_rp_i]
z_bin_na = z_na[index_na_i]
if (z_bin_uvup.size==0):
ratio_sf_i = 0
ratio_sa_i = 0
ratio_wa_i = 0
ratio_rp_i = 0
ratio_na_i = 0
print "There are no UV Upturn galaxies in this range of redshift: %.2f and %.2f" % (bins[i-1], bins[i])
else:
ratio_sf_i = (np.float(z_bin_sf.size)/np.float(z_bin_uvup.size))*100
ratio_sa_i = (np.float(z_bin_sa.size)/np.float(z_bin_uvup.size))*100
ratio_wa_i = (np.float(z_bin_wa.size)/np.float(z_bin_uvup.size))*100
ratio_rp_i = (np.float(z_bin_rp.size)/np.float(z_bin_uvup.size))*100
ratio_na_i = (np.float(z_bin_na.size)/np.float(z_bin_uvup.size))*100
ratio_sf.append(ratio_sf_i)
ratio_sa.append(ratio_sa_i)
ratio_wa.append(ratio_wa_i)
ratio_rp.append(ratio_rp_i)
ratio_na.append(ratio_na_i)
ratio_sf = np.array(ratio_sf)
ratio_sa = np.array(ratio_sa)
ratio_wa = np.array(ratio_wa)
ratio_rp = np.array(ratio_rp)
ratio_na = np.array(ratio_na)
In [12]:
%matplotlib notebook
In [13]:
palette = ['#018571', '#80cdc1', '#dfc27d', '#a6611a', 'gray']
alphas = float(0.85)
In [14]:
n_groups = bins.size
index = np.arange(1, n_groups, 1)
index2 = np.arange(0, index.max()+4, 2)
bins2 = np.arange(0., bins.max(), 0.1)
sns.set_style('white')
plt.rcParams["axes.edgecolor"] = "0.15"
plt.rcParams["axes.linewidth"] = 1.
plt.rcParams['mathtext.fontset'] = u'stixsans'
ylims = [0.0, 55.]
xlims = [0.05, 0.35]
plt.subplots(1,1, figsize=(10,3))
ax1=plt.subplot(1,5,1)
plt.bar(index, ratio_sf, width=1., alpha=alphas, color=palette[0], edgecolor=palette[0], linewidth=2.,
label='WHAN\'s SF')
plt.ylabel("% of Galaxies", fontsize=15)
plt.title('WHAN\'s SF')
plt.ylim(ylims)
plt.xlim(xlims)
plt.xticks(index2, bins2)
plt.yticks(list(np.arange(ylims[0], ylims[1], 10)))
plt.tick_params('both', labelsize='13')
ax2=plt.subplot(1,5,2)
plt.bar(index, ratio_sa, width=1., alpha=alphas, color=palette[1], edgecolor=palette[1], linewidth=2.,
label='WHAN\'s sAGN')
plt.title('WHAN\'s sAGN')
ax2.yaxis.set_visible(False)
plt.ylim(ylims)
plt.xlim(xlims)
plt.xticks(index2, bins2)
plt.tick_params('both', labelsize='13')
ax3=plt.subplot(1,5,3)
plt.bar(index, ratio_wa, width=1., alpha=alphas, color=palette[2], edgecolor=palette[2], linewidth=2.,
label='WHAN\'s wAGN')
plt.title('WHAN\'s wAGN')
ax3.yaxis.set_visible(False)
plt.ylim(ylims)
plt.xlim(xlims)
plt.xticks(index2, bins2)
plt.tick_params('both', labelsize='13')
plt.xlabel("Redshift", fontsize=14)
ax4=plt.subplot(1,5,4)
plt.bar(index, ratio_rp, width=1., alpha=alphas, color=palette[3], edgecolor=palette[3], linewidth=2.,
label='WHAN\'s R/P')
plt.title('WHAN\'s R/P')
ax4.yaxis.set_visible(False)
plt.ylim(ylims)
plt.xlim(xlims)
plt.xticks(index2, bins2)
plt.tick_params('both', labelsize='13')
ax5=plt.subplot(1,5,5)
plt.bar(index, ratio_na, width=1., alpha=alphas, color=palette[4], edgecolor=palette[4], linewidth=2.,
label='Not classified')
plt.title('Not classified')
ax5.yaxis.set_visible(False)
plt.ylim(ylims)
plt.xlim(xlims)
plt.xticks(index2, bins2)
plt.tick_params('both', labelsize='13')
plt.tight_layout(w_pad=0.5)
plt.savefig('./../Figs/g2_barplot_propuv.png')
plt.savefig('./../Figs/g2_barplot_propuv.pdf')
plt.show()
In [15]:
print index
print bins
In [16]:
index2 = np.arange(0, index.max()+2, 2)
bins2 = np.arange(0, bins.max()+0.2, 0.1)
In [17]:
print index2
print bins2
In [18]:
list(np.arange(ylims[0], ylims[1], 10))
Out[18]:
In [ ]: