streamobs.background.background module

streamobs.background.background module#

Top-level background generation wrapper.

class streamobs.background.background.Background(surveys=None, source_type: str = 'both', method: str = 'light', storage: BackgroundStorage = None, bands: tuple = ('g', 'r'), catalog_stars=None, catalog_galaxies=None, **kwargs)[source]#

Bases: object

High-level wrapper for background generation.

Dispatches to BackgroundCatalogInjector (method='injection') or LightBackgroundGenerator (method='light') depending on the chosen method. Stars and galaxies are handled independently.

Parameters:
  • surveys (Survey or list of Survey) – One or more survey instances. A single Survey is wrapped in a list.

  • source_type ({'stars', 'galaxies', 'both'}, optional) – Which components to generate. Default 'both'.

  • method ({'light', 'injection'}, optional) – 'light' uses precomputed CMD grids (fast); 'injection' runs the full injection pipeline. Default 'light'.

  • storage (BackgroundStorage, optional) – Resource storage for the light method. None falls back to bundled package resources via _default_storage().

  • bands (tuple of str, optional) – Band pair forwarded to the light generator. Default ('g', 'r').

  • catalog_stars (pd.DataFrame, optional) – Required when method='injection' and source_type includes stars.

  • catalog_galaxies (pd.DataFrame, optional) – Required when method='injection' and source_type includes galaxies.

  • **kwargs – Forwarded to the underlying injector or generator.

generate(phi1_limits, phi2_limits, gc_frame=None, **kwargs)[source]#

Generate a background catalog for the given sky region.

Parameters:
  • phi1_limits (tuple of float) – (phi1_min, phi1_max) in degrees.

  • phi2_limits (tuple of float) – (phi2_min, phi2_max) in degrees.

  • gc_frame (gala.coordinates.GreatCircleICRSFrame, optional) – Great-circle frame. Required for method='light'.

  • **kwargs – Forwarded to the underlying generator or injector.

Returns:

  • pd.DataFrame – For method='injection': survey-namespaced magnitude and flag columns plus source_type.

  • tuple of (pd.DataFrame, dict) – For method='light': catalog with phi1, phi2, mag_<band>, source_type columns, plus a metadata dict.