ytree.arbor.tree_node_selector.add_tree_node_selector

ytree.arbor.tree_node_selector.add_tree_node_selector(name, function)

Add a TreeNodeSelector to the registry of known selectors, so they can be chosen with set_selector.

name : string
Name of the selector.
function : callable
The associated function.
>>> 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"])