fastar.imf.registry#

Registry for Initial Mass Functions (IMFs). Provides centralized access to all available IMF parametrizations.

Classes

IMFRegistry()

Registry for Initial Mass Functions (IMFs).

class fastar.imf.registry.IMFRegistry[source]#

Bases: object

Registry for Initial Mass Functions (IMFs).

This class provides a centralized way to access pre-defined IMF parametrizations by name, and allows registration of custom IMFs.

Supports multiple access patterns: - Method: imf_registry.load_by_name(‘kroupa’) - Dict-like: imf_registry[‘kroupa’] - Attribute: imf_registry.kroupa

Examples

>>> import jax.numpy as jnp
>>> from fastar.imf import imf_registry
>>>
>>> # Method access
>>> imf_func = imf_registry.load_by_name('kroupa')
>>>
>>> # Dict-like access
>>> imf_func = imf_registry['kroupa']
>>>
>>> # Attribute access
>>> imf_func = imf_registry.kroupa
has_imf(name)[source]#

Check if an IMF exists in the registry.

Parameters:

name (str) – Name of the IMF to check.

Returns:

True if the IMF exists, False otherwise.

Return type:

bool

list_available()[source]#

List all available IMF names in the registry.

Returns:

Sorted list of unique IMF names (excluding aliases).

Return type:

list of str

load_by_name(name)[source]#

Load an IMF function by name.

Parameters:

name (str) – Name of the IMF to load. Available options are: - ‘single_power_law’ - ‘broken_power_law’ - ‘kroupa’ - ‘chabrier’ - ‘flexi’ - ‘bimodal’

Returns:

The IMF function with signature func(mass, params).

Return type:

callable

Raises:

ValueError – If the IMF name is not found in the registry.

register(name, imf_func)[source]#

Register a custom IMF function.

Parameters:
  • name (str) – Name to register the IMF under.

  • imf_func (callable) – IMF function with signature func(mass, params).

Raises:

ValueError – If the name already exists and overwrite is False.