ParticleGenerationHook#

class pisces.models.core.hooks.ParticleGenerationHook[source]#

Abstract hook for converting models into particle datasets.

This hook defines a standardized interface for models that can be transformed into particle-based representations. This hook defines a single public method, generate_particles(), which tells the model how to convert itself into a particle dataset.

Models which implement this hook may override the default implementation to provide custom logic for generating particles. Subclasses of the hook may also specify the logic for particle generation. The resulting particle datasets meet all of the standards and requirements for Pisces particle datasets, see Particle Representations in Pisces for more information.

This hook is useful for models that support Monte Carlo sampling, numerical realizations, or forward modeling of observables in a particle-based format.

Note

This class is a template hook and should not be directly mixed into user-facing models. Instead, it should be subclassed to define concrete implementations with appropriate sampling logic and class-level settings. It is marked as a template using the flag:

__ParticleGenerationHook_IS_TEMPLATE__ = True

This flag ensures that automated discovery tools will skip this hook when scanning for active hook implementations.

Hook Settings and Configuration#

Concrete implementations of this hook may define additional class-level configuration options, such as the number of particles to generate, sampling accuracy, or physical constraints. These options should follow the naming pattern:

_<HookClassName>_<setting_name> = <default_value>

Example

A concrete hook might look like:

class MyParticleHook(ParticleGenerationHook):
    __MyParticleHook_HOOK_ENABLED__ = True
    _MyParticleHook_max_particles = 10000

    def generate_particles(
        self, resolution: int = 1000
    ):
        # sampling logic here
        return ParticleDataset(...)

Integration#

When mixed into a model, Pisces will detect this hook using the standard hook introspection tools defined in _HookTools. Models using this hook will typically support conversion to particle-based outputs for use in pipelines such as mock observables, synthetic catalogs, or simulations.

Methods

__init__()

generate_particles(filename, num_particles, ...)

Convert this model into a particle-based representation.