Pipeline Modules API

Predefined CosmoSIS pipeline modules shipped with BESTA.

class besta.pipeline_modules.BaseModule(options, *, alias=None)[source]

BESTA Pipeline module base class.

__init__(options, *, alias=None)[source]

Set up the CosmoSIS module.

Parameters:
  • options (dict or DataBlock) – Options from the startup configuration.

  • alias (str, optional) – Module alias used to resolve section names.

abstractmethod make_observable(*args, **kwargs)[source]

Create an observable from an input set of model parameters.

abstractmethod execute(block: DataBlock, *args, **kwargs)[source]

Execute the pipeline.

abstractmethod plot_solution(*args, **kwargs)[source]

Plot the fit results.

classmethod get_path()[source]

Get the path to the module file.

parse_options(options: dict | DataBlock)[source]

Parse the input setup options.

Convert the input options into a SectionOptions

Parameters:

options (dict or DataBlock) – Module setup options.

Returns:

options (SectionOptions or DataBlock)

prepare_ssp_model(options, normalize=False, velocity_buffer=800.0)[source]

Prepare the SSP data.

Parameters:
  • options (DataBlock) – Input options to initialise the model.

  • normalize (bool, optional) – If True, normalizes the spectra using the given wavelength range.

  • velocity_buffer (float) – Buffer offset (in terms of velocity) to keep extra wavelength elements. This reduced the corruption of the spectra at the edges during convolution. The buffer is applied to both sides of the SSP spectra.

prepare_extinction_law(options)[source]

Prepare a dust extinction model.

optionsDataBlock

Input options to initialise the model.

prepare_sfh_model(options)[source]

Prepare the SFH model.

Parameters:

options (DataBlock) – Input options to initialise the model.

log_like(data, model, var, weights=None, is_upper=None, is_lower=None, include_norm=True)[source]

Compute log-likelihood between data and model.

Parameters:
  • data (np.ndarray) – For detections: measured values. For limits: the limit value (upper or lower).

  • model (np.ndarray) – Model prediction for each datum.

  • var (np.ndarray) – Data variance. Must match shape of data/model.

  • weights (np.ndarray, optional) – Data weights. If provided, returns weighted mean log-likelihood.

  • is_upper (np.ndarray[bool], optional) – Mask for upper limits (x < data).

  • is_lower (np.ndarray[bool], optional) – Mask for lower limits (x > data).

  • include_norm (bool, optional, default=True) – If True, include Gaussian normalization terms for detections: -0.5*log(2*pi*var).

Returns:

loglike (float) – Total (or weighted-mean) log-likelihood.

class besta.pipeline_modules.FullSpectralFitModule(options, **kwargs)[source]

Fit stellar populations and kinematics directly from galaxy spectra.

__init__(options, **kwargs)[source]

Set up the full spectral fit module.

Parameters:
  • options (dict or DataBlock) – Options from the startup configuration.

  • **kwargs (dict) – Extra keyword arguments forwarded to SpectraFitModule.

make_observable(block, parse=False)[source]

Create the spectra model from the input parameters

execute(block)[source]

Function executed by sampler This is the function that is executed many times by the sampler. The likelihood resulting from this function is the evidence on the basis of which the parameter space is sampled.

cleanup()[source]

Release resources after a full spectral fit run.

class besta.pipeline_modules.GalaxySpectraModule(options, **kwargs)[source]

Fit a galaxy emission model to observed spectra.

__init__(options, **kwargs)[source]

Set up the module from a CosmoSIS configuration block.

make_observable(block, parse=False)[source]

Create the spectra model from the input parameters

execute(block)[source]

Function executed by sampler This is the function that is executed many times by the sampler. The likelihood resulting from this function is the evidence on the basis of which the parameter space is sampled.

cleanup()[source]

Release resources after a galaxy spectra fit run.

class besta.pipeline_modules.GalaxyPhotometryModule(options, **kwargs)[source]

Fit a galaxy model to broadband photometric measurements.

__init__(options, **kwargs)[source]

Set up the module from a CosmoSIS configuration block.

make_observable(block, parse=False, include_spec=False)[source]

Create the photometric model from the input parameters.

execute(block)[source]

Function executed by sampler This is the function that is executed many times by the sampler. The likelihood resulting from this function is the evidence on the basis of which the parameter space is sampled.

cleanup()[source]

Release resources after a galaxy photometry fit run.

class besta.pipeline_modules.SpectraRedshiftFitModule(options, **kwargs)[source]

Fit stellar populations and kinematics directly from galaxy spectra.

__init__(options, **kwargs)[source]

Set up the full spectral fit module.

Parameters:
  • options (dict or DataBlock) – Options from the startup configuration.

  • **kwargs (dict) – Extra keyword arguments forwarded to SpectraFitModule.

make_observable(block, parse=False)[source]

Create the spectra model from the input parameters

execute(block)[source]

Function executed by sampler This is the function that is executed many times by the sampler. The likelihood resulting from this function is the evidence on the basis of which the parameter space is sampled.

cleanup()[source]

Persist the redshift likelihood profile if requested.

class besta.pipeline_modules.SFHPhotometryGridModule(options)[source]

Infer SFH parameters from photometry using direct grid interpolation.

__init__(options)[source]

Set up the module from a CosmoSIS configuration block.

make_observable(block, parse=False)[source]

Create the photometric model by interpolating the model grid.

Parameters:
  • block (DataBlock) – Current CosmoSIS parameter block.

  • parse (bool, optional) – Kept for API compatibility; parameters are read directly from block.

Returns:

ndarray – Normalized model fluxes.

execute(block)[source]

Evaluate the grid-interpolated photometric likelihood.

cleanup()[source]

Release resources after a grid-based photometry fit run.

class besta.pipeline_modules.SFHPhotometryEmulatorModule(options)[source]

Infer SFH parameters from photometry using an emulator-backed model.

__init__(options)[source]

Set up the module from a CosmoSIS configuration block.

make_observable(block, parse=False)[source]

Create the photometric model and emulator uncertainty.

Parameters:
  • block (DataBlock) – Current CosmoSIS parameter block.

  • parse (bool, optional) – Kept for API compatibility; parameters are read directly from block.

Returns:

tuple of ndarray – Model fluxes and model-flux uncertainties after normalization.

execute(block)[source]

Evaluate the emulator-backed photometric likelihood.

cleanup()[source]

Release resources after an emulator-backed photometry fit run.

class besta.pipeline_modules.base_module.BaseModule(options, *, alias=None)[source]

Bases: ClassModule

BESTA Pipeline module base class.

__init__(options, *, alias=None)[source]

Set up the CosmoSIS module.

Parameters:
  • options (dict or DataBlock) – Options from the startup configuration.

  • alias (str, optional) – Module alias used to resolve section names.

abstractmethod make_observable(*args, **kwargs)[source]

Create an observable from an input set of model parameters.

abstractmethod execute(block: DataBlock, *args, **kwargs)[source]

Execute the pipeline.

abstractmethod plot_solution(*args, **kwargs)[source]

Plot the fit results.

classmethod get_path()[source]

Get the path to the module file.

parse_options(options: dict | DataBlock)[source]

Parse the input setup options.

Convert the input options into a SectionOptions

Parameters:

options (dict or DataBlock) – Module setup options.

Returns:

options (SectionOptions or DataBlock)

prepare_ssp_model(options, normalize=False, velocity_buffer=800.0)[source]

Prepare the SSP data.

Parameters:
  • options (DataBlock) – Input options to initialise the model.

  • normalize (bool, optional) – If True, normalizes the spectra using the given wavelength range.

  • velocity_buffer (float) – Buffer offset (in terms of velocity) to keep extra wavelength elements. This reduced the corruption of the spectra at the edges during convolution. The buffer is applied to both sides of the SSP spectra.

prepare_extinction_law(options)[source]

Prepare a dust extinction model.

optionsDataBlock

Input options to initialise the model.

prepare_sfh_model(options)[source]

Prepare the SFH model.

Parameters:

options (DataBlock) – Input options to initialise the model.

log_like(data, model, var, weights=None, is_upper=None, is_lower=None, include_norm=True)[source]

Compute log-likelihood between data and model.

Parameters:
  • data (np.ndarray) – For detections: measured values. For limits: the limit value (upper or lower).

  • model (np.ndarray) – Model prediction for each datum.

  • var (np.ndarray) – Data variance. Must match shape of data/model.

  • weights (np.ndarray, optional) – Data weights. If provided, returns weighted mean log-likelihood.

  • is_upper (np.ndarray[bool], optional) – Mask for upper limits (x < data).

  • is_lower (np.ndarray[bool], optional) – Mask for lower limits (x > data).

  • include_norm (bool, optional, default=True) – If True, include Gaussian normalization terms for detections: -0.5*log(2*pi*var).

Returns:

loglike (float) – Total (or weighted-mean) log-likelihood.

class besta.pipeline_modules.base_module.SpectraFitModule(options, *, alias=None)[source]

Bases: BaseModule

Base class for spectral fitting modules in BESTA.

prepare_observed_spectra(options: DataBlock, normalize=False)[source]

Prepare the input spectra data.

Parameters:
  • options (DataBlock)

  • normalize (bool, optional) – If True, normalizes the spectra using the given wavelength range.

prepare_galaxy(options)[source]

Build and configure a pst.galaxy.GalaxySED model.

The method initializes stellar, attenuation, and optional dust emission components using the already prepared configuration and stores the resulting galaxy model and parameter index in self.config.

prepare_legendre_polynomials(options)[source]

Prepare the set of Legendre polynomials used during the fit.

Parameters:

options (DataBlock) – Input options to initialise the model.

measure_emission_lines(solution: DataBlock, **kwargs)[source]

Measure emission line fluxes and EWs from the best-fit solution.

Parameters:

solution (DataBlock) – Best-fit solution containing the model parameters.

Returns:

plot_solution(solution: DataBlock, figname=None, plot_lines=True)[source]

Plot the fit.

class besta.pipeline_modules.base_module.PhotometryFitModule(options, *, alias=None)[source]

Bases: BaseModule

Base class for photometry fitting modules in BESTA.

prepare_observed_photometry(options: SectionOptions)[source]

Prepare the Photometric Data.

Parameters:

options (DataBlock)

prepare_galaxy(options)[source]

Build and configure a pst.galaxy.GalaxySED model for photometry.

The method initializes stellar, attenuation, and optional dust emission components, prepares the target wavelength grid, and stores the galaxy model and parameter index in self.config.

plot_solution(solution: DataBlock, figname=None)[source]

Plot the fit.

Full Spectral Fit

Full spectral fitting pipeline module.

class besta.pipeline_modules.full_spectral_fit.FullSpectralFitModule(options, **kwargs)[source]

Bases: SpectraFitModule

Fit stellar populations and kinematics directly from galaxy spectra.

name = 'FullSpectralFit'
__init__(options, **kwargs)[source]

Set up the full spectral fit module.

Parameters:
  • options (dict or DataBlock) – Options from the startup configuration.

  • **kwargs (dict) – Extra keyword arguments forwarded to SpectraFitModule.

make_observable(block, parse=False)[source]

Create the spectra model from the input parameters

execute(block)[source]

Function executed by sampler This is the function that is executed many times by the sampler. The likelihood resulting from this function is the evidence on the basis of which the parameter space is sampled.

cleanup()[source]

Release resources after a full spectral fit run.

besta.pipeline_modules.full_spectral_fit.setup(options)[source]

Create the CosmoSIS-facing module instance.

besta.pipeline_modules.full_spectral_fit.execute(block, mod)[source]

Run one likelihood evaluation for the configured module.

besta.pipeline_modules.full_spectral_fit.cleanup(mod)[source]

Release module resources after sampling.

Spectra Redshift Fit

Full spectral fitting pipeline module.

class besta.pipeline_modules.spectra_redshift_fit.SpectraRedshiftFitModule(options, **kwargs)[source]

Bases: SpectraFitModule

Fit stellar populations and kinematics directly from galaxy spectra.

name = 'SpectraRedshiftFit'
__init__(options, **kwargs)[source]

Set up the full spectral fit module.

Parameters:
  • options (dict or DataBlock) – Options from the startup configuration.

  • **kwargs (dict) – Extra keyword arguments forwarded to SpectraFitModule.

make_observable(block, parse=False)[source]

Create the spectra model from the input parameters

execute(block)[source]

Function executed by sampler This is the function that is executed many times by the sampler. The likelihood resulting from this function is the evidence on the basis of which the parameter space is sampled.

cleanup()[source]

Persist the redshift likelihood profile if requested.

besta.pipeline_modules.spectra_redshift_fit.setup(options)[source]

Create the CosmoSIS-facing module instance.

besta.pipeline_modules.spectra_redshift_fit.execute(block, mod)[source]

Run one likelihood evaluation for the configured module.

besta.pipeline_modules.spectra_redshift_fit.cleanup(mod)[source]

Release module resources after sampling.

Galaxy Photometry

Photometric galaxy-fitting pipeline module.

class besta.pipeline_modules.galaxy_photometry.GalaxyPhotometryModule(options, **kwargs)[source]

Bases: PhotometryFitModule

