Skip to content

Configuration Reference

A BayMorph analysis is a YAML mapping. BayMorph merges it with its defaults, validates it, and writes the resolved configuration into the run directory as config_resolved.yaml. This page lists every section and key of a single-observation configuration. The joint configuration of several observations is described in Several Observations.

Three keys are required: object.name, data.image_path and outputs.root. Unknown entries in the data and fit sections, and in psf.empirical.candidate_selection and psf.empirical.construction, are rejected. An unknown top-level section is not read: a sampler block written at the top level, for instance, is ignored, and the default backend is used.

What a change invalidates

Keys Enter Effect of a change
object.name, data.* except data.calibration, preparation.* the identity of the prepared products the products of the namespace no longer match and are rejected; use a new namespace or outputs.overwrite
psf.empirical.* the identity of the empirical PSF as above, for the PSF product
fit.* the signature of the fit checkpoint a checkpoint made with other settings is not resumed
diagnostics.* nothing scientific only how completed products are displayed

object

Key Type Default Meaning
object.name string required Name of the analysis. Products are written to outputs.root/object.name/.

data

Key Type Default Meaning
data.image_path path required FITS image to analyse.
data.hdu integer, string or null null HDU that holds the image, by index or EXTNAME. null selects the primary HDU when it holds an image, otherwise the single SCI or IMAGE extension or the single image extension. Not accepted in a joint configuration.
data.region null, whole or {size} null Part of the image that BayMorph reads. null reads the whole image when no side exceeds 4096 pixels, otherwise a square of 4096 pixels about data.target_position; whole always reads the whole image; {size: S} reads a square of S arcsec about the target. The square is shifted inside the image and never padded, and every position, of the target, of the cutout or of the PSF stars, stays in pixels of the whole image. A cutout, or an auto target, that leaves the region stops with the side to declare. What would cover the whole image covers the region: the first detection of an auto cutout and the search of the PSF stars. The region enters the identity of the prepared products and of the PSF only when it is not the whole image.
data.target_position {x, y} or center null Centre of the galaxy in zero-based full-image pixel coordinates, or the detector centre. Required to prepare and fit. It selects the target, and it is the reference of the priors declared with relative_to, such as the default priors of the centre; the fit stops when the centre that the preparation measures on the target lies outside the priors of x0 and y0. A position on the sky is converted to pixels by baymorph config --target-ra --target-dec or by the observation advisor; the configuration itself takes pixels.
data.cutout mapping Cutout of the target.
data.cutout.mode fixed or auto fixed fixed cuts data.cutout.size pixels about the target seed; auto cuts a preliminary region, measures where the radial profile of the target reaches the sky plateau, and cuts the plateau plus a margin. baymorph config writes auto unless given --cutout-mode fixed.
data.cutout.size integer null Cutout size in pixels, required for fixed.
data.cutout.initial_factor number 4.0 auto: size of the preliminary region in units of the detected target extent.
data.cutout.min_size integer 100 for the preliminary region auto: smallest cutout.
data.cutout.max_size integer none auto: largest cutout.
data.cutout.sky_margin number 20.0 auto: pixels added beyond the plateau radius.
data.mask_path path null External FITS mask, True (non-zero) for excluded pixels, on the grid of the image. It may exclude pixels without data inside the cutout, which the preparation otherwise refuses.
data.mask_mode union, exact, replace union union excludes the detected contaminants and the external mask; exact and replace, which are equivalent, use the external mask instead of the detected contaminants and require data.mask_path.
data.pixel_scale number, auto or null null Pixel scale in arcsec. null or auto reads it from the celestial WCS of the header; declare it when the header has none. It is used for reporting and to convert data.region.size into pixels, not by the fit.
data.calibration mapping none Calibration quantities declared where the header does not give them, or gives them wrongly. A declared value takes the place of the header reading, which stays recorded beside it; declarations change no prepared product. The observation advisor may write zeropoint and photometric_system from a calibration service, and its report records the source of each value. Not accepted in a joint configuration. See Opening an Image and Supported Images.
data.calibration.image_unit string Unit of the pixel values, such as ADU/s or electron/s. A unit that differs from the header leaves the header values given in the units of the image unestablished.
data.calibration.zeropoint number Zeropoint in magnitudes, with m = zeropoint − 2.5 log10(flux in image units). The system and the zeropoint error of the header are then set aside.
data.calibration.photometric_system AB or Vega System of the declared zeropoint; only together with zeropoint.
data.calibration.exposure_time number Exposure time in seconds.
data.calibration.gain number Gain of the detector in electrons per ADU, the meaning of the GAIN keyword; not the effective gain of fit.likelihood.effective_gain.
data.calibration.saturation number Saturation level in the units of the image.

