Arbor.select_halos(criteria, trees=None, select_from='tree', fields=None)

Select halos from the arbor based on a set of criteria given as a string.

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 : optional, “tree” or “prog”
Determines whether to perform the search over the full tree or just the main progenitors. Note, the value given must be consistent with what appears in the criteria string. For example, a criteria string of ‘tree[“tree”, “redshift”] > 1’ cannot be used when setting select_from to “prog”. Default: “tree”.
fields : optional, list of strings
Use to provide a list of fields required by the criteria evaluation. If given, fields will be preloaded in an optimized way and the search will go faster. Default: None.
halos : array of TreeNodes
A flat array of all TreeNodes meeting the criteria.
>>> import ytree
>>> a = ytree.load("tree_0_0_0.dat")
>>> halos = a.select_halos('tree["tree", "redshift"] > 1',
...                        fields=["redshift"])
>>> halos = a.select_halos('tree["prog", "mass"].to("Msun") >= 1e10',
...                        select_from="prog", fields=["mass"])