def massfunc_plot(halos, props, mmax=12.5, mmin=5.0, nbins=30, output='SMN', nvolumes=15): """ Plots stellar mass functions, cold gas mass functions, & BH MF """ #files path_BH = '/Users/niemi/Desktop/Research/IDL/obs/phopkins/' #BH_file = path_BH + 'rachel_bhmf_data.dat' #overrides weight for a single Bolshoi sub-volume #halos.weight = halos.weight * 0. + 1./(50.0/0.7)**3 halos.weight = halos.weight * 0. + 1. / (nvolumes * (50. / 0.7) ** 3) ngal = len(props.gal_id) print '%i galaxies found' % ngal dm = (mmax - mmin) / nbins print dm mbin = mmin + (N.arange(nbins) + 0.5) * dm #mfit = mmin + N.arange(150) * 0.05 mf_cold = N.zeros(nbins) mf_star = N.zeros(nbins) mf_star_central = N.zeros(nbins) mf_bar = N.zeros(nbins) mf_bh = N.zeros(nbins) mf_early = N.zeros(nbins) mf_late = N.zeros(nbins) mf_bulge = N.zeros(nbins) #from IDL, should be done without looping btt = 10.0 ** (props.mbulge - props.mstar) for i in range(ngal): ihalo = props.halo_id[i] #cold gas ibin = int(N.floor((props.mcold[i] - mmin) / dm)) if ibin >= 0 and ibin < nbins: mf_cold[ibin] += halos.weight[ihalo] #stellar mass ibin = int(N.floor((props.mstar[i] - mmin) / dm)) if ibin >= 0 and ibin < nbins: mf_star[ibin] += halos.weight[ihalo] #stellar mass, by type if btt[i] >= 0.4: mf_early[ibin] += halos.weight[ihalo] else: mf_late[ibin] += halos.weight[ihalo] #stellar mass, centrals if props.gal_id[i] == 1: if ibin >= 0 and ibin < nbins: mf_star_central[ibin] += halos.weight[ihalo] #bulge mass ibin = int(N.floor((props.mbulge[i] - mmin) / dm)) if ibin >= 0 and ibin < nbins: mf_bulge[ibin] += halos.weight[ihalo] #baryonic mass mbar = N.log10(10.0 ** props.mcold[i] + 10.0 ** props.mstar[i]) ibin = int(N.floor((mbar - mmin) / dm)) if ibin >= 0 and ibin < nbins: mf_bar[ibin] += halos.weight[ihalo] #black hole ibin = int(N.floor((props.mbh[i] - mmin) / dm)) if ibin >= 0 and ibin < nbins: mf_bh[ibin] += halos.weight[ihalo] mf_cold = N.log10(mf_cold / dm) mf_star = N.log10(mf_star / dm) #mf_early = N.log10(mf_early / dm) #mf_late = N.log10(mf_late / dm) #mf_bulge = N.log10(mf_bulge / dm) #mf_star_central = N.log10(mf_star_central / dm) mf_bar = N.log10(mf_bar / dm) mf_bh = N.log10(mf_bh / dm) #stellar mass function plot #obs constrains mg, phig, phi_lowg, phi_highg = stellarMFs.bellG() mk, phik, phi_lowk, phi_highk = stellarMFs.bellK() #ml, phil, phi_lowl, phi_hiugl = mstar_lin(obs + 'sdss_mf/SDSS_SMF.dat') m, n, nlow, nhigh = stellarMFs.panter() fig = P.figure() ax = fig.add_subplot(111) ax.plot(mbin, mf_star, label='Stellar Mass Function') ax.errorbar(mg, phig, yerr=[phig - phi_highg, phi_lowg - phig], label='Bell et al. G') ax.errorbar(mk, phik, yerr=[phik - phi_highk, phi_lowk - phik], label='Bell et al. K') #ax.errorbar(ml, phil, yerr = [phi_lowl, phi_highl], label = 'Lin et al. K') ax.errorbar(m, n, yerr=[nlow - n, n - nhigh], label='Panter et al. K') ax.set_xlim(8.0, 12.5) ax.set_ylim(-6.0, -1.0) ax.set_xlabel(r'$\log M_{star} \quad [M_{\odot}]$') ax.set_ylabel(r'$\frac{\log \textrm{d}N}{\textrm{d}\log M_{star}} \quad [\textrm{Mpc}^{-3} \textrm{dex}^{-1}]$') #small ticks m = ax.get_yticks()[1] - ax.get_yticks()[0] yminorLocator = MultipleLocator(m / 5) yminorFormattor = NullFormatter() ax.yaxis.set_minor_locator(yminorLocator) ax.yaxis.set_minor_formatter(yminorFormattor) m = ax.get_xticks()[1] - ax.get_xticks()[0] xminorLocator = MultipleLocator(m / 5) xminorFormattor = NullFormatter() ax.xaxis.set_minor_locator(xminorLocator) ax.xaxis.set_minor_formatter(xminorFormattor) P.legend() P.savefig('mfstar_' + output + '.pdf') P.close() #cold gas mass function #obs constrains #mhi_bell_h70 #mgas_bell_h70 theta = gas.HIMassFunctionZwaan(mbin) m_hi, phi_hi, phi_low_hi, phi_high_hi = gas.HIMassFunctionBell() m_h2, phi_h2, phi_low_h2, phi_high_h2 = gas.H2MassFunctionBell() fig = P.figure() ax = fig.add_subplot(111) ax.plot(mbin, mf_cold, label='Cold Gas Mass Function') ax.plot(mbin, theta, 'g-', lw=1.8, label='Zwaan et al.') ax.errorbar(m_hi, phi_hi, yerr=[phi_hi - phi_high_hi, phi_low_hi - phi_hi], c='cyan', ls='--', lw=1.5, label='Bell et al. $H_{I}$') ax.errorbar(m_h2, phi_h2, yerr=[phi_h2 - phi_high_h2, phi_low_h2 - phi_h2], c='magenta', ls=':', lw=1.5, label='Bell et al. $H_{2}$') ax.plot(m_hi, N.log10(10.0 ** phi_hi + 10 ** phi_h2), 'r-', label='$H_{I} + H_{2}$') ax.set_xlim(8.0, 11.5) ax.set_ylim(-5.5, -0.8) ax.set_xlabel(r'$\log_{10} M_{cold} \quad [M_{\odot}]$') ax.set_ylabel(r'$\frac{\log_{10} \textrm{d}N}{\textrm{d}\log M} \quad [\textrm{Mpc}^{-3} \textrm{dex}^{-1}]$') #small ticks m = ax.get_yticks()[1] - ax.get_yticks()[0] yminorLocator = MultipleLocator(m / 5) yminorFormattor = NullFormatter() ax.yaxis.set_minor_locator(yminorLocator) ax.yaxis.set_minor_formatter(yminorFormattor) m = ax.get_xticks()[1] - ax.get_xticks()[0] xminorLocator = MultipleLocator(m / 5) xminorFormattor = NullFormatter() ax.xaxis.set_minor_locator(xminorLocator) ax.xaxis.set_minor_formatter(xminorFormattor) P.legend() P.savefig('mfcold_' + output + '.pdf') P.close() #total baryons #obs contstrains m_bar, phi_bar, phi_low_bar, phi_high_bar = baryons.BellBaryonicMassFunction() fig = P.figure() ax = fig.add_subplot(111) ax.plot(mbin, mf_bar, label='Total Baryon Mass') ax.errorbar(m_bar, phi_bar, yerr=[phi_bar - phi_high_bar, phi_low_bar - phi_bar], c='g', ls='-', label='Bell et al.') ax.set_xlim(8.0, 12.5) ax.set_ylim(-5.0, -0.25) ax.set_xlabel(r'$\log_{10} M_{baryons} \quad [M_{\odot}]$') ax.set_ylabel( r'$\frac{\log_{10} \mathrm{d}N}{\mathrm{d}\log M_{baryons}} \quad [\mathrm{Mpc}^{-3} \mathrm{dex}^{-1}]$') #small ticks m = ax.get_yticks()[1] - ax.get_yticks()[0] yminorLocator = MultipleLocator(m / 5) yminorFormattor = NullFormatter() ax.yaxis.set_minor_locator(yminorLocator) ax.yaxis.set_minor_formatter(yminorFormattor) m = ax.get_xticks()[1] - ax.get_xticks()[0] xminorLocator = MultipleLocator(m / 5) xminorFormattor = NullFormatter() ax.xaxis.set_minor_locator(xminorLocator) ax.xaxis.set_minor_formatter(xminorFormattor) P.legend() P.savefig('mfbar_' + output + '.pdf') P.close() #BH mass function #obs constrains m_bh, phi_low_bh, phi_med_bh, phi_high_bh = bh.MarconiMassFunction() fig = P.figure() ax = fig.add_subplot(111) ax.plot(mbin, mf_bh, 'k-', label='Black Hole Mass Function') ax.plot(m_bh, phi_low_bh, 'g--') ax.plot(m_bh, phi_med_bh, 'g-', label='Marconi et al.') ax.plot(m_bh, phi_high_bh, 'g--') ax.set_xlim(6.0, 10.2) ax.set_ylim(-7.0, -1.5) ax.set_xlabel(r'$\log_{10} M_{BH} \quad [M_{\odot}]$') ax.set_ylabel(r'$\frac{\log_{10} \mathrm{d}N}{\mathrm{d}\log M} \quad [\mathrm{Mpc}^{-3} \mathrm{dex}^{-1}]$') #small ticks m = ax.get_yticks()[1] - ax.get_yticks()[0] yminorLocator = MultipleLocator(m / 5) yminorFormattor = NullFormatter() ax.yaxis.set_minor_locator(yminorLocator) ax.yaxis.set_minor_formatter(yminorFormattor) m = ax.get_xticks()[1] - ax.get_xticks()[0] xminorLocator = MultipleLocator(m / 5) xminorFormattor = NullFormatter() ax.xaxis.set_minor_locator(xminorLocator) ax.xaxis.set_minor_formatter(xminorFormattor) P.legend() P.savefig('mfBH_' + output + '.pdf') P.close()
def massfunctions(path, db, mmax=12.5, mmin=5.0, nbins=30, output='SMN', nvolumes=15): ''' Plots stellar mass functions, cold gas mass functions, & BH MF ''' #get data query = '''select gal_id, halo_id, mbulge, mstar, mcold, mbh from galprop''' data = sq.get_data_sqliteSMNfunctions(path, db, query) gal_id = data[:, 0] halo_id = data[:, 1] mbulge = data[:, 2] mstar = data[:, 3] mcold = data[:, 4] mbh = data[:, 5] ngal = len(gal_id) print '%i galaxies found' % ngal #overrides weight for nvolumes Bolshoi sub-volumes weight = N.zeros(ngal) + 1. / (nvolumes * (50. / 0.7) ** 3) #mass bins dm = (mmax - mmin) / nbins mbin = mmin + (N.arange(nbins) + 0.5) * dm #mfit = mmin + N.arange(150) * 0.05 mf_cold = N.zeros(nbins) mf_star = N.zeros(nbins) mf_star_central = N.zeros(nbins) mf_bar = N.zeros(nbins) mf_bh = N.zeros(nbins) mf_early = N.zeros(nbins) mf_late = N.zeros(nbins) mf_bulge = N.zeros(nbins) #TODO from IDL, should be done without looping btt = 10.0 ** (mbulge - mstar) for i in range(ngal): ihalo = halo_id[i] #cold gas ibin = int(N.floor((mcold[i] - mmin) / dm)) if ibin >= 0 and ibin < nbins: mf_cold[ibin] += weight[ihalo] #stellar mass ibin = int(N.floor((mstar[i] - mmin) / dm)) if ibin >= 0 and ibin < nbins: mf_star[ibin] += weight[ihalo] #stellar mass, by type if btt[i] >= 0.4: mf_early[ibin] += weight[ihalo] else: mf_late[ibin] += weight[ihalo] #stellar mass, centrals if gal_id[i] == 1: if ibin >= 0 and ibin < nbins: mf_star_central[ibin] += weight[ihalo] #bulge mass ibin = int(N.floor((mbulge[i] - mmin) / dm)) if ibin >= 0 and ibin < nbins: mf_bulge[ibin] += weight[ihalo] #baryonic mass mbar = N.log10(10.0 ** mcold[i] + 10.0 ** mstar[i]) ibin = int(N.floor((mbar - mmin) / dm)) if ibin >= 0 and ibin < nbins: mf_bar[ibin] += weight[ihalo] #black hole ibin = int(N.floor((mbh[i] - mmin) / dm)) if ibin >= 0 and ibin < nbins: mf_bh[ibin] += weight[ihalo] mf_cold = N.log10(mf_cold / dm) mf_star = N.log10(mf_star / dm) #mf_early = N.log10(mf_early / dm) #mf_late = N.log10(mf_late / dm) #mf_bulge = N.log10(mf_bulge / dm) #mf_star_central = N.log10(mf_star_central / dm) mf_bar = N.log10(mf_bar / dm) mf_bh = N.log10(mf_bh / dm) #stellar mass function plot #obs constrains mg, phig, phi_lowg, phi_highg = stellarMFs.bellG() mk, phik, phi_lowk, phi_highk = stellarMFs.bellK() #ml, phil, phi_lowl, phi_hiugl = mstar_lin(obs + 'sdss_mf/SDSS_SMF.dat') m, n, nlow, nhigh = stellarMFs.panter() fig = P.figure() ax = fig.add_subplot(111) ax.plot(mbin, mf_star, label='Stellar Mass Function') ax.errorbar(mg, phig, yerr=[phig - phi_highg, phi_lowg - phig], label='$G$-band from Bell et al.') ax.errorbar(mk, phik, yerr=[phik - phi_highk, phi_lowk - phik], label='$K$-band from Bell et al.') #ax.errorbar(ml, phil, yerr = [phi_lowl, phi_highl], label = 'Lin et al. K') ax.errorbar(m, n, yerr=[nlow - n, n - nhigh], label='$K$-band from Panter et al.') ax.set_xlim(8.0, 12.5) ax.set_ylim(-6.1, -1.0) ax.set_xlabel(r'$\log_{10} \left ( M_{\star} \ [M_{\odot}] \right )$') ax.set_ylabel( r'$\frac{\log_{10} \mathrm{d}N}{\mathrm{d}\log_{10} M_{\star}} \quad [\mathrm{Mpc}^{-3} \mathrm{dex}^{-1}]$') #small ticks m = ax.get_yticks()[1] - ax.get_yticks()[0] yminorLocator = MultipleLocator(m / 5) yminorFormattor = NullFormatter() ax.yaxis.set_minor_locator(yminorLocator) ax.yaxis.set_minor_formatter(yminorFormattor) m = ax.get_xticks()[1] - ax.get_xticks()[0] xminorLocator = MultipleLocator(m / 5) xminorFormattor = NullFormatter() ax.xaxis.set_minor_locator(xminorLocator) ax.xaxis.set_minor_formatter(xminorFormattor) P.legend() P.savefig('mfstar_' + output + '.pdf') P.close() #cold gas mass function #obs constrains #mhi_bell_h70 #mgas_bell_h70 theta = gas.HIMassFunctionZwaan(mbin) m_hi, phi_hi, phi_low_hi, phi_high_hi = gas.HIMassFunctionBell() m_h2, phi_h2, phi_low_h2, phi_high_h2 = gas.H2MassFunctionBell() fig = P.figure() ax = fig.add_subplot(111) ax.plot(mbin, mf_cold, label='Cold Gas Mass Function') ax.plot(mbin, theta, 'g-', lw=1.8, label='Zwaan et al.') ax.errorbar(m_hi, phi_hi, yerr=[phi_hi - phi_high_hi, phi_low_hi - phi_hi], c='cyan', ls='--', lw=1.5, label='Bell et al. $H_{I}$') ax.errorbar(m_h2, phi_h2, yerr=[phi_h2 - phi_high_h2, phi_low_h2 - phi_h2], c='magenta', ls=':', lw=1.5, label='Bell et al. $H_{2}$') ax.plot(m_hi, N.log10(10.0 ** phi_hi + 10 ** phi_h2), 'r-', label='$H_{I} + H_{2}$') ax.set_xlim(8.0, 11.5) ax.set_ylim(-5.5, -0.8) ax.set_xlabel(r'$\log_{10} \left ( M_{\mathrm{cold}} \ [M_{\odot}] \right )$') ax.set_ylabel(r'$\frac{\log_{10} \mathrm{d}N}{\mathrm{d}\log_{10} M} \quad [\mathrm{Mpc}^{-3} \mathrm{dex}^{-1}]$') #small ticks m = ax.get_yticks()[1] - ax.get_yticks()[0] yminorLocator = MultipleLocator(m / 5) yminorFormattor = NullFormatter() ax.yaxis.set_minor_locator(yminorLocator) ax.yaxis.set_minor_formatter(yminorFormattor) m = ax.get_xticks()[1] - ax.get_xticks()[0] xminorLocator = MultipleLocator(m / 5) xminorFormattor = NullFormatter() ax.xaxis.set_minor_locator(xminorLocator) ax.xaxis.set_minor_formatter(xminorFormattor) P.legend() P.savefig('mfcold_' + output + '.pdf') P.close() #total baryons #obs contstrains m_bar, phi_bar, phi_low_bar, phi_high_bar = baryons.BellBaryonicMassFunction() fig = P.figure() ax = fig.add_subplot(111) ax.plot(mbin, mf_bar, label='Total Baryon Mass') ax.errorbar(m_bar, phi_bar, yerr=[phi_bar - phi_high_bar, phi_low_bar - phi_bar], c='g', ls='-', label='Bell et al.') ax.set_xlim(8.0, 12.5) ax.set_ylim(-4.9, -0.25) ax.set_xlabel(r'$\log_{10} \left ( M_{\mathrm{baryons}} \ [M_{\odot}] \right )$') ax.set_ylabel( r'$\frac{\log_{10} \mathrm{d}N}{\mathrm{d}\log_{10} M_{\mathrm{baryons}}} \quad [\mathrm{Mpc}^{-3} \mathrm{dex}^{-1}]$') #small ticks m = ax.get_yticks()[1] - ax.get_yticks()[0] yminorLocator = MultipleLocator(m / 5) yminorFormattor = NullFormatter() ax.yaxis.set_minor_locator(yminorLocator) ax.yaxis.set_minor_formatter(yminorFormattor) m = ax.get_xticks()[1] - ax.get_xticks()[0] xminorLocator = MultipleLocator(m / 5) xminorFormattor = NullFormatter() ax.xaxis.set_minor_locator(xminorLocator) ax.xaxis.set_minor_formatter(xminorFormattor) P.legend() P.savefig('mfbar_' + output + '.pdf') P.close() #BH mass function #obs constrains m_bh, phi_low_bh, phi_med_bh, phi_high_bh = bh.MarconiMassFunction() fig = P.figure() ax = fig.add_subplot(111) ax.plot(mbin, mf_bh, 'k-', label='Black Hole Mass Function') ax.plot(m_bh, phi_low_bh, 'g--') ax.plot(m_bh, phi_med_bh, 'g-', label='Marconi et al.') ax.plot(m_bh, phi_high_bh, 'g--') ax.set_xlim(6.0, 10.2) ax.set_ylim(-6.9, -1.5) ax.set_xlabel(r'$\log_{10} \left ( M_{BH} \ [M_{\odot}] \right )$') ax.set_ylabel(r'$\frac{\log_{10} \mathrm{d}N}{\mathrm{d}\log_{10} M} \quad [\mathrm{Mpc}^{-3} \mathrm{dex}^{-1}]$') #small ticks m = ax.get_yticks()[1] - ax.get_yticks()[0] yminorLocator = MultipleLocator(m / 5) yminorFormattor = NullFormatter() ax.yaxis.set_minor_locator(yminorLocator) ax.yaxis.set_minor_formatter(yminorFormattor) m = ax.get_xticks()[1] - ax.get_xticks()[0] xminorLocator = MultipleLocator(m / 5) xminorFormattor = NullFormatter() ax.xaxis.set_minor_locator(xminorLocator) ax.xaxis.set_minor_formatter(xminorFormattor) P.legend() P.savefig('mfBH_' + output + '.pdf') P.close()
def massfunctions(path, db, mmax=12.5, mmin=5.0, nbins=30, output='SMN', nvolumes=15): ''' Plots stellar mass functions, cold gas mass functions, & BH MF ''' #get data query = '''select gal_id, halo_id, mbulge, mstar, mcold, mbh from galprop''' data = sq.get_data_sqliteSMNfunctions(path, db, query) gal_id = data[:, 0] halo_id = data[:, 1] mbulge = data[:, 2] mstar = data[:, 3] mcold = data[:, 4] mbh = data[:, 5] ngal = len(gal_id) print '%i galaxies found' % ngal #overrides weight for nvolumes Bolshoi sub-volumes weight = N.zeros(ngal) + 1. / (nvolumes * (50. / 0.7)**3) #mass bins dm = (mmax - mmin) / nbins mbin = mmin + (N.arange(nbins) + 0.5) * dm #mfit = mmin + N.arange(150) * 0.05 mf_cold = N.zeros(nbins) mf_star = N.zeros(nbins) mf_star_central = N.zeros(nbins) mf_bar = N.zeros(nbins) mf_bh = N.zeros(nbins) mf_early = N.zeros(nbins) mf_late = N.zeros(nbins) mf_bulge = N.zeros(nbins) #TODO from IDL, should be done without looping btt = 10.0**(mbulge - mstar) for i in range(ngal): ihalo = halo_id[i] #cold gas ibin = int(N.floor((mcold[i] - mmin) / dm)) if ibin >= 0 and ibin < nbins: mf_cold[ibin] += weight[ihalo] #stellar mass ibin = int(N.floor((mstar[i] - mmin) / dm)) if ibin >= 0 and ibin < nbins: mf_star[ibin] += weight[ihalo] #stellar mass, by type if btt[i] >= 0.4: mf_early[ibin] += weight[ihalo] else: mf_late[ibin] += weight[ihalo] #stellar mass, centrals if gal_id[i] == 1: if ibin >= 0 and ibin < nbins: mf_star_central[ibin] += weight[ihalo] #bulge mass ibin = int(N.floor((mbulge[i] - mmin) / dm)) if ibin >= 0 and ibin < nbins: mf_bulge[ibin] += weight[ihalo] #baryonic mass mbar = N.log10(10.0**mcold[i] + 10.0**mstar[i]) ibin = int(N.floor((mbar - mmin) / dm)) if ibin >= 0 and ibin < nbins: mf_bar[ibin] += weight[ihalo] #black hole ibin = int(N.floor((mbh[i] - mmin) / dm)) if ibin >= 0 and ibin < nbins: mf_bh[ibin] += weight[ihalo] mf_cold = N.log10(mf_cold / dm) mf_star = N.log10(mf_star / dm) #mf_early = N.log10(mf_early / dm) #mf_late = N.log10(mf_late / dm) #mf_bulge = N.log10(mf_bulge / dm) #mf_star_central = N.log10(mf_star_central / dm) mf_bar = N.log10(mf_bar / dm) mf_bh = N.log10(mf_bh / dm) #stellar mass function plot #obs constrains mg, phig, phi_lowg, phi_highg = stellarMFs.bellG() mk, phik, phi_lowk, phi_highk = stellarMFs.bellK() #ml, phil, phi_lowl, phi_hiugl = mstar_lin(obs + 'sdss_mf/SDSS_SMF.dat') m, n, nlow, nhigh = stellarMFs.panter() fig = P.figure() ax = fig.add_subplot(111) ax.plot(mbin, mf_star, label='Stellar Mass Function') ax.errorbar(mg, phig, yerr=[phig - phi_highg, phi_lowg - phig], label='$G$-band from Bell et al.') ax.errorbar(mk, phik, yerr=[phik - phi_highk, phi_lowk - phik], label='$K$-band from Bell et al.') #ax.errorbar(ml, phil, yerr = [phi_lowl, phi_highl], label = 'Lin et al. K') ax.errorbar(m, n, yerr=[nlow - n, n - nhigh], label='$K$-band from Panter et al.') ax.set_xlim(8.0, 12.5) ax.set_ylim(-6.1, -1.0) ax.set_xlabel(r'$\log_{10} \left ( M_{\star} \ [M_{\odot}] \right )$') ax.set_ylabel( r'$\frac{\log_{10} \mathrm{d}N}{\mathrm{d}\log_{10} M_{\star}} \quad [\mathrm{Mpc}^{-3} \mathrm{dex}^{-1}]$' ) #small ticks m = ax.get_yticks()[1] - ax.get_yticks()[0] yminorLocator = MultipleLocator(m / 5) yminorFormattor = NullFormatter() ax.yaxis.set_minor_locator(yminorLocator) ax.yaxis.set_minor_formatter(yminorFormattor) m = ax.get_xticks()[1] - ax.get_xticks()[0] xminorLocator = MultipleLocator(m / 5) xminorFormattor = NullFormatter() ax.xaxis.set_minor_locator(xminorLocator) ax.xaxis.set_minor_formatter(xminorFormattor) P.legend() P.savefig('mfstar_' + output + '.pdf') P.close() #cold gas mass function #obs constrains #mhi_bell_h70 #mgas_bell_h70 theta = gas.HIMassFunctionZwaan(mbin) m_hi, phi_hi, phi_low_hi, phi_high_hi = gas.HIMassFunctionBell() m_h2, phi_h2, phi_low_h2, phi_high_h2 = gas.H2MassFunctionBell() fig = P.figure() ax = fig.add_subplot(111) ax.plot(mbin, mf_cold, label='Cold Gas Mass Function') ax.plot(mbin, theta, 'g-', lw=1.8, label='Zwaan et al.') ax.errorbar(m_hi, phi_hi, yerr=[phi_hi - phi_high_hi, phi_low_hi - phi_hi], c='cyan', ls='--', lw=1.5, label='Bell et al. $H_{I}$') ax.errorbar(m_h2, phi_h2, yerr=[phi_h2 - phi_high_h2, phi_low_h2 - phi_h2], c='magenta', ls=':', lw=1.5, label='Bell et al. $H_{2}$') ax.plot(m_hi, N.log10(10.0**phi_hi + 10**phi_h2), 'r-', label='$H_{I} + H_{2}$') ax.set_xlim(8.0, 11.5) ax.set_ylim(-5.5, -0.8) ax.set_xlabel( r'$\log_{10} \left ( M_{\mathrm{cold}} \ [M_{\odot}] \right )$') ax.set_ylabel( r'$\frac{\log_{10} \mathrm{d}N}{\mathrm{d}\log_{10} M} \quad [\mathrm{Mpc}^{-3} \mathrm{dex}^{-1}]$' ) #small ticks m = ax.get_yticks()[1] - ax.get_yticks()[0] yminorLocator = MultipleLocator(m / 5) yminorFormattor = NullFormatter() ax.yaxis.set_minor_locator(yminorLocator) ax.yaxis.set_minor_formatter(yminorFormattor) m = ax.get_xticks()[1] - ax.get_xticks()[0] xminorLocator = MultipleLocator(m / 5) xminorFormattor = NullFormatter() ax.xaxis.set_minor_locator(xminorLocator) ax.xaxis.set_minor_formatter(xminorFormattor) P.legend() P.savefig('mfcold_' + output + '.pdf') P.close() #total baryons #obs contstrains m_bar, phi_bar, phi_low_bar, phi_high_bar = baryons.BellBaryonicMassFunction( ) fig = P.figure() ax = fig.add_subplot(111) ax.plot(mbin, mf_bar, label='Total Baryon Mass') ax.errorbar(m_bar, phi_bar, yerr=[phi_bar - phi_high_bar, phi_low_bar - phi_bar], c='g', ls='-', label='Bell et al.') ax.set_xlim(8.0, 12.5) ax.set_ylim(-4.9, -0.25) ax.set_xlabel( r'$\log_{10} \left ( M_{\mathrm{baryons}} \ [M_{\odot}] \right )$') ax.set_ylabel( r'$\frac{\log_{10} \mathrm{d}N}{\mathrm{d}\log_{10} M_{\mathrm{baryons}}} \quad [\mathrm{Mpc}^{-3} \mathrm{dex}^{-1}]$' ) #small ticks m = ax.get_yticks()[1] - ax.get_yticks()[0] yminorLocator = MultipleLocator(m / 5) yminorFormattor = NullFormatter() ax.yaxis.set_minor_locator(yminorLocator) ax.yaxis.set_minor_formatter(yminorFormattor) m = ax.get_xticks()[1] - ax.get_xticks()[0] xminorLocator = MultipleLocator(m / 5) xminorFormattor = NullFormatter() ax.xaxis.set_minor_locator(xminorLocator) ax.xaxis.set_minor_formatter(xminorFormattor) P.legend() P.savefig('mfbar_' + output + '.pdf') P.close() #BH mass function #obs constrains m_bh, phi_low_bh, phi_med_bh, phi_high_bh = bh.MarconiMassFunction() fig = P.figure() ax = fig.add_subplot(111) ax.plot(mbin, mf_bh, 'k-', label='Black Hole Mass Function') ax.plot(m_bh, phi_low_bh, 'g--') ax.plot(m_bh, phi_med_bh, 'g-', label='Marconi et al.') ax.plot(m_bh, phi_high_bh, 'g--') ax.set_xlim(6.0, 10.2) ax.set_ylim(-6.9, -1.5) ax.set_xlabel(r'$\log_{10} \left ( M_{BH} \ [M_{\odot}] \right )$') ax.set_ylabel( r'$\frac{\log_{10} \mathrm{d}N}{\mathrm{d}\log_{10} M} \quad [\mathrm{Mpc}^{-3} \mathrm{dex}^{-1}]$' ) #small ticks m = ax.get_yticks()[1] - ax.get_yticks()[0] yminorLocator = MultipleLocator(m / 5) yminorFormattor = NullFormatter() ax.yaxis.set_minor_locator(yminorLocator) ax.yaxis.set_minor_formatter(yminorFormattor) m = ax.get_xticks()[1] - ax.get_xticks()[0] xminorLocator = MultipleLocator(m / 5) xminorFormattor = NullFormatter() ax.xaxis.set_minor_locator(xminorLocator) ax.xaxis.set_minor_formatter(xminorFormattor) P.legend() P.savefig('mfBH_' + output + '.pdf') P.close()
def massfunc_plot(halos, props, mmax=12.5, mmin=5.0, nbins=30, output='SMN', nvolumes=15): """ Plots stellar mass functions, cold gas mass functions, & BH MF """ #files path_BH = '/Users/niemi/Desktop/Research/IDL/obs/phopkins/' #BH_file = path_BH + 'rachel_bhmf_data.dat' #overrides weight for a single Bolshoi sub-volume #halos.weight = halos.weight * 0. + 1./(50.0/0.7)**3 halos.weight = halos.weight * 0. + 1. / (nvolumes * (50. / 0.7)**3) ngal = len(props.gal_id) print '%i galaxies found' % ngal dm = (mmax - mmin) / nbins print dm mbin = mmin + (N.arange(nbins) + 0.5) * dm #mfit = mmin + N.arange(150) * 0.05 mf_cold = N.zeros(nbins) mf_star = N.zeros(nbins) mf_star_central = N.zeros(nbins) mf_bar = N.zeros(nbins) mf_bh = N.zeros(nbins) mf_early = N.zeros(nbins) mf_late = N.zeros(nbins) mf_bulge = N.zeros(nbins) #from IDL, should be done without looping btt = 10.0**(props.mbulge - props.mstar) for i in range(ngal): ihalo = props.halo_id[i] #cold gas ibin = int(N.floor((props.mcold[i] - mmin) / dm)) if ibin >= 0 and ibin < nbins: mf_cold[ibin] += halos.weight[ihalo] #stellar mass ibin = int(N.floor((props.mstar[i] - mmin) / dm)) if ibin >= 0 and ibin < nbins: mf_star[ibin] += halos.weight[ihalo] #stellar mass, by type if btt[i] >= 0.4: mf_early[ibin] += halos.weight[ihalo] else: mf_late[ibin] += halos.weight[ihalo] #stellar mass, centrals if props.gal_id[i] == 1: if ibin >= 0 and ibin < nbins: mf_star_central[ibin] += halos.weight[ihalo] #bulge mass ibin = int(N.floor((props.mbulge[i] - mmin) / dm)) if ibin >= 0 and ibin < nbins: mf_bulge[ibin] += halos.weight[ihalo] #baryonic mass mbar = N.log10(10.0**props.mcold[i] + 10.0**props.mstar[i]) ibin = int(N.floor((mbar - mmin) / dm)) if ibin >= 0 and ibin < nbins: mf_bar[ibin] += halos.weight[ihalo] #black hole ibin = int(N.floor((props.mbh[i] - mmin) / dm)) if ibin >= 0 and ibin < nbins: mf_bh[ibin] += halos.weight[ihalo] mf_cold = N.log10(mf_cold / dm) mf_star = N.log10(mf_star / dm) #mf_early = N.log10(mf_early / dm) #mf_late = N.log10(mf_late / dm) #mf_bulge = N.log10(mf_bulge / dm) #mf_star_central = N.log10(mf_star_central / dm) mf_bar = N.log10(mf_bar / dm) mf_bh = N.log10(mf_bh / dm) #stellar mass function plot #obs constrains mg, phig, phi_lowg, phi_highg = stellarMFs.bellG() mk, phik, phi_lowk, phi_highk = stellarMFs.bellK() #ml, phil, phi_lowl, phi_hiugl = mstar_lin(obs + 'sdss_mf/SDSS_SMF.dat') m, n, nlow, nhigh = stellarMFs.panter() fig = P.figure() ax = fig.add_subplot(111) ax.plot(mbin, mf_star, label='Stellar Mass Function') ax.errorbar(mg, phig, yerr=[phig - phi_highg, phi_lowg - phig], label='Bell et al. G') ax.errorbar(mk, phik, yerr=[phik - phi_highk, phi_lowk - phik], label='Bell et al. K') #ax.errorbar(ml, phil, yerr = [phi_lowl, phi_highl], label = 'Lin et al. K') ax.errorbar(m, n, yerr=[nlow - n, n - nhigh], label='Panter et al. K') ax.set_xlim(8.0, 12.5) ax.set_ylim(-6.0, -1.0) ax.set_xlabel(r'$\log M_{star} \quad [M_{\odot}]$') ax.set_ylabel( r'$\frac{\log \textrm{d}N}{\textrm{d}\log M_{star}} \quad [\textrm{Mpc}^{-3} \textrm{dex}^{-1}]$' ) #small ticks m = ax.get_yticks()[1] - ax.get_yticks()[0] yminorLocator = MultipleLocator(m / 5) yminorFormattor = NullFormatter() ax.yaxis.set_minor_locator(yminorLocator) ax.yaxis.set_minor_formatter(yminorFormattor) m = ax.get_xticks()[1] - ax.get_xticks()[0] xminorLocator = MultipleLocator(m / 5) xminorFormattor = NullFormatter() ax.xaxis.set_minor_locator(xminorLocator) ax.xaxis.set_minor_formatter(xminorFormattor) P.legend() P.savefig('mfstar_' + output + '.pdf') P.close() #cold gas mass function #obs constrains #mhi_bell_h70 #mgas_bell_h70 theta = gas.HIMassFunctionZwaan(mbin) m_hi, phi_hi, phi_low_hi, phi_high_hi = gas.HIMassFunctionBell() m_h2, phi_h2, phi_low_h2, phi_high_h2 = gas.H2MassFunctionBell() fig = P.figure() ax = fig.add_subplot(111) ax.plot(mbin, mf_cold, label='Cold Gas Mass Function') ax.plot(mbin, theta, 'g-', lw=1.8, label='Zwaan et al.') ax.errorbar(m_hi, phi_hi, yerr=[phi_hi - phi_high_hi, phi_low_hi - phi_hi], c='cyan', ls='--', lw=1.5, label='Bell et al. $H_{I}$') ax.errorbar(m_h2, phi_h2, yerr=[phi_h2 - phi_high_h2, phi_low_h2 - phi_h2], c='magenta', ls=':', lw=1.5, label='Bell et al. $H_{2}$') ax.plot(m_hi, N.log10(10.0**phi_hi + 10**phi_h2), 'r-', label='$H_{I} + H_{2}$') ax.set_xlim(8.0, 11.5) ax.set_ylim(-5.5, -0.8) ax.set_xlabel(r'$\log_{10} M_{cold} \quad [M_{\odot}]$') ax.set_ylabel( r'$\frac{\log_{10} \textrm{d}N}{\textrm{d}\log M} \quad [\textrm{Mpc}^{-3} \textrm{dex}^{-1}]$' ) #small ticks m = ax.get_yticks()[1] - ax.get_yticks()[0] yminorLocator = MultipleLocator(m / 5) yminorFormattor = NullFormatter() ax.yaxis.set_minor_locator(yminorLocator) ax.yaxis.set_minor_formatter(yminorFormattor) m = ax.get_xticks()[1] - ax.get_xticks()[0] xminorLocator = MultipleLocator(m / 5) xminorFormattor = NullFormatter() ax.xaxis.set_minor_locator(xminorLocator) ax.xaxis.set_minor_formatter(xminorFormattor) P.legend() P.savefig('mfcold_' + output + '.pdf') P.close() #total baryons #obs contstrains m_bar, phi_bar, phi_low_bar, phi_high_bar = baryons.BellBaryonicMassFunction( ) fig = P.figure() ax = fig.add_subplot(111) ax.plot(mbin, mf_bar, label='Total Baryon Mass') ax.errorbar(m_bar, phi_bar, yerr=[phi_bar - phi_high_bar, phi_low_bar - phi_bar], c='g', ls='-', label='Bell et al.') ax.set_xlim(8.0, 12.5) ax.set_ylim(-5.0, -0.25) ax.set_xlabel(r'$\log_{10} M_{baryons} \quad [M_{\odot}]$') ax.set_ylabel( r'$\frac{\log_{10} \mathrm{d}N}{\mathrm{d}\log M_{baryons}} \quad [\mathrm{Mpc}^{-3} \mathrm{dex}^{-1}]$' ) #small ticks m = ax.get_yticks()[1] - ax.get_yticks()[0] yminorLocator = MultipleLocator(m / 5) yminorFormattor = NullFormatter() ax.yaxis.set_minor_locator(yminorLocator) ax.yaxis.set_minor_formatter(yminorFormattor) m = ax.get_xticks()[1] - ax.get_xticks()[0] xminorLocator = MultipleLocator(m / 5) xminorFormattor = NullFormatter() ax.xaxis.set_minor_locator(xminorLocator) ax.xaxis.set_minor_formatter(xminorFormattor) P.legend() P.savefig('mfbar_' + output + '.pdf') P.close() #BH mass function #obs constrains m_bh, phi_low_bh, phi_med_bh, phi_high_bh = bh.MarconiMassFunction() fig = P.figure() ax = fig.add_subplot(111) ax.plot(mbin, mf_bh, 'k-', label='Black Hole Mass Function') ax.plot(m_bh, phi_low_bh, 'g--') ax.plot(m_bh, phi_med_bh, 'g-', label='Marconi et al.') ax.plot(m_bh, phi_high_bh, 'g--') ax.set_xlim(6.0, 10.2) ax.set_ylim(-7.0, -1.5) ax.set_xlabel(r'$\log_{10} M_{BH} \quad [M_{\odot}]$') ax.set_ylabel( r'$\frac{\log_{10} \mathrm{d}N}{\mathrm{d}\log M} \quad [\mathrm{Mpc}^{-3} \mathrm{dex}^{-1}]$' ) #small ticks m = ax.get_yticks()[1] - ax.get_yticks()[0] yminorLocator = MultipleLocator(m / 5) yminorFormattor = NullFormatter() ax.yaxis.set_minor_locator(yminorLocator) ax.yaxis.set_minor_formatter(yminorFormattor) m = ax.get_xticks()[1] - ax.get_xticks()[0] xminorLocator = MultipleLocator(m / 5) xminorFormattor = NullFormatter() ax.xaxis.set_minor_locator(xminorLocator) ax.xaxis.set_minor_formatter(xminorFormattor) P.legend() P.savefig('mfBH_' + output + '.pdf') P.close()