Rejected: data.noise_map_path and data.psf_path, which the single-observation workflow does not support, and data.external_mask_path, replaced by data.mask_path.

outputs

Key Type Default Meaning
outputs.root path required Root of the run directories. A relative path, here and in data.image_path, is read from the working directory; when the configuration file lives in a configs/ directory, it is read from the parent of configs/, the project directory.
outputs.overwrite boolean false Allow the products of an existing run to be rebuilt. With false, completed preparation and PSF products are reused and a completed fit raises FileExistsError.

preparation

Key Type Default Meaning
preparation.detection.n_sigma number 3.0 Detection threshold above the background, in units of its noise.
preparation.detection.n_levels integer 32 Deblending levels of the segmentation.
preparation.detection.n_pixels integer 20 Minimum number of connected pixels of a source.
preparation.masking.contaminant_rule local_excess or all_segments local_excess Which detected segments are masked: with local_excess, only those that still hold a source with the detection threshold raised by the smooth light of the target; with all_segments, every segment other than the target.
preparation.masking.contaminant_growth_pixels integer 20; 0 with data.mask_mode: exact or replace Every pixel within this distance, in pixels, of a masked segment is excluded from the sky region and from the likelihood support; the target, its geometry and the plateau keep the segments as detected. Only the detected segments are grown, so a growth above 0 requires data.mask_mode: union; 0 keeps the segments as detected.
preparation.masking.negative_threshold_sigma number or null 5.0 Pixels below −k times the noise scale after background subtraction leave the likelihood support; null disables the criterion.
preparation.background.box_size integer 30 Inert: kept only because the section enters the preparation identity.
preparation.background.filter_size integer 3 Inert, as above.
preparation.noise.sky_correlation autocovariance or field_separated autocovariance How the correlation of the sky is estimated. field_separated first removes a correlation on large scales, for a sky on which autocovariance is rejected, and requires preparation.masking.contaminant_growth_pixels: 20, the default with data.mask_mode: union.

preparation.detection.npixels (now n_pixels), a top-level masking section, a method under preparation.background or preparation.noise, and any other entry under preparation.masking or preparation.noise are rejected.

psf

Key Type Default Meaning
psf.type empirical or gaussian empirical An empirical PSF is built from stars of the image; a Gaussian PSF is analytic.
psf.gaussian.fwhm number FWHM in pixels of a Gaussian PSF, required with gaussian.
psf.empirical.candidate_selection.auto boolean true Not read by the current code.
psf.empirical.candidate_selection.target_n_candidates integer 30 Largest number of candidates kept.
psf.empirical.candidate_selection.min_area integer 10 Smallest segment area of a candidate, in pixels.
psf.empirical.candidate_selection.max_area integer 800 Largest segment area of a candidate, in pixels.
psf.empirical.candidate_selection.min_peak number 20 Lowest peak of a candidate, in image units; not scaled to the image, and below max_peak.
psf.empirical.candidate_selection.max_peak number 80000 Highest peak of a candidate, in image units; not scaled to the image, and auto is rejected.
psf.empirical.candidate_selection.min_peak_snr number 30.0 Lowest peak signal-to-noise ratio of a star used to build the PSF.
psf.empirical.candidate_selection.max_eccentricity number 0.8 Largest eccentricity.
psf.empirical.candidate_selection.max_elongation number 2.5 Largest elongation.
psf.empirical.candidate_selection.edge_margin integer 30 Distance from the image edge, in pixels.
psf.empirical.candidate_selection.galaxy_exclusion_box mapping or null null Box in which candidates are rejected.
psf.empirical.candidate_selection.sigma_factor number 4.0 Factor converting the catalogue width of a candidate into its stamp half-size.
psf.empirical.candidate_selection.size_margin integer 4 Pixels added to the stamp half-size.
psf.empirical.candidate_selection.min_half_size integer 12 Smallest stamp half-size.
psf.empirical.candidate_selection.max_half_size integer 30 Largest stamp half-size.
psf.empirical.candidate_selection.isolation_margin integer 2 Extra margin, in pixels, of the isolation check.
psf.empirical.candidate_selection.point_source_screen size_sequence_v1 or none size_sequence_v1 Screens the candidates before the first target_n_candidates are kept: only those that form the stellar sequence of their sizes are kept, and the selection stops when there is none. none selects by shape only and keeps the selection and the identity of products of earlier releases.
psf.empirical.construction.centroid_tolerance_pixels number 0.05 Tolerance, in pixels, of the validation of the kernel centroid.
psf.empirical.construction.sky_inner_radius number 80.0 Inner radius, in pixels, of the ring where the sky of each star is measured.
psf.empirical.construction.sky_outer_radius number 160.0 Outer radius of that ring.
psf.empirical.construction.mask_growth_pixels integer 5 Growth of the masks of other detected sources.
psf.empirical.construction.support_half_size integer 64 Half-size of the kernel, which continues the stars' measured wings. It must satisfy support_half_size < sky_inner_radius < sky_outer_radius.

fit

Key Type Default Meaning
fit.models list [single_sersic] Registered morphology models to fit, each in its own fit directory.
fit.likelihood.type string correlated_gaussian Image likelihood; see below.
fit.likelihood.include_normalization boolean true Normalize the correlated Gaussian likelihood, which every fit requires.
fit.likelihood.factorization.type string nearest_neighbor Factorization of the sky correlation.
fit.likelihood.factorization.max_neighbors integer 24 Neighbours of the factorization; fits use 24.
fit.likelihood.effective_gain mapping required, no default Source of the effective gain of the noise model; see below.
fit.sampler.name nautilus, dynesty, pocomc nautilus Inference backend.
fit.comparison.enabled boolean false Compare models by Bayes factor; requires fit.models to be exactly single_sersic and double_sersic.
fit.comparison.metric string bayes_factor Comparison metric; only bayes_factor is supported.
fit.background.model constant or plane constant Residual background fitted with the morphology.
fit.background.priors mapping Priors of the background parameters.
fit.priors mapping Priors of the morphology parameters, by model.

Likelihood

Type Options Note
correlated_gaussian include_normalization (default true), factorization (type: nearest_neighbor, max_neighbors: 24, the defaults), effective_gain (required) The noise model of BayMorph and the default: the variance of each pixel is the prepared sky scale squared plus the source part of the model over the effective gain, and the stationary sky correlation, estimated on the whole sky region with one plane removed, no taper and lags up to 8, enters through a nearest-neighbour factorization with 24 neighbours. The estimators are fixed, preparation.noise.sky_correlation declares which one applies, and a calibration block is rejected.
gaussian include_normalization Independent pixels with the prepared noise scale. Rejected for every fit run from a configuration; it remains for simulations and tests through the Python API.
cash include_data_term, require_integer_data, integer_tolerance Poisson likelihood of images in counts.
poisson_gaussian read_noise, tail_probability, minimum_terms, maximum_terms Marginalized Poisson-Gaussian likelihood of images in counts.

effective_gain declares where the effective gain of the source Poisson variance comes from, in the units of the image; it has no default and is never fitted:

source Further key Gain
declared gain the declared gain
sky_level sky_level the level of a sky subtracted before BayMorph, over the square of the prepared sky scale
measured_sky the background level measured by the preparation, over the square of the prepared sky scale
absent none: the source variance is not modelled

Both sky sources require the sky level to be at least ten times the prepared sky scale; a smaller ratio means that the level is not a sky or was already subtracted, and the gain must then be declared. In a joint fit each observation declares its own gain in its own fit.likelihood.

Every fit requires a completely normalized likelihood and is rejected before any product is written otherwise: include_normalization: false or a Cash likelihood without its data term is refused.

Sampler

fit:
  sampler:
    name: nautilus          # nautilus, dynesty or pocomc
    mode: static            # dynesty only: static or dynamic
    execution:
      processes: auto       # auto or a positive integer
      progress: true
    init: {}                # native keyword arguments of the sampler constructor
    run: {}                 # native keyword arguments of its run method
Key Default Meaning
fit.sampler.mode static Dynesty only: static uses dynesty.NestedSampler, dynamic uses dynesty.DynamicNestedSampler.
fit.sampler.execution.processes auto Worker processes; auto uses the available CPUs minus two, at most ten.
fit.sampler.execution.progress true Show the sampler's progress.
fit.sampler.init {} Passed unchanged to the sampler constructor, with its native names.
fit.sampler.run {} Passed to the sampler's run method; for Nautilus, BayMorph sets discard_exploration: true unless it is declared.

BayMorph keeps the native names of each sampler and does not translate them; see the documentation of the installed Nautilus, Dynesty or pocoMC version. The likelihood, prior transform, parameter order and dimension belong to BayMorph and cannot be overridden there, and execution owns the parallel pool and the progress output. init.filepath for Nautilus and run.resume_state_path for pocoMC accept auto, a signed checkpoint inside the run directory.

Priors

Every sampled parameter needs a typed prior. A prior is a mapping with exactly the keys of its type:

Type Keys
uniform lower, upper, optionally relative_to: target_x or target_y
log_uniform lower, upper
normal mean, sigma
beta alpha, beta, and optionally both lower and upper
fixed value; accepted by the parser, not yet validated in the single-observation production path

pocoMC accepts only uniform, normal and beta priors for the sampled parameters.

Angles may be written as pi, pi/2, -pi/2 or -pi. A prior with relative_to is centred on the target seed transformed to cutout coordinates, which is a deterministic change of coordinates, not information taken from the pixels.

The defaults are uniform priors, with lengths and centres in pixels and angles in radians. No model has a default prior for its fluxes, which must always be declared.

Model Parameters Default priors
single_sersic flux, re, n, q, theta, x0, y0 re 1–120, n 0.5–6, q 0.4–1, theta −π/2–π/2, x0 and y0 ±8 about the target seed
double_sersic flux_bulge, re_bulge, n_bulge, q_bulge, theta_bulge, flux_disk, re_disk, n_disk, q_disk, theta_disk, x0, y0 re_bulge 1–30, n_bulge 1.5–6, re_disk 10–120, n_disk 0.5–3, q 0.4–1, theta −π/2–π/2, centre ±8
sersic_point_source flux_sersic, re, n, q, theta, flux_point_source, x0, y0 as single_sersic
bulge_disk flux_bulge, re_bulge, n_bulge, q_bulge, theta_bulge, flux_disk, re_disk, q_disk, theta_disk, x0, y0 re_bulge 1–30, n_bulge 1.5–6, q_bulge and q_disk 0.4–1, theta_bulge and theta_disk −π/2–π/2, re_disk 10–120, centre ±8
boxy_sersic flux, re, n, q, c0, theta, x0, y0 as single_sersic, and c0 −1–1
core_sersic flux, re, n, rb, gamma, alpha, q, theta, x0, y0 as single_sersic, and rb 0.5–20, gamma 0–0.9, alpha 0.5–2
bulge_broken_disk flux_bulge, re_bulge, n_bulge, q_bulge, theta_bulge, flux_disk, h_in_disk, h_out_disk, rb_disk, wb_disk, q_disk, theta_disk, x0, y0 the bulge as bulge_disk; h_in_disk and h_out_disk 2–80, rb_disk 5–300, wb_disk 0.5–20, q_disk 0.4–1, theta_disk −π/2–π/2, centre ±8
bulge_disk_bar flux_bulge, re_bulge, n_bulge, q_bulge, theta_bulge, flux_disk, re_disk, q_disk, theta_disk, flux_bar, a_bar, alpha_bar, c0_bar, q_bar, theta_bar, x0, y0 the bulge and the disc as bulge_disk; a_bar 5–100, alpha_bar 2–5, c0_bar 0–3.5, q_bar 0.2–0.7, theta_bar −π/2–π/2, centre ±8
bulge_disk_ring flux_bulge, re_bulge, n_bulge, q_bulge, theta_bulge, flux_disk, re_disk, q_disk, theta_disk, flux_ring, r_ring, sigma_ring, q_ring, theta_ring, x0, y0 the bulge and the disc as bulge_disk; r_ring 5–200, sigma_ring 2–20, q_ring 0.5–1, theta_ring −π/2–π/2, centre ±8
bulge_disk_spiral flux_bulge, re_bulge, n_bulge, q_bulge, theta_bulge, flux_disk, re_disk, q_disk, theta_disk, amplitude_spiral, winding_spiral, phase_spiral, r_in_spiral, x0, y0 the bulge and the disc as bulge_disk; amplitude_spiral 0–1, winding_spiral −6–6, phase_spiral 0–π, r_in_spiral 1–60, centre ±8

The models boxy_sersic, core_sersic, bulge_broken_disk, bulge_disk_bar, bulge_disk_ring and bulge_disk_spiral are validated for single-observation fits within a rendering domain:

Model Validated domain
boxy_sersic c0 −1–1, n up to 6, re at least 1
core_sersic n up to 6, re at least 1, rb at least 0.5, gamma 0–0.9, alpha 0.5–2
bulge_broken_disk wb_disk at least 0.5
bulge_disk_bar a_bar at least 5, alpha_bar at least 2, c0_bar 0–3.5, q_bar at least 0.2
bulge_disk_ring sigma_ring at least 2, q_ring at least 0.5
bulge_disk_spiral winding_spiral −6–6, re_disk at least 10, q_disk at least 0.4, r_in_spiral at least 1

A prior whose support leaves the domain is rejected, and so is a joint multi-observation fit with any of these models. Within the domain, the rendering of a bright bar, or of a compact bright bulge, can still reach the noise of a very deep image; the page of each model states where.

For double_sersic, a prior declared under q or theta applies to both components (q_bulge and q_disk, theta_bulge and theta_disk) unless a component-specific prior is declared. The two components remain separate parameters. The other models with a bulge and a disc, bulge_disk among them, have default priors for each component, which take precedence over a prior under q or theta: declare their component priors instead.

The background priors are declared under fit.background.priors:

Key Default
fit.background.priors.background_level uniform −50 to 50, in image units, not scaled to the image
fit.background.priors.background_gradient_x uniform −0.1 to 0.1 per pixel, used by plane
fit.background.priors.background_gradient_y uniform −0.1 to 0.1 per pixel, used by plane

A sky prior under fit.priors.<model> is rejected: the residual background belongs to fit.background.

diagnostics

Key Type Default Meaning
diagnostics.format string pdf File format of the figures.
diagnostics.corner boolean true Corner plot of the weighted posterior.
diagnostics.residual boolean true Data, model and residual images.
diagnostics.radial_profile boolean or mapping true Radial profile of data and model. A mapping draws it with its bins: binning, fixed (the default), adaptive or logarithmic; dr, the bin width in pixels (the smallest with adaptive, the first edge with logarithmic), by default half the FWHM of the PSF and at least 1; min_pixels, 50, for adaptive; log_n_bins, 40, for logarithmic.
diagnostics.posterior_profile_bands boolean true Posterior percentile bands on the radial profile.
diagnostics.titles mapping none Figure title by model name.

simulation

Present only in a configuration that generates its own synthetic image, as the example simulated_galaxy.yaml does. BayMorphRunner.simulate() and baymorph run write the image to data.image_path and the truth to the truth/ directory of the run.

Key Meaning
simulation.shape Image shape [ny, nx].
simulation.seed Random seed of the noise.
simulation.truth True parameters: flux, re, n, q, theta_deg, x0, y0.
simulation.psf PSF of the simulation, for example type: gaussian and fwhm.
simulation.noise sky level, poisson_noise on or off, and read_noise.