def red_spectra(): set_plot_properties() # change style from SpectraTools.get_spectra import read_boss_dr12_spec fig, ax = plt.subplots(figsize=figsize(0.7)) wav, dw, flux, err = read_boss_dr12_spec('spec-4240-55455-0626.fits') ax.plot(wav, flux, color=cs[-1], label='SDSSJ0240+0103') wav, dw, flux, err = read_boss_dr12_spec('spec-5481-55983-0346.fits') ax.plot(wav, flux + 10, color=cs[0], label='SDSSJ1500+0826') plt.legend(frameon=False) ax.set_xlim(4000, 9000) ax.set_ylim(-5, 20) ax.set_xlabel(r'Wavelength $\lambda$ [\AA]') ax.set_ylabel('Flux F$_{\lambda}$ [Arbitary Units]') fig.tight_layout() fig.savefig('/home/lc585/thesis/figures/chapter06/red_spectra.pdf') plt.show() return None
def plot(): from PlottingTools.plot_setup_thesis import figsize, set_plot_properties from astropy.table import Table, join import numpy as np import matplotlib.pyplot as plt set_plot_properties() # change style tab = Table.read('/data/lc585/QSOSED/Results/141209/sample1/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']) < 1.] tab1 = Table.read('/data/lc585/QSOSED/Results/141124/sample2/out.fits' ) # 9000 - 23500 fit tab1['BBPLSLP'] = tab1['BBPLSLP'] - 1.0 goodnames = Table() goodnames['NAME'] = tab['NAME'] tab1 = join(tab1, goodnames, join_type='right', keys='NAME') fig, ax = plt.subplots(figsize=figsize(1, 0.7)) im = ax.hexbin( tab['BBT'], tab['RATIO_IR_UV'], C=tab1['BBPLSLP'], gridsize=80, ) cb = plt.colorbar(im) cb.set_label(r'$\beta_{\rm NIR}$') # Digitize beta nbins = 20 bins = np.linspace(-1.5, 1.5, nbins + 1) ind = np.digitize(tab1['BBPLSLP'], bins) bbt_locus = [np.median(tab['BBT'][ind == j]) for j in range(1, nbins)] ratio_locus = [ np.median(tab['RATIO_IR_UV'][ind == j]) for j in range(1, nbins) ] ax.plot(bbt_locus[7:-2], ratio_locus[7:-2], color='black', linewidth=2.0) ax.set_ylabel(r'$R_{{\rm NIR}/{\rm UV}}$') ax.set_xlabel(r'$T_{\rm BB}$') ax.set_ylim(0, 2) plt.tight_layout() fig.savefig('/home/lc585/thesis/figures/chapter06/ratio_tbb_beta.pdf') plt.show() return None
def kishimoto_model(): set_plot_properties() # change style fig, axs = plt.subplots(2, 2, figsize=figsize(0.9, 1.0)) plt.subplots_adjust(hspace=0.0, wspace=0.0) for ax in axs.flatten(): ax.axes.get_xaxis().set_ticks([]) ax.axes.get_yaxis().set_ticks([]) axs[0, 0].set_title('Strong outflows', fontsize=10) axs[0, 1].set_title('Weak outflows', fontsize=10) axs[0, 0].set_ylabel('Face-on') axs[1, 0].set_ylabel('Edge-on') fig.savefig('../../figures/chapter05/kishimoto.jpg', dpi=1000) plt.show()
from qsosed.loaddatraw import loaddatraw import numpy as np import numpy.ma as ma from qsosed.sedmodel import model from scipy.interpolate import interp1d from matplotlib import cm import brewer2mpl from PlottingTools.truncate_colormap import truncate_colormap import matplotlib.colors as colors import numpy as np import palettable import matplotlib.pyplot as plt from scipy import histogram2d from qsosed.get_data import get_data, extcut from PlottingTools.plot_setup_thesis import figsize, set_plot_properties set_plot_properties() # change style def plot(): cs = palettable.colorbrewer.qualitative.Set1_3.mpl_colors # Load parameter file with open('/home/lc585/qsosed/input.yml', 'r') as f: parfile = yaml.load(f) ebvmin = -0.075 ebvmax = 0.075 zmin = 1 zmax = 3.0
def plot(): from PlottingTools.plot_setup_thesis import figsize, set_plot_properties from astropy.table import Table import matplotlib.pyplot as plt from scipy import histogram2d import numpy as np from matplotlib import cm from PlottingTools.truncate_colormap import truncate_colormap import brewer2mpl from PlottingTools import running import collections from PlottingTools.kde_contours import kde_contours from PlottingTools.scatter_hist import scatter_hist import palettable cs = palettable.colorbrewer.qualitative.Set1_9.mpl_colors fig, axScatter, axHistx, axHisty = scatter_hist(figsize=figsize(1, 1), left=0.12, bottom=0.12) set_plot_properties() # change style tab = Table.read('/home/lc585/qsosed/out.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']) < 1.] #data definition xdat, ydat = tab['BBT'] * 1e3, tab['IR_UV_RATIO'] bad = np.isnan(xdat) | np.isnan(ydat) xdat = xdat[~bad] ydat = ydat[~bad] bad = (xdat > 2000) | (xdat < 500) | (ydat < 0) | (ydat > 1) xdat = xdat[~bad] ydat = ydat[~bad] kde_contours(xdat, ydat, axScatter, filled=True, lims=(600, 1800, 0, 0.8)) axScatter.set_xlabel(r'$T_{\rm BB}$') axScatter.set_ylabel(r'$R_{{\rm NIR}/{\rm UV}}$') axScatter.set_ylim(0, 0.8) axScatter.set_xlim(800, 1600) axHisty.hist(ydat, bins=np.arange(0, 0.8, 0.05), facecolor=cs[1], histtype='stepfilled', edgecolor='black', orientation='horizontal', normed=True) axHistx.hist(xdat, bins=np.arange(800, 1600, 50), histtype='stepfilled', edgecolor='black', facecolor=cs[1], normed=True) # Sample from single (T,Norm) with gaussian errors on photometry. # Mock magnitude file made in model.py and then fit in runsingleobjfit.py. # tab2 = Table.read('/data/lc585/QSOSED/Results/150309/sample5/out_add.fits') # axScatter.scatter(tab2['BBT'], # tab2['RATIO_IR_UV'], # edgecolor='None', # color=cs[0], # s=8, # zorder=10) axHistx.set_xlim(axScatter.get_xlim()) axHisty.set_ylim(axScatter.get_ylim()) axHistx.set_ylim(0, 5e-3) axHisty.set_xlim(0, 4) fig.savefig('/home/lc585/thesis/figures/chapter05/ratio_tbb_density.pdf') plt.show() return None
def plot(): set_plot_properties() # change style fig, axs = plt.subplots(3, 2, figsize=figsize(1, vscale=1.5), sharey='col', sharex='row') t = Table.read('/home/lc585/qsosed/out_bbt_fixed.fits') t = t[['NAME', 'BBT', 'IR_UV_RATIO']] t.rename_column('NAME', 'SDSS_NAME') df_fit = t.to_pandas() df_bhm = pd.read_csv('/data/lc585/SDSS/civ_bs_basesub.liam', delimiter='|') df_bhm.drop('Unnamed: 0', inplace=True, axis=1) df_bhm.drop('Unnamed: 18', inplace=True, axis=1) df = pd.merge(df_fit, df_bhm, how='inner', on='SDSS_NAME') Lbol = 3.81 * 10**df['LOGL1350_SDSS'] Ledd = 3.2e4 * 10**df['CIV_LOGBH_SDSS'] Lbol = Lbol / (3.846e33*(u.erg/u.s)) # in units of solar luminosity EddRatio = Lbol / Ledd df['EddRatio_Bias'] = EddRatio Lbol = 3.81 * 10**df['LOGL1350_SDSS'] Ledd = 3.2e4 * 10**df['CIV_LOGBH_CORR_HW10'] Lbol = Lbol / (3.846e33*(u.erg/u.s)) # in units of solar luminosity EddRatio = Lbol / Ledd df['EddRatio'] = EddRatio df = df[~np.isinf(df.EddRatio_Bias)] df = df[(df.LOGL1350_SDSS > 45) & (df.LOGL1350_SDSS < 47)] df = df[(df.CIV_LOGBH_SDSS > 8) & (df.CIV_LOGBH_SDSS < 10.5)] df = df[(np.log10(df.EddRatio_Bias) > -1.5) & (np.log10(df.EddRatio_Bias) < 0.5)] kde_contours(df.LOGL1350_SDSS, df.IR_UV_RATIO, axs[0, 0], color=cs[1]) kde_contours(df.CIV_LOGBH_SDSS, df.IR_UV_RATIO, axs[1, 0], color=cs[1]) kde_contours(np.log10(df.EddRatio_Bias), df.IR_UV_RATIO, axs[2, 0], color=cs[1]) kde_contours(df.LOGL1350_SDSS, df.IR_UV_RATIO, axs[0, 1], color=cs[1]) kde_contours(df.CIV_LOGBH_CORR_HW10, df.IR_UV_RATIO, axs[1, 1], color=cs[1]) kde_contours(np.log10(df.EddRatio), df.IR_UV_RATIO, axs[2, 1], color=cs[1]) axs[0, 0].set_xlim(45.8, 47) axs[0, 0].xaxis.set_major_locator(MaxNLocator(4)) axs[1, 0].set_xlim(8.25, 10.25) axs[2, 0].set_xlim(-1.5, 0.5) axs[0, 1].set_xlim(45.8, 47) axs[1, 1].set_xlim(8.25, 10.25) axs[2, 1].set_xlim(-1.5, 0.5) axs[0, 0].set_ylim(0, 0.8) axs[0, 1].set_ylim(0, 0.8) axs[0, 0].yaxis.set_major_locator(MaxNLocator(4)) axs[0, 1].yaxis.set_major_locator(MaxNLocator(4)) axs[0, 0].set_ylabel(r'R$_{\rm NIR/UV}$') axs[1, 0].set_ylabel(r'R$_{\rm NIR/UV}$') axs[2, 0].set_ylabel(r'R$_{\rm NIR/UV}$') axs[0, 0].set_xlabel(r'Log L$_{\rm UV}$ [erg~$\rm{s}^{-1}$]') axs[1, 0].set_xlabel(r'Log M$_{\rm BH}$ [M$\odot$]') axs[2, 0].set_xlabel(r'Log $\lambda_{\rm Edd}$') axs[0, 1].set_xlabel(r'Log L$_{\rm UV}$ [erg~$\rm{s}^{-1}$]') axs[1, 1].set_xlabel(r'Log M$_{\rm BH}$ [M$\odot$]') axs[2, 1].set_xlabel(r'Log $\lambda_{\rm Edd}$') labels = ['(a)', '(b)', '(b)', '(d)', '(c)', '(e)'] print len(axs.flatten()) for i, ax in enumerate(axs.flatten()): ax.text(0.1, 0.93, labels[i], horizontalalignment='center', verticalalignment='center', transform = ax.transAxes) fig.delaxes(axs[0, 1]) fig.tight_layout() plt.subplots_adjust(wspace=0.25, hspace=0.25) fig.savefig('/home/lc585/thesis/figures/chapter05/correlations_contour.pdf') plt.show() return None
def plot(): from PlottingTools.plot_setup_thesis import figsize, set_plot_properties from astropy.table import Table import matplotlib.pyplot as plt from scipy import histogram2d import numpy as np from matplotlib import cm from PlottingTools.truncate_colormap import truncate_colormap import brewer2mpl from PlottingTools import running import collections 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/150309/sample3/out_add.fits') # tab = tab[ tab['Z'] > 0.5 ] tab = tab[ tab['BBT_STDERR'] < 1000.] tab = tab[ tab['BBFLXNRM_STDERR'] < 1.] tab = tab[ tab['CHI2_RED'] < 2.0] fig, ax = plt.subplots(figsize=figsize(1, vscale=0.9)) #histogram definition xyrange = [[1,4],[0,3]] # data range bins = [120,80] # number of bins thresh = 3 #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 = ax.imshow(np.flipud(hh.T), cmap=mycm, extent=np.array(xyrange).flatten(), interpolation='none', aspect='auto', ) ax.scatter(xdat1, ydat1,color=cset[-1],s=8) #axcb = fig.add_axes([0.13,0.01,0.6,0.02]) clb = fig.colorbar(im,orientation='horizontal') clb.set_label('Number of Objects') ax.set_xlabel(r'Redshift $z$') ax.set_ylabel(r'$R_{\mathrm{NIR/UV}}$') ax.set_ylim(0,1.5) ax.set_xlim(1.5,3.2) tabtmp = tab tabtmp.sort('Z') xdat = running.RunningMedian(np.array(tabtmp['Z']),101) ydat = running.RunningMedian(np.array(tabtmp['RATIO_IR_UV']),101) ax.plot(xdat[::100],ydat[::100],color='black',linewidth=2.0) plt.tick_params(axis='both',which='major') # Generate magnitude file in model.py # Fit in runsingleobjfit.py (comment out load dat section) modtab = Table.read('/data/lc585/QSOSED/Results/150107/sample2/out_lumcalc.fits') ax.plot(modtab['Z'],modtab['RATIO_IR_UV'],color='black',linestyle='--', linewidth=2.0) ax.grid(which='major',c='k') #histogram definition x_range = [0.5,3.1] # data range bins = [13] # number of bins dat = np.vstack([tab['Z'],tab['LUM_IR_SIGMA']*tab['RATIO_IR_UV']]) # histogram the data h, locx = np.histogram(dat[0,:], range=x_range, bins=bins[0]) posx = np.digitize(dat[0,:], locx) xindices = collections.defaultdict(set) for index, bin in enumerate(posx): xindices[bin].add(index) ys = [] for i in range(bins[0]): ys.append(np.mean(dat[1,list(xindices[i+1])])) ax.errorbar(locx[:-1] + 0.1,np.repeat(1,13),yerr=ys,linestyle='',color='black') ax.axvline(2.0, color='black') ax.axvline(2.7, color='black') fig.tight_layout() fig.savefig('/home/lc585/thesis/figures/chapter06/ratio_z_errors_highz.pdf') plt.show() return None
def plot(): set_plot_properties() # change style cs = palettable.colorbrewer.qualitative.Set1_8.mpl_colors with open('/home/lc585/qsosed/input.yml', 'r') as f: parfile = yaml.load(f) fittingobj = load(parfile) wavlen = fittingobj.get_wavlen() lin = fittingobj.get_lin() galspc = fittingobj.get_galspc() ext = fittingobj.get_ext() galcnt = fittingobj.get_galcnt() ignmin = fittingobj.get_ignmin() ignmax = fittingobj.get_ignmax() ztran = fittingobj.get_ztran() lyatmp = fittingobj.get_lyatmp() lybtmp = fittingobj.get_lybtmp() lyctmp = fittingobj.get_lyctmp() whmin = fittingobj.get_whmin() whmax = fittingobj.get_whmax() qsomag = fittingobj.get_qsomag() flxcorr = fittingobj.get_flxcorr() cosmo = fittingobj.get_cosmo() params = Parameters() params.add('plslp1', value = -0.478) params.add('plslp2', value = -0.199) params.add('plbrk', value = 2.40250) params.add('bbt', value = 1.30626) params.add('bbflxnrm', value = 2.673) params.add('elscal', value = 1.240) params.add('scahal',value = 0.713) params.add('galfra',value = 0.0) params.add('bcnrm',value = 0.135) params.add('ebv',value = 0.0) params.add('imod',value = 18.0) # Load median magnitudes with open('/home/lc585/qsosed/sdss_ukidss_wise_medmag_ext.dat') as f: datz = np.loadtxt(f, usecols=(0,)) datz = datz[:-5] # Load filters ftrlst = fittingobj.get_ftrlst()[2:-2] lameff = fittingobj.get_lameff()[2:-2] bp = fittingobj.get_bp()[2:-2] # these are in ab and data is in vega dlam = fittingobj.get_bp()[2:-2] zromag = fittingobj.get_zromag()[2:-2] with open('ftgd_dr7.dat') as f: ftgd = np.loadtxt(f, skiprows=1, usecols=(1,2,3,4,5,6,7,8,9)) modarr = residual(params, parfile, wavlen, datz, lin, bp, dlam, zromag, galspc, ext, galcnt, ignmin, ignmax, ztran, lyatmp, lybtmp, lyctmp, ftrlst, whmin, whmax, cosmo, flxcorr, qsomag, ftgd) fname = '/home/lc585/qsosed/sdss_ukidss_wise_medmag_ext.dat' datarr = np.genfromtxt(fname, usecols=(5,7,9,11,13,15,17,19,21)) datarr[datarr < 0.0] = np.nan datarr = datarr[:-5, :] # remove less than lyman break col1 = np.arange(8) col2 = col1 + 1 col_label = ['$r$ - $i$', '$i$ - $z$', '$z$ - $Y$', '$Y$ - $J$', '$J$ - $H$', '$H$ - $K$', '$K$ - $W1$', '$W1$ - $W2$'] df = get_data() df = df[(df.z_HW > 1) & (df.z_HW < 3)] colstr1 = ['rVEGA', 'iVEGA', 'zVEGA', 'YVEGA', 'JVEGA', 'HVEGA', 'KVEGA', 'W1VEGA'] colstr2 = ['iVEGA', 'zVEGA', 'YVEGA', 'JVEGA', 'HVEGA', 'KVEGA', 'W1VEGA', 'W2VEGA'] ylims = [[0, 0.6], [-0.1, 0.5], [-0.1, 0.5], [-0.1, 0.5], [0.2, 0.9], [0.2, 0.9], [0.5, 1.6], [0.8, 1.5]] fig, axs = plt.subplots(4, 2, figsize=figsize(1, vscale=2), sharex=True) for i, ax in enumerate(axs.flatten()): #data definition ydat = datarr[:, col1[i]] - datarr[:, col2[i]] ax.scatter(datz, ydat, color='black', s=5, label='Data') ax.plot(datz, modarr[:,col1[i]] - modarr[:, col2[i]], color=cs[1], label='Model') # ax.scatter(df.z_HW, df[colstr1[i]] - df[colstr2[i]], s=1, alpha=0.1) ax.set_title(col_label[i], size=10) ax.set_ylim(ylims[i]) ax.set_xlim(0.75, 3.25) axs[0, 0].legend(bbox_to_anchor=(0.7, 0.99), bbox_transform=plt.gcf().transFigure, fancybox=True, shadow=True, scatterpoints=1, ncol=2) axs[3, 0].set_xlabel(r'Redshift $z$') axs[3, 1].set_xlabel(r'Redshift $z$') fig.tight_layout() fig.subplots_adjust(wspace=0.2, hspace=0.15, top=0.93) fig.savefig('/home/lc585/thesis/figures/chapter05/sed_color_plot.pdf') plt.show() return None
def plot(): import yaml from qsosed.load import load import numpy as np from qsosed.sedmodel import model import matplotlib.pyplot as plt from qsosed.pl import pl from qsosed.bb import bb import cosmolopy.distance as cd from PlottingTools.plot_setup_thesis import figsize, set_plot_properties import palettable from lmfit import Parameters from qsosed.qsrmod import qsrmod from qsosed.flx2mag import flx2mag set_plot_properties() # change style cs = palettable.colorbrewer.qualitative.Set1_9.mpl_colors plslp1 = 0.508 plslp2 = 0.068 plbrk = 2944.99 bbt = 1174.0 bbflxnrm = 0.208 galfra = 0.313 elscal = 0.624 imod = 18.0 ebv = 0.0 redshift = 2.0 scahal = 0.8 with open('/home/lc585/qsosed/input.yml', 'r') as f: parfile = yaml.load(f) fittingobj = load(parfile) wavlen = fittingobj.get_wavlen() flxcorr = np.array([1.0] * len(wavlen)) params = Parameters() params.add('plslp1', value=-0.478) params.add('plslp2', value=-0.199) params.add('plbrk', value=2.40250) params.add('bbt', value=1.30626) params.add('bbflxnrm', value=2.673) params.add('elscal', value=1.240) params.add('scahal', value=0.713) params.add('galfra', value=0.0) params.add('bcnrm', value=0.135) params.add('ebv', value=0.0) params.add('imod', value=18.0) lin = fittingobj.get_lin() galspc = fittingobj.get_galspc() ext = fittingobj.get_ext() galcnt = fittingobj.get_galcnt() ignmin = fittingobj.get_ignmin() ignmax = fittingobj.get_ignmax() bp = fittingobj.get_bp() dlam = fittingobj.get_dlam() zromag = fittingobj.get_zromag() ftrlst = fittingobj.get_ftrlst() ztran = fittingobj.get_ztran() lyatmp = fittingobj.get_lyatmp() lybtmp = fittingobj.get_lybtmp() lyctmp = fittingobj.get_lyctmp() whmin = fittingobj.get_whmin() whmax = fittingobj.get_whmax() qsomag = fittingobj.get_qsomag() cosmo = fittingobj.get_cosmo() nftr = len(bp) redshift = 0.5 wavlentmp, fluxtmp = qsrmod(params, parfile, wavlen, redshift, lin, galspc, ext, galcnt, ignmin, ignmax, ztran, lyatmp, lybtmp, lyctmp, whmin, whmax, cosmo, flxcorr, qsomag) magtmp = flx2mag(params, wavlentmp, fluxtmp, bp, dlam, zromag, ftrlst) fig = plt.figure(figsize=figsize(1, vscale=0.8)) ax1 = fig.add_subplot(111) ax1.loglog(wavlentmp, 0.5 * fluxtmp, color='black', label=r'$z=0.5$') redshift = 2.0 wavlentmp, fluxtmp = qsrmod(params, parfile, wavlen, redshift, lin, galspc, ext, galcnt, ignmin, ignmax, ztran, lyatmp, lybtmp, lyctmp, whmin, whmax, cosmo, flxcorr, qsomag) magtmp = flx2mag(params, wavlentmp, fluxtmp, bp, dlam, zromag, ftrlst) ax1.loglog(wavlentmp, 5 * fluxtmp, color='black', label=r'$z=2.0$') redshift = 3.5 wavlentmp, fluxtmp = qsrmod(params, parfile, wavlen, redshift, lin, galspc, ext, galcnt, ignmin, ignmax, ztran, lyatmp, lybtmp, lyctmp, whmin, whmax, cosmo, flxcorr, qsomag) magtmp = flx2mag(params, wavlentmp, fluxtmp, bp, dlam, zromag, ftrlst) ax1.loglog(wavlentmp, 50 * fluxtmp, color='black', label=r'$z=3.5$') ax1.set_xlabel(r'log $\lambda$ [${\rm \AA}$]') ax1.set_ylabel(r'log $F_{\lambda}$ [Arbitary Units]') # ax1.loglog(wavlentmp,1.e10/wavlentmp**2,linestyle='--') ax2 = ax1.twinx() ax2.set_yticks([]) labs = ['u', 'g', 'r', 'i', 'z', 'Y', 'J', 'H', 'K', 'W1', 'W2', 'W3'] xpos = fittingobj.get_lameff() xpos[:5] = xpos[:5] - 200.0 xpos[5] = 10405 xpos[6] = 12505 xpos[7] = 16411 xpos[8] = 21942 xpos[9] = 33500 xpos[10] = 46027 xpos[11] = 112684 ax2.text(19225, 3.923, r'$z=3.5$', ha='right') ax2.text(11674, 3.099, r'$z=2.0$', ha='right') ax2.text(6000, 2.135, r'$z=0.5$', ha='right') color_idx = np.linspace(0, 1, 12) from palettable.colorbrewer.diverging import Spectral_11_r for i in range(len(bp[:-1])): wavtmp = (bp[i][0, :]) flxtmp = bp[i][1, :] / np.max(bp[i][1, :]) ax2.plot(wavtmp, flxtmp, color=Spectral_11_r.mpl_colormap(color_idx[i])) # ax2.fill_between(wavtmp, flxtmp, alpha=0.2, facecolor=Spectral_11.mpl_colormap(color_idx[i])) ax2.text(xpos[i], 0.2, r'${}$'.format(labs[i]), ha='center') ax2.set_ylim(0, 5) ax1.set_ylim(1e-3, 200) ax1.set_xlim(2800, 190000) ax2.set_xlim(ax1.get_xlim()) plt.tight_layout() fig.savefig('/home/lc585/thesis/figures/chapter05/throughput.pdf') plt.show() return None
def shang_sed(): import matplotlib.pyplot as plt import numpy as np from scipy.constants import c from PlottingTools.plot_setup_thesis import figsize, set_plot_properties set_plot_properties() # change style rltab = np.genfromtxt('rlmsedMR.txt') fig, ax = plt.subplots(figsize=figsize(1.0, vscale=0.8)) ax.plot(1.0e10 * c / (10**rltab[:, 0]), 10**rltab[:, 1], color='black', lw=1) ax.set_xlabel(r'Wavelength [\AA]') ax.set_ylabel(r'${\lambda}f_{\lambda}$ [Arbitrary Units]') ax.set_xscale('log') ax.set_yscale('log') ax.set_ylim(1e-2, 10) ax.set_xlim(10, 10**8) ax.text(0.22, 0.3, 'Accretion \n disc', transform=ax.transAxes, multialignment='center') ax.text(0.52, 0.8, 'Torus', transform=ax.transAxes, multialignment='center') ax.text(0.1, 0.85, 'BLR \& \n NLR', transform=ax.transAxes, multialignment='center') ax.arrow(0.30, 0.4, 0.0, 0.2, color='black', transform=ax.transAxes, head_width=0.015) ax.arrow(0.22, 0.88, 0.04, 0.0, color='black', transform=ax.transAxes, head_width=0.015) ax.arrow(0.57, 0.78, 0.0, -0.06, color='black', transform=ax.transAxes, head_width=0.015) plt.tight_layout() plt.savefig('../../figures/chapter01/shangsed.pdf') plt.show() return None
def plot(): set_plot_properties() # change style fig, axs = plt.subplots(2, 3, figsize=figsize(1, vscale=0.8), sharex='col', sharey='row') tab1 = Table.read('/data/lc585/QSOSED/Results/150224/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/150224/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] kde_contours(tab1['LUM_UV'], tab1['RATIO_IR_UV'], axs[0, 0]) kde_contours(tab2['LUM_UV'], tab2['RATIO_IR_UV'], axs[0, 0], color='red') kde_contours(tab1['LOGBH'], tab1['RATIO_IR_UV'], axs[0, 1]) kde_contours(tab2['LOGBH'], tab2['RATIO_IR_UV'], axs[0, 1], color='red') kde_contours(tab1['LOGEDD_RATIO'][tab1['LOGEDD_RATIO'] > -2.0], tab1['RATIO_IR_UV'][tab1['LOGEDD_RATIO'] > -2.0], axs[0, 2]) kde_contours(tab2['LOGEDD_RATIO'][tab2['LOGEDD_RATIO'] > -2.0], tab2['RATIO_IR_UV'][tab2['LOGEDD_RATIO'] > -2.0], axs[0, 2], color='red') 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] kde_contours(tab1['LUM_UV'], tab1['BBT'], axs[1, 0]) kde_contours(tab2['LUM_UV'], tab2['BBT'], axs[1, 0], color='red') kde_contours(tab1['LOGBH'], tab1['BBT'], axs[1, 1]) kde_contours(tab2['LOGBH'], tab2['BBT'], axs[1, 1], color='red') kde_contours(tab1['LOGEDD_RATIO'][tab1['LOGEDD_RATIO'] > -2.0], tab1['BBT'][tab1['LOGEDD_RATIO'] > -2.0], axs[1, 2]) kde_contours(tab2['LOGEDD_RATIO'][tab2['LOGEDD_RATIO'] > -2.0], tab2['BBT'][tab2['LOGEDD_RATIO'] > -2.0], axs[1, 2], color='red') axs[0, 0].set_xlim(45, 47) axs[0, 1].set_xlim(8, 10.5) axs[0, 2].set_xlim(-1.5, 0.5) axs[1, 0].set_ylim(800, 1800) axs[0, 0].set_ylim(0, 0.8) axs[0, 0].set_ylabel(r'$R_{NIR/UV}$') axs[1, 0].set_ylabel(r'$T_{BB}$') axs[1, 0].set_xlabel('UV Luminosity') axs[1, 1].set_xlabel('Black Hole Mass') axs[1, 2].set_xlabel('Eddington Ratio') fig.tight_layout() plt.subplots_adjust(wspace=0.2, hspace=0.1) fig.savefig( '/home/lc585/thesis/figures/chapter06/correlations_contour.pdf') plt.show() return None
def plot(): set_plot_properties() # change style with open('/home/lc585/qsosed/input.yml', 'r') as f: parfile = yaml.load(f) fittingobj = load(parfile) df = get_data() zs = np.linspace(1, 3.0, 100) wavlen = fittingobj.get_wavlen() uvintmin = np.argmin(np.abs(wavlen - 2000.)) uvintmax = np.argmin(np.abs(wavlen - 9000.)) irintmin = np.argmin(np.abs(wavlen - 10000.)) irintmax = np.argmin(np.abs(wavlen - 30000.)) def ratiogoal(rg): ratio = 0.0 bbflxnrm = 0.0 z = 2.0 bbt = 1306 plslp1 = -0.478 plslp2 = -0.199 plbrk = 2402.0 flxnrm = 1.0 wavnrm = 5500.0 bbwavnrm = 20000.0 # while ratio < rg: # flux = np.zeros(len(wavlen), dtype=np.float) # # Define normalisation constant to ensure continuity at wavbrk # const2 = flxnrm / (wavnrm**(-plslp2)) # const1 = const2 * ((plbrk**(-plslp2)) / (plbrk**(-plslp1))) # wavnumbrk = wav2num(wavlen, plbrk) # flux[:wavnumbrk] = flux[:wavnumbrk] + pl(wavlen[:wavnumbrk], plslp1, const1) # flux[wavnumbrk:] = flux[wavnumbrk:] + pl(wavlen[wavnumbrk:], plslp2, const2) # # Hot blackbody --------------------------------------------------- # bbflux = bb(wavlen*u.AA, # bbt*u.K, # bbflxnrm, # bbwavnrm*u.AA, # units='freq') # flux = flux*(u.erg / u.s / u.cm**2 / u.Hz) # flux = flux.to(u.erg / u.s / u.cm**2 / u.AA, # equivalencies=u.spectral_density(wavlen * u.AA)) # bbflux = bbflux*(u.erg / u.s / u.cm**2 / u.Hz) # bbflux = bbflux.to(u.erg / u.s / u.cm**2 / u.AA, # equivalencies=u.spectral_density(wavlen * u.AA)) # ratio = np.sum(bbflux[irintmin:irintmax]) / np.sum(flux[uvintmin:uvintmax]) # bbflxnrm = bbflxnrm + 0.01 # print ratio, bbflxnrm # parfile['quasar']['bb']['flxnrm'] = bbflxnrm print rg if rg == 0.5: parfile['quasar']['bb']['flxnrm'] = 4.47 elif rg == 0.4: parfile['quasar']['bb']['flxnrm'] = 3.58 elif rg == 0.3: parfile['quasar']['bb']['flxnrm'] = 2.69 elif rg == 0.2: parfile['quasar']['bb']['flxnrm'] = 1.8 elif rg == 0.1: parfile['quasar']['bb']['flxnrm'] = 0.91 elif rg == 0.0: parfile['quasar']['bb']['flxnrm'] = 0.0 cols = [] for z in zs: magtmp, wavlentmp, fluxtmp = model(redshift=z, parfile=parfile) cols.append(magtmp[9] - magtmp[10]) return cols fig, ax = plt.subplots(figsize=figsize(1.0, vscale=0.7)) mycm = cm.get_cmap('Blues_r') mycm.set_under('w') mycm = truncate_colormap(mycm, 0.0, 0.8) cset = brewer2mpl.get_map('Blues', 'sequential', 9).mpl_colors #histogram definition xyrange = [[1, 3], [0, 2]] # data range bins = [50, 50] # number of bins thresh = 4 #density threshold #data definition xdat, ydat = df.z_HW, df.W1VEGA - df.W2VEGA # 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 = ax.imshow(np.flipud(hh.T), cmap=mycm, extent=np.array(xyrange).flatten(), interpolation='none', aspect='auto', vmin=thresh, vmax=45) cb = plt.colorbar(im) cb.set_label('Number of Objects') ax.scatter(xdat1, ydat1, color=cset[-1], s=3) cset = brewer2mpl.get_map('YlOrRd', 'sequential', 8).mpl_colors ax.plot(zs, ratiogoal(0.5), c=cset[7], linewidth=2.0, label=r'0.5') ax.plot(zs, ratiogoal(0.4), c=cset[6], linewidth=2.0, label=r'0.4') ax.plot(zs, ratiogoal(0.3), c=cset[5], linewidth=2.0, label=r'0.3') ax.plot(zs, ratiogoal(0.2), c=cset[4], linewidth=2.0, label=r'0.2') ax.plot(zs, ratiogoal(0.1), c=cset[3], linewidth=2.0, label=r'0.1') ax.plot(zs, ratiogoal(0.0), c=cset[2], linewidth=2.0, label=r'0.0') ax.set_xlabel(r'Redshift $z$') ax.set_ylabel(r'$W1-W2$') ax.set_xlim(1, 4) ax.set_ylim(0.2, 2) ax.text(0.72, 0.7, r'${\mathrm R_{\mathrm NIR/UV}}$', transform=ax.transAxes) plt.legend(frameon=False, loc=(0.7, 0.15)) plt.tight_layout() fig.savefig( '/home/lc585/thesis/figures/chapter05/w1w2_versus_redshift_ratio.pdf') plt.show() return None
def plot(): """ Generates residual plot using model parameters in input.yml """ set_plot_properties() # change style with open('/home/lc585/qsosed/input.yml', 'r') as f: parfile = yaml.load(f) fittingobj = load(parfile) wavlen = fittingobj.get_wavlen() lin = fittingobj.get_lin() galspc = fittingobj.get_galspc() ext = fittingobj.get_ext() galcnt = fittingobj.get_galcnt() ignmin = fittingobj.get_ignmin() ignmax = fittingobj.get_ignmax() ztran = fittingobj.get_ztran() lyatmp = fittingobj.get_lyatmp() lybtmp = fittingobj.get_lybtmp() lyctmp = fittingobj.get_lyctmp() whmin = fittingobj.get_whmin() whmax = fittingobj.get_whmax() qsomag = fittingobj.get_qsomag() flxcorr = fittingobj.get_flxcorr() cosmo = fittingobj.get_cosmo() # Load median magnitudes with open('/home/lc585/qsosed/sdss_ukidss_wise_medmag_ext.dat') as f: datz = np.loadtxt(f, usecols=(0,)) datz = datz[:-5] # Load filters ftrlst = fittingobj.get_ftrlst()[2:-2] lameff = fittingobj.get_lameff()[2:-2] bp = fittingobj.get_bp()[2:-2] # these are in ab and data is in vega dlam = fittingobj.get_bp()[2:-2] zromag = fittingobj.get_zromag()[2:-2] with open('ftgd_dr7.dat') as f: ftgd = np.loadtxt(f, skiprows=1, usecols=(1,2,3,4,5,6,7,8,9)) fname = '/home/lc585/qsosed/sdss_ukidss_wise_medmag_ext.dat' datarr = np.genfromtxt(fname, usecols=(5,7,9,11,13,15,17,19,21)) datarr[datarr < 0.0] = np.nan datarr = datarr[:-5, :] params = Parameters() params.add('plslp1', value = -0.478) params.add('plslp2', value = -0.199) params.add('plbrk', value = 2.40250) params.add('bbt', value = 1.30626) params.add('bbflxnrm', value = 2.673) params.add('elscal', value = 1.240) params.add('scahal',value = 0.713) params.add('galfra',value = 0.0) params.add('bcnrm',value = 0.135) params.add('ebv',value = 0.0) params.add('imod',value = 18.0) modarr = residual(params, parfile, wavlen, datz, lin, bp, dlam, zromag, galspc, ext, galcnt, ignmin, ignmax, ztran, lyatmp, lybtmp, lyctmp, ftrlst, whmin, whmax, cosmo, flxcorr, qsomag, ftgd) lameff = lameff.reshape( len(lameff), 1) lameff = np.repeat(lameff,len(datz),axis=1) datz = datz.reshape(1, len(datz) ) datz = np.repeat(datz,len(lameff),axis=0) lam = lameff / (1.0 + datz) res = np.ndarray.transpose(modarr - datarr) fig = plt.figure(figsize=figsize(1, 0.8)) ax = fig.add_subplot(1,1,1) colormap = plt.cm.Paired plt.gca().set_color_cycle([colormap(i) for i in np.linspace(0, 0.8, 9)]) labels = ['r','i','z','Y','J','H','K','W1','W2'] for i in range(9): ax.plot(lam[i,:], res[i,:], label=labels[i]) ax.grid() ax.set_xlim(1000,30000) ax.set_ylim(-0.3,0.3) ax.set_xlabel(r'Rest Frame Wavelength [${\rm \AA}$]') ax.set_ylabel(r'$m_{\rm mod} - m_{\rm dat}$') plt.legend(prop={'size':10}) plt.tick_params(axis='both',which='major') plt.tight_layout() plt.savefig('/home/lc585/thesis/figures/chapter05/model_residuals.pdf') plt.show() return None