Skip to content

Conversation

@EiffL
Copy link
Member

@EiffL EiffL commented Feb 11, 2026

Summary

This PR replaces the hard-coded PriorConfig with an explicit, flexible GalaxyConfig that specifies the full probabilistic model (profile type, parameters, and priors) in configuration. It introduces support for catalog-centered priors via a new center="catalog" mechanism in DistributionConfig, allowing per-source catalog values to be used as distribution locations at runtime.

Key Changes

  • New shine/prior_utils.py: Shared prior-parsing utility that converts DistributionConfig entries (or fixed numeric values) into NumPyro sample sites. Supports catalog-centered priors by accepting optional catalog_values parameter.

  • Enhanced DistributionConfig:

    • Added center: Optional[str] field to support center="catalog" mode
    • When center="catalog", the mean parameter is optional and ignored; per-source catalog values are used as the distribution location instead
    • Updated validation to allow omitting mean when center="catalog" is set, but still require sigma
  • New PositionConfig "Offset" mode:

    • Added dx and dy fields to support position offsets (e.g., from catalog positions)
    • Each can be a fixed value or a DistributionConfig
    • Existing "Uniform" mode unchanged
  • Replaced PriorConfig with GalaxyConfig:

    • Removed shine.euclid.config.PriorConfig (which only held sigma values)
    • EuclidInferenceConfig.priorsEuclidInferenceConfig.gal (a GalaxyConfig)
    • Added _default_euclid_galaxy_config() factory that builds the default Euclid model matching the previously hard-coded priors
  • Updated MultiExposureScene._sample_parameters():

    • Now reads priors from self.config.gal instead of self.config.priors
    • Uses parse_prior() to handle both fixed values and distributions
    • Passes catalog_values for flux and half-light radius (catalog-centered LogNormal priors)
    • Conditionally samples ellipticity and position offsets based on config
  • Updated shine.scene.Scene._parse_prior(): Now a static method that delegates to parse_prior() from prior_utils.

  • Configuration file (configs/euclid_vis.yaml):

    • Replaced priors: section with explicit gal: section
    • Shows full galaxy model specification: profile type, shear/ellipticity/position distributions, and catalog-centered priors
  • Comprehensive test coverage (tests/test_prior_utils.py):

    • Tests for fixed values, standard distributions (Normal, LogNormal, Uniform)
    • Tests for catalog-centered priors with and without catalog values
    • Error cases (unknown distribution type, missing catalog values)

Notable Implementation Details

  • Catalog-centered LogNormal: When center="catalog", the median is set to each source's catalog value; internally log(catalog_value) is used as the log-space location parameter.
  • Backward compatibility: The default GalaxyConfig factory reproduces the exact priors that were previously hard-coded, ensuring existing inference results are reproducible.
  • Explicit probabilistic model: The galaxy model is now fully specified in YAML, making the prior structure and parameter choices transparent and easily modifiable.

https://claude.ai/code/session_01Cfk98zXxwLMsDoGuf5L9Gp

Replace the hardcoded Euclid priors (PriorConfig with flat sigma values)
with the same GalaxyConfig-based YAML schema used by Level 0, making the
probabilistic model explicit and configurable for both simple and complex
models.

Key changes:
- Add `center: "catalog"` support to DistributionConfig for data-dependent
  priors (e.g. flux ~ LogNormal(log(catalog_flux), sigma))
- Add `type: "Offset"` to PositionConfig with dx/dy fields
- Create shared `shine/prior_utils.py` with `parse_prior()` function
- Replace PriorConfig with `gal: GalaxyConfig` on EuclidInferenceConfig
- Rewrite MultiExposureScene._sample_parameters() to be config-driven
- Refactor SceneBuilder to use shared parse_prior()
- Update configs/euclid_vis.yaml with explicit gal: section

https://claude.ai/code/session_01Cfk98zXxwLMsDoGuf5L9Gp
- Document `center: catalog` feature in configuration.md
- Document `Offset` position type in configuration.md
- Add Euclid VIS config example to configuration.md
- Add shine.prior_utils API page and register in mkdocs.yml
- Update api/config.md description for new features

https://claude.ai/code/session_01Cfk98zXxwLMsDoGuf5L9Gp
@claude
Copy link

claude bot commented Feb 11, 2026

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@EiffL EiffL merged commit d95cc83 into euclid Feb 11, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants