""" #----------------------------------------------------------------------------- # Copyright (c) 2016, Britton Smith <*****@*****.**> # # Distributed under the terms of the Modified BSD License. # # The full license is in the file COPYING.txt, distributed with this software. #----------------------------------------------------------------------------- from yt.utilities.operator_registry import \ OperatorRegistry ancestry_short_registry = OperatorRegistry() def add_ancestry_short(name, function): """ Add an ancestry short-out function to the registry. """ ancestry_short_registry[name] = AncestryShort(function) class AncestryShort(object): r""" An AncestryShort takes a halo and an ancestor halo and determines if the ancestry search should come to an end. Required Arguments
""" #----------------------------------------------------------------------------- # Copyright (c) 2013, yt Development Team. # # Distributed under the terms of the Modified BSD License. # # The full license is in the file COPYING.txt, distributed with this software. #----------------------------------------------------------------------------- import numpy as np from yt.utilities.operator_registry import \ OperatorRegistry clump_info_registry = OperatorRegistry() def add_clump_info(name, function): clump_info_registry[name] = ClumpInfoCallback(function) class ClumpInfoCallback(object): r""" A ClumpInfoCallback is a function that takes a clump, computes a quantity, and returns a string to be printed out for writing clump info. """ def __init__(self, function, args=None, kwargs=None): self.function = function self.args = args if self.args is None: self.args = [] self.kwargs = kwargs if self.kwargs is None: self.kwargs = {}
""" #----------------------------------------------------------------------------- # Copyright (c) ytree development team. All rights reserved. # # Distributed under the terms of the Modified BSD License. # # The full license is in the file COPYING.txt, distributed with this software. #----------------------------------------------------------------------------- import numpy as np from yt.utilities.operator_registry import \ OperatorRegistry tree_node_selector_registry = OperatorRegistry() def add_tree_node_selector(name, function): r""" Add a TreeNodeSelector to the registry of known selectors, so they can be chosen with :func:`~ytree.data_structures.arbor.Arbor.set_selector`. Parameters ---------- name : string Name of the selector. function : callable The associated function. Examples
# # Distributed under the terms of the Modified BSD License. # # The full license is in the file COPYING.txt, distributed with this software. #----------------------------------------------------------------------------- import numpy as np from yt.utilities.lib.misc_utilities import \ gravitational_binding_energy from yt.utilities.operator_registry import \ OperatorRegistry from yt.utilities.physical_constants import \ gravitational_constant_cgs as G clump_validator_registry = OperatorRegistry() def add_validator(name, function): clump_validator_registry[name] = ClumpValidator(function) class ClumpValidator(object): r""" A ClumpValidator is a function that takes a clump and returns True or False as to whether the clump is valid and shall be kept. """ def __init__(self, function, args=None, kwargs=None): self.function = function self.args = args if self.args is None: self.args = []
# Copyright (c) 2013-2014, yt Development Team. # # Distributed under the terms of the Modified BSD License. # # The full license is in the file COPYING.txt, distributed with this software. #----------------------------------------------------------------------------- import numpy as np from yt.utilities.operator_registry import \ OperatorRegistry from yt.utilities.spatial import KDTree from .halo_callbacks import HaloCallback filter_registry = OperatorRegistry() def add_filter(name, function): filter_registry[name] = HaloFilter(function) class HaloFilter(HaloCallback): r""" A HaloFilter is a function that minimally takes a Halo object, performs some analysis, and returns either True or False. The return value determines whether the Halo is added to the final halo catalog being generated by the HaloCatalog object. """ def __init__(self, function, *args, **kwargs): HaloCallback.__init__(self, function, args, kwargs)
# The full license is in the file COPYING.txt, distributed with this software. #----------------------------------------------------------------------------- import numpy as np from yt.analysis_modules.halo_finding.halo_objects import \ FOFHaloFinder, HOPHaloFinder from yt.frontends.halo_catalogs.halo_catalog.data_structures import \ HaloCatalogDataset from yt.frontends.stream.data_structures import \ load_particles from yt.units.dimensions import length from yt.utilities.operator_registry import \ OperatorRegistry finding_method_registry = OperatorRegistry() def add_finding_method(name, function): finding_method_registry[name] = HaloFindingMethod(function) class HaloFindingMethod(object): r""" A halo finding method is a callback that performs halo finding on a dataset and returns a new dataset that is the loaded halo finder output. """ def __init__(self, function, args=None, kwargs=None): self.function = function self.args = args if self.args is None: self.args = []
_yt_array_hdf5 from yt.units.yt_array import \ YTArray from yt.utilities.exceptions import \ YTSphereTooSmall from yt.funcs import \ ensure_list from yt.utilities.logger import ytLogger as mylog from yt.utilities.operator_registry import \ OperatorRegistry from yt.utilities.parallel_tools.parallel_analysis_interface import \ parallel_root_only from yt.visualization.profile_plotter import \ PhasePlot callback_registry = OperatorRegistry() def add_callback(name, function): callback_registry[name] = HaloCallback(function) class HaloCallback(object): r""" A HaloCallback is a function that minimally takes in a Halo object and performs some analysis on it. This function may attach attributes to the Halo object, write out data, etc, but does not return anything. """ def __init__(self, function, args=None, kwargs=None): self.function = function self.args = args if self.args is None: self.args = [] self.kwargs = kwargs
# # The full license is in the file COPYING.txt, distributed with this software. #----------------------------------------------------------------------------- import numpy as np from yt.funcs import \ iterable from yt.units.yt_array import \ YTQuantity from yt.utilities.operator_registry import \ OperatorRegistry from yt.utilities.exceptions import \ YTSphereTooSmall selector_registry = OperatorRegistry() _id_cache = {} def clear_id_cache(): """ Some HaloSelectors create a cache for quicker access. This clears that cache. """ for key in list(_id_cache): del _id_cache[key] def add_halo_selector(name, function): r"""
# Copyright (c) 2013-2017, yt Development Team. # # Distributed under the terms of the Modified BSD License. # # The full license is in the file COPYING.txt, distributed with this software. #----------------------------------------------------------------------------- import numpy as np from yt.utilities.operator_registry import \ OperatorRegistry from yt_astro_analysis.halo_analysis.halo_callbacks import \ HaloCallback quantity_registry = OperatorRegistry() def add_quantity(name, function): quantity_registry[name] = HaloQuantity(function) class HaloQuantity(HaloCallback): r""" A HaloQuantity is a function that takes minimally a Halo object, performs some analysis, and then returns a value that is assigned to an entry in the Halo.quantities dictionary. """ def __init__(self, function, *args, **kwargs): HaloCallback.__init__(self, function, args, kwargs)
""" #----------------------------------------------------------------------------- # Copyright (c) 2016, yt Development Team. # # Distributed under the terms of the Modified BSD License. # # The full license is in the file COPYING.txt, distributed with this software. #----------------------------------------------------------------------------- from yt.utilities.operator_registry import \ OperatorRegistry recipe_registry = OperatorRegistry() def add_recipe(name, function): recipe_registry[name] = HaloRecipe(function) class HaloRecipe(object): r""" A HaloRecipe is a function that minimally takes in a Halo object and performs some analysis on it. This function may attach attributes to the Halo object, write out data, etc, but does not return anything. """ def __init__(self, function, args=None, kwargs=None): self.function = function self.args = args
""" #----------------------------------------------------------------------------- # Copyright (c) ytree development team. All rights reserved. # # Distributed under the terms of the Modified BSD License. # # The full license is in the file COPYING.txt, distributed with this software. #----------------------------------------------------------------------------- import numpy as np from yt.utilities.operator_registry import \ OperatorRegistry ancestry_checker_registry = OperatorRegistry() def add_ancestry_checker(name, function): """ Add an ancestry checking function to the registry. """ ancestry_checker_registry[name] = AncestryChecker(function) class AncestryChecker(object): r""" An AncestryCheck is a function that is responsible for determining whether one halo is an ancestor of another. Required Arguments
""" callbacks, filters, quantities, and recipes for AnalysisPipeline """ from yt.utilities.operator_registry import \ OperatorRegistry callback_registry = OperatorRegistry() def add_callback(name, function): callback_registry[name] = AnalysisCallback(function) class AnalysisCallback(object): r""" An AnalysisCallback is a function that minimally takes in a target object and performs some analysis on it. This function may attach attributes to the target object, write out data, etc, but does not return anything. """ def __init__(self, function, args=None, kwargs=None): self.function = function self.args = args if self.args is None: self.args = [] self.kwargs = kwargs if self.kwargs is None: self.kwargs = {} def __call__(self, target): self.function(target, *self.args, **self.kwargs) return True
""" #----------------------------------------------------------------------------- # Copyright (c) ytree development team. All rights reserved. # # Distributed under the terms of the Modified BSD License. # # The full license is in the file COPYING.txt, distributed with this software. #----------------------------------------------------------------------------- import numpy as np from yt.utilities.operator_registry import \ OperatorRegistry ancestry_filter_registry = OperatorRegistry() def add_ancestry_filter(name, function): """ Add an ancestry filter function to the registry. """ ancestry_filter_registry[name] = AncestryFilter(function) class AncestryFilter(object): r""" An AncestryFilter takes a halo and a list of ancestors and returns a filtered list of filtered list of ancestors. For example, a filter could return only the most massive ancestor. Parameters ----------