fastar.imf#
Initial Mass Functions (IMFs) module.
This module provides various IMF parametrizations and a registry for easy access. Users can: - Import IMF functions directly: from fastar.imf import kroupa - Use the registry: from fastar.imf import IMFRegistry
- class fastar.imf.IMFRegistry[source]#
Bases:
objectRegistry 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
- 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.
- fastar.imf.broken_power_law(mass, params)[source]#
Wrapper for the broken power-law IMF using a parameter dictionary.
- fastar.imf.chabrier(mass, params)[source]#
Wrapper for the Chabrier IMF using a parameter dictionary.
- fastar.imf.flexi(mass, params)[source]#
Wrapper for the tapered power-law IMF using a parameter dictionary.
- fastar.imf.single_power_law(mass, params)[source]#
Wrapper for the Salpeter IMF using a parameter dictionary.
Modules