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


/home/mldantas/miniconda2/lib/python2.7/site-packages/matplotlib/font_manager.py:273: UserWarning: Matplotlib is building the font cache using fc-list. This may take a moment.
  warnings.warn('Matplotlib is building the font cache using fc-list. This may take a moment.')

In [2]:
my_environment = np.loadtxt('./myGAMA_ALL_ENVIRONMENT.csv', delimiter=',', dtype=str)

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

In [4]:
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)
stellar_mass    = my_dictionary['MASS_k0'].astype(float)
surface_density = my_dictionary['SurfaceDensity'].astype(float) #in Mpc^-2
gal_density     = my_dictionary['AGEDensity'].astype(float)     #in Mpc^-3

In [5]:
index_uvup        = np.where(((redshift>0.015)*(r_band>0)*(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))
index_rsf         = np.where(((redshift>0.015)*(r_band>0)*(nuv_band>0)*(fuv_band>0)*(nuv_band - r_band) < 5.4)*(fuv_band-nuv_band<50)*(fuv_band-nuv_band>-20))
index_uvweak      = np.where(((redshift>0.015)*(r_band>0)*(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))
index_redsequence = np.where(((redshift>0.015)*(r_band>0)*(nuv_band>0)*(fuv_band>0)*(nuv_band - r_band) > 5.4)*(fuv_band-nuv_band<50)*(fuv_band-nuv_band>-20))

In [6]:
plt.hist(surface_density, bins=50, color='blue')
plt.hist(surface_density[index_uvup], bins=25, color='red')
plt.gca().set_yscale("log")
plt.show()



In [7]:
plt.hist(gal_density, bins=50, color='blue')
plt.hist(gal_density[index_uvup], bins=25, color='red')
plt.gca().set_yscale("log")
plt.show()



In [8]:
sns.set_style("whitegrid")
plt.subplots(1,1, figsize=(10,7))
plt.plot((nuv_band - r_band), (fuv_band - nuv_band), 'o', color = '#fec44f', alpha=0.7)
plt.plot((nuv_band - r_band)[index_redsequence], (fuv_band - nuv_band)[index_redsequence], 'o', color = '#feb24c', alpha=0.7)
plt.plot((nuv_band - r_band)[index_uvup], (fuv_band - nuv_band)[index_uvup], 'o', color = '#f03b20', alpha=0.7)
plt.text(-1, 8, r"RSF", fontsize=15)
plt.text(-1, -1.5, r"RSF", fontsize=15)
plt.text(6, 8, r"UV Weak", fontsize=15)
plt.text(6, -1.5, r"UV upturn", fontsize=15)
plt.axvline(x=5.4, color='black', linewidth=2.)
plt.axhline(y=0.9, color='black', linewidth=2.)
plt.xlabel("NUV-r", fontsize=15)
plt.ylabel("FUV-NUV", fontsize=15)
plt.tick_params('both', labelsize='15')
plt.grid(alpha=0.40)
plt.savefig('./Figs/yi_diagram.pdf', dpi=200)
plt.show()



In [9]:
print nuv_band[index_uvup].size


110

In [10]:
bins = np.arange(0, (redshift).max(), 0.03)
ratio_uvup_redseq = []
average_redshift = []
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]))
        ratio_uvup_redseq.append(ratio_uvup_i)
        average_redshift.append(average_redshift_i)
ratio_uvup_redseq = np.array(ratio_uvup_redseq)
average_redshift  = np.array(average_redshift)
print ratio_uvup_redseq
print average_redshift


[  0.          11.39240506  10.71428571  17.9245283   21.11553785]
[ 0.015  0.045  0.075  0.105  0.135]

In [11]:
plt.hist(redshift, bins=20)
plt.show()



In [12]:
plt.plot(average_redshift, ratio_uvup_redseq, 'o')
plt.show()



In [13]:
%matplotlib notebook

In [14]:
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
plt.scatter((nuv_band - r_band), (fuv_band - nuv_band), gal_density, c= '#fec44f', alpha=0.7)
plt.scatter((nuv_band - r_band)[index_redsequence], (fuv_band - nuv_band)[index_redsequence], gal_density, c = '#feb24c', alpha=0.7)
plt.scatter((nuv_band - r_band)[index_uvup], (fuv_band - nuv_band)[index_uvup], gal_density, c = '#f03b20', alpha=0.7)
plt.show()



In [ ]: