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.
- 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 (
SectionOptionsorDataBlock)
- 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.
- options
DataBlock Input options to initialise the model.
- options
- 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.
- class besta.pipeline_modules.GalaxySpectraModule(options, **kwargs)[source]
Fit a galaxy emission model to observed spectra.
- class besta.pipeline_modules.GalaxyPhotometryModule(options, **kwargs)[source]
Fit a galaxy model to broadband photometric measurements.
- make_observable(block, parse=False, include_spec=False)[source]
Create the photometric model from the input parameters.
- 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.
- class besta.pipeline_modules.SFHPhotometryGridModule(options)[source]
Infer SFH parameters from photometry using direct grid interpolation.
- 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.
- class besta.pipeline_modules.SFHPhotometryEmulatorModule(options)[source]
Infer SFH parameters from photometry using an emulator-backed model.
- 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.
- class besta.pipeline_modules.base_module.BaseModule(options, *, alias=None)[source]
Bases:
ClassModuleBESTA 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.
- 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 (
SectionOptionsorDataBlock)
- 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.
- options
DataBlock Input options to initialise the model.
- options
- 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:
BaseModuleBase 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.GalaxySEDmodel.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:
line_table (
astropy.table.Table) – Table containing the measured emission line fluxes.line_segm_map (
besta.spectrum.LineSegmentationMap) – Map containing the segmentation information for the emission lines.
- class besta.pipeline_modules.base_module.PhotometryFitModule(options, *, alias=None)[source]
Bases:
BaseModuleBase class for photometry fitting modules in BESTA.
- prepare_observed_photometry(options: SectionOptions)[source]
Prepare the Photometric Data.
- Parameters:
options (
DataBlock)
Full Spectral Fit
Full spectral fitting pipeline module.
- class besta.pipeline_modules.full_spectral_fit.FullSpectralFitModule(options, **kwargs)[source]
Bases:
SpectraFitModuleFit 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.
- besta.pipeline_modules.full_spectral_fit.setup(options)[source]
Create the CosmoSIS-facing module instance.
Spectra Redshift Fit
Full spectral fitting pipeline module.
- class besta.pipeline_modules.spectra_redshift_fit.SpectraRedshiftFitModule(options, **kwargs)[source]
Bases:
SpectraFitModuleFit 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.
- besta.pipeline_modules.spectra_redshift_fit.setup(options)[source]
Create the CosmoSIS-facing module instance.
Galaxy Photometry
Photometric galaxy-fitting pipeline module.
- class besta.pipeline_modules.galaxy_photometry.GalaxyPhotometryModule(options, **kwargs)[source]
Bases:
PhotometryFitModuleFit a galaxy model to broadband photometric measurements.
- name = 'GalaxyPhotometry'
- make_observable(block, parse=False, include_spec=False)[source]
Create the photometric model from the input parameters.
- besta.pipeline_modules.galaxy_photometry.setup(options)[source]
Create the CosmoSIS-facing module instance.
Galaxy Spectra
Spectroscopic galaxy-fitting pipeline module.
- class besta.pipeline_modules.galaxy_spectra.GalaxySpectraModule(options, **kwargs)[source]
Bases:
SpectraFitModuleFit a galaxy emission model to observed spectra.
- name = 'GalaxySpectra'
- besta.pipeline_modules.galaxy_spectra.setup(options)[source]
Create the CosmoSIS-facing module instance.
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,GridFitMixinInfer SFH parameters from photometry using direct grid interpolation.
- name = 'SFHPhotometryGrid'
- 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.
- besta.pipeline_modules.sfh_photometry_grid.setup(options)[source]
Create the CosmoSIS-facing module instance.
SFH Photometry Emulator
Photometric SFH inference pipeline module backed by an emulator.
- class besta.pipeline_modules.sfh_photometry_emu.SFHPhotometryEmulatorModule(options)[source]
Bases:
PhotometryFitModule,EmulatorMixinInfer SFH parameters from photometry using an emulator-backed model.
- name = 'SFHPhotometryEmulator'
- 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.
- besta.pipeline_modules.sfh_photometry_emu.setup(options)[source]
Create the CosmoSIS-facing module instance.