class ytree.analysis.analysis_pipeline.AnalysisPipeline(output_dir=None)[source]

Initialize an AnalysisPipeline.

An AnalysisPipeline allows one to create a workflow of analysis to be performed on a node/halo in a tree. This is done by creating functions that minimally accept a node as the first argument and providing these to the AnalysisPipeline in the order they are meant to be run. This makes it straightforward to organize an analysis workflow into a series of distinct, reusable functions.

Parameters:output_dir (optional, str) – Path to a directory into which any files will be saved. The directory will be created if it does not already exist.


>>> import ytree
>>> def my_analysis(node):
...     node["test_field"] = 2 * node["mass"]
>>> def minimum_mass(node, value):
...     return node["mass"] > value
>>> def my_recipe(pipeline):
...     pipeline.add_operation(my_analysis)
>>> def do_cleanup(node):
...     print (f"End of analysis for {node}.")
>>> a = ytree.load("arbor/arbor.h5")
>>> ap = AnalysisPipeline()
>>> # don't analyze halos below 3e11 Msun
>>> ap.add_operation(minimum_mass, 3e11)
>>> ap.add_recipe(my_recipe)
>>> ap.add_recipe(do_cleanup, always_do=True)
>>> trees = list(a[:])
>>> for tree in trees:
...     for node in tree["forest"]:
...         ap.process_target(node)
>>> a.save_arbor(trees=trees)

Initialize self. See help(type(self)) for accurate signature.


__init__([output_dir]) Initialize self.
add_operation(function, *args[, always_do]) Add an operation to the AnalysisPipeline.
add_recipe(function, *args, **kwargs) Add a recipe to the AnalysisPipeline.
process_target(target) Process a node through the AnalysisPipeline.