def plot(): plslp1 = 0.71 plslp2 = 0.05 plbrk = 2679.92 bbt = 1158.99 bbflxnrm = 0.25 galfra = 0.89 elscal = 0.72 imod = 18.0 scahal = 1.0 with open('input.yml', 'r') as f: parfile = yaml.load(f) # Load stuff fittingobj = load(parfile) wavlen = fittingobj.get_wavlen() flxcorr = np.array([1.0] * len(wavlen)) ik0, ik1, ik2 = [], [], [] zs = np.arange(2,4.01,0.01) for z in zs: print z magtmp, wavlentmp1, fluxtmp1 = model(plslp1, plslp2, plbrk, bbt, bbflxnrm, elscal, scahal, galfra, 0.0, imod, z, fittingobj, flxcorr, parfile) ik0.append( magtmp[3] - magtmp[8] ) magtmp, wavlentmp1, fluxtmp1 = model(plslp1, plslp2, plbrk, bbt, bbflxnrm, elscal, scahal, galfra, 0.1, imod, z, fittingobj, flxcorr, parfile) ik1.append( magtmp[3] - magtmp[8] ) magtmp, wavlentmp1, fluxtmp1 = model(plslp1, plslp2, plbrk, bbt, bbflxnrm, elscal, scahal, galfra, 0.2, imod, z, fittingobj, flxcorr, parfile) ik2.append( magtmp[3] - magtmp[8] ) datmag, sigma, datz, name, snr = loaddatraw('DR10', '/data/lc585/SDSS/DR10QSO_AllWISE_matched.v2.fits', True, 0, 23.0, 15.0, False, 0.1) fig = plt.figure(figsize=figsize(0.7)) ax = fig.add_subplot(111) ax.plot(zs,ik0,color='black',linewidth=2, zorder=1) ax.plot(zs,ik1,color='black',linewidth=2, zorder=1) ax.plot(zs,ik2,color='black',linewidth=2, zorder=1) ax.plot(datz, datmag[:,3] - datmag[:,8], marker='o', markersize=2, alpha=0.5, markeredgecolor='none', markerfacecolor='gray', linestyle='', zorder=0) textprops = dict(fontsize=10,ha='left',va='center', zorder=1, color='red') ax.text(3.5,0.646,'E(B-V) = 0.0', **textprops) ax.text(3.5,1.455,'E(B-V) = 0.1', **textprops) ax.text(3.5,2.285,'E(B-V) = 0.2', **textprops) ax.set_xlim(2,4) ax.set_ylim(-2,4) ax.set_xlabel(r'Redshift $z$') ax.set_ylabel(r'$i - K$') fig.tight_layout() fig.savefig('/home/lc585/thesis/figures/chapter06/ik_versus_z_high_ext.pdf') plt.show() return None
def plot(): tab = Table.read('/data/lc585/QSOSED/Results/141203/sample1/out_add.fits') tab = tab[tab['BBT_STDERR'] < 200.0] tab = tab[tab['BBFLXNRM_STDERR'] < 0.05] tab = tab[tab['CHI2_RED'] < 3.0] tab = tab[tab['LUM_IR'] > 40.0] # just gets rid of one annoying point mycm = cm.get_cmap('YlOrRd_r') mycm.set_under('w') cset = brewer2mpl.get_map('YlOrRd', 'sequential', 9).mpl_colors mycm = truncate_colormap(mycm, 0.0, 0.8) set_plot_properties() # change style fig = plt.figure(figsize=figsize(1.5, 0.7)) gs = gridspec.GridSpec(9, 13) ax1 = fig.add_subplot(gs[1:5, 0:4]) ax2 = fig.add_subplot(gs[5:, 0:4]) ax3 = fig.add_subplot(gs[0, 0:4]) ax4 = fig.add_subplot(gs[1:5, 4:8]) ax5 = fig.add_subplot(gs[5:, 4:8]) ax6 = fig.add_subplot(gs[0, 4:8]) ax7 = fig.add_subplot(gs[1:5, 8:12]) ax8 = fig.add_subplot(gs[5:, 8:12]) ax9 = fig.add_subplot(gs[0, 8:12]) ax10 = fig.add_subplot(gs[1:5, 12]) ax11 = fig.add_subplot(gs[5:, 12]) fig.subplots_adjust(wspace=0.0) fig.subplots_adjust(hspace=0.0) #histogram definition xyrange = [[44, 48], [0, 2]] # data range bins = [80, 40] # number of bins thresh = 4 #density threshold #data definition xdat, ydat = tab['LUM_UV'], tab['RATIO_IR_UV'] # histogram the data hh, locx, locy = histogram2d(xdat, ydat, range=xyrange, bins=bins) posx = np.digitize(xdat, locx) posy = np.digitize(ydat, locy) #select points within the histogram ind = (posx > 0) & (posx <= bins[0]) & (posy > 0) & (posy <= bins[1]) hhsub = hh[posx[ind] - 1, posy[ind] - 1] # values of the histogram where the points are xdat1 = xdat[ind][hhsub < thresh] # low density points ydat1 = ydat[ind][hhsub < thresh] hh[hh < thresh] = np.nan # fill the areas with low density by NaNs im = ax1.imshow(np.flipud(hh.T), cmap=mycm, extent=np.array(xyrange).flatten(), interpolation='none', aspect='auto', vmin=thresh, vmax=45) ax1.scatter(xdat1, ydat1, color=cset[-1]) ax1.set_ylabel(r'$R_{{\rm NIR}/{\rm UV}}$', fontsize=14) ax1.set_ylim(0., 2.) ax1.set_xlim(45.25, 47) ax3.hist(tab['LUM_UV'], color=cset[-1], bins=20) ax3.set_xlim(ax1.get_xlim()) ax3.set_axis_off() #histogram definition xyrange = [[44, 48], [200, 2000]] # data range bins = [90, 35] # number of bins thresh = 4 #density threshold #data definition xdat, ydat = tab['LUM_UV'], tab['BBT'] # histogram the data hh, locx, locy = histogram2d(xdat, ydat, range=xyrange, bins=bins) posx = np.digitize(xdat, locx) posy = np.digitize(ydat, locy) #select points within the histogram ind = (posx > 0) & (posx <= bins[0]) & (posy > 0) & (posy <= bins[1]) hhsub = hh[posx[ind] - 1, posy[ind] - 1] # values of the histogram where the points are xdat1 = xdat[ind][hhsub < thresh] # low density points ydat1 = ydat[ind][hhsub < thresh] hh[hh < thresh] = np.nan # fill the areas with low density by NaNs im = ax2.imshow(np.flipud(hh.T), cmap=mycm, extent=np.array(xyrange).flatten(), interpolation='none', aspect='auto', vmin=thresh, vmax=45) ax2.scatter(xdat1, ydat1, color=cset[-1]) ax2.set_xlabel(r'Log$_{10} (L_{\rm UV} ({\rm erg/s}))$', fontsize=14) ax2.set_ylabel(r'$T_{\mathrm{BB}}$', fontsize=14) ax2.set_xlim(ax1.get_xlim()) ax2.set_ylim(500, 2100) plt.tick_params(axis='both', which='major', labelsize=10) ax1.get_xaxis().set_ticks([]) ax2.get_yaxis().set_ticks([600, 800, 1000, 1200, 1400, 1600, 1800, 2000]) ax2.get_xaxis().set_ticks([45.4, 45.6, 45.8, 46.0, 46.2, 46.4, 46.6, 46.8]) ############################################################################# #histogram definition xyrange = [[7.5, 10.5], [0, 2]] # data range bins = [30, 30] # number of bins thresh = 4 #density threshold #data definition xdat, ydat = tab['LOGBH'], tab['RATIO_IR_UV'] # histogram the data hh, locx, locy = histogram2d(xdat, ydat, range=xyrange, bins=bins) posx = np.digitize(xdat, locx) posy = np.digitize(ydat, locy) #select points within the histogram ind = (posx > 0) & (posx <= bins[0]) & (posy > 0) & (posy <= bins[1]) hhsub = hh[posx[ind] - 1, posy[ind] - 1] # values of the histogram where the points are xdat1 = xdat[ind][hhsub < thresh] # low density points ydat1 = ydat[ind][hhsub < thresh] hh[hh < thresh] = np.nan # fill the areas with low density by NaNs im = ax4.imshow(np.flipud(hh.T), cmap=mycm, extent=np.array(xyrange).flatten(), interpolation='none', aspect='auto', vmin=thresh, vmax=45) ax4.scatter(xdat1, ydat1, color=cset[-1]) ax4.set_ylim(ax1.get_ylim()) ax4.set_xlim(7.5, 10.5) ax4.set_xticklabels([]) ax4.set_yticklabels([]) ax6.hist(tab[tab['LOGBH'] > 6]['LOGBH'], color=cset[-1], bins=20) ax6.set_xlim(ax4.get_xlim()) ax6.set_axis_off() #histogram definition xyrange = [[7.5, 10.5], [500, 2000]] # data range bins = [50, 30] # number of bins thresh = 4 #density threshold #data definition xdat, ydat = tab['LOGBH'], tab['BBT'] # histogram the data hh, locx, locy = histogram2d(xdat, ydat, range=xyrange, bins=bins) posx = np.digitize(xdat, locx) posy = np.digitize(ydat, locy) #select points within the histogram ind = (posx > 0) & (posx <= bins[0]) & (posy > 0) & (posy <= bins[1]) hhsub = hh[posx[ind] - 1, posy[ind] - 1] # values of the histogram where the points are xdat1 = xdat[ind][hhsub < thresh] # low density points ydat1 = ydat[ind][hhsub < thresh] hh[hh < thresh] = np.nan # fill the areas with low density by NaNs im = ax5.imshow(np.flipud(hh.T), cmap=mycm, extent=np.array(xyrange).flatten(), interpolation='none', aspect='auto', vmin=thresh, vmax=45) ax5.scatter(xdat1, ydat1, color=cset[-1]) ax5.set_xlabel(r'Log$_{10}$ (Black Hole Mass $M_{\rm BH}$)') ax5.set_yticklabels([]) # ax5.hist(tab['BBT'], orientation='horizontal',color=cset[-1],bins=20) # ax5.set_ylim(ax2.get_ylim()) # ax5.set_axis_off() plt.tick_params(axis='both', which='major') ax4.set_ylim(ax1.get_ylim()) ax5.set_ylim(ax2.get_ylim()) ax5.set_xlim(ax4.get_xlim()) ax6.hist(tab['LOGBH'][tab['LOGBH'] > 6], color=cset[-1], bins=20) ax6.set_xlim(ax5.get_xlim()) ax6.set_axis_off() ###################################################################################### #histogram definition xyrange = [[-2, 0.5], [0, 2]] # data range bins = [30, 30] # number of bins thresh = 4 #density threshold #data definition xdat, ydat = tab['LOGEDD_RATIO'], tab['RATIO_IR_UV'] # histogram the data hh, locx, locy = histogram2d(xdat, ydat, range=xyrange, bins=bins) posx = np.digitize(xdat, locx) posy = np.digitize(ydat, locy) #select points within the histogram ind = (posx > 0) & (posx <= bins[0]) & (posy > 0) & (posy <= bins[1]) hhsub = hh[posx[ind] - 1, posy[ind] - 1] # values of the histogram where the points are xdat1 = xdat[ind][hhsub < thresh] # low density points ydat1 = ydat[ind][hhsub < thresh] hh[hh < thresh] = np.nan # fill the areas with low density by NaNs im = ax7.imshow(np.flipud(hh.T), cmap=mycm, extent=np.array(xyrange).flatten(), interpolation='none', aspect='auto', vmin=thresh, vmax=45) ax7.scatter(xdat1, ydat1, color=cset[-1]) ax7.set_ylim(ax1.get_ylim()) ax7.set_xlim(-2, 0.5) ax9.hist(tab[tab['LOGEDD_RATIO'] > -2.5]['LOGEDD_RATIO'], color=cset[-1], bins=20) ax9.set_xlim(ax7.get_xlim()) ax9.set_axis_off() #histogram definition xyrange = [[-2, 0.5], [500, 2000]] # data range bins = [50, 30] # number of bins thresh = 4 #density threshold #data definition xdat, ydat = tab['LOGEDD_RATIO'], tab['BBT'] # histogram the data hh, locx, locy = histogram2d(xdat, ydat, range=xyrange, bins=bins) posx = np.digitize(xdat, locx) posy = np.digitize(ydat, locy) #select points within the histogram ind = (posx > 0) & (posx <= bins[0]) & (posy > 0) & (posy <= bins[1]) hhsub = hh[posx[ind] - 1, posy[ind] - 1] # values of the histogram where the points are xdat1 = xdat[ind][hhsub < thresh] # low density points ydat1 = ydat[ind][hhsub < thresh] hh[hh < thresh] = np.nan # fill the areas with low density by NaNs im = ax8.imshow(np.flipud(hh.T), cmap=mycm, extent=np.array(xyrange).flatten(), interpolation='none', aspect='auto', vmin=thresh, vmax=45) ax8.scatter(xdat1, ydat1, color=cset[-1]) axcb = fig.add_axes([0.33, 0.05, 0.33, 0.02]) clb = fig.colorbar(im, cax=axcb, orientation='horizontal') clb.set_label('Number of Objects') ax8.set_xlabel(r'Log$_{10}$ (Eddington Ratio $\lambda$)') ax8.set_ylim(ax2.get_ylim()) ax8.set_xlim(ax7.get_xlim()) plt.tick_params(axis='both', which='major') ax8.set_yticklabels([]) ax8.set_xticklabels(['', '-1.5', '-1.0', '-0.5', '0.0', '0.5']) ax7.set_yticklabels([]) ax7.set_xticklabels([]) ax9.hist(tab['LOGBH'][tab['LOGBH'] > 6], color=cset[-1], bins=20) ax9.set_xlim(ax8.get_xlim()) ax9.set_axis_off() ax10.hist(tab['RATIO_IR_UV'], orientation='horizontal', color=cset[-1], bins=np.arange(0, 2, 0.1)) ax10.set_ylim(ax1.get_ylim()) ax10.set_axis_off() ax11.hist(tab['BBT'], orientation='horizontal', color=cset[-1], bins=20) ax11.set_ylim(ax2.get_ylim()) ax11.set_axis_off() s1 = spearmanr(tab[tab['LOGEDD_RATIO'] > -2.5]['LOGEDD_RATIO'], tab[tab['LOGEDD_RATIO'] > -2.5]['RATIO_IR_UV'])[0] s2 = spearmanr(tab[tab['LOGBH'] > 6]['LOGBH'], tab[tab['LOGBH'] > 6]['RATIO_IR_UV'])[0] s3 = spearmanr(tab['LUM_UV'], tab['RATIO_IR_UV'])[0] s4 = spearmanr(tab[tab['LOGEDD_RATIO'] > -2.5]['LOGEDD_RATIO'], tab[tab['LOGEDD_RATIO'] > -2.5]['BBT'])[0] s5 = spearmanr(tab[tab['LOGBH'] > 6]['LOGBH'], tab[tab['LOGBH'] > 6]['BBT'])[0] s6 = spearmanr(tab['LUM_UV'], tab['BBT'])[0] ax1.text(46.5, 0.2, r'$\rho =$ {0:.2f}'.format(s3)) ax4.text(9.7, 0.2, r'$\rho =$ {0:.2f}'.format(s2)) ax7.text(-0.1, 0.2, r'$\rho =$ {0:.2f}'.format(s1)) ax2.text(46.5, 1900, r'$\rho =$ {0:.2f}'.format(s6)) ax5.text(9.7, 1900, r'$\rho =$ {0:.2f}'.format(s5)) ax8.text(-0.1, 1900, r'$\rho =$ {0:.2f}'.format(s4)) fig.savefig('/home/lc585/thesis/figures/chapter06/correlations.pdf') plt.show() return None
def plot(): mycm = cm.get_cmap('YlOrRd_r') mycm.set_under('w') mycm = truncate_colormap(mycm, 0.0, 0.8) cset = brewer2mpl.get_map('YlOrRd', 'sequential', 9).mpl_colors set_plot_properties() # change style tab = Table.read('/data/lc585/QSOSED/Results/150217/sample2/out_add.fits') tab = tab[~np.isnan(tab['BBT_STDERR'])] tab = tab[tab['BBT_STDERR'] < 500.] tab = tab[tab['BBT_STDERR'] > 5.0] tab = tab[(tab['LUM_IR_SIGMA'] * tab['RATIO_IR_UV']) < 0.4] fig = plt.figure(figsize=figsize(1, 0.6)) gs = gridspec.GridSpec(6, 13) ax1 = fig.add_subplot(gs[1:5, 0:4]) ax3 = fig.add_subplot(gs[0, 0:4]) ax4 = fig.add_subplot(gs[1:5, 4:8]) ax6 = fig.add_subplot(gs[0, 4:8]) ax7 = fig.add_subplot(gs[1:5, 8:12]) ax9 = fig.add_subplot(gs[0, 8:12]) ax10 = fig.add_subplot(gs[1:5, 12]) fig.subplots_adjust(wspace=0.0) fig.subplots_adjust(hspace=0.0) #histogram definition xyrange = [[43, 47], [0, 2]] # data range bins = [60, 40] # number of bins thresh = 4 #density threshold #data definition xdat, ydat = tab['LUM_UV'], tab['RATIO_IR_UV'] # histogram the data hh, locx, locy = histogram2d(xdat, ydat, range=xyrange, bins=bins) posx = np.digitize(xdat, locx) posy = np.digitize(ydat, locy) #select points within the histogram ind = (posx > 0) & (posx <= bins[0]) & (posy > 0) & (posy <= bins[1]) hhsub = hh[posx[ind] - 1, posy[ind] - 1] # values of the histogram where the points are xdat1 = xdat[ind][hhsub < thresh] # low density points ydat1 = ydat[ind][hhsub < thresh] hh[hh < thresh] = np.nan # fill the areas with low density by NaNs im = ax1.imshow(np.flipud(hh.T), cmap=mycm, extent=np.array(xyrange).flatten(), interpolation='none', aspect='auto', vmin=thresh) ax1.scatter(xdat1, ydat1, color=cset[-1]) ax1.set_ylabel(r'$R_{1-3{\mu}m/UV}$') ax1.set_ylim(-0.4, 1) ax1.set_xlim(45, 47) ax3.hist(tab['LUM_UV'], color=cset[-1], bins=20) ax3.set_xlim(ax1.get_xlim()) ax3.set_axis_off() #ax1.get_xaxis().set_ticks([46,46.5,47]) #ax1.get_yaxis().set_ticks([0.05,0.15,0.25,0.35,0.45]) ############################################################################ #histogram definition xyrange = [[7.5, 10.5], [0, 2]] # data range bins = [40, 40] # number of bins thresh = 4 #density threshold #data definition xdat, ydat = tab['LOGBH'], tab['RATIO_IR_UV'] # histogram the data hh, locx, locy = histogram2d(xdat, ydat, range=xyrange, bins=bins) posx = np.digitize(xdat, locx) posy = np.digitize(ydat, locy) #select points within the histogram ind = (posx > 0) & (posx <= bins[0]) & (posy > 0) & (posy <= bins[1]) hhsub = hh[posx[ind] - 1, posy[ind] - 1] # values of the histogram where the points are xdat1 = xdat[ind][hhsub < thresh] # low density points ydat1 = ydat[ind][hhsub < thresh] hh[hh < thresh] = np.nan # fill the areas with low density by NaNs im = ax4.imshow(np.flipud(hh.T), cmap=mycm, extent=np.array(xyrange).flatten(), interpolation='none', aspect='auto', vmin=thresh) ax4.scatter(xdat1, ydat1, color=cset[-1]) ax4.set_ylim(ax1.get_ylim()) ax4.set_xlim(7.9, 10.5) ax4.set_xticklabels([7.5, 8, 8.5, 9, 9.5, 10]) #ax4.set_yticks([0.05,0.15,0.25,0.35,0.45]) ax4.set_yticklabels([]) ax6.hist(tab[tab['LOGBH'] > 6]['LOGBH'], color=cset[-1], bins=20) ax6.set_xlim(ax4.get_xlim()) ax4.set_ylim(ax1.get_ylim()) ax6.hist(tab['LOGBH'][tab['LOGBH'] > 6], color=cset[-1], bins=20) ax6.set_xlim(ax4.get_xlim()) ax6.set_axis_off() ###################################################################################### #histogram definition xyrange = [[-2, 0.5], [0, 2]] # data range bins = [40, 40] # number of bins thresh = 4 #density threshold #data definition xdat, ydat = tab['LOGEDD_RATIO'], tab['RATIO_IR_UV'] # histogram the data hh, locx, locy = histogram2d(xdat, ydat, range=xyrange, bins=bins) posx = np.digitize(xdat, locx) posy = np.digitize(ydat, locy) #select points within the histogram ind = (posx > 0) & (posx <= bins[0]) & (posy > 0) & (posy <= bins[1]) hhsub = hh[posx[ind] - 1, posy[ind] - 1] # values of the histogram where the points are xdat1 = xdat[ind][hhsub < thresh] # low density points ydat1 = ydat[ind][hhsub < thresh] hh[hh < thresh] = np.nan # fill the areas with low density by NaNs im = ax7.imshow(np.flipud(hh.T), cmap=mycm, extent=np.array(xyrange).flatten(), interpolation='none', aspect='auto', vmin=thresh) ax7.scatter(xdat1, ydat1, color=cset[-1]) ax7.set_ylim(ax1.get_ylim()) ax7.set_xlim(-1.8, 0.7) ax9.hist(tab[tab['LOGEDD_RATIO'] > -2.5]['LOGEDD_RATIO'], color=cset[-1], bins=20) ax9.set_xlim(ax7.get_xlim()) ax9.set_axis_off() plt.tick_params(axis='both', which='major') #ax7.set_yticks([0.05,0.15,0.25,0.35,0.45]) ax7.set_yticklabels([]) #ax7.set_xticklabels([]) ax9.hist(tab['LOGBH'][tab['LOGBH'] > 6], color=cset[-1], bins=20) ax9.set_xlim(ax7.get_xlim()) ax9.set_axis_off() ax10.hist(tab['RATIO_IR_UV'], orientation='horizontal', color=cset[-1], bins=25) ax10.set_ylim(ax1.get_ylim()) ax10.set_axis_off() ax4.set_xlabel(r'Log$_{10}$ (BH Mass $M_{\rm BH}$)') ax1.set_xlabel(r'Log$_{10} (L_{\rm UV} ({\rm erg/s}))$') ax7.set_xlabel(r'Log$_{10}$ ($\lambda_{\rm Edd}$)') axcb = fig.add_axes([0.33, 0.1, 0.33, 0.03]) clb = fig.colorbar(im, cax=axcb, orientation='horizontal') clb.set_label('Number of Objects', fontsize=14) s1 = spearmanr(tab[tab['LOGEDD_RATIO'] > -2.5]['LOGEDD_RATIO'], tab[tab['LOGEDD_RATIO'] > -2.5]['RATIO_IR_UV'])[0] s2 = spearmanr(tab[tab['LOGBH'] > 6]['LOGBH'], tab[tab['LOGBH'] > 6]['RATIO_IR_UV'])[0] s3 = spearmanr(tab['LUM_UV'], tab['RATIO_IR_UV'])[0] p1 = spearmanr(tab[tab['LOGEDD_RATIO'] > -2.5]['LOGEDD_RATIO'], tab[tab['LOGEDD_RATIO'] > -2.5]['RATIO_IR_UV'])[1] p2 = spearmanr(tab[tab['LOGBH'] > 6]['LOGBH'], tab[tab['LOGBH'] > 6]['RATIO_IR_UV'])[1] p3 = spearmanr(tab['LUM_UV'], tab['RATIO_IR_UV'])[1] ax1.text(45.6, -0.2, r'$\rho =$ {0:.2f} ({1:.2f})'.format(s3, p3)) ax4.text(8.7, -0.2, r'$\rho =$ {0:.2f} ({1:.2f})'.format(s2, p2)) ax7.text(-1.1, -0.2, r'$\rho =$ {0:.2f} ({1:.2f})'.format(s1, p1)) fig.savefig( '/home/lc585/thesis/figures/chapter06/ratio_lowz_correlations.pdf') plt.show() return None
def plot(): from astropy.table import Table, join import matplotlib.pyplot as plt import numpy as np from scipy.stats import spearmanr import brewer2mpl from PlottingTools.truncate_colormap import truncate_colormap from matplotlib import cm import matplotlib.gridspec as gridspec from scipy import histogram2d from PlottingTools.plot_setup import figsize, set_plot_properties mycm = cm.get_cmap('YlOrRd_r') mycm.set_under('w') cset = brewer2mpl.get_map('YlOrRd', 'sequential', 9).mpl_colors mycm = truncate_colormap(mycm, 0.0, 0.8) set_plot_properties() # change style tab = Table.read( '/data/lc585/QSOSED/Results/141124/sample4/out_add_lumcalc.fits') tab.sort('Z') tab = tab[tab['BBPLSLP_STDERR'] < 0.25] fig = plt.figure(figsize=figsize(1.2, 0.4)) gs = gridspec.GridSpec(6, 13) ax1 = fig.add_subplot(gs[1:5, 0:4]) ax3 = fig.add_subplot(gs[0, 0:4]) ax4 = fig.add_subplot(gs[1:5, 4:8]) ax6 = fig.add_subplot(gs[0, 4:8]) ax7 = fig.add_subplot(gs[1:5, 8:12]) ax9 = fig.add_subplot(gs[0, 8:12]) ax10 = fig.add_subplot(gs[1:5, 12]) fig.subplots_adjust(wspace=0.0) fig.subplots_adjust(hspace=0.0) #histogram definition xyrange = [[45.5, 48], [-0.5, 1.5]] # data range bins = [50, 30] # number of bins thresh = 4 #density threshold #data definition xdat, ydat = tab['LUM_UV'], tab['BBPLSLP'] # histogram the data hh, locx, locy = histogram2d(xdat, ydat, range=xyrange, bins=bins) posx = np.digitize(xdat, locx) posy = np.digitize(ydat, locy) #select points within the histogram ind = (posx > 0) & (posx <= bins[0]) & (posy > 0) & (posy <= bins[1]) hhsub = hh[posx[ind] - 1, posy[ind] - 1] # values of the histogram where the points are xdat1 = xdat[ind][hhsub < thresh] # low density points ydat1 = ydat[ind][hhsub < thresh] hh[hh < thresh] = np.nan # fill the areas with low density by NaNs im = ax1.imshow(np.flipud(hh.T), cmap=mycm, extent=np.array(xyrange).flatten(), interpolation='none', aspect='auto', vmin=thresh, vmax=45) ax1.scatter(xdat1, ydat1, color=cset[-1]) ax1.set_ylabel(r'$\beta_{\rm NIR}$') ax1.set_ylim(-0.8, 1.5) ax1.set_xlim(45.8, 47.5) ax3.hist(tab['LUM_UV'], color=cset[-1], bins=20) ax3.set_xlim(ax1.get_xlim()) ax3.set_axis_off() ax1.get_xaxis().set_ticks([46, 46.5, 47]) #ax1.get_yaxis().set_ticks([0.05,0.15,0.25,0.35,0.45]) ############################################################################ #histogram definition xyrange = [[7.5, 10.5], [-0.5, 1.5]] # data range bins = [30, 30] # number of bins thresh = 4 #density threshold #data definition xdat, ydat = tab['LOGBH'], tab['BBPLSLP'] # histogram the data hh, locx, locy = histogram2d(xdat, ydat, range=xyrange, bins=bins) posx = np.digitize(xdat, locx) posy = np.digitize(ydat, locy) #select points within the histogram ind = (posx > 0) & (posx <= bins[0]) & (posy > 0) & (posy <= bins[1]) hhsub = hh[posx[ind] - 1, posy[ind] - 1] # values of the histogram where the points are xdat1 = xdat[ind][hhsub < thresh] # low density points ydat1 = ydat[ind][hhsub < thresh] hh[hh < thresh] = np.nan # fill the areas with low density by NaNs im = ax4.imshow(np.flipud(hh.T), cmap=mycm, extent=np.array(xyrange).flatten(), interpolation='none', aspect='auto', vmin=thresh, vmax=45) ax4.scatter(xdat1, ydat1, color=cset[-1]) ax4.set_ylim(ax1.get_ylim()) ax4.set_xlim(7.9, 10.5) ax4.set_xticklabels([7.5, 8, 8.5, 9, 9.5, 10]) #ax4.set_yticks([0.05,0.15,0.25,0.35,0.45]) ax4.set_yticklabels([]) ax6.hist(tab[tab['LOGBH'] > 6]['LOGBH'], color=cset[-1], bins=20) ax6.set_xlim(ax4.get_xlim()) plt.tick_params(axis='both', which='major') ax4.set_ylim(ax1.get_ylim()) ax6.hist(tab['LOGBH'][tab['LOGBH'] > 6], color=cset[-1], bins=20) ax6.set_xlim(ax4.get_xlim()) ax6.set_axis_off() ###################################################################################### #histogram definition xyrange = [[-2, 0.5], [-0.5, 1.5]] # data range bins = [30, 30] # number of bins thresh = 4 #density threshold #data definition xdat, ydat = tab['LOGEDD_RATIO'], tab['BBPLSLP'] # histogram the data hh, locx, locy = histogram2d(xdat, ydat, range=xyrange, bins=bins) posx = np.digitize(xdat, locx) posy = np.digitize(ydat, locy) #select points within the histogram ind = (posx > 0) & (posx <= bins[0]) & (posy > 0) & (posy <= bins[1]) hhsub = hh[posx[ind] - 1, posy[ind] - 1] # values of the histogram where the points are xdat1 = xdat[ind][hhsub < thresh] # low density points ydat1 = ydat[ind][hhsub < thresh] hh[hh < thresh] = np.nan # fill the areas with low density by NaNs im = ax7.imshow(np.flipud(hh.T), cmap=mycm, extent=np.array(xyrange).flatten(), interpolation='none', aspect='auto', vmin=thresh, vmax=45) ax7.scatter(xdat1, ydat1, color=cset[-1]) ax7.set_ylim(ax1.get_ylim()) ax7.set_xlim(-1.8, 0.7) ax9.hist(tab[tab['LOGEDD_RATIO'] > -2.5]['LOGEDD_RATIO'], color=cset[-1], bins=20) ax9.set_xlim(ax7.get_xlim()) ax9.set_axis_off() plt.tick_params(axis='both', which='major') #ax7.set_yticks([0.05,0.15,0.25,0.35,0.45]) ax7.set_yticklabels([]) #ax7.set_xticklabels([]) ax9.hist(tab['LOGBH'][tab['LOGBH'] > 6], color=cset[-1], bins=20) ax9.set_xlim(ax7.get_xlim()) ax9.set_axis_off() ax10.hist(tab['BBPLSLP'], orientation='horizontal', color=cset[-1], bins=25) ax10.set_ylim(ax1.get_ylim()) ax10.set_axis_off() ax4.set_xlabel(r'Log$_{10}$ (Black Hole Mass $M_{\rm BH}$)') ax1.set_xlabel(r'Log$_{10} (L_{\rm UV} ({\rm erg/s}))$') ax7.set_xlabel(r'Log$_{10}$ (Eddington Ratio $\lambda$)') axcb = fig.add_axes([0.33, 0.1, 0.33, 0.03]) clb = fig.colorbar(im, cax=axcb, orientation='horizontal') clb.set_label('Number of Objects') s1 = spearmanr(tab[tab['LOGEDD_RATIO'] > -2.5]['LOGEDD_RATIO'], tab[tab['LOGEDD_RATIO'] > -2.5]['BBPLSLP'])[0] s2 = spearmanr(tab[tab['LOGBH'] > 6]['LOGBH'], tab[tab['LOGBH'] > 6]['BBPLSLP'])[0] s3 = spearmanr(tab['LUM_UV'], tab['BBPLSLP'])[0] ax1.text(46.95, 1.2, r'$\rho =$ {0:.2f}'.format(s3)) ax4.text(9.7, 1.2, r'$\rho =$ {0:.2f}'.format(s2)) ax7.text(-0.1, 1.2, r'$\rho =$ {0:.2f}'.format(s1)) fig.savefig('/home/lc585/thesis/figures/chapter06/correlations_highz.pdf') plt.show() return None
def plot(): set_plot_properties() # change style tab1 = Table.read('/data/lc585/QSOSED/Results/141209/sample1/out_add.fits') tab1 = tab1[~np.isnan(tab1['BBT_STDERR'])] tab1 = tab1[tab1['BBT_STDERR'] < 500.] tab1 = tab1[tab1['BBT_STDERR'] > 5.0] tab1 = tab1[(tab1['LUM_IR_SIGMA'] * tab1['RATIO_IR_UV']) < 0.4] tab2 = Table.read('/data/lc585/QSOSED/Results/150211/sample2/out_add.fits') tab2 = tab2[~np.isnan(tab2['BBT_STDERR'])] tab2 = tab2[tab2['BBT_STDERR'] < 500.] tab2 = tab2[tab2['BBT_STDERR'] > 5.0] tab2 = tab2[(tab2['LUM_IR_SIGMA'] * tab2['RATIO_IR_UV']) < 0.4] fig, axs = plt.subplots(1, 3, figsize=figsize(1, vscale=0.4), sharey=True) m1, m2 = tab1['LUM_UV'], tab1['BBT'] xmin = m1.min() xmax = m1.max() ymin = m2.min() ymax = m2.max() X, Y = np.mgrid[xmin:xmax:100j, ymin:ymax:100j] positions = np.vstack([X.ravel(), Y.ravel()]) values = np.vstack([m1, m2]) kernel = stats.gaussian_kde(values) Z = np.reshape(kernel(positions).T, X.shape) CS = axs[0].contour(X, Y, Z, colors='black') threshold = CS.levels[0] z = kernel(values) # mask points above density threshold x = np.ma.masked_where(z > threshold, m1) y = np.ma.masked_where(z > threshold, m2) # plot unmasked points axs[0].scatter(x, y, c='black', edgecolor='None', s=3) m1, m2 = tab2['LUM_UV'], tab2['BBT'] xmin = m1.min() xmax = m1.max() ymin = m2.min() ymax = m2.max() X, Y = np.mgrid[xmin:xmax:100j, ymin:ymax:100j] positions = np.vstack([X.ravel(), Y.ravel()]) values = np.vstack([m1, m2]) kernel = stats.gaussian_kde(values) Z = np.reshape(kernel(positions).T, X.shape) CS = axs[0].contour(X, Y, Z, colors='red') threshold = CS.levels[0] z = kernel(values) # mask points above density threshold x = np.ma.masked_where(z > threshold, m1) y = np.ma.masked_where(z > threshold, m2) # plot unmasked points axs[0].scatter(x, y, c='red', edgecolor='None', s=3) m1, m2 = tab1['LOGBH'], tab1['BBT'] xmin = m1.min() xmax = m1.max() ymin = m2.min() ymax = m2.max() X, Y = np.mgrid[xmin:xmax:100j, ymin:ymax:100j] positions = np.vstack([X.ravel(), Y.ravel()]) values = np.vstack([m1, m2]) kernel = stats.gaussian_kde(values) Z = np.reshape(kernel(positions).T, X.shape) CS = axs[1].contour(X, Y, Z, colors='black') threshold = CS.levels[0] z = kernel(values) # mask points above density threshold x = np.ma.masked_where(z > threshold, m1) y = np.ma.masked_where(z > threshold, m2) # plot unmasked points axs[1].scatter(x, y, c='black', edgecolor='None', s=3) m1, m2 = tab2['LOGBH'], tab2['BBT'] xmin = m1.min() xmax = m1.max() ymin = m2.min() ymax = m2.max() X, Y = np.mgrid[xmin:xmax:100j, ymin:ymax:100j] positions = np.vstack([X.ravel(), Y.ravel()]) values = np.vstack([m1, m2]) kernel = stats.gaussian_kde(values) Z = np.reshape(kernel(positions).T, X.shape) CS = axs[1].contour(X, Y, Z, colors='red') threshold = CS.levels[0] z = kernel(values) # mask points above density threshold x = np.ma.masked_where(z > threshold, m1) y = np.ma.masked_where(z > threshold, m2) # plot unmasked points axs[1].scatter(x, y, c='red', edgecolor='None', s=3) m1, m2 = tab1['LOGEDD_RATIO'][tab1['LOGEDD_RATIO'] > -2.0], tab1['BBT'][ tab1['LOGEDD_RATIO'] > -2.0] xmin = m1.min() xmax = m1.max() ymin = m2.min() ymax = m2.max() X, Y = np.mgrid[xmin:xmax:100j, ymin:ymax:100j] positions = np.vstack([X.ravel(), Y.ravel()]) values = np.vstack([m1, m2]) kernel = stats.gaussian_kde(values) Z = np.reshape(kernel(positions).T, X.shape) CS = axs[2].contour(X, Y, Z, colors='black') threshold = CS.levels[0] z = kernel(values) # mask points above density threshold x = np.ma.masked_where(z > threshold, m1) y = np.ma.masked_where(z > threshold, m2) # plot unmasked points axs[2].scatter(x, y, c='black', edgecolor='None', s=3) m1, m2 = tab2['LOGEDD_RATIO'][tab2['LOGEDD_RATIO'] > -2.0], tab2['BBT'][ tab2['LOGEDD_RATIO'] > -2.0] xmin = m1.min() xmax = m1.max() ymin = m2.min() ymax = m2.max() X, Y = np.mgrid[xmin:xmax:100j, ymin:ymax:100j] positions = np.vstack([X.ravel(), Y.ravel()]) values = np.vstack([m1, m2]) kernel = stats.gaussian_kde(values) Z = np.reshape(kernel(positions).T, X.shape) CS = axs[2].contour(X, Y, Z, colors='red') threshold = CS.levels[0] z = kernel(values) # mask points above density threshold x = np.ma.masked_where(z > threshold, m1) y = np.ma.masked_where(z > threshold, m2) # plot unmasked points axs[2].scatter(x, y, c='red', edgecolor='None', s=3) axs[0].set_ylim(800, 1800) axs[0].set_xlim(45.2, 47) axs[1].set_xlim(8, 10.5) axs[2].set_xlim(-1.6, 0.5) axs[0].set_xticks([45.4, 45.8, 46.2, 46.6]) axs[0].set_ylabel('Blackbody Temperature') axs[0].set_xlabel('UV Luminosity') axs[1].set_xlabel('Black Hole Mass') axs[2].set_xlabel('Eddington Ratio') fig.tight_layout() fig.savefig( '/home/lc585/thesis/figures/chapter06/bbt_correlations_contour.pdf') plt.show() return None
def plot(): mycm = cm.get_cmap('YlOrRd_r') mycm.set_under('w') mycm = truncate_colormap(mycm, 0.0, 0.8) cset = brewer2mpl.get_map('YlOrRd', 'sequential', 9).mpl_colors tab = Table.read('/data/lc585/QSOSED/Results/141031/sample1.fits') fig = plt.figure(figsize=figsize(0.7, vscale=1.5)) ax1 = fig.add_subplot(2,1,1) ax2 = fig.add_subplot(2,1,2) fig.subplots_adjust(wspace=0.0) fig.subplots_adjust(hspace=0.0) fig.subplots_adjust(top=0.99, bottom=0.2) #histogram definition xyrange = [[0.5,1.5],[-0.4,1.2]] # data range bins = [45,45] # number of bins thresh = 4 #density threshold #data definition w1mag = tab['W1MPRO_ALLWISE'] + 2.699 w2mag = tab['W2MPRO_ALLWISE'] + 3.339 z = tab['Z_HEWETT'] xdat, ydat = z, w1mag - w2mag # histogram the data hh, locx, locy = histogram2d(xdat, ydat, range=xyrange, bins=bins) posx = np.digitize(xdat, locx) posy = np.digitize(ydat, locy) #select points within the histogram ind = (posx > 0) & (posx <= bins[0]) & (posy > 0) & (posy <= bins[1]) hhsub = hh[posx[ind] - 1, posy[ind] - 1] # values of the histogram where the points are xdat1 = xdat[ind][hhsub < thresh] # low density points ydat1 = ydat[ind][hhsub < thresh] hh[hh < thresh] = np.nan # fill the areas with low density by NaNs im = ax1.imshow(np.flipud(hh.T),cmap=mycm,extent=np.array(xyrange).flatten(), interpolation='none',aspect='auto', vmin=thresh, vmax=45) ax1.scatter(xdat1, ydat1,color=cset[-1]) ax1.set_ylabel(r'$W1-W2$',fontsize=14) for tick in ax1.xaxis.get_major_ticks(): tick.label.set_fontsize(10) for tick in ax1.yaxis.get_major_ticks(): tick.label.set_fontsize(10) ax1.set_ylim(-0.4,1.2) ax1.set_xlim(0.25,1.7) im = ax2.imshow(np.flipud(hh.T),cmap=mycm,extent=np.array(xyrange).flatten(), interpolation='none',aspect='auto', vmin=thresh, vmax=45) ax2.scatter(xdat1, ydat1,color=cset[-1]) axcb = fig.add_axes([0.13,0.1,0.75,0.02]) clb = fig.colorbar(im, cax=axcb,orientation='horizontal') clb.set_label('Number of Objects',fontsize=12) clb.ax.tick_params(labelsize=10) ax2.set_xlabel(r'Redshift $z$',fontsize=14) ax2.set_ylabel(r'$W1-W2$',fontsize=14) for tick in ax2.xaxis.get_major_ticks(): tick.label.set_fontsize(10) for tick in ax2.yaxis.get_major_ticks(): tick.label.set_fontsize(10) ax2.set_ylim(ax1.get_ylim()) ax2.set_xlim(ax1.get_xlim()) tabtmp = tab tabtmp.sort('Z') #plt.tick_params(axis='both',which='major',labelsize=12) ax1.get_xaxis().set_ticks([]) ax1.set_yticklabels(['',0.0,0.2,0.4,0.6,0.8,1.0,1.2]) ax2.set_yticklabels([-0.4,-0.2,0.0,0.2,0.4,0.6,0.8,1.0]) #plt.scatter(z,w1mag-w2mag,c='grey',alpha=0.3) #xdat = z #ydat = w1mag - w2mag #zdat = tab['LOGLBOL'] # #plt.hexbin(xdat,ydat,C=tab['LUM_UV'],gridsize=10,cmap=mycm) #cb = plt.colorbar() #cb.set_label('UV Luminosity') #plt.ylim(-0.2,1.2) #plt.xlim(0.4,1.6) ##plt.savefig('/data/lc585/QSOSED/Results/141030/figure1.jpg') # #xyrange = [[0.5,1.5],[0,1.2]] # data range #bins = [10,6] # number of bins #thresh = 20 #hh, locx, locy = histogram2d(xdat, # ydat, # range=xyrange, # bins=bins) # # #print locy # #posx = np.digitize(xdat, locx) #posy = np.digitize(ydat, locy) # #grid = [] #for i in range(10): # row = [] # for j in range(6): # row.append(np.median(zdat[(posx == i+1) & (posy ==j+1)])) # grid.append(row) #ind = (posx > 0) & (posx <= bins[0]) & (posy > 0) & (posy <= bins[1]) #hhsub = hh[posx[ind] - 1, posy[ind] - 1] # values of the histogram where the points are #xdat1 = xdat[ind][hhsub < thresh] # low density points #ydat1 = ydat[ind][hhsub < thresh] #hh[hh < thresh] = np.nan # fill the areas with low density by NaNs #ax.scatter(z[ind],w1mag[ind]-w2mag[ind]) #im = ax.imshow(np.flipud(hh.T), # cmap=mycm, # extent=np.array(xyrange).flatten(), # interpolation='none', # aspect='auto',vmin=10) #ax.scatter(xdat1,ydat1) # loop over bins #for i in range(len(locx)): # for j in range(len(locy)): # print np.median(tab['LUM_UV'][ (posx == i) & (posy == j)]) #ax.hist2d(z, # w1mag-w2mag, # range=xyrange, # bins=bins, # cmap=mycm, # vmin=10.) with open('/home/lc585/Dropbox/IoA/QSOSED/Model/qsofit/input.yml', 'r') as f: parfile = yaml.load(f) fittingobj = load(parfile) wavlen = fittingobj.get_wavlen() with open('/data/lc585/QSOSED/Results/140811/allsample_2/fluxcorr.array','rb') as f: flxcorr = pickle.load(f) plslp1 = 0.46 plslp2 = 0.03 plbrk = 2822. bbt = 1216. bbflxnrm = 0.24 elscal = 0.71 scahal = 0.86 galfra = 0.31 ebv = 0.0 imod = 18.0 zs = np.arange(0.5,1.525,0.025) bbt = 1200. w1w2_model = [] for z in zs: magtmp, wavlentmp, fluxtmp = model(plslp1, plslp2, plbrk, bbt, bbflxnrm, elscal, scahal, galfra, ebv, imod, z, fittingobj, flxcorr, parfile) w1w2_model.append(magtmp[9] - magtmp[10]) print w1w2_model[0] ax1.plot(zs,w1w2_model,linewidth=2.0,color='black') bbt = 1100. w1w2_model = [] for z in zs: magtmp, wavlentmp, fluxtmp = model(plslp1, plslp2, plbrk, bbt, bbflxnrm, elscal, scahal, galfra, ebv, imod, z, fittingobj, flxcorr, parfile) w1w2_model.append(magtmp[9] - magtmp[10]) print w1w2_model[0] ax1.plot(zs,w1w2_model,linewidth=2.0,color='black') bbt = 1300. w1w2_model = [] for z in zs: magtmp, wavlentmp, fluxtmp = model(plslp1, plslp2, plbrk, bbt, bbflxnrm, elscal, scahal, galfra, ebv, imod, z, fittingobj, flxcorr, parfile) w1w2_model.append(magtmp[9] - magtmp[10]) print w1w2_model[0] ax1.plot(zs,w1w2_model,linewidth=2.0,color='black') bbt = 1400. w1w2_model = [] for z in zs: magtmp, wavlentmp, fluxtmp = model(plslp1, plslp2, plbrk, bbt, bbflxnrm, elscal, scahal, galfra, ebv, imod, z, fittingobj, flxcorr, parfile) w1w2_model.append(magtmp[9] - magtmp[10]) print w1w2_model[0] ax1.plot(zs,w1w2_model,linewidth=2.0,color='black') bbt = 1500. w1w2_model = [] for z in zs: magtmp, wavlentmp, fluxtmp = model(plslp1, plslp2, plbrk, bbt, bbflxnrm, elscal, scahal, galfra, ebv, imod, z, fittingobj, flxcorr, parfile) w1w2_model.append(magtmp[9] - magtmp[10]) print w1w2_model[0] ax1.plot(zs,w1w2_model,linewidth=2.0,color='black') bbt = 1000. w1w2_model = [] for z in zs: magtmp, wavlentmp, fluxtmp = model(plslp1, plslp2, plbrk, bbt, bbflxnrm, elscal, scahal, galfra, ebv, imod, z, fittingobj, flxcorr, parfile) w1w2_model.append(magtmp[9] - magtmp[10]) ax1.plot(zs,w1w2_model,linewidth=2.0,color='black') ax1.text(0.33,0.67,'1000K',fontsize=12,color='black') ax1.text(0.33,0.52,'1100K',fontsize=12,color='black') ax1.text(0.33,0.40,'1200K',fontsize=12,color='black') ax1.text(0.33,0.28,'1300K',fontsize=12,color='black') ax1.text(0.33,0.20,'1400K',fontsize=12,color='black') ax1.text(0.33,0.10,'1500K',fontsize=12) #plt.savefig('/home/lc585/Dropbox/IoA/HotDustPaper/w1w2_temp.pdf') bbt = 1216. bbflxnrm = 0.0 w1w2_model = [] for z in zs: magtmp, wavlentmp, fluxtmp = model(plslp1, plslp2, plbrk, bbt, bbflxnrm, elscal, scahal, galfra, ebv, imod, z, fittingobj, flxcorr, parfile) w1w2_model.append(magtmp[9] - magtmp[10]) ax2.plot(zs,w1w2_model,linewidth=2.0,color='black') bbflxnrm = 0.1 w1w2_model = [] for z in zs: magtmp, wavlentmp, fluxtmp = model(plslp1, plslp2, plbrk, bbt, bbflxnrm, elscal, scahal, galfra, ebv, imod, z, fittingobj, flxcorr, parfile) w1w2_model.append(magtmp[9] - magtmp[10]) ax2.plot(zs,w1w2_model,linewidth=2.0,color='black') bbflxnrm = 0.2 w1w2_model = [] for z in zs: magtmp, wavlentmp, fluxtmp = model(plslp1, plslp2, plbrk, bbt, bbflxnrm, elscal, scahal, galfra, ebv, imod, z, fittingobj, flxcorr, parfile) w1w2_model.append(magtmp[9] - magtmp[10]) ax2.plot(zs,w1w2_model,linewidth=2.0,color='black') bbflxnrm = 0.3 w1w2_model = [] for z in zs: magtmp, wavlentmp, fluxtmp = model(plslp1, plslp2, plbrk, bbt, bbflxnrm, elscal, scahal, galfra, ebv, imod, z, fittingobj, flxcorr, parfile) w1w2_model.append(magtmp[9] - magtmp[10]) ax2.plot(zs,w1w2_model,linewidth=2.0,color='black') bbflxnrm = 0.4 w1w2_model = [] for z in zs: magtmp, wavlentmp, fluxtmp = model(plslp1, plslp2, plbrk, bbt, bbflxnrm, elscal, scahal, galfra, ebv, imod, z, fittingobj, flxcorr, parfile) w1w2_model.append(magtmp[9] - magtmp[10]) ax2.plot(zs,w1w2_model,linewidth=2.0,color='black') #plt.xlim(0.2,1.8) ax2.text(1.55,-0.1,'0.17',fontsize=12,color='black') ax2.text(1.55,0.38,'0.28',fontsize=12,color='black') ax2.text(1.55,0.60,'0.40',fontsize=12,color='black') ax2.text(1.55,0.75,'0.52',fontsize=12,color='black') ax2.text(1.55,0.90,'0.64',fontsize=12,color='black') fig.savefig('/home/lc585/thesis/figures/chapter06/w1w2_versus_redshift.pdf') #plt.xlabel(r'$z$',fontsize=12) #plt.ylabel('$W1$-$W2$',fontsize=12) #plt.tight_layout() #plt.tick_params(axis='both',which='major',labelsize=10) #sns.set_style('ticks') #xdat = np.arange(0.1,1.2,0.2) #plt.savefig('/data/lc585/QSOSED/Results/141101/figure1.jpg') #fig, ax = plt.subplots() #for row in grid: # ax.plot(xdat,row) #ax.set_xlabel('W1-W2') #ax.set_ylabel('LUM BOL') #plt.savefig('/data/lc585/QSOSED/Results/141101/figure2.jpg') #plt.show() #plt.savefig('/home/lc585/Dropbox/IoA/HotDustPaper/w1w2_bbnorm.pdf') plt.show() return None
def plot(): set_plot_properties() # change style tab = Table.read('/data/lc585/QSOSED/Results/141203/sample1/out_add.fits') tab = tab[ tab['BBT_STDERR'] < 200.0 ] tab = tab[ tab['BBFLXNRM_STDERR'] < 0.05] tab = tab[ tab['CHI2_RED'] < 3.0] tab = tab[ tab['LUM_IR'] > 40.0] # just gets rid of one annoying point mycm = cm.get_cmap('YlOrRd_r') mycm.set_under('w') cset = brewer2mpl.get_map('YlOrRd', 'sequential', 9).mpl_colors mycm = truncate_colormap(mycm, 0.0, 0.8) fig = plt.figure(figsize=figsize(0.8, 1.8)) gs = gridspec.GridSpec(9, 5) ax1 = fig.add_subplot(gs[1:5, 0:4]) ax2 = fig.add_subplot(gs[5:, 0:4]) ax3 = fig.add_subplot(gs[0,0:4]) ax4 = fig.add_subplot(gs[1:5,4]) ax5 = fig.add_subplot(gs[5:,4]) fig.subplots_adjust(wspace=0.0) fig.subplots_adjust(hspace=0.0) #histogram definition xyrange = [[-0.4,1.6],[0,2]] # data range bins = [120,30] # number of bins thresh = 4 #density threshold #data definition xdat, ydat = tab['Z'],tab['RATIO_IR_UV'] # histogram the data hh, locx, locy = histogram2d(xdat, ydat, range=xyrange, bins=bins) posx = np.digitize(xdat, locx) posy = np.digitize(ydat, locy) #select points within the histogram ind = (posx > 0) & (posx <= bins[0]) & (posy > 0) & (posy <= bins[1]) hhsub = hh[posx[ind] - 1, posy[ind] - 1] # values of the histogram where the points are xdat1 = xdat[ind][hhsub < thresh] # low density points ydat1 = ydat[ind][hhsub < thresh] hh[hh < thresh] = np.nan # fill the areas with low density by NaNs im = ax1.imshow(np.flipud(hh.T), cmap=mycm, extent=np.array(xyrange).flatten(), interpolation='none', aspect='auto', vmin=thresh, vmax=45) ax1.scatter(xdat1, ydat1,color=cset[-1]) ax1.set_ylabel(r'$R_{{\rm NIR}/{\rm UV}}$') ax1.set_ylim(0.,2.0) ax1.set_xlim(1,1.5) tabtmp = tab tabtmp.sort('Z') xdat = running.RunningMedian(np.array(tabtmp['Z']),101) ydat = running.RunningMedian(np.array(tabtmp['RATIO_IR_UV']),101) ax1.plot(xdat[::100],ydat[::100],color='black',linewidth=2.0) ax1.axhline(np.median(tab['RATIO_IR_UV']),color='black',linestyle='--') ax1.axhline(np.percentile(tab['RATIO_IR_UV'],70),color='black',linestyle='--') ax1.axhline(np.percentile(tab['RATIO_IR_UV'],30),color='black',linestyle='--') ax1.get_xaxis().set_visible(False) ax3.hist(tab['Z'],color=cset[-1],bins=20) ax3.set_xlim(ax1.get_xlim()) ax3.set_axis_off() ax4.hist(tab['RATIO_IR_UV'], orientation='horizontal',color=cset[-1],bins=np.arange(0,2,0.1)) ax4.set_ylim(ax1.get_ylim()) ax4.set_axis_off() #histogram definition xyrange = [[-0.4,1.6],[500,2000]] # data range bins = [100,50] # number of bins thresh = 4 #density threshold #data definition xdat, ydat = tab['Z'],tab['BBT'] # histogram the data hh, locx, locy = histogram2d(xdat, ydat, range=xyrange, bins=bins) posx = np.digitize(xdat, locx) posy = np.digitize(ydat, locy) #select points within the histogram ind = (posx > 0) & (posx <= bins[0]) & (posy > 0) & (posy <= bins[1]) hhsub = hh[posx[ind] - 1, posy[ind] - 1] # values of the histogram where the points are xdat1 = xdat[ind][hhsub < thresh] # low density points ydat1 = ydat[ind][hhsub < thresh] hh[hh < thresh] = np.nan # fill the areas with low density by NaNs im = ax2.imshow(np.flipud(hh.T), cmap=mycm, extent=np.array(xyrange).flatten(), interpolation='none', aspect='auto', vmin=thresh, vmax=45) ax2.scatter(xdat1, ydat1,color=cset[-1]) axcb = fig.add_axes([0.13,0.05,0.6,0.02]) clb = fig.colorbar(im, cax=axcb,orientation='horizontal') clb.set_label('Number of Objects') ax2.set_xlabel(r'Redshift $z$') ax2.set_ylabel(r'$T_{\mathrm{BB}}$') ax2.set_ylim(500,1900) ax2.set_xlim(1,1.5) tabtmp = tab tabtmp.sort('Z') xdat = running.RunningMedian(np.array(tabtmp['Z']),101) ydat = running.RunningMedian(np.array(tabtmp['BBT']),101) ax2.plot(xdat[::100],ydat[::100],color='black',linewidth=2.0) ax2.axhline(1200,color='black',linestyle='--') ax2.axhline(1100,color='black',linestyle='--') ax2.axhline(1300,color='black',linestyle='--') ax5.hist(tab['BBT'], orientation='horizontal',color=cset[-1],bins=20) ax5.set_ylim(ax2.get_ylim()) ax5.set_axis_off() fig.savefig('/home/lc585/thesis/figures/chapter06/ratio_bbt_z.pdf') plt.show() return None