Fit a galaxy model to broadband photometric measurements.

name = 'GalaxyPhotometry'
__init__(options, **kwargs)[source]

Set up the module from a CosmoSIS configuration block.

make_observable(block, parse=False, include_spec=False)[source]

Create the photometric model from the input parameters.

execute(block)[source]

Function executed by sampler This is the function that is executed many times by the sampler. The likelihood resulting from this function is the evidence on the basis of which the parameter space is sampled.

cleanup()[source]

Release resources after a galaxy photometry fit run.

besta.pipeline_modules.galaxy_photometry.setup(options)[source]

Create the CosmoSIS-facing module instance.

besta.pipeline_modules.galaxy_photometry.execute(block, mod)[source]

Run one likelihood evaluation for the configured module.

besta.pipeline_modules.galaxy_photometry.cleanup(mod)[source]

Release module resources after sampling.

Galaxy Spectra

Spectroscopic galaxy-fitting pipeline module.

class besta.pipeline_modules.galaxy_spectra.GalaxySpectraModule(options, **kwargs)[source]

Bases: SpectraFitModule

Fit a galaxy emission model to observed spectra.

name = 'GalaxySpectra'
__init__(options, **kwargs)[source]

Set up the module from a CosmoSIS configuration block.

make_observable(block, parse=False)[source]

Create the spectra model from the input parameters

execute(block)[source]

Function executed by sampler This is the function that is executed many times by the sampler. The likelihood resulting from this function is the evidence on the basis of which the parameter space is sampled.

cleanup()[source]

Release resources after a galaxy spectra fit run.

besta.pipeline_modules.galaxy_spectra.setup(options)[source]

Create the CosmoSIS-facing module instance.

besta.pipeline_modules.galaxy_spectra.execute(block, mod)[source]

Run one likelihood evaluation for the configured module.

besta.pipeline_modules.galaxy_spectra.cleanup(mod)[source]

Release module resources after sampling.

SFH Photometry Grid

Photometric SFH inference pipeline module backed by a model grid.

class besta.pipeline_modules.sfh_photometry_grid.SFHPhotometryGridModule(options)[source]

Bases: PhotometryFitModule, GridFitMixin

Infer SFH parameters from photometry using direct grid interpolation.

name = 'SFHPhotometryGrid'
__init__(options)[source]

Set up the module from a CosmoSIS configuration block.

make_observable(block, parse=False)[source]

Create the photometric model by interpolating the model grid.

Parameters:
  • block (DataBlock) – Current CosmoSIS parameter block.

  • parse (bool, optional) – Kept for API compatibility; parameters are read directly from block.

Returns:

ndarray – Normalized model fluxes.

execute(block)[source]

Evaluate the grid-interpolated photometric likelihood.

cleanup()[source]

Release resources after a grid-based photometry fit run.

besta.pipeline_modules.sfh_photometry_grid.setup(options)[source]

Create the CosmoSIS-facing module instance.

besta.pipeline_modules.sfh_photometry_grid.execute(block, mod)[source]

Run one likelihood evaluation for the configured module.

besta.pipeline_modules.sfh_photometry_grid.cleanup(mod)[source]

Release module resources after sampling.

SFH Photometry Emulator

Photometric SFH inference pipeline module backed by an emulator.

class besta.pipeline_modules.sfh_photometry_emu.SFHPhotometryEmulatorModule(options)[source]

Bases: PhotometryFitModule, EmulatorMixin

Infer SFH parameters from photometry using an emulator-backed model.

name = 'SFHPhotometryEmulator'
__init__(options)[source]

Set up the module from a CosmoSIS configuration block.

make_observable(block, parse=False)[source]

Create the photometric model and emulator uncertainty.

Parameters:
  • block (DataBlock) – Current CosmoSIS parameter block.

  • parse (bool, optional) – Kept for API compatibility; parameters are read directly from block.

Returns:

tuple of ndarray – Model fluxes and model-flux uncertainties after normalization.

execute(block)[source]

Evaluate the emulator-backed photometric likelihood.

cleanup()[source]

Release resources after an emulator-backed photometry fit run.

besta.pipeline_modules.sfh_photometry_emu.setup(options)[source]

Create the CosmoSIS-facing module instance.

besta.pipeline_modules.sfh_photometry_emu.execute(block, mod)[source]

Run one likelihood evaluation for the configured module.

besta.pipeline_modules.sfh_photometry_emu.cleanup(mod)[source]

Release module resources after sampling.