xlens.simulator.galaxies
Galaxy catalog classes for building GalSim objects from input truth tables.
Provides an abstract BaseGalaxyCatalog and concrete implementations
for CatSim 2017, OpenUniverse 2024 Rubin-Roman, and Euclid Flagship 2025
catalogs.
Classes
Abstract base class for galaxy catalogs used to build GalSim objects. |
|
Galaxy catalog from CatSim 2017 ( |
|
DiffSky-based Rubin-Roman input galaxies ( |
|
Catalog of galaxies from the Euclid Flagship 2025 simulation |
Functions
|
Read a FITS or Parquet catalog and append an |
Module Contents
- get_catalog(fname)[source]
Read a FITS or Parquet catalog and append an
indicescolumn.- Parameters:
fname (str) – Path to a FITS or Parquet file readable by
fitsio.- Returns:
Structured array with an additional
indicescolumn (int32).- Return type:
numpy.ndarray
- class BaseGalaxyCatalog(*, rng: numpy.random.RandomState, tract_info: lsst.skymap.tractInfo.ExplicitTractInfo, layout_name: str, sep_arcsec: float | None = None, indice_group_id: int | None = None, select_observable: list[str] | str | None = None, select_lower_limit: Iterable[float] | None = None, select_upper_limit: Iterable[float] | None = None, extend_ratio: float = 1.08, force_pixel_center: bool = False, catsim_dir: str | None = None)[source]
Bases:
abc.ABCAbstract base class for galaxy catalogs used to build GalSim objects.
- Subclasses must implement:
_read_catalog(…)
_compute_density(cat)
_generate_galaxy(entry, mag_zero, band, **kwargs)
- Optionally override:
_probabilities_for_sampling(cat) -> Optional[np.ndarray]
- dtype = [('indices', 'i8'), ('redshift', 'f8'), ('angles', 'f8'), ('gamma1', 'f8'), ('gamma2', 'f8'),...[source]
- abstract _read_catalog(*, select_observable, select_lower_limit, select_upper_limit) Any[source]
Return the catalog object (array / table) with any requested filtering applied.
- abstract _compute_density(cat: Any) float[source]
Return object surface density in objects / arcmin^2.
- abstract _generate_galaxy(*, entry: Any, mag_zero: float, band: str, use_mog=False, **kwargs) galsim.GSObject[source]
Build and return a GalSim GSObject from one catalog entry.
- abstract _half_light_radius(catalog) numpy.ndarray[source]
Return galaxy half-light radii (arcsec) for the given entries.
- _probabilities_for_sampling(cat: Any) numpy.ndarray | None[source]
Optional per-row sampling probabilities. Default: None (uniform).
- classmethod from_array(*, table: numpy.ndarray, tract_info: lsst.skymap.tractInfo.ExplicitTractInfo, select_observable: list[str] | str | None = None, select_lower_limit: Iterable[float] | None = None, select_upper_limit: Iterable[float] | None = None, catsim_dir: str | None = None) BaseGalaxyCatalog[source]
Build a catalog directly from a table structured array.
- Parameters:
table (np.ndarray) – Structured array with columns ‘dx’, ‘dy’, ‘indices’, ‘angles’.
catsim_dir (str or None) – Directory containing input galaxy catalogs. Falls back to the
CATSIM_DIRenvironment variable when None.select_observable – Passed to _read_catalog(…) so subclasses can load/filter input_catalog.
select_lower_limit – Passed to _read_catalog(…) so subclasses can load/filter input_catalog.
select_upper_limit – Passed to _read_catalog(…) so subclasses can load/filter input_catalog.
- lens(*, shear_obj, apply_position_shifts: bool = True)[source]
Apply lensing distortions from
shear_objto every galaxy.- Parameters:
shear_obj – Object with a
distort_galaxy(src)method that returns a dict with keysdx, dy, gamma1, gamma2, kappa, has_finite_shear.apply_position_shifts (bool, optional) – If True, update image positions to the lensed coordinates; otherwise keep pre-lensing positions.
- get_obj(*, ind, mag_zero: float, band: str, use_mog: bool = False, force_isotropic: bool = False, include_point_source: bool = True, survey_name: str = '') dict[str, list][source]
Build a lensed, rotated GalSim object for galaxy at index ind.
- Parameters:
ind (int) – Index into
self.data.mag_zero (float) – Zeropoint magnitude for flux conversion.
band (str) – Photometric band label.
use_mog (bool, optional) – Use Mixture-of-Gaussians profiles instead of native GalSim.
force_isotropic (bool, optional) – Force all galaxies to have circular isophotes.
include_point_source (bool, optional) – Include AGN or point-source components.
survey_name (str, optional) – Survey name used to select magnitude columns.
- Returns:
Lensed galaxy object ready for PSF convolution.
- Return type:
galsim.GSObject
- class CatSim2017Catalog(*, rng: numpy.random.RandomState, tract_info: lsst.skymap.tractInfo.ExplicitTractInfo, layout_name: str, sep_arcsec: float | None = None, indice_group_id: int | None = None, select_observable: list[str] | str | None = None, select_lower_limit: Iterable[float] | None = None, select_upper_limit: Iterable[float] | None = None, extend_ratio: float = 1.08, force_pixel_center: bool = False, catsim_dir: str | None = None)[source]
Bases:
BaseGalaxyCatalogGalaxy catalog from CatSim 2017 (
OneDegSq.fits).Each galaxy is a single Sersic profile with half-light radius, Sersic index, axis ratio, and position angle read from the input FITS file.
- _read_catalog(*, select_observable=None, select_lower_limit=None, select_upper_limit=None)[source]
Read the catalog from the cache, but update the position angles each time
- Parameters:
select_observable (list[str] | str) – A list of observables to apply selection
select_lower_limit (list[float] | ndarray[float]) – lower limits of the slection cuts
select_upper_limit (list[float] | ndarray[float]) – upper limits of the slection cuts
- Return type:
array with fields
- _probabilities_for_sampling(cat)[source]
Optional per-row sampling probabilities. Default: None (uniform).
- class OpenUniverse2024RubinRomanCatalog(*, rng: numpy.random.RandomState, tract_info: lsst.skymap.tractInfo.ExplicitTractInfo, layout_name: str, sep_arcsec: float | None = None, indice_group_id: int | None = None, select_observable: list[str] | str | None = None, select_lower_limit: Iterable[float] | None = None, select_upper_limit: Iterable[float] | None = None, extend_ratio: float = 1.08, force_pixel_center: bool = False, catsim_dir: str | None = None)[source]
Bases:
BaseGalaxyCatalogDiffSky-based Rubin-Roman input galaxies (
OpenUniverse2024).Galaxies are decomposed into bulge + disk components, each with its own Sersic index, half-light radius, and axis ratio. Read from HEALPix nside=32 tiles.
- _read_catalog(*, select_observable=None, select_lower_limit=None, select_upper_limit=None)[source]
Read the catalog from the cache, but update the position angles each time
- Parameters:
select_observable (list[str] | str) – A list of observables to apply selection
select_lower_limit (list[float] | ndarray[float]) – lower limits of the slection cuts
select_upper_limit (list[float] | ndarray[float]) – upper limits of the slection cuts
- Return type:
array with fields
- _compute_density(cat) float[source]
Return density in objects/arcmin^2 for an nside=32 HEALPix tile.
- class Flagship2025Catalog(*, rng: numpy.random.RandomState, tract_info: lsst.skymap.tractInfo.ExplicitTractInfo, layout_name: str, sep_arcsec: float | None = None, indice_group_id: int | None = None, select_observable: list[str] | str | None = None, select_lower_limit: Iterable[float] | None = None, select_upper_limit: Iterable[float] | None = None, extend_ratio: float = 1.08, force_pixel_center: bool = False, catsim_dir: str | None = None)[source]
Bases:
BaseGalaxyCatalogCatalog of galaxies from the Euclid Flagship 2025 simulation (COSMOS field extraction, flagship_cosmos.fits).
The axis ratios (disk_axis_ratio, bulge_axis_ratio) are stored as minor/major ratio, which maps directly to GalSim’s
qparameter.- _read_catalog(*, select_observable=None, select_lower_limit=None, select_upper_limit=None)[source]
Return the catalog object (array / table) with any requested filtering applied.
- _compute_density(cat) float[source]
Return density in objects/arcmin^2 from the catalog sky footprint.