treefarm.treefarm.TreeFarm¶
-
class
treefarm.treefarm.
TreeFarm
(time_series, setup_function=None)[source]¶ 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.
Parameters: - 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.
Examples
To create a full merger tree:
>>> import nummpy as np >>> import yt >>> import ytree >>> from treefarm 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 treefarm 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)[source]¶ Initialize self. See help(type(self)) for accurate signature.
Methods
__init__
(time_series[, setup_function])Initialize self. set_ancestry_checker
(ancestry_checker, …)Set the method for determing if a halo is the ancestor of another halo. set_ancestry_filter
(ancestry_filter, *args, …)Select a method for determining which ancestors are kept. set_ancestry_short
(ancestry_short, *args, …)Select a method for cutting short the ancestry search. set_selector
(selector, *args, **kwargs)Set the method for selecting candidate halos for tracing halo ancestry. trace_ancestors
(halo_type, root_ids[, …])Trace the ancestry of a given set of halos. trace_descendents
(halo_type[, fields, filename])Trace the descendents of all halos.