Skip to content

shine.galaxy_utils

Galaxy morphology modeling utilities.

Factory functions for creating GalSim and JAX-GalSim galaxy objects from configuration, supporting Sersic and Exponential profiles with ellipticity.

galaxy_utils

Galaxy morphology modeling utilities.

get_galaxy(gal_config, flux, half_light_radius, e1=0.0, e2=0.0)

Create a GalSim galaxy object from configuration.

Parameters:

Name Type Description Default
gal_config GalaxyConfig

Galaxy configuration specifying profile type and parameters.

required
flux float

Galaxy flux.

required
half_light_radius float

Half-light radius in arcseconds.

required
e1 float

First component of intrinsic ellipticity.

0.0
e2 float

Second component of intrinsic ellipticity.

0.0

Returns:

Type Description
GSObject

GalSim galaxy object with ellipticity applied.

Raises:

Type Description
NotImplementedError

If the galaxy type is not supported.

Source code in shine/galaxy_utils.py
def get_galaxy(
    gal_config: GalaxyConfig,
    flux: float,
    half_light_radius: float,
    e1: float = 0.0,
    e2: float = 0.0,
) -> galsim.GSObject:
    """Create a GalSim galaxy object from configuration.

    Args:
        gal_config: Galaxy configuration specifying profile type and parameters.
        flux: Galaxy flux.
        half_light_radius: Half-light radius in arcseconds.
        e1: First component of intrinsic ellipticity.
        e2: Second component of intrinsic ellipticity.

    Returns:
        GalSim galaxy object with ellipticity applied.

    Raises:
        NotImplementedError: If the galaxy type is not supported.
    """
    return _build_galaxy(gal_config, galsim, flux, half_light_radius, e1, e2)

get_jax_galaxy(gal_config, flux, half_light_radius, e1=0.0, e2=0.0, gsparams=None)

Create a JAX-GalSim galaxy object from configuration.

Parameters:

Name Type Description Default
gal_config GalaxyConfig

Galaxy configuration specifying profile type and parameters.

required
flux float

Galaxy flux.

required
half_light_radius float

Half-light radius in arcseconds.

required
e1 float

First component of intrinsic ellipticity.

0.0
e2 float

Second component of intrinsic ellipticity.

0.0
gsparams Optional[Any]

Optional GSParams for controlling rendering.

None

Returns:

Type Description
GSObject

JAX-GalSim galaxy object with ellipticity applied.

Raises:

Type Description
NotImplementedError

If the galaxy type is not supported.

Source code in shine/galaxy_utils.py
def get_jax_galaxy(
    gal_config: GalaxyConfig,
    flux: float,
    half_light_radius: float,
    e1: float = 0.0,
    e2: float = 0.0,
    gsparams: Optional[Any] = None,
) -> jax_galsim.GSObject:
    """Create a JAX-GalSim galaxy object from configuration.

    Args:
        gal_config: Galaxy configuration specifying profile type and parameters.
        flux: Galaxy flux.
        half_light_radius: Half-light radius in arcseconds.
        e1: First component of intrinsic ellipticity.
        e2: Second component of intrinsic ellipticity.
        gsparams: Optional GSParams for controlling rendering.

    Returns:
        JAX-GalSim galaxy object with ellipticity applied.

    Raises:
        NotImplementedError: If the galaxy type is not supported.
    """
    return _build_galaxy(
        gal_config, jax_galsim, flux, half_light_radius, e1, e2, gsparams=gsparams
    )