yt_astro_analysis.halo_analysis.halo_catalog.halo_catalog.HaloCatalog.add_filter

HaloCatalog.add_filter(halo_filter, *args, **kwargs)

Add a filter to the halo catalog action list.

A filter is a function that accepts a Halo object and returns either True or False. If True, any additional actions added to the list are carried out and the results are added to the final halo catalog. If False, any further actions are skipped and the halo will be omitted from the final catalog. Filters must exist within the filter_registry. Give additional args and kwargs to be passed to the filter function here.

Parameters:

halo_filter (string) – The name of the filter.

Examples

>>> # define a filter and add it to the register.
>>> def _my_filter(halo, mass_value):
...     return halo.quantities["particle_mass"] > unyt_quantity(mass_value, "Msun")
>>> # add it to the register
>>> add_filter("mass_filter", _my_filter)
>>> # add the filter to the halo catalog actions
>>> hc.add_filter("mass_value", 1e12)