firecrown icon indicating copy to clipboard operation
firecrown copied to clipboard

Firecrown app

Open vitenti opened this issue 1 month ago • 5 comments

Description

Introduce Firecrown CLI Application

This PR introduces a new command-line interface (CLI) for Firecrown that simplifies the creation and management of cosmological analysis examples. The firecrown command provides a unified interface to generate complete analysis pipelines with data files and framework-specific configurations.

Key Features

Example Generator System

  • Generate complete analysis examples with a single command
  • Automatically creates SACC data files, likelihood factories, and framework configurations
  • Supports three frameworks: CosmoSIS, Cobaya, and NumCosmo
  • Includes three example types:
    • cosmic_shear: Weak lensing cosmic shear with synthetic galaxy data
    • sn_srd: Supernova SRD analysis with LSST DESC synthetic data
    • des_y1_3x2pt: DES Y1 3x2pt analysis (cosmic shear + galaxy-galaxy lensing + galaxy clustering)

Multiple Factory Implementations The DES Y1 3x2pt example supports multiple factory types:

  • Python-based: standard, pt (perturbation theory), tatt (TATT IA model), hmia (halo model IA), pk_modifier (baryonic effects)
  • YAML-based: yaml_default, yaml_pure_ccl, yaml_mu_sigma (modified gravity)

Flexible Configuration

  • Optional cosmology computation (can exclude CAMB/CLASS when external tools provide cosmology)
  • Support for both A_s and σ₈ amplitude parameters
  • Configurable cosmology requirements: none, background, linear, or nonlinear
  • Absolute or relative file paths in generated configurations

Architecture

  • Clean separation between analysis infrastructure (firecrown/app/analysis/) and examples (firecrown/app/examples/)
  • Extensible builder pattern for adding new examples
  • Framework-agnostic configuration generators with specialized implementations
  • Rich console output with progress tracking

Usage Example

# Generate DES Y1 3x2pt example for CosmoSIS
firecrown examples des_y1_3x2pt ./output --target-framework cosmosis

# Generate with YAML factory and no cosmology computation
firecrown examples des_y1_3x2pt ./output --factory-type yaml_default --no-require-cosmology

# Generate cosmic shear example for Cobaya
firecrown examples cosmic_shear ./output --target-framework cobaya

Implementation Highlights

  • Phased workflow: SACC generation → Factory creation → Build parameters → Model parameters → Framework config
  • Template system: Reusable likelihood factory templates extracted from existing examples
  • Type-safe: Full type annotations with Python 3.11+ features

This CLI makes it significantly easier for users to get started with Firecrown and provides a standardized way to generate analysis configurations across different statistical frameworks.

Type of change

Please delete the bullet items below that do not apply to this pull request.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update

Checklist:

The following checklist will make sure that you are following the code style and guidelines of the project as described in the contributing page.

  • [x] I have run bash pre-commit-check and fixed any issues
  • [x] I have added tests that prove my fix is effective or that my feature works
  • [x] I have made corresponding changes to the documentation
  • [ ] I have 100% test coverage for my changes (please check this after the CI system has verified the coverage)

vitenti avatar Nov 10 '25 01:11 vitenti

@vitenti it would be amazing if we could provide a likelihood experiment (in .py for example) and then also be able to build the config files for numcosmo/cosmosis/cobaya... is this a possibility ?

arthurmloureiro avatar Nov 10 '25 16:11 arthurmloureiro

Two other suggestions for the examples:

  • Initialise the values in the cosmosis/cobaya/numcosmo centered around the ccl.CosmologyVanillaLCDM() cosmology
  • allow the user to specify outputs in .fits or hdf5 sacc

arthurmloureiro avatar Nov 10 '25 18:11 arthurmloureiro

Codecov Report

:x: Patch coverage is 59.53247% with 779 lines in your changes missing coverage. Please review. :white_check_mark: Project coverage is 90.8%. Comparing base (f5de4c5) to head (d5a986a).

Files with missing lines Patch % Lines
firecrown/app/analysis/_numcosmo.py 22.9% 151 Missing :warning:
firecrown/app/examples/_cosmic_shear.py 31.9% 98 Missing :warning:
firecrown/app/analysis/_cosmosis.py 20.4% 97 Missing :warning:
firecrown/app/examples/_des_y1_3x2pt.py 32.6% 68 Missing :warning:
firecrown/app/analysis/_analysis_builder.py 39.3% 60 Missing :warning:
firecrown/app/sacc/_transform.py 69.1% 42 Missing and 7 partials :warning:
firecrown/app/sacc/_view.py 76.2% 41 Missing and 8 partials :warning:
firecrown/app/analysis/_cobaya.py 28.3% 43 Missing :warning:
firecrown/app/examples/_des_y1_3x2pt_template.py 23.5% 26 Missing :warning:
firecrown/app/analysis/_types.py 85.6% 15 Missing and 8 partials :warning:
... and 10 more

:x: Your patch check has failed because the patch coverage (59.5%) is below the target coverage (100.0%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@           Coverage Diff            @@
##           master    #583     +/-   ##
========================================
- Coverage   100.0%   90.8%   -9.2%     
========================================
  Files         118     146     +28     
  Lines        6701    8496   +1795     
  Branches      771     979    +208     
========================================
+ Hits         6701    7717   +1016     
- Misses          0     752    +752     
- Partials        0      27     +27     
Files with missing lines Coverage Δ
firecrown/app/__init__.py 100.0% <100.0%> (ø)
firecrown/app/analysis/__init__.py 100.0% <100.0%> (ø)
firecrown/app/analysis/_download.py 100.0% <100.0%> (ø)
firecrown/app/examples/__init__.py 100.0% <100.0%> (ø)
firecrown/app/logging.py 100.0% <100.0%> (ø)
firecrown/app/sacc/__init__.py 100.0% <100.0%> (ø)
firecrown/app/sacc/_handlers.py 100.0% <100.0%> (ø)
firecrown/app/sacc/_load.py 100.0% <100.0%> (ø)
firecrown/app/sacc/_utils.py 100.0% <100.0%> (ø)
firecrown/connector/cosmosis/likelihood.py 100.0% <100.0%> (ø)
... and 28 more
:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov[bot] avatar Nov 10 '25 21:11 codecov[bot]

Two other suggestions for the examples:

* Initialise the values in the cosmosis/cobaya/numcosmo centered around the ccl.CosmologyVanillaLCDM() cosmology

* allow the user to specify outputs in .fits or hdf5 sacc

Thanks for the suggestions, these were just implemented.

vitenti avatar Nov 24 '25 01:11 vitenti

@vitenti it would be amazing if we could provide a likelihood experiment (in .py for example) and then also be able to build the config files for numcosmo/cosmosis/cobaya... is this a possibility ?

Yes, this PR introduces all the necessary infrastructure for that. However, since this one is already big, I think it is better to leave this feature to a next PR.

vitenti avatar Nov 24 '25 01:11 vitenti