select_halos(criteria, trees=None, select_from=None, fields=None)¶
Select halos from the arbor based on a set of criteria given as a string.
Halos matching the criteria will be returned through a generator. Matches are returned as soon as they are found, allowing you to begin working with them before the search has completed. The progress bar will update to report the number of matches found as the search progresses.
- criteria (string) – A string that will eval to a Numpy-like selection operation performed on a TreeNode object called “tree”. Example: ‘tree[“tree”, “redshift”] > 1’
- trees (optional, list or array of TreeNodes) – A list or array of TreeNode objects in which to search. If none given, the search is performed over the full arbor.
- select_from (deprecated, do not use) – This keyword is no longer required and using it does nothing.
- fields (deprecated, do not use) – This keyword is no longer required and using it does nothing.
halos – A generator yielding all TreeNodes meeting the criteria.
>>> import ytree >>> a = ytree.load("tree_0_0_0.dat") >>> for halo in a.select_halos('tree["tree", "redshift"] > 1'): ... print (halo["mass"]) >>> >>> halos = list(a.select_halos('tree["prog", "mass"].to("Msun") >= 1e10')) >>> print (len(halos))