ytree.tree_farm.tree_farm.TreeFarm¶
-
class
ytree.tree_farm.tree_farm.
TreeFarm
(time_series, setup_function=None)¶ TreeFarm is the merger-tree creator for Gadget FoF and Subfind halo catalogs.
TreeFarm can be used to create a merger-tree for the full set of halos, starting from the first catalog, or can be used to trace the ancestry of specific halos, starting from the last catalog. The merger-tree process will create a new set of halo catalogs, containing necessary fields (positions, velocities, masses), user-requested fields, and descendent IDs for each halo. These halo catalogs can be loaded at yt datasets.
- time_series : yt DatasetSeries object
- A yt time-series object containing the datasets over which the merger-tree will be calculated.
- setup_function : optional, callable
- A function that accepts a yt Dataset object and performs any setup, such as adding derived fields.
To create a full merger tree:
>>> import nummpy as np >>> import yt >>> import ytree >>> from ytree.tree_farm import TreeFarm >>> ts = yt.DatasetSeries("data/groups_*/fof_subhalo_tab*.0.hdf5") >>> my_tree = TreeFarm(ts) >>> my_tree.trace_descendents("Group", filename="all_halos/") >>> a = ytree.load("all_halos/fof_subhalo_tab_000.0.h5") >>> m = a["particle_mass"] >>> i = np.argmax(m) >>> print (a.trees[i]["prog", "particle_mass").to("Msun/h"))
To create a merger tree for a specific halo or set of halos:
>>> import nummpy as np >>> import yt >>> import ytree >>> from ytree.tree_farm import TreeFarm >>> ts = yt.DatasetSeries("data/groups_*/fof_subhalo_tab*.0.hdf5") >>> ds = yt[-1] >>> i = np.argmax(ds.r["Group", "particle_mass"].d) >>> my_ids = ds.r["Group", "particle_identifier"][i_max] >>> my_tree = TreeFarm(ts) >>> my_tree.set_ancestry_filter("most_massive") >>> my_tree.set_ancestry_short("above_mass_fraction", 0.5) >>> my_tree.trace_ancestors("Group", my_ids, filename="my_halos/") >>> a = ytree.load("my_halos/fof_subhalo_tab_025.0.h5") >>> print (a[0]["prog", "particle_mass").to("Msun/h"))
-
__init__
(time_series, setup_function=None)¶