xlens.simulator.perturbation

Lensing and astrometric perturbation models for simulated galaxies.

Submodules

Classes

DcrDistort

Apply an astrometric position shift to simulate DCR effects.

ShearHalo

Shear and convergence field generated by an NFW halo lens.

ShearLogNormalFlat

Flat-sky log-normal shear field generated from a CCL weak-lensing

ShearRedshift

Constant shear in each redshift slice.

Package Contents

class DcrDistort(distort_func)[source]

Bases: object

Apply an astrometric position shift to simulate DCR effects.

distort_func
distort_galaxy(gso, shift, redshift)[source]

This function distorts the galaxy’s shape and position :param gso (galsim object): :type gso (galsim object): galsim galaxy :param shift (galsim.PositionD): :type shift (galsim.PositionD): position of the galaxy :param redshift (float): :type redshift (float): redshift of galaxy

Returns:

distorted galaxy object and shift

Return type:

gso, shift

class ShearHalo(*, mass, conc, z_lens, halo_profile='NFW', cosmo=None, no_kappa=False, gmax=0.95)[source]

Bases: object

Shear and convergence field generated by an NFW halo lens.

cosmo = None
mass
z_lens
conc
no_kappa = False
lens
lens_solver
gmax = 0.95
distort_galaxy(src)[source]

This function distorts the galaxy’s shape and position :param src (np.array): :type src (np.array): row of structured array

Return type:

distorted galaxy position and lensing distortions

class ShearLogNormalFlat(z_source, field_size_deg=5.0, npix=2048, seed=None)[source]

Flat-sky log-normal shear field generated from a CCL weak-lensing power spectrum.

The constructor computes kappa, gamma1, and gamma2 maps and builds bivariate spline interpolators so that distort_galaxy can evaluate the lensing fields at arbitrary sky positions.

Parameters:
  • z_source (float) – Source redshift for the weak-lensing tracer.

  • field_size_deg (float, optional) – Side length of the square field in degrees.

  • npix (int, optional) – Number of pixels per side used for the Fourier-space generation.

  • seed (int or None, optional) – Random seed for reproducible field realisations.

cosmo
z_source
field_size_deg = 5.0
npix = 2048
seed = None
ell
cl_kappa
kappa_G_map
kappa_LN_map
gamma1_map
gamma2_map
kappa_map
kappa_interp
gamma1_interp
gamma2_interp
distort_galaxy(src)[source]

Return lensing distortions interpolated at the galaxy position.

Parameters:

src (numpy structured scalar) – Row with "dx" and "dy" fields (arcseconds).

Returns:

Standard shear result dict (see _get_shear_res_dict()).

Return type:

dict

class ShearRedshift(z_bounds, mode, g_dist='g1', shear_value=0.02, kappa_value=0.0)[source]

Bases: object

Constant shear in each redshift slice.

The shear pattern across redshift bins is encoded as a ternary integer (mode), where each base-3 digit maps to -shear_value, +shear_value, or 0.0.

Parameters:
  • z_bounds (list[float]) – Redshift bin boundaries (length nz_bins + 1).

  • mode (int) – Ternary-encoded shear assignment (see class docstring).

  • g_dist ({'g1', 'g2'}) – Which shear component receives the test signal.

  • shear_value (float) – Absolute shear amplitude per bin.

  • kappa_value (float) – Constant convergence applied to all bins.

nz_bins
code
z_bounds
g_dist = 'g1'
shear_value = 0.02
shear_list
kappa = 0.0
determine_shear_list(code)[source]

Convert a ternary code string into a list of shear values.

_get_zshear(redshift)[source]

Return the shear value for a galaxy at the given redshift.

get_shear(redshift)[source]

Return (g1, g2, mu, gamma1, gamma2) for a given redshift.

distort_galaxy(src)[source]

This function distorts the galaxy’s shape and position :param src (np.array): :type src (np.array): row of structured array

Return type:

distorted galaxy position and lensing distortions