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

BaseGalaxyCatalog

Abstract base class for galaxy catalogs used to build GalSim objects.

CatSim2017Catalog

Galaxy catalog from CatSim 2017 (OneDegSq.fits).

OpenUniverse2024RubinRomanCatalog

DiffSky-based Rubin-Roman input galaxies (OpenUniverse2024).

Flagship2025Catalog

Catalog of galaxies from the Euclid Flagship 2025 simulation

Functions

get_catalog(fname)

Read a FITS or Parquet catalog and append an indices column.

Module Contents

get_catalog(fname)[source]

Read a FITS or Parquet catalog and append an indices column.

Parameters:

fname (str) – Path to a FITS or Parquet file readable by fitsio.

Returns:

Structured array with an additional indices column (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.ABC

Abstract 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]

catsim_dir[source]
pixel_scale[source]
input_catalog[source]
dtype = [('indices', 'i8'), ('redshift', 'f8'), ('angles', 'f8'), ('gamma1', 'f8'), ('gamma2', 'f8'),...[source]
data[source]
lensed = False[source]
set_z_source(redshift)[source]

Override all galaxy redshifts with a fixed value.

prepare_tract_info(tract_info)[source]

Store tract info and compute the pixel-centre coordinates.

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.

_build_hlr_array(indices: numpy.ndarray) numpy.ndarray[source]
_probabilities_for_sampling(cat: Any) numpy.ndarray | None[source]

Optional per-row sampling probabilities. Default: None (uniform).

__len__() int[source]
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_DIR environment 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.

rotate(theta, degrees=False)[source]

Rotate by an angle theta (radians).

lens(*, shear_obj, apply_position_shifts: bool = True)[source]

Apply lensing distortions from shear_obj to every galaxy.

Parameters:
  • shear_obj – Object with a distort_galaxy(src) method that returns a dict with keys dx, 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: BaseGalaxyCatalog

Galaxy 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

_compute_density(cat) float[source]

Return density in objects/arcmin^2 for a 1-deg^2 catalog.

_probabilities_for_sampling(cat)[source]

Optional per-row sampling probabilities. Default: None (uniform).

_half_light_radius(catalog) numpy.ndarray[source]

Return galaxy half-light radii (arcsec) for the given entries.

_generate_galaxy(*, entry, mag_zero, band, use_mog=False, include_point_source=True, force_isotropic=False, **kwargs) galsim.GSObject[source]

Build a GalSim galaxy from a CatSim 2017 catalog row.

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: BaseGalaxyCatalog

DiffSky-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.

_half_light_radius(catalog) numpy.ndarray[source]

Return galaxy half-light radii (arcsec) for the given entries.

_generate_galaxy(*, entry, mag_zero, band, survey_name, use_mog=False, force_isotropic=False, **kwargs) galsim.GSObject[source]

Build a GalSim galaxy from an OpenUniverse 2024 catalog row.

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: BaseGalaxyCatalog

Catalog 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 q parameter.

_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.

_half_light_radius(catalog) numpy.ndarray[source]

Return galaxy half-light radii (arcsec) for the given entries.

_generate_galaxy(*, entry, mag_zero, band, survey_name, use_mog=False, force_isotropic=False, **kwargs) galsim.GSObject[source]

Build a GalSim galaxy from a Flagship 2025 catalog row.