def AncestorPlots(**sfinh_kwargs): ''' FQ for the SF Inherited Ancestor galaxy population. This test is mainly to see what the discrepancy between the empirical SF/Q classifcation and the parameterized FQ model. Ideally, the model and the ''' bloodline = Lineage(nsnap_ancestor=sfinh_kwargs['nsnap_ancestor'], subhalo_prop=sfinh_kwargs['subhalo_prop']) bloodline.Read([1]) bloodline.AssignSFR_ancestor(sfr_prop=sfinh_kwargs['sfr_prop']) ancestor = getattr(bloodline, 'ancestor') ancestor.sfr_prop = sfinh_kwargs['sfr_prop'] fig_file = lambda prop: ''.join([ 'figure/test/', 'Ancestor', str(sfinh_kwargs['nsnap_ancestor']), '.', prop.upper(), '.png' ]) ancestor.plotSsfr(savefig=fig_file('ssfr')) plt.close() # FQ ancestor.plotFq(model=True, savefig=fig_file('fq')) ancestor.plotSFMS(sfqcut=True, gal_class='all', bovyplot=False, sigSFR=False, model=False, savefig=fig_file('sfms')) plt.close() return None
def _Read_Lineage(self): ''' Read in Lineage object and import all the GalPop objects within lineage to Inherit object. ''' # read in the lineage (< 0.05 seconds for one snapshot) if not self.quiet: read_time = time.time() bloodline = Lineage(nsnap_ancestor=self.nsnap_ancestor, subhalo_prop=self.subhalo_prop, quiet=self.quiet) bloodline.Read(self.nsnap_descendants, quiet=self.quiet) #DEFUNCT #if 'subhalogrowth' in self.sfr_prop.keys(): # # depending on whether SFR assign includes subhalo growth AM # sfr_prop['subhalogrowth']['nsnap_descendant'] = nsnap_descendant # assign SFR to ancestor object bloodline.AssignSFR_ancestor(sfr_prop=self.sfr_prop, quiet=self.quiet) if not self.quiet: print 'Lineage Read Time = ', time.time() - read_time self.ancestor = bloodline.ancestor # ancestor object self.ancestor.tQ[np.where(self.ancestor.tQ != 999.)] = 0. self.MshamEvol = self.ancestor.Msham_evol[0] self._ImportDescendants(bloodline) return None
def InheritSF(nsnap_descendant, nsnap_ancestor=20, subhalo_prop=None, sfr_prop=None, evol_prop=None, quiet=True): ''' Evolve star formation properties of 'ancestor' CentralGalaxyPopulation class at redshift specified by nsnap_ancestor to descendant CentralGalaxlyPopulation object at redshift specified by nsnap_descendant. Both ancestor and descendant objects are attributes in the Lineage class, which contains all the 'lineage' information i.e. all the halo tracking information. Parameters ---------- nsnap_ancestor : int Snapshot number of ancestor CGPop object. The ancestor object is constructed with from subhalo catalog with subhalo_prop properties. They are also assigned SFRs with sfr_prop properties. subhalo_prop : dict Dictionary that describes the subhalo properties. The key 'scatter' corresponds to the M*-M_halo relation. The key 'soruce' describes the source SMF used for the SHAM masses. sfr_prop : dict Dictionary that describes the SFR properties assigned to the ancestor CenQue object. The key 'fq' describes the quiescent fraction used for the ancestor while the key 'sfr' describes the properties of the SFR assignment. evol_prop : dict Dictionary that consists of dictionaries which each describe paramter choices in the model. - evol_prop['pq'] dictates the quenching properties. - evol_prop['tau'] dictates the quenching timescale. - evol_prop['sfr'] dictates the SFR evolution. - evol_prop['mass'] dictates the mass evolution. ''' if isinstance(nsnap_descendant, list): d_list = True else: d_list = False # read in the lineage (< 0.05 seconds for one snapshot) #read_time = time.time() bloodline = Lineage(nsnap_ancestor=nsnap_ancestor, subhalo_prop=subhalo_prop, quiet=quiet) if not d_list: bloodline.Read(range(nsnap_descendant, nsnap_ancestor), quiet=quiet) else: bloodline.Read(range(np.min(nsnap_descendant), nsnap_ancestor), quiet=quiet) if 'subhalogrowth' in sfr_prop.keys( ): # depending on whether SFR assign includes subhalo growth AM sfr_prop['subhalogrowth']['nsnap_descendant'] = nsnap_descendant bloodline.AssignSFR_ancestor(sfr_prop=sfr_prop, quiet=quiet) #print 'Lineage Read Time = ', time.time() - read_time ancestor = bloodline.ancestor # ancestor object t_init = ancestor.t_cosmic z_init = ancestor.zsnap ancestor.tQ[np.where(ancestor.tQ != 999.)] = 0. if not isinstance(nsnap_descendant, list): nsnap_descendant = [nsnap_descendant] descendants = [] sf_ancestors, q_ancestors = [], [] successions, wills = [], [] for nd in nsnap_descendant: des = getattr(bloodline, 'descendant_snapshot' + str(nd)) des._clean_initialize() # initialize SF properties des.sfr_prop = ancestor.sfr_prop # match indices up with each other succession, will = intersection_index( getattr(des, 'ancestor' + str(nsnap_ancestor)), ancestor.snap_index) if len(succession) != len(des.mass): raise ValueError('Something wrong with the lineage') q_ancestor = np.where( ancestor.sfr_class[will] == 'quiescent')[0] # Q ancestors sf_ancestor = np.where( ancestor.sfr_class[will] == 'star-forming')[0] # SF ancestors if not quiet: print "nsnap_descendant = ", nd, "Ancestors: Nq = ", len( q_ancestor), ', Nsf = ', len(sf_ancestor) descendants.append(des) wills.append(will) successions.append(succession) q_ancestors.append(q_ancestor) sf_ancestors.append(sf_ancestor) # Evolve queiscent ancestor galaxies if not quiet: q_time = time.time() descendants = _QuiescentEvol(ancestor, descendants, successions=successions, wills=wills, q_ancestors=q_ancestors) if not quiet: print 'Quiescent evolution takes ', time.time() - q_time # Evolve Star Forming Galaxies if not quiet: sf_time = time.time() ################## PQ BASED DROPPED ############################## # if evol_prop['type'] == 'pq_based': # _StarformingEvol_Pq(ancestor, descendant, succession=succession, will=will, # evol_prop=evol_prop, sfr_prop=sfr_prop, # lineage=bloodline) # elif evol_prop['type'] == 'simult': ################## PQ BASED DROPPED ############################## descendants = _StarformingEvol_SimulEvo(ancestor, descendants, successions=successions, wills=wills, evol_prop=evol_prop, sfr_prop=sfr_prop, lineage=bloodline, quiet=quiet) if not quiet: print 'Star Forming Evolution takes ', time.time() - sf_time descendants = _Overquenching(descendants, successions=successions, wills=wills, sf_ancestors=sf_ancestors) for descendant in descendants: descendant.data_columns = list(descendant.data_columns) + [ 'ssfr', 'sfr', 'min_ssfr', 'sfr_class' ] setattr(bloodline, 'descendant_snapshot' + str(descendant.nsnap), descendant) return bloodline
def InheritSF(nsnap_descendant, nsnap_ancestor=20, subhalo_prop={ 'scatter': 0.0, 'source': 'li-march' }, sfr_prop={ 'fq': { 'name': 'wetzelsmooth' }, 'sfms': { 'name': 'linear', 'mslope': 0.55, 'zslope': 1.1 } }, evol_prop={ 'pq': { 'slope': 0.05, 'yint': 0.0 }, 'tau': { 'name': 'line', 'fid_mass': 10.75, 'slope': -0.6, 'yint': 0.6 }, 'sfr': { 'dutycycle': { 'name': 'notperiodic' } }, 'mass': { 'name': 'sham' } }): ''' Evolve star formation properties of ancestor CentralGalaxyPopulation class within the Lineage Class to descendant CentralGalaxlyPopulation object Parameters ---------- nsnap_ancestor : int Snapshot number of ancestor CGPop object. The ancestor object is constructed with from subhalo catalog with subhalo_prop properties. They are also assigned SFRs with sfr_prop properties. subhalo_prop : dict Dictionary that describes the subhalo properties. The key 'scatter' corresponds to the M*-M_halo relation. The key 'soruce' describes the source SMF used for the SHAM masses. sfr_prop : dict Dictionary that describes the SFR properties assigned to the ancestor CenQue object. The key 'fq' describes the quiescent fraction used for the ancestor while the key 'sfr' describes the properties of the SFR assignment. evol_prop : dict Dictionary that consists of dictionaries which each describe paramter choices in the model. - evol_prop['pq'] dictates the quenching properties. - evol_prop['tau'] dictates the quenching timescale. - evol_prop['sfr'] dictates the SFR evolution. - evol_prop['mass'] dictates the mass evolution. ''' # make sure that snapshot = 1 is included among imported descendants # and the first element of the list if isinstance(nsnap_descendant, list): raise ValueError('nsnap_descendant arg has to be an int') # evolution properties pq_prop = evol_prop['pq'] tau_prop = evol_prop['tau'] sfrevol_prop = evol_prop['sfr'] massevol_prop = evol_prop['mass'] # read in the lineage (< 0.05 seconds for one snapshot) read_time = time.time() bloodline = Lineage(nsnap_ancestor=nsnap_ancestor, subhalo_prop=subhalo_prop) bloodline.Read(range(nsnap_descendant, nsnap_ancestor), sfr_prop='default') if 'subhalogrowth' in sfr_prop.keys(): sfr_prop['subhalogrowth']['nsnap_descendant'] = nsnap_descendant bloodline.AssignSFR_ancestor(sfr_prop=sfr_prop) print 'Lineage Read Time = ', time.time() - read_time ancestor = bloodline.ancestor # ancestor object t_init = ancestor.t_cosmic z_init = ancestor.zsnap # descendant object descendant = getattr(bloodline, 'descendant_snapshot' + str(nsnap_descendant)) t_final = descendant.t_cosmic z_final = descendant.zsnap print 'Evolve until z = ', z_final # initialize SF properties of descendant n_descendant = len(descendant.snap_index) descendant.sfr = np.repeat(-999., n_descendant) descendant.ssfr = np.repeat(-999., n_descendant) descendant.min_ssfr = np.repeat(-999., n_descendant) descendant.tau = np.repeat(-999., n_descendant) descendant.sfr_class = np.chararray(n_descendant, itemsize=16) descendant.sfr_class[:] = '' succession, will = intersection_index( getattr(descendant, 'ancestor' + str(nsnap_ancestor)), ancestor.snap_index) if len(succession) != len(descendant.mass): raise ValueError('Something wrong with the lineage') q_ancestors = np.where( ancestor.sfr_class[will] == 'quiescent')[0] # Q ancestors sf_ancestors = np.where( ancestor.sfr_class[will] == 'star-forming')[0] # SF ancestors # Evolve queiscent ancestor galaxies q_time = time.time() descendant = _QuiescentEvol(ancestor, descendant, succession=succession, will=will) print 'Quiescent evolution takes ', time.time() - q_time # Evolve Star Forming Galaxies sf_time = time.time() _StarformingEvol(ancestor, descendant, succession=succession, will=will, evol_prop=evol_prop, sfr_prop=sfr_prop, lineage=bloodline) print 'Star Forming Evolution takes ', time.time() - sf_time # Deal with over quenched galaxies overquenched = np.where(descendant.min_ssfr[succession[sf_ancestors]] > descendant.ssfr[succession[sf_ancestors]]) if len(overquenched[0]) > 0: descendant.ssfr[succession[ sf_ancestors[overquenched]]] = descendant.min_ssfr[succession[ sf_ancestors[overquenched]]] descendant.sfr[succession[sf_ancestors[overquenched]]] = descendant.ssfr[succession[sf_ancestors[overquenched]]] \ + descendant.mass[succession[sf_ancestors[overquenched]]] #descendant.tau[succession[sf_ancestors[overquenched]]] = -999. descendant.data_columns = list(descendant.data_columns) + [ 'ssfr', 'sfr', 'min_ssfr', 'sfr_class' ] #, 'tau']) setattr(bloodline, 'descendant_snapshot' + str(nsnap_descendant), descendant) return bloodline