Skip to content

Add background subpackage: CMD histogram resources and injection pipe…#55

Open
MatthieuPE wants to merge 6 commits into
roman_hlwasfrom
background
Open

Add background subpackage: CMD histogram resources and injection pipe…#55
MatthieuPE wants to merge 6 commits into
roman_hlwasfrom
background

Conversation

@MatthieuPE

Copy link
Copy Markdown
Collaborator

Summary

Introduces the streamobs.background subpackage, providing two pipelines for
generating star and galaxy backgrounds alongside stream injections.

Survey / injector changes

  • Add gal_misclassification field and get_gal_misclassification() to Survey
    (detection × misclassification probability for galaxies, without the bright-end
    1-padding applied to stars).
  • Add SurveyFactory.set_gal_misclassification() and auto-loading from the
    gal_misclassification config key.
  • Add source_type='stars'|'galaxies' parameter to StreamInjector.inject() and
    detect_flag().
  • Add load_catalog() utility to utils.py (accepts a DataFrame or a parquet/CSV path).

New streamobs/background/ subpackage (scaffold — all methods stubbed)

  • BackgroundCatalogInjector: thin wrapper around StreamInjector with
    inject_stars() / inject_galaxies() and a unified _prepare_survey()
    (uniform maglim, no-dust options).
  • BackgroundResourceBuilder: builds 2-D color–magnitude histogram grids by
    injecting true catalogs into uniform surveys at a grid of (maglim_ref, Δmaglim)
    pairs.
  • BackgroundStorage: saves/loads CMD grids as long-format zstd-compressed
    parquet files under data/background/ (gitignored). Exposes get_path(),
    save_data(), load_data(), exists().
  • LightBackgroundGenerator: per-pixel fast generation — nearest-neighbour CMD
    lookup, Poisson count scaling, position sampling.
  • Background: top-level wrapper dispatching to the full injection or light
    method; defaults to bundled package resources when no storage is provided.

Tests / docs

  • tests/test_background.py: 31 test stubs marked @pytest.mark.background,
    using tmp_path for all disk I/O.
  • docs/source/background.md (user guide) and
    docs/source/build_background_resources.md (developer guide).
  • background marker registered in pytest.ini; data/background/ added to
    .gitignore.

MatthieuPE and others added 6 commits June 19, 2026 17:26
…line

- Add gal_misclassification field and method to Survey
- Extend set_completeness() with selection='missclassified'
- Thread source_type kwarg through StreamInjector.inject() and detect_flag()
- New streamobs/background/ subpackage: BackgroundCatalogInjector,
  BackgroundResourceBuilder, BackgroundStorage, LightBackgroundGenerator,
  Background wrapper
- Add load_catalog() utility to utils.py
- Add tests/test_background.py (31 stubs, @pytest.mark.background)
- Add user and developer documentation for background generation
- Gitignore data/background/ and .claude/

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@MatthieuPE

Copy link
Copy Markdown
Collaborator Author

So far coded:

  • loading missclassification efficiency
  • using it in the injection for galaxies if specified
  • build missclassification + detection if only missclassification loaded
  • StreamInjector wrapper to inject either stars or galaxies background

Now we should be able to get background realization from any truth catalogs.

Next:

  • verify that nothing broken by visual inspection of the different efficiencies functions
  • add tests for missclassification behavior
  • Continue to fill the other parts of the code

WARNING
Missclassication and optionnaly missclassication+detection must be added to the data base of each survey. Now tests ran with missclassication+detection of lsst added by hand in the files

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.

1 participant