In [1]:
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
In [2]:
my_data = np.loadtxt('./myGAMA_ALL_AB_ABSOL_MAGS_clean_postprocess.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 [90]:
cataid = my_dictionary['CATAID'].astype(int)
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)
sex_index_r = my_dictionary['SEX_INDEX_R'].astype(float) #SEx Sérsic Index
gal_index_r = my_dictionary['GAL_INDEX_R'].astype(float) #Galfit Sérsic Index
uv_class = my_dictionary['UV_CLASS_YI2011'].astype(str)
In [91]:
sex_clean = sex_index_r[[(sex_index_r!=-9999.)*(gal_index_r!=-9999.)*(sex_index_r<=10)*(gal_index_r<=10)]]
gal_clean = gal_index_r[[(sex_index_r!=-9999.)*(gal_index_r!=-9999.)*(sex_index_r<=10)*(gal_index_r<=10)]]
redshift_clean = redshift[[(sex_index_r!=-9999.)*(gal_index_r!=-9999.)*(sex_index_r<=10)*(gal_index_r<=10)]]
fuv_band_clean = fuv_band[[(sex_index_r!=-9999.)*(gal_index_r!=-9999.)*(sex_index_r<=10)*(gal_index_r<=10)]]
nuv_band_clean = nuv_band[[(sex_index_r!=-9999.)*(gal_index_r!=-9999.)*(sex_index_r<=10)*(gal_index_r<=10)]]
r_band_clean = r_band[[(sex_index_r!=-9999.)*(gal_index_r!=-9999.)*(sex_index_r<=10)*(gal_index_r<=10)]]
cataid_clean = cataid[[(sex_index_r!=-9999.)*(gal_index_r!=-9999.)*(sex_index_r<=10)*(gal_index_r<=10)]]
uv_class_clean = uv_class[[(sex_index_r!=-9999.)*(gal_index_r!=-9999.)*(sex_index_r<=10)*(gal_index_r<=10)]]
In [60]:
print r_band_clean.size
print sex_clean.size
In [39]:
index_uvup = np.where(((redshift_clean>0.015)*(r_band_clean>0)*(nuv_band_clean>0)*(fuv_band_clean>0)*(nuv_band_clean - r_band_clean) > 5.4)*(fuv_band_clean-nuv_band_clean<0.9)*(fuv_band_clean - r_band_clean<6.6)*(fuv_band_clean-nuv_band_clean<50)*(fuv_band_clean-nuv_band_clean>-20))
index_rsf = np.where(((redshift_clean>0.015)*(r_band_clean>0)*(nuv_band_clean>0)*(fuv_band_clean>0)*(nuv_band_clean - r_band_clean) < 5.4)*(fuv_band_clean-nuv_band_clean<50)*(fuv_band_clean-nuv_band_clean>-20))
index_uvweak = np.where(((redshift_clean>0.015)*(r_band_clean>0)*(nuv_band_clean>0)*(fuv_band_clean>0)*(nuv_band_clean - r_band_clean) > 5.4)*((fuv_band_clean - r_band_clean)>6.6)*(fuv_band_clean-nuv_band_clean<50)*(fuv_band_clean-nuv_band_clean>-20))
index_redsequence = np.where(((redshift_clean>0.015)*(r_band_clean>0)*(nuv_band_clean>0)*(fuv_band_clean>0)*(nuv_band_clean - r_band_clean) > 5.4)*(fuv_band_clean-nuv_band_clean<50)*(fuv_band_clean-nuv_band_clean>-20))
In [29]:
plt.hist(sex_clean, bins=50)
# plt.gca().set_yscale("log")
plt.show()
In [30]:
plt.hist(gal_clean, bins=50)
# plt.gca().set_yscale("log")
plt.show()
In [31]:
gal_clean_df = pd.DataFrame(gal_clean)
sex_clean_df = pd.DataFrame(gal_clean)
In [32]:
plt.subplot(1,2,1)
sns.violinplot(y=gal_clean)
plt.subplot(1,2,2)
sns.violinplot(y=sex_clean)
plt.show()
In [33]:
plt.plot(gal_clean, sex_clean, '.', alpha=.1, markersize=15)
plt.show()
In [35]:
plt.plot(gal_clean, stellar_mass[[(sex_index_r!=-9999.)*(gal_index_r!=-9999.)*(sex_index_r<=10)*(gal_index_r<=10)]], 'o')
plt.gca().set_yscale("log")
plt.show()
In [83]:
marker_size_all = gal_clean**3
marker_size_red = gal_clean[index_redsequence]**3
marker_size_uvu = gal_clean[index_uvup]**3
In [84]:
print type(gal_clean)
In [86]:
sns.set_style("whitegrid")
plt.subplots(1,1, figsize=(10,7))
plt.scatter((nuv_band_clean - r_band_clean), (fuv_band_clean - nuv_band_clean), c= '#fec44f', alpha=0.4, s=gal_clean)
plt.scatter((nuv_band_clean - r_band_clean)[index_redsequence], (fuv_band_clean - nuv_band_clean)[index_redsequence], color = '#feb24c', alpha=0.4, s=marker_size_red)
plt.scatter((nuv_band_clean - r_band_clean)[index_uvup], (fuv_band_clean - nuv_band_clean)[index_uvup], color = '#f03b20', alpha=0.4, s=marker_size_uvu)
plt.xlim(-6,10)
plt.text(-5, 8, r"RSF", fontsize=20)
plt.text(-5, -3, r"RSF", fontsize=20)
plt.text(7, 8, r"UV Weak", fontsize=20)
plt.text(7, -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='20')
plt.grid(alpha=0.40)
plt.savefig('./Figs/yi_diagram_gal.pdf', dpi=100)
plt.show()
In [93]:
print uv_class_clean[1:100]
In [94]:
logit_class = []
for i in range (cataid_clean[index_redsequence].size):
if uv_class_clean[index_redsequence][i] == 'UV_UPTURN':
logit_class_i = int(1)
else:
logit_class_i = int(0)
logit_class.append(logit_class_i)
logit_class = np.array(logit_class)
In [87]:
logit_dataset = {}
In [95]:
logit_dataset['CATAID'] = cataid_clean[index_redsequence]
logit_dataset['LOGIT_CLASS(1-UVUP;0-UVWEAK)'] = logit_class
logit_dataset['SERSIC_GALFIT'] = gal_clean[index_redsequence]
logit_dataset['SERSIC_SEXTRACTOR'] = sex_clean[index_redsequence]
logit_dataset['REDSHIFT'] = redshift_clean[index_redsequence]
In [96]:
logit_df = pd.DataFrame(logit_dataset)
In [97]:
logit_df.to_csv('./logit_3d_dataset.csv', sep=',', header=True, index=False)
In [98]:
print logit_class.size
In [103]:
from mpl_toolkits.mplot3d import Axes3D
In [104]:
%matplotlib notebook
In [108]:
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
plt.scatter(redshift_clean[index_redsequence], logit_class, gal_clean[index_redsequence], c = '#feb24c', alpha=0.7)
plt.scatter(redshift_clean[index_uvup], logit_class[[logit_class==1]], gal_clean[index_uvup], c = '#f03b20', alpha=0.7)
ax.set_xlabel("Redshift", fontsize=15)
ax.set_ylabel("Logit Class", fontsize=15)
ax.set_zlabel("Sersic Index", fontsize=15)
plt.show()
In [ ]: