streamobs.background.generator module#
Fast per-pixel background generation from precomputed CMD grids.
- class streamobs.background.generator.LightBackgroundGenerator(storage: BackgroundStorage, surveys, bands=('g', 'r'), **kwargs)[source]#
Bases:
objectGenerate background catalogs rapidly from precomputed CMD histogram grids.
For each HEALPix pixel in the requested sky region the generator:
Retrieves the effective magnitude limit (observed maglim minus dust extinction).
Bilinearly interpolates the CMD histogram grid at that effective maglim (taking into account the dust absorption in each band).
Scales the reference object count to the pixel area via a Poisson draw.
Samples
(color, mag)pairs from the 2-D histogram.Samples sky positions uniformly within the pixel.
Stars and galaxies are handled independently so that users can build custom mixed background models.
- Parameters:
storage (BackgroundStorage) – Storage backend holding the precomputed CMD grids.
survey (Survey) – Survey with real (non-uniform) HEALPix magnitude limit maps used to look up per-pixel depth.
bands (tuple of str, optional) –
(band_g, band_r)— must match the bands used when building resources. Default('g', 'r').**kwargs – Reserved for future use.
Examples
>>> gen = LightBackgroundGenerator(storage, survey, bands=('g', 'r')) >>> catalog, meta = gen.generate( ... phi1_limits=(-20, 20), ... phi2_limits=(-2, 2), ... gc_frame=frame, ... nside=4096, ... source_type='both', ... )
- generate(phi1_limits, phi2_limits, gc_frame, nside=4096, source_type='both', **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) – Great-circle frame mapping
(phi1, phi2)to(RA, Dec).nside (int, optional) – HEALPix resolution. Default
4096.source_type (str, optional) –
'stars','galaxies', or'both'. Default'both'.**kwargs – rng : numpy.random.Generator, optional seed : int, optional
- Returns:
Background catalog with columns
phi1,phi2,mag_{band_r}(e.g.mag_r),mag_{band_g}(e.g.mag_g), andsource_type; plus a metadata dict with keysnside,color_edges,mag_edges,band1,band2.- Return type:
tuple of (pd.DataFrame, dict)