Catalog¶
Generates tomographic galaxy catalogs from lightcone shells using uniform or clustered sampling methods, with augmentors adding columns to them (e.g. reduced shear and observed ellipticities). Their statistics are in Statistics.
Tomographic source catalogs from the shells and lensing maps, by uniform or clustered sampling of the galaxies.
Their two-point statistics (Cls with NaMaster, two-point functions with TreeCorr) and predictions are methods inherited from
CatalogStatistics.
- class pollux.catalog.CatalogGenerator(lensing, tag=None, *, nbar_input, interp_fields=('kappa', 'gamma1', 'gamma2'), interp_method='bilinear', smooth_fields=('positions', 'density', 't11', 't22', 't12'), smooth_Mpc=None, augmentors=None, cls_b=None, cls_lmax_mask=None, catalog_format='hdf5')[source]¶
Bases:
CatalogStatistics,ABCGeneric generator for mock source-galaxy catalogs for lensing analyses.
This class generates positions and redshifts for galaxies in each tomographic bin and interpolates lensing quantities (e.g. kappa/gamma) from maps produced by a lensing builder.
- Parameters:
lensing (LensingBuilder) – Lensing map builder used to define tomographic bins and provide maps to interpolate.
tag (str or None, optional) – Tag of the catalogs: they go to
catalogs/{nz}/{tag}/next to the maps (seepollux.io.files.PolluxIO),defaultif None.nbar_input (float or array-like) – Galaxy surface density in gal/arcmin^2 (required, keyword only). If a float, the same surface density is used for all tomographic bins; if an array-like, it must have length
lensing.nmapsand provide a per-bin value.interp_fields (tuple of str, optional) – Fields interpolated at the galaxies, among
FIELDS('kappa','gamma1','gamma2','density','t11','t22','t12'); the fields required by the augmentors are added. Default is('kappa', 'gamma1', 'gamma2').interp_method ({'bilinear', 'nearest'}, optional) – Interpolation of the maps at the galaxy positions: bilinear across pixels (default), or the value of the nearest pixel.
smooth_fields (tuple of str, optional) – Fields read from their maps smoothed by
smooth_Mpc, amongFIELDSand'positions'(the density contrast used to place galaxies). Default is('positions', 'density', 't11', 't22', 't12'). The smoothed maps are made by the builders (compute_maps_from_alms(),compute_tidal_tensor_maps(),compute_shear_maps()).smooth_Mpc (float, array-like, dict or None, optional) – Comoving Gaussian smoothing scale in Mpc of
smooth_fields, or one scale per shell (e.g.lognormal_smoothing()), or a dict of either per field (thensmooth_fieldsis ignored, and fields not in the dict are not smoothed). None (default) means no smoothing. Fields made together (t11,t22,t12;gamma1,gamma2) must share their scale.augmentors (list, optional) – List of catalog augmentors. Default is empty list.
cls_b (pymaster.NmtBin or None, optional) – Binning of
compute_cls()andpredict_cls(), whoselmaxis the maximum multipole of the catalog fields and workspaces. Default is the shell builder’s binning (seeb).cls_lmax_mask (int or None, optional) – Maximum multipole of the fields’ masks (at least the
lmaxofb). Default is thatlmax.catalog_format ({'hdf5', 'fits'}, optional) – Format of the catalog files (
pollux.io.files.PolluxIO.write_columns()).'hdf5'(default): the columns in acataloggroup, with each bin also laid out as a bin of TXPipe’s binned shear and lens catalogs (shear/bin_{b},lens/bin_{b}, linking the columns without copying them), gathered inbinned_catalog.hdf5, thebinned_shear_catalogandbinned_lens_catalogof TXPipe.'fits': a FITS table per bin.
- Variables:
Ngal (ndarray of int) – Number of galaxies drawn per tomographic bin over the footprint (
nbartimes its area).nbar_per_pix (ndarray) – Mean expected counts per pixel per tomographic bin.
metadata (dict) – Metadata stored in the catalog files (FITS header keywords, or HDF5 attributes): galaxy densities and bias, and the code version,
POLLUXV(git commit) andDIRTY(uncommitted changes).
- FIELDS = ('kappa', 'gamma1', 'gamma2', 'density', 't11', 't22', 't12')¶
- SHELL_FIELDS = ('density', 't11', 't22', 't12')¶
- CATALOG_FORMATS = ('hdf5', 'fits')¶
- config()[source]¶
Return the configuration of the catalogs, for their
config.yaml(pollux.io.config.write_config()).- Returns:
product('catalogs'),parameters(generator, galaxy densities and bias, interpolated fields and their smoothing, augmentors: theirCatalogAugmentor.config()) andinputs(the convergence maps of the n(z) and per shell, shells and smoothed maps).- Return type:
- property columns: list[str]¶
positions, redshift and distance, interpolated fields, and those of the augmentors.
- Type:
Columns of the catalogs
- path(ibin, ext=None, ishell=None)[source]¶
Return the path for the saved catalog of one tomographic bin.
- Parameters:
ibin (int) – Tomographic-bin index.
ext (str or None, optional) – File extension without the leading dot. Default is that of
catalog_format('hdf5'or'fits').ishell (int or None, optional) – If given, path of the catalog of shell
ishell(generate()withishell).
- Returns:
{catalog_dir}/cat_bin{ibin}.{ext}, withcatalog_dirthecatalogs/{nz}/{tag}directory of the maps’ products (seepollux.io.files), or{intermediate}/shells/cat_bin{ibin}_{ishell:03d}.{ext}for the catalog of one shell.- Return type:
- property path_txpipe: str¶
File gathering the bins as TXPipe’s binned shear and lens catalogs (HDF5 catalogs, see
catalog_format).
- property path_nzs: str¶
File of the redshift distributions of the bins (
nzs) in qp’s format, theshear_photoz_stackandlens_photoz_stackinputs of TXPipe (HDF5 catalogs).
- property nzs: tuple[ndarray, ndarray]¶
those of the lensing builder up to the far edge of the last shell, normalized, on the union of their grids (piecewise linear).
- Returns:
z (ndarray) – Redshift grid.
nzs (ndarray) – Distributions, shape
(nbins, len(z)).
- Type:
Redshift distributions of the galaxies of the bins, as they are drawn
- classmethod smoothing_scales(smooth_fields, smooth_Mpc, nshells)[source]¶
Return the smoothing scale of every field and shell (see
smooth_fieldsandsmooth_Mpc).- Parameters:
- Returns:
Tuple of the scales (Mpc, or None if not smoothed) of the shells, for each of
FIELDSand'positions', e.g. to schedule the smoothed maps needed by a catalog.- Return type:
- generate(ibins=None, ishell=None)[source]¶
Generate mock catalogs and interpolate requested map quantities.
- Parameters:
ibins (int or array_like of int or None, optional) – Tomographic-bin indices to generate. If None, generate for all bins.
ishell (int or None, optional) – If given, only generate the galaxies of shell
ishelland save them as the catalogs of the shell (one per bin), to be merged withmerge_shell_catalogs(). Only supported by subclasses drawing galaxies shell by shell (CatalogClusteredPoisson).
- Return type:
None
Notes
The generation proceeds in four steps: 1) draw galaxies (positions/redshifts and shell membership), 2) interpolate requested fields from maps, 3) apply the augmentors, 4) write one file per tomographic bin (
catalog_format).
- merge_shell_catalogs(ibins=None)[source]¶
Merge the catalogs of the shells (
generate()withishell, saved inshells/) into one catalog per bin.- Parameters:
ibins (int or array_like of int or None, optional) – Tomographic-bin indices to merge. If None, merge all bins.
- Return type:
None
Notes
Partial catalogs are produced by
generate()withishelland are concatenated in shell order, which gives the same catalog as generating all shells at once.
- read_catalogs(ibins=None, return_metadata=False, subsample=None, seed=None, columns=None, remove_mean=None)[source]¶
Read the catalogs of one or more tomographic bins, in either format.
- Parameters:
ibins (int or array_like of int or None, optional) – Tomographic-bin indices to load. If None, loads all bins.
return_metadata (bool, optional) – If True, also return the metadata of the files (
pollux.io.files.PolluxIO.read_columns_info()).subsample (float or None, optional) – If not None, randomly draw (without replacement, seeded by
seed + ibin) this fraction of galaxies from each loaded catalog, with0 < subsample < 1. A random draw is used rather than a fixed stride, since galaxies are stored in a fixed (non-random) order and a stride would sample a specific, non-representative pattern. Default is None (no subsampling).seed (int or None, optional) – Seed for the subsampling RNG. Only used when
subsampleis not None. Default is the shell builder’s seed.columns (list of str or None, optional) – Columns to read. If None (default), all columns.
remove_mean (list of str or None, optional) – Columns whose mean over each loaded catalog is subtracted.
- Returns:
metadata (dict, optional) – Only if
return_metadata=True: of the bin ifibinsis a single int, otherwise a dict keyed by bin index.catalog (dict) – Arrays by column name if
ibinsis a single int, otherwise a dict of them keyed by bin index.
- Return type:
- class pollux.catalog.CatalogUniform(lensing, tag=None, *, nbar_input, interp_fields=('kappa', 'gamma1', 'gamma2'), interp_method='bilinear', smooth_fields=('positions', 'density', 't11', 't22', 't12'), smooth_Mpc=None, augmentors=None, cls_b=None, cls_lmax_mask=None, catalog_format='hdf5')[source]¶
Bases:
CatalogGeneratorGenerate source galaxies uniformly over the footprint.
Redshifts are drawn from the tomographic tracer distributions. Angular positions are drawn uniformly over the footprint of the maps.
- Parameters:
lensing (LensingBuilder) – Lensing map builder.
tag (str or None, optional) – Tag of the catalogs: they go to
catalogs/{nz}/{tag}/next to the maps (seepollux.io.files.PolluxIO),defaultif None.nbar_input (float or array-like) – Galaxy surface density in gal/arcmin^2, per bin or for all (required, keyword only).
interp_fields (tuple[str, ...]) – Interpolation and smoothing of the fields, see
CatalogGenerator.interp_method (str) – Interpolation and smoothing of the fields, see
CatalogGenerator.smooth_fields (tuple[str, ...]) – Interpolation and smoothing of the fields, see
CatalogGenerator.smooth_Mpc (float | dict[str, float] | None) – Interpolation and smoothing of the fields, see
CatalogGenerator.augmentors (list, optional) – List of augmentors. Default is empty list.
cls_b (nmt.NmtBin | None)
cls_lmax_mask (int | None)
catalog_format (str)
- class pollux.catalog.CatalogClustered(lensing, tag=None, *, nbar_input, bias=None, bias_model='linear', interp_fields=('kappa', 'gamma1', 'gamma2'), interp_method='bilinear', smooth_fields=('positions', 'density', 't11', 't22', 't12'), smooth_Mpc=None, augmentors=None, cls_b=None, cls_lmax_mask=None, catalog_format='hdf5')[source]¶
Bases:
CatalogGeneratorBase class for clustered source galaxy catalogs.
This class provides common functionality for generating clustered catalogs where galaxy positions are biased by a density field.
- Parameters:
lensing (LensingBuilder) – Lensing map builder.
tag (str or None, optional) – Tag of the catalogs: they go to
catalogs/{nz}/{tag}/next to the maps (seepollux.io.files.PolluxIO),defaultif None.nbar_input (float or array-like) – Galaxy surface density in gal/arcmin^2, per bin or for all (required, keyword only).
bias (float or array-like, optional) – Galaxy bias per tomographic bin. If a float, the same bias is used for all tomographic bins; if an array-like, it must have length
lensing.nmapsand provide a per-bin value.bias_model ({'linear', 'power_law'}, optional) –
Relative galaxy density per pixel, given the density contrast
delta(see_density_weight()):'linear'(default):1 + b * delta, clipped at zero where negative (underdense pixels withb > 1);'power_law':(1 + delta)**b / <(1 + delta)**b>, the mean over the footprint pixels of the shell, positive everywhere (no clipping), and with linear biasbon large scales.
interp_fields (optional) – Interpolation and smoothing of the fields (including the density used to place galaxies,
'positions'), seeCatalogGenerator.interp_method (optional) – Interpolation and smoothing of the fields (including the density used to place galaxies,
'positions'), seeCatalogGenerator.smooth_fields (optional) – Interpolation and smoothing of the fields (including the density used to place galaxies,
'positions'), seeCatalogGenerator.smooth_Mpc (optional) – Interpolation and smoothing of the fields (including the density used to place galaxies,
'positions'), seeCatalogGenerator.augmentors (list, optional) – List of augmentors applied after map interpolation. Default is empty list.
cls_b (optional) – Binning of the catalog angular power spectra, see
CatalogGenerator.cls_lmax_mask (optional) – Binning of the catalog angular power spectra, see
CatalogGenerator.catalog_format ({'hdf5', 'fits'}, optional) – Format of the catalog files, see
CatalogGenerator.
- BIAS_MODELS = ('linear', 'power_law')¶
- class pollux.catalog.CatalogClusteredMultinomial(lensing, tag=None, *, nbar_input, bias=None, bias_model='linear', interp_fields=('kappa', 'gamma1', 'gamma2'), interp_method='bilinear', smooth_fields=('positions', 'density', 't11', 't22', 't12'), smooth_Mpc=None, augmentors=None, cls_b=None, cls_lmax_mask=None, catalog_format='hdf5')[source]¶
Bases:
CatalogClusteredGenerate clustered source galaxies using multinomial sampling.
The total number of galaxies per tomographic bin is fixed, and positions are drawn per shell from a multinomial distribution over pixels, proportional to the relative density of the bias model (
1 + b * deltaby default, wheredeltais the density contrast field, seeCatalogClustered).- Parameters:
lensing (LensingBuilder) – Lensing map builder.
tag (str or None, optional) – Tag of the catalogs: they go to
catalogs/{nz}/{tag}/next to the maps (seepollux.io.files.PolluxIO),defaultif None.nbar_input (float or array-like) – Galaxy surface density in gal/arcmin^2, per bin or for all (required, keyword only).
bias (optional) – Galaxy bias per tomographic bin, and bias model, see
CatalogClustered.bias_model (optional) – Galaxy bias per tomographic bin, and bias model, see
CatalogClustered.interp_fields (tuple[str, ...]) – Interpolation and smoothing of the fields, see
CatalogGenerator.interp_method (str) – Interpolation and smoothing of the fields, see
CatalogGenerator.smooth_fields (tuple[str, ...]) – Interpolation and smoothing of the fields, see
CatalogGenerator.smooth_Mpc (float | dict[str, float] | None) – Interpolation and smoothing of the fields, see
CatalogGenerator.augmentors (list, optional) – List of augmentors. Default is empty list.
cls_b (nmt.NmtBin | None)
cls_lmax_mask (int | None)
catalog_format (str)
- class pollux.catalog.CatalogClusteredPoisson(lensing, tag=None, *, nbar_input, bias=None, bias_model='linear', interp_fields=('kappa', 'gamma1', 'gamma2'), interp_method='bilinear', smooth_fields=('positions', 'density', 't11', 't22', 't12'), smooth_Mpc=None, augmentors=None, cls_b=None, cls_lmax_mask=None, catalog_format='hdf5')[source]¶
Bases:
CatalogClusteredGenerate clustered source galaxies using Poisson sampling.
In each shell and tomographic bin, the number of galaxies per pixel is drawn as a Poisson random variable with mean
<nbar>times the relative density of the bias model (1 + b * deltaby default, seeCatalogClustered). The total number of galaxies therefore fluctuates.- Parameters:
lensing (LensingBuilder) – Lensing map builder.
tag (str or None, optional) – Tag of the catalogs: they go to
catalogs/{nz}/{tag}/next to the maps (seepollux.io.files.PolluxIO),defaultif None.nbar_input (float or array-like) – Galaxy surface density in gal/arcmin^2, per bin or for all (required, keyword only).
bias (optional) – Galaxy bias per tomographic bin, and bias model, see
CatalogClustered.bias_model (optional) – Galaxy bias per tomographic bin, and bias model, see
CatalogClustered.interp_fields (tuple[str, ...]) – Interpolation and smoothing of the fields, see
CatalogGenerator.interp_method (str) – Interpolation and smoothing of the fields, see
CatalogGenerator.smooth_fields (tuple[str, ...]) – Interpolation and smoothing of the fields, see
CatalogGenerator.smooth_Mpc (float | dict[str, float] | None) – Interpolation and smoothing of the fields, see
CatalogGenerator.augmentors (list, optional) – List of augmentors. Default is empty list.
cls_b (nmt.NmtBin | None)
cls_lmax_mask (int | None)
catalog_format (str)
Notes
In shell \(i\) and bin \(j\), pixel \(p\) gets
\[N_p \sim \mathrm{Poisson}\left(\bar N_{ij}\, w(\delta_p)\right), \qquad \bar N_{ij} = \bar n_j\, \Omega_{\rm pix} \frac{\int_{z_i}^{z_{i+1}} n_j(z)\, dz}{\sum_k \int_{z_k}^{z_{k+1}} n_j(z)\, dz},\]with \(\bar n_j\) the density of the bin (
nbar_input), \(w\) the relative density of_density_weight(), and \(\delta_p\) the density contrast smoothed for the positions. Galaxies are placed uniformly within their pixel, at redshifts drawn from \(n_j(z)\) within the shell.
- class pollux.catalog.CatalogAugmentor[source]¶
Bases:
ABCBase class for catalog augmentors that add fields to existing catalogs.
Subclasses must implement the
augment_catalogmethod and setself.name,self.required_interp_fields, andself.new_columnsin their__init__.- config()[source]¶
Return the type and parameters of the augmentor, for the
config.yamlof the catalogs.- Returns:
type(the class of the augmentor), extended by subclasses with their parameters.- Return type:
- class pollux.catalog.CatalogAugmentorShear(compute_reduced_shear=True, compute_magnification=False, generate_intrinsic=False, compute_observed=False, include_ia=True, sigma_e=0.3, seed=None)[source]¶
Bases:
CatalogAugmentorAugmentor that computes shear-derived quantities and shapes.
Options include reduced shear, magnification, intrinsic shapes, and observed shapes. Intrinsic alignment (IA) shear contributions are included when available and requested.
- Parameters:
compute_reduced_shear (bool, optional) – If True, compute reduced shear g1, g2. Default is True.
compute_magnification (bool, optional) – If True, compute magnification mu. Default is False.
generate_intrinsic (bool, optional) – If True, generate random intrinsic shapes e1_int, e2_int. Default is False.
compute_observed (bool, optional) – If True, compute observed shapes by adding lensing and IA contributions to intrinsic shapes. Requires generate_intrinsic=True. Default is False.
include_ia (bool, optional) – If True, include IA contributions in lensed shapes. Default is True.
sigma_e (float, optional) – Standard deviation of the intrinsic ellipticity distribution. Default is 0.3.
seed (int or None, optional) – Extra seed of the intrinsic shapes, if not None. The shapes of the galaxies of tomographic bin
ibinin shellishellare drawn from a stream of their own, seeded by the seed of the realization (given by the catalog generator),ibinandishell: they differ between realizations, and do not depend on how the catalog is split into shells. Default is None.
- config()[source]¶
Return the type and parameters of the augmentor, for the
config.yamlof the catalogs.The parameters setting the values of the shapes (
sigma_e,include_ia,seed) are recorded when they differ from their defaults, so that the configurations of catalogs made before they were recorded stay valid.- Returns:
typeand the parameters that differ from their defaults.- Return type:
- augment_catalog(cosmo, catalog, ibin=0, realization_seed=0, **kwargs)[source]¶
Compute derived shear quantities and add them to the catalog.
- Parameters:
cosmo (pyccl.Cosmology) – Cosmology (unused).
catalog (dict[str, np.ndarray]) – Catalog of one tomographic bin, with
'kappa','gamma1','gamma2'and'idx_shell'; updated in place.ibin (int, optional) – Tomographic-bin index, used to seed the intrinsic shapes.
realization_seed (int, optional) – Seed of the realization (that of the shell builder), used to seed the intrinsic shapes.
**kwargs – Unused (other augmentor options).
- Return type:
None