ytree.data_structures.tree_node_selector.TreeNodeSelector
- class ytree.data_structures.tree_node_selector.TreeNodeSelector(function, args=None, kwargs=None)[source]
The TreeNodeSelector is responsible for choosing which one of a halo’s ancestors to return when querying the line of main progenitors for a halo.
- Parameters:
ancestors (list of TreeNode objects) – List of TreeNode objects from which to select.
TreeNode. (The function should return a single)
Examples
>>> import ytree >>> def max_value(ancestors, field): ... vals = np.array([a[field] for a in ancestors]) ... return ancestors[np.argmax(vals)] >>> ytree.add_tree_node_selector("max_field_value", max_value) >>> a = ytree.load("tree_0_0_0.dat") >>> a.set_selector("max_field_value", "mass") >>> print (a[0]["prog"])
Methods
__init__(function[, args, kwargs])