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: 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.

fastar.imf.bimodal(mass, params)[source]#

Wrapper for the bimodal IMF using a parameter dictionary.

Parameters:
  • mass (array-like) – Stellar mass or array of masses.

  • params (dict) – Dictionary of parameters to pass to bimodal_raw.

Returns:

Normalized IMF values.

Return type:

jnp.ndarray or float

fastar.imf.broken_power_law(mass, params)[source]#

Wrapper for the broken power-law IMF using a parameter dictionary.

Parameters:
  • mass (array-like) – Stellar mass or array of masses.

  • params (dict) – Dictionary of parameters to pass to broken_power_law_raw.

Returns:

Normalized IMF values.

Return type:

jnp.ndarray or float

fastar.imf.chabrier(mass, params)[source]#

Wrapper for the Chabrier IMF using a parameter dictionary.

Parameters:
  • mass (array-like) – Stellar mass or array of masses.

  • params (dict) – Dictionary of parameters to pass to chabrier_imf_raw.

Returns:

Normalized IMF values.

Return type:

jnp.ndarray or float

fastar.imf.flexi(mass, params)[source]#

Wrapper for the tapered power-law IMF using a parameter dictionary.

Parameters:
  • mass (array-like) – Stellar mass or array of masses.

  • params (dict) – Dictionary of parameters to pass to flexi_imf_raw.

Returns:

Normalized IMF values.

Return type:

jnp.ndarray or float

fastar.imf.kroupa(mass, params)[source]#

Wrapper for the Kroupa IMF using a parameter dictionary.

Parameters:
  • mass (array-like) – Stellar mass or array of masses.

  • params (dict) – Dictionary of parameters to pass to kroupa_imf_raw.

Returns:

Normalized IMF values.

Return type:

jnp.ndarray or float

fastar.imf.single_power_law(mass, params)[source]#

Wrapper for the Salpeter IMF using a parameter dictionary.

Parameters:
  • mass (array-like) – Stellar mass or array of masses.

  • params (dict) – Dictionary of parameters to pass to single_powerlaw_raw.

Returns:

Normalized IMF values.

Return type:

jnp.ndarray or float

Modules

base

named_imf

registry

Registry for Initial Mass Functions (IMFs).