ytree.data_structures.tree_node.TreeNode.get_node¶
-
TreeNode.
get_node
(selector, index)[source]¶ Get a single TreeNode from a tree.
Use this to get the nth TreeNode from a forest, tree, or progenitor list for which the calling TreeNode is the head.
Parameters: - selector (str ("forest", "tree", or "prog")) – The tree selector from which to get the TreeNode. This should be “forest”, “tree”, or “prog”.
- index (int) – The index of the desired TreeNode in the forest, tree, or progenitor list.
Returns: node
Return type: Examples
>>> import ytree >>> a = ytree.load("tiny_ctrees/locations.dat") >>> my_tree = a[0] >>> # get 6th TreeNode in the progenitor list >>> my_node = my_tree.get_node('prog', 5)