Creating Branch-Matrices
References
- haccytrees.mergertrees.forest2matrix(forest, simulation, target_index=None, *, subhalo_data=None, branchmass_threshold=None)[source]
Convert a haccytree forest to a matrix, where each row is a branch
- Parameters:
forest (Mapping[str, ndarray]) – the full treenode forest returned by
read_forest()
simulation (str | Simulation) – the full progenitor array created by
read_forest()
target_index (int | None) – (optional) if set, a matrix of only the tree starting at target_index will be calculated
subhalo_data (Mapping[str, ndarray] | None) – currently does nothing
branchmass_threshold (float | None) – if set, removes all branches that have a mass below the threshold at infall
- Returns:
matrices – arrays of shape (nbranches, nsnapshots) for each of the forest properties. Additionally, matrices[“top_host_row”] contains the row number of the main host, matrices[“direct_host_row”] contains the row of the direct host in the hierarchy, and matrices[“parent_tni”] contains the `tree_node_index of the main (top) host halo. top_host_row and direct_host_row are -1 for host halos. parent_tni of a host halo is its own tree_node_index.
- Return type:
Mapping[str, np.ndarray]
Notes
All the properties (except top_host_row, direct_host_row, parent_tni) are 0 for entries where the halo does not exist or when the halo is a subhalo. For top_host_row, direct_host_row, and parent_tni, the values are -1 prior to the nucleation of the branch.