def CentralSubhalo(self, nsnap, subhalo_prop=None): ''' Plot SMF of Central Subhalos ''' if subhalo_prop is None: raise ValueError censub = CentralSubhalos() censub.Read(nsnap, scatter=subhalo_prop['scatter'], source=subhalo_prop['source'], nsnap_ancestor=subhalo_prop['nsnap_ancestor']) self.plot(mass=censub.mass, line_color='k', line_style='-', label='Central Subhalos') return None
def LineageSMF(nsnap_ancestor, descendants=None, subhalo_prop={ 'scatter': 0.0, 'source': 'li-march' }, sfr_prop={ 'fq': { 'name': 'wetzelsmooth' }, 'sfr': { 'name': 'average' } }): ''' Plot the SMF of lineage galaxy population (both ancestor and descendants). Compare the lineage SMF to the central subhalo and analytic SMFs for all subhalos. The main agreement, is between the lineage SMF and the central subhalo SMF. If nsnap_ancestor is high, then there should be more discrepancy between LIneage SMF and CentralSubhalos SMF because more galaxies are lost. ''' # read in desendants from the lineage object if descendants is None: descendants = range(1, nsnap_ancestor) bloodline = Lineage(nsnap_ancestor=nsnap_ancestor, subhalo_prop=subhalo_prop) bloodline.Read(descendants) smf_plot = plots.PlotSMF() # plot ancestor against the analytic SMF ancestor = getattr(bloodline, 'ancestor') #smf_plot.cenque(ancestor) # SMF of lineage ancestor #smf_plot.analytic( # ancestor.zsnap, # source=ancestor.subhalo_prop['source'], # line_style='-', lw=1, # label='All Subhalos') #smf = SMF() #subh = CentralSubhalos() #subh.Read( # nsnap_ancestor, # scatter=ancestor.subhalo_prop['scatter'], # source=ancestor.subhalo_prop['source']) #subh_mass, subh_phi = smf.centralsubhalos(subh) #smf_plot.sub.plot(subh_mass, subh_phi, lw=4, ls='--', c='gray', label='Central Subhalos') for isnap in descendants: descendant = getattr(bloodline, 'descendant_snapshot' + str(isnap)) smf = SMF() subh = CentralSubhalos() subh.Read(isnap, scatter=descendant.subhalo_prop['scatter'], source=descendant.subhalo_prop['source']) subh_mass, subh_phi = smf.Obj(subh) smf_plot.sub.plot(subh_mass, subh_phi, lw=4, ls='--', c='gray') #print (subh_phi - d_phi)/d_phi #smf_plot.analytic( # descendant.zsnap, # source=descendant.subhalo_prop['source'], # line_style='-', lw=1, # label=None) smf_plot.set_axes() plt.show() smf_plot_file = ''.join([ 'figure/test/', 'LineageSMF', '.ancestor', str(nsnap_ancestor), bloodline._file_spec(subhalo_prop=bloodline.subhalo_prop, sfr_prop=bloodline.sfr_prop), '.png' ]) smf_plot.save_fig(smf_plot_file) return None
def OrphanSubhaloSMF(type, nsnap_ancestor=20, scatter=0.0, source='li-drory-march'): ''' SMF for orphan central subhalos that do not have ancestors at snapshot nsnap_ancestor. ''' prettyplot() pretty_colors = prettycolors() fig = plt.figure(figsize=(10, 10)) sub = fig.add_subplot(111) # Central subhalo at nsnap_ancestor if type == 'central': subh = CentralSubhalos() elif type == 'all': subh = Subhalos() subh.Read(nsnap_ancestor, scatter=scatter, source=source, nsnap_ancestor=nsnap_ancestor) ancestor_index = subh.index ancestor_mass = subh.mass for i_snap in [1, 5, 10, 15]: if i_snap >= nsnap_ancestor: continue smf = SMF() if type == 'central': subh = CentralSubhalos() elif type == 'all': subh = Subhalos() subh.Read(i_snap, scatter=scatter, source=source, nsnap_ancestor=nsnap_ancestor) # total central subhalo SMF subh_mass, subh_phi = smf.centralsubhalos(subh) sub.plot(subh_mass, subh_phi, lw=4, c=pretty_colors[i_snap], alpha=0.5) # SMF of central subhalos who's ancestors are centrals at snapshot 20 if i_snap == 1: label = 'Galaxies that do not have Ancestors' else: label = None orphan = np.invert( np.in1d(getattr(subh, 'ancestor' + str(nsnap_ancestor)), ancestor_index)) orph_mass, orph_phi = smf.smf(subh.mass[orphan]) sub.plot(orph_mass, orph_phi, lw=2, ls='--', c=pretty_colors[i_snap], label=label) anc_mass, anc_phi = smf.smf(ancestor_mass) sub.plot(anc_mass, anc_phi, lw=4, c='gray', label='Total') sub.set_yscale('log') sub.set_ylim([10**-5, 10**-1]) sub.set_xlim([6.0, 12.0]) sub.legend(loc='upper right') fig_file = ''.join([ 'figure/test/' 'OrphanSubhaloSMF', '.', type, '_subhalo', '.scatter', str(round(scatter, 2)), '.ancestor', str(nsnap_ancestor), '.', source, '.png' ]) fig.savefig(fig_file, bbox_inches='tight') plt.close() return None
def DescendantSubhaloSMF(type, nsnap_ancestor=20, scatter=0.0, source='li-drory-march', nomass=False): ''' SMF for 'descendant' all/central subhalos that have ancestors. If nomass is specified, then we highlight the portion of the SMF from galaxies whose ancestors have M* = 0 at snapshot nsnap_ancestor. ''' prettyplot() pretty_colors = prettycolors() fig = plt.figure(figsize=(10, 10)) sub = fig.add_subplot(111) # Central subhalo at nsnap_ancestor if type == 'central': subh = CentralSubhalos() elif type == 'all': subh = Subhalos() # read in ancestor snapshot subh.Read(nsnap_ancestor, scatter=scatter, source=source, nsnap_ancestor=nsnap_ancestor) ancestor_index = subh.index ancestor_mass = subh.mass # galaxy has M* = 0 at nsnap_ancestor nomass = np.where(subh.mass == 0.0) nomass_anc_index = subh.index[nomass] nomass_anc_mass = subh.mass[nomass] # galaxy has M* > 0 at nsnap_ancestor massive = np.where(subh.mass > 0.0) massive_anc_index = subh.index[massive] massive_anc_mass = subh.mass[massive] for i_snap in [1, 5, 10, 15]: if i_snap == 1: massive_label = 'Galaxies whose Ancestors have M* > 0' nomass_label = 'Galaxies whose Ancestors have M* = 0' label = 'Total' elif i_snap >= nsnap_ancestor: continue else: massive_label = None nomass_label = None label = None smf = SMF() # total central subhalo SMF if type == 'central': subh = CentralSubhalos() elif type == 'all': subh = Subhalos() subh.Read(i_snap, scatter=scatter, source=source, nsnap_ancestor=nsnap_ancestor) subh_mass, subh_phi = smf.centralsubhalos(subh) sub.plot(subh_mass, subh_phi, lw=3, c=pretty_colors[i_snap], label=label) anc_ind = getattr(subh, 'ancestor' + str(nsnap_ancestor)) if not nomass: # SMF of central subhalos who's ancestors are massive centrals at snapshot 20 if i_snap == 1: has_ancestor, has_descendant = intersection_index( anc_ind, massive_anc_index) else: has_ancestor, has_d = intersection_index( anc_ind, massive_anc_index) mass, phi = smf.smf(subh.mass[has_ancestor]) sub.plot(mass, phi, lw=2, ls='--', c=pretty_colors[i_snap], label=massive_label) if nomass: # SMF of central subhalos who's ancestors have M*=0 centrals at snapshot 20 if i_snap == 1: has_ancestor, has_descendant = intersection_index( anc_ind, nomass_anc_index) else: has_ancestor, has_d = intersection_index( anc_ind, nomass_anc_index) mass, phi = smf.smf(subh.mass[has_ancestor]) sub.plot(mass, phi, lw=2, ls='--', c=pretty_colors[i_snap], label=nomass_label) del subh anc_mass, anc_phi = smf.smf(ancestor_mass) sub.plot(anc_mass, anc_phi, lw=2, c='k', label='Initial Redshift') #print 'With descendants at snapshot 1', len(ancestor_mass[has_descendant]) #anc_massive = np.where(ancestor_mass[has_descendant] > 0.) #print 'With mass greater than 0', len(ancestor_mass[has_descendant[anc_massive]]) #anc_mass, anc_phi = smf.smf(ancestor_mass[has_descendant]) #sub.plot(anc_mass, anc_phi, ls='--', lw=4, c='k') #anc_mass, anc_phi = smf.smf(ancestor_mass[has_descendant[anc_massive]]) #sub.plot(anc_mass, anc_phi, ls='--', lw=2, c='green') sub.set_yscale('log') sub.set_ylim([10**-5, 10**-1]) sub.set_xlim([6.0, 12.0]) sub.legend(loc='upper right') if nomass: nomass_str = '.ancestor_Mstar0' else: nomass_str = '' fig_file = ''.join([ 'figure/test/' 'DescendantSubhaloSMF', '.', type, '_subhalo', '.scatter', str(round(scatter, 2)), '.ancestor', str(nsnap_ancestor), '.', source, nomass_str, '.png' ]) fig.savefig(fig_file, bbox_inches='tight') plt.close() return None
def DescendantQAplot(nsnap_descendants, **sfinh_kwargs): ''' The ultimate QAplot t rule them all. 4 panels showing all the properties. ''' sfinherit_file = InheritSF_file(nsnap_descendants, **sfinh_kwargs) bloodline = Lineage(nsnap_ancestor=sfinh_kwargs['nsnap_ancestor'], subhalo_prop=sfinh_kwargs['subhalo_prop']) if not isinstance(nsnap_descendants, list): nsnap_descendants = [nsnap_descendants] bloodline.Read(nsnap_descendants, filename=sfinherit_file) for nsnap_descendant in nsnap_descendants: descendant = getattr(bloodline, 'descendant_snapshot' + str(nsnap_descendant)) descendant.sfr_prop = sfinh_kwargs['sfr_prop'] started_here = np.where( descendant.nsnap_genesis == sfinh_kwargs['nsnap_ancestor']) start_mass = descendant.mass_genesis[started_here] # Mass bins mass_bins = np.arange(7., 12.5, 0.5) mass_bin_low = mass_bins[:-1] mass_bin_high = mass_bins[1:] plt.close() prettyplot() fig = plt.figure(1, figsize=[25, 6]) for i_sub in range(1, 5): sub_i = fig.add_subplot(1, 4, i_sub) if i_sub == 1: # SMF mf = SMF() mass, phi = mf.Obj(descendant) sub_i.plot(mass, phi, lw=4, c=pretty_colors[descendant.nsnap], label=r'Simulated') censub = CentralSubhalos() censub.Read(descendant.nsnap, scatter=sfinh_kwargs['subhalo_prop']['scatter'], source=sfinh_kwargs['subhalo_prop']['source'], nsnap_ancestor=sfinh_kwargs['nsnap_ancestor']) mass, phi = mf._smf(censub.mass) sub_i.plot(mass, phi, c='k', lw=4, ls='--', label='Central Subhalos') sub_i.set_ylim([10**-5, 10**-1]) sub_i.set_xlim([7.5, 12.0]) plt.xticks([8., 9., 10., 11., 12.]) sub_i.set_yscale('log') # x,y labels sub_i.set_xlabel(r'Mass $\mathtt{M_*}$', fontsize=25) sub_i.set_ylabel(r'Stellar Mass Function $\mathtt{\Phi}$', fontsize=25) sub_i.legend(loc='upper right', frameon=False) elif i_sub == 2: # SFMS # SMF composition based on their initial mass at nsnap_ancestor for i_m in range(len(mass_bin_low)): mbin = np.where((start_mass > mass_bin_low[i_m]) & (start_mass <= mass_bin_high[i_m])) sub_i.scatter(descendant.mass[started_here[0][mbin]], descendant.sfr[started_here[0][mbin]], color=pretty_colors[i_m], label=r"$\mathtt{M_{*,i}=}$" + str(round(mass_bin_low[i_m], 2)) + "-" + str(round(mass_bin_high[i_m], 2))) qfrac = Fq() m_arr = np.arange(9.0, 12.5, 0.5) sub_i.plot(m_arr, qfrac.SFRcut( m_arr, descendant.zsnap, sfms_prop=(sfinh_kwargs['sfr_prop'])['sfms']), c='k', ls='--', lw=4) sub_i.set_xlim([9.0, 12.0]) sub_i.set_ylim([-5.0, 2.0]) sub_i.set_xlabel(r'$\mathtt{log\;M_*}$', fontsize=25) sub_i.set_ylabel(r'$\mathtt{log\;SFR}$', fontsize=25) elif i_sub == 3: #SMHM for i_m in range(len(mass_bin_low)): mbin = np.where((start_mass > mass_bin_low[i_m]) & (start_mass <= mass_bin_high[i_m])) sub_i.scatter(descendant.halo_mass[started_here[0][mbin]], descendant.mass[started_here[0][mbin]], color=pretty_colors[i_m], label=r"$\mathtt{M_{*,i}=}$" + str(round(mass_bin_low[i_m], 2)) + "-" + str(round(mass_bin_high[i_m], 2))) stellarmass = descendant.mass[started_here] halomass = descendant.halo_mass[started_here] mbin = np.arange(halomass.min(), halomass.max(), 0.25) mlow = mbin[:-1] mhigh = mbin[1:] muMstar = np.zeros(len(mlow)) sigMstar = np.zeros(len(mlow)) for im in range(len(mlow)): mbin = np.where((halomass > mlow[im]) & (halomass <= mhigh[im])) muMstar[im] = np.mean(stellarmass[mbin]) sigMstar[im] = np.std(stellarmass[mbin]) sub_i.errorbar(0.5 * (mlow + mhigh), muMstar, yerr=sigMstar, color='k', lw=3, fmt='o', capthick=2) sub_i.set_ylim([9.0, 12.0]) sub_i.set_xlim([10.0, 15.0]) sub_i.set_ylabel(r'Stellar Mass $\mathtt{M_*}$', fontsize=25) sub_i.set_xlabel(r'Halo Mass $\mathtt{M_{Halo}}$', fontsize=25) #sub_i.legend(loc='upper left', frameon=False, scatterpoints=1) elif i_sub == 4: # Fq #mass, fq = descendant.Fq() sfq = qfrac.Classify(descendant.mass, descendant.sfr, descendant.zsnap, sfms_prop=descendant.sfr_prop['sfms']) gc = GroupCat(Mrcut=18, position='central') gc.Read() gc_sfq = qfrac.Classify(gc.mass, gc.sfr, np.mean(gc.z), sfms_prop=descendant.sfr_prop['sfms']) #sub_i.plot(mass, fq, color=pretty_colors[descendant.nsnap], lw=3, ls='--', # label=r'$\mathtt{z =} '+str(descendant.zsnap)+'$') M_bin = np.array([9.7, 10.1, 10.5, 10.9, 11.3]) M_low = M_bin[:-1] M_high = M_bin[1:] M_mid = 0.5 * (M_low + M_high) fq = np.zeros(len(M_low)) gc_fq = np.zeros(len(M_low)) for i_m in xrange(len(M_low)): mlim = np.where((descendant.mass > M_low[i_m]) & (descendant.mass <= M_high[i_m])) gc_mlim = np.where((gc.mass > M_low[i_m]) & (gc.mass <= M_high[i_m])) ngal = np.float(len(mlim[0])) gc_ngal = np.float(len(gc_mlim[0])) if ngal != 0: # no galaxy in mass bin ngal_q = np.float( len(np.where(sfq[mlim] == 'quiescent')[0])) fq[i_m] = ngal_q / ngal if gc_ngal != 0: gc_ngal_q = np.float( len(np.where(gc_sfq[gc_mlim] == 'quiescent')[0])) gc_fq[i_m] = gc_ngal_q / gc_ngal sub_i.plot(M_mid, fq, color=pretty_colors[descendant.nsnap], lw=3, label=r'$\mathtt{z =} ' + str(descendant.zsnap) + '$') fq_model = qfrac.model( M_bin, descendant.zsnap, lit=sfinh_kwargs['sfr_prop']['fq']['name']) sub_i.plot(M_bin, fq_model, color='k', lw=4, ls='--', label=sfinh_kwargs['sfr_prop']['fq']['name']) sub_i.scatter(M_mid, gc_fq, color='k', s=100, lw=0, label='Group Catalog') sub_i.set_xlim([9.0, 12.0]) sub_i.set_ylim([0.0, 1.0]) sub_i.set_xlabel(r'Mass $\mathtt{M_*}$') sub_i.set_ylabel(r'Quiescent Fraction $\mathtt{f_Q}$', fontsize=20) sub_i.legend(loc='upper left', frameon=False, scatterpoints=1, markerscale=0.75) plt.tight_layout(pad=0.4, w_pad=0.5, h_pad=1.0) fig_name = ''.join([ 'figure/test/', 'QAplot.', '.nsnap', str(nsnap_descendant), '.'.join( (sfinherit_file.rsplit('/')[-1]).rsplit('.')[:-1]), '.png' ]) fig.savefig(fig_name, bbox_inches='tight') plt.close() return None
def ImportSubhalo(self, nsnap, subhalo_prop=None): ''' Import Central Subhalo Snapshots with SHAM M* through the CentralSubhalos class object. The CentralSubhalos class is a wrapper for Andrew Wetzel's TreePM code. Parameters ---------- nsnap : int Subhalo Snapshot number. Each snapshot represents a different redshift. Higher number are at higher redshifts. subhalo_prop : dict (optional) Optional dictionary that specifies the subhalo snapshot properties. The properties include, - scatter : float Scatter between SMF and HMF in SHAM - source : str Specifies which analytic SMF to use for SHAM Notes ----- Also imports snapshot, redshift and t_cosmic metadata. * SHAM stellar mass * parent index * child index * halo mass ''' if self.subhalo_prop is None: self.subhalo_prop = subhalo_prop else: if subhalo_prop and self.subhalo_prop != subhalo_prop: # subhalo_prop values do not match raise ValueError centsub = CentralSubhalos() centsub.Read( nsnap, # snapshot scatter=self.subhalo_prop['scatter'], # scatter source=self.subhalo_prop['source'], # SMF source nsnap_ancestor=self.subhalo_prop['nsnap_ancestor']) #print centsub.file_name # pass CentralSubhalos class attributes to self.data_columns = self.get_datacol() for col in centsub.data_columns: if col == 'halo.m.max': newcol = 'halo_mass_max' elif col == 'index': newcol = 'snap_index' elif col == 'halo.m': newcol = 'halo_mass' else: newcol = col setattr(self, newcol, getattr(centsub, col)) if newcol not in self.data_columns: self.data_columns.append(newcol) # Meta data self.metadata = [ 'nsnap', 'zsnap', 't_cosmic', 't_step', 'subhalo_prop' ] # get snapshot redshift/cosmic time data using Andrew's table n_snaps, z_snap, t_snap, t_wid = np.loadtxt(Util.snapshottable(), unpack=True, usecols=[0, 2, 3, 4]) self.nsnap = nsnap self.zsnap = z_snap[( n_snaps.tolist()).index(nsnap)] # redshift of snapshot self.t_cosmic = t_snap[( n_snaps.tolist()).index(nsnap)] # t_cosmic of snapshot self.t_step = t_wid[( n_snaps.tolist()).index(nsnap)] # Gyrs until next snapshot #print "import_treepm takes ", time.time() - start_time return None
def QAplot(descendant, sfinh_kwargs, fig_name=None, **kwargs): ''' Given galpop object and the SF Inheritance parametes, plot its SMF, ''' # Mass bins mass_bins = np.arange(7., 12.5, 0.5) mass_bin_low = mass_bins[:-1] mass_bin_high = mass_bins[1:] plt.close() prettyplot() fig = plt.figure(1, figsize=[20,12]) for i_sub in range(1,6): sub_i = fig.add_subplot(2,3,i_sub) if i_sub == 1: # SMF mf = SMF() mass, phi = mf.Obj(descendant) sub_i.plot(mass, phi, lw=4, c='r', label=r'Simulated') censub = CentralSubhalos() censub.Read(descendant.nsnap, scatter=sfinh_kwargs['subhalo_prop']['scatter'], source=sfinh_kwargs['subhalo_prop']['source'], nsnap_ancestor=sfinh_kwargs['nsnap_ancestor']) mass, phi = mf._smf(censub.mass) sub_i.plot(mass, phi, c='k', lw=4, ls='--', label='Central Subhalos') sub_i.set_ylim([10**-5, 10**-1]) sub_i.set_xlim([7.5, 12.0]) plt.xticks([8., 9., 10., 11., 12.]) sub_i.set_yscale('log') # x,y labels sub_i.set_ylabel(r'Stellar Mass ($\mathtt{log\; M_*}$)', fontsize=20) sub_i.set_ylabel(r'Stellar Mass Function $\mathtt{\Phi}$', fontsize=20) sub_i.legend(loc='upper right', frameon=False) elif i_sub == 2: # SFMS # SMF composition based on their initial mass at nsnap_ancestor # random subsample n_tot = len(descendant.mass) r_subsample = np.random.choice(n_tot, size=100000) sub_i.scatter(descendant.mass[r_subsample], descendant.sfr[r_subsample], color='b', s=0.5) qfrac = Fq() m_arr = np.arange(9.0, 12.5, 0.5) sub_i.plot( m_arr, qfrac.SFRcut(m_arr, descendant.zsnap, sfms_prop=(sfinh_kwargs['sfr_prop'])['sfms']), c='k', ls='--', lw=4) sub_i.text(10.5, -4., r'$\mathtt{z='+str(descendant.zsnap)+'}$', fontsize=25) sub_i.set_xlim([9.0, 12.0]) sub_i.set_ylim([-5.0, 2.0]) sub_i.set_ylabel(r'Stellar Mass ($\mathtt{log\; M_*}$)', fontsize=20) sub_i.set_ylabel(r'$\mathtt{log\;SFR}$', fontsize=20) elif i_sub == 3: #SMHM #corner.hist2d(descendant.halo_mass, descendant.mass, ax=sub_i, c='b', fill_contours=True, smooth=1.0) n_tot = len(descendant.mass) r_subsample = np.random.choice(n_tot, size=100000) sub_i.scatter(descendant.halo_mass[r_subsample], descendant.mass[r_subsample], color='b', s=0.5) stellarmass = descendant.mass halomass = descendant.halo_mass mbin = np.arange(halomass.min(), halomass.max(), 0.25) mlow = mbin[:-1] mhigh = mbin[1:] muMstar = np.zeros(len(mlow)) sigMstar = np.zeros(len(mlow)) for im in range(len(mlow)): mbin = np.where((halomass > mlow[im]) & (halomass <= mhigh[im])) muMstar[im] = np.mean(stellarmass[mbin]) sigMstar[im] = np.std(stellarmass[mbin]) sub_i.errorbar(0.5*(mlow+mhigh), muMstar, yerr=sigMstar, color='k', lw=3, fmt='o', capthick=2) sub_i.set_ylim([9.0, 12.0]) sub_i.set_xlim([10.0, 15.0]) sub_i.set_ylabel(r'Stellar Mass ($\mathtt{log\; M_*}$)', fontsize=20) sub_i.set_xlabel(r'Halo Mass ($\mathtt{log\;M_{Halo}}$)', fontsize=20) elif i_sub == 4: # Fq sfq = qfrac.Classify(descendant.mass, descendant.sfr, descendant.zsnap, sfms_prop=descendant.sfr_prop['sfms']) gc = GroupCat(Mrcut=18, position='central') gc.Read() gc_sfq = qfrac.Classify(gc.mass, gc.sfr, np.mean(gc.z), sfms_prop=descendant.sfr_prop['sfms']) #sub_i.plot(mass, fq, color=pretty_colors[descendant.nsnap], lw=3, ls='--', # label=r'$\mathtt{z =} '+str(descendant.zsnap)+'$') M_bin = np.array([9.7, 10.1, 10.5, 10.9, 11.3]) M_low = M_bin[:-1] M_high = M_bin[1:] M_mid = 0.5 * (M_low + M_high) fq = np.zeros(len(M_low)) gc_fq = np.zeros(len(M_low)) for i_m in xrange(len(M_low)): mlim = np.where((descendant.mass > M_low[i_m]) & (descendant.mass <= M_high[i_m])) gc_mlim = np.where((gc.mass > M_low[i_m]) & (gc.mass <= M_high[i_m])) ngal = np.float(len(mlim[0])) gc_ngal = np.float(len(gc_mlim[0])) if ngal != 0: # no galaxy in mass bin ngal_q = np.float(len(np.where(sfq[mlim] == 'quiescent')[0])) fq[i_m] = ngal_q/ngal if gc_ngal != 0: gc_ngal_q = np.float(len(np.where(gc_sfq[gc_mlim] == 'quiescent')[0])) gc_fq[i_m] = gc_ngal_q/gc_ngal sub_i.plot(M_mid, fq, color='r', lw=3, label=r'Simulated') # fQ of the Group Catalog sub_i.scatter(M_mid, gc_fq, color='k', s=100, lw=0, label='Group Catalog') # fQ of the model (input) fQ fq_model = qfrac.model(M_bin, descendant.zsnap, lit=sfinh_kwargs['sfr_prop']['fq']['name']) sub_i.plot(M_bin, fq_model, color='k', lw=4, ls='--', label=sfinh_kwargs['sfr_prop']['fq']['name'].replace('_', ' ').title() ) sub_i.set_xlim([9.0, 12.0]) sub_i.set_ylim([0.0, 1.0]) sub_i.set_ylabel(r'Stellar Mass ($\mathtt{log\; M_*}$)', fontsize=20) sub_i.set_ylabel(r'Quiescent Fraction $\mathtt{f_Q}$', fontsize=20) sub_i.legend(loc='upper left', frameon=False, scatterpoints=1, markerscale=0.75) elif i_sub == 5: # Tau_Q(M*) mass_bin = np.arange(9.0, 12.0, 0.1) tau_m = getTauQ(mass_bin, tau_prop=sfinh_kwargs['evol_prop']['tau']) sub_i.plot(10**mass_bin, tau_m, color='r', lw=4, label='Simulated') if 'taus' in kwargs: tau_slopes, tau_offsets = kwargs['taus'] i_tau_ms = np.zeros((len(mass_bin), len(tau_slopes))) for i_tau in range(len(tau_slopes)): i_tau_prop = sfinh_kwargs['evol_prop']['tau'].copy() i_tau_prop['slope'] = tau_slopes[i_tau] i_tau_prop['yint'] = tau_offsets[i_tau] i_tau_m = getTauQ(mass_bin, tau_prop=i_tau_prop) #sub_i.plot(10**mass_bin, i_tau_m, color='r', alpha=0.1, lw=2) i_tau_ms[:,i_tau] = i_tau_m sig_tau = np.zeros(len(mass_bin)) for im in range(len(mass_bin)): sig_tau[im] = np.std(i_tau_ms[im,:]) sub_i.errorbar(10**mass_bin, tau_m, yerr=sig_tau, color='r', lw=4) # satellite quenching fraction for comparison tau_sat = getTauQ(mass_bin, tau_prop={'name': 'satellite'}) sub_i.plot(10**mass_bin, tau_sat, color='black', lw=4, ls='--', label=r'Satellite (Wetzel+ 2013)') sub_i.set_xlim([10**9.5, 10**11.75]) sub_i.set_ylim([0.0, 2.0]) sub_i.set_xscale('log') sub_i.set_xlabel(r'Stellar Mass $[\mathtt{M_\odot}]$',fontsize=20) sub_i.legend(loc='upper right') sub_i.set_ylabel(r'Quenching Timescales $(\tau_\mathtt{Q})$ [Gyr]',fontsize=20) plt.tight_layout(pad=0.4, w_pad=0.5, h_pad=1.0) if fig_name is None: plt.show() plt.close() else: fig.savefig(fig_name, bbox_inches='tight') plt.close() return None