dsigma.stacking module

Module for stacking lensing results after pre-computation.

dsigma.stacking.boost_factor(table_l, table_r)[source]

Compute the boost factor.

Boost factor is computed by comparing the number of lens-source pairs in real lenses and random lenses.

Parameters:
table_lastropy.table.Table

Precompute results for the lenses.

table_rastropy.table.Table

Precompute results for random lenses.

Returns:
bnumpy.ndarray

Boost factor in each radial bin.

dsigma.stacking.excess_surface_density(table_l, table_r=None, photo_z_dilution_correction=False, boost_correction=False, scalar_shear_response_correction=False, matrix_shear_response_correction=False, shear_responsivity_correction=False, selection_bias_correction=False, random_subtraction=False, return_table=False)[source]

Compute the mean excess surface density with corrections, if applicable.

Parameters:
table_lastropy.table.Table

Precompute results for the lenses.

table_rastropy.table.Table, optional

Precompute results for random lenses. Default is None.

photo_z_dilution_correctionbool, optional

If True, correct for photo-z biases. This can only be done if a calibration catalog has been provided in the precomputation phase. Default is False.

boost_correctionbool, optional

If True, calculate and apply a boost factor correction. This can only be done if a random catalog is provided. Default is False.

scalar_shear_response_correctionbool or str, optional

Whether to correct for the multiplicative shear bias (scalar form). Default is False.

matrix_shear_response_correctionbool or str, optional

Whether to correct for the multiplicative shear bias (tensor form). Default is False.

shear_responsivity_correctionbool, optional

If True, correct for the shear responsivity. Default is False.

selection_bias_correctionbool, optional

If True, correct for the multiplicative selection bias in, e.g., HSC. Default is False.

random_subtractionbool, optional

If True, subtract the signal around randoms. This can only be done if a random catalog is provided. Default is False.

return_tablebool, optional

If True, return a table with many intermediate steps of the computation. Otherwise, a simple array with just the final excess surface density is returned. Default is False.

Returns:
dsnumpy.ndarray or astropy.table.Table

The excess surface density in each radial bin specified in the precomputation phase. If return_table is True, will return a table with detailed information for each radial bin. The final result is in the column ds.

Raises:
ValueError

If boost or random subtraction correction are requested but no random catalog is provided.

dsigma.stacking.lens_magnification_bias(table_l, alpha_l, sigma_8=0.82, n_s=0.96, photo_z_dilution_correction=False, shear=False)[source]

Estimate the additive lens magnification bias.

Note that the assumed cosmology is taken from table_l.meta['cosmology'] which is added by precompute.

Parameters:
table_lastropy.table.Table

Precompute results for the lenses.

alpha_lfloat

The response of the lenses to magnification.

sigma_8float, optional

Scale of fluctuations at \(8 h^{-1} \, \mathrm{Mpc}\). Default is 0.82.

n_sfloat, optional

Primordial power spectrum index. Default is 0.96.

photo_z_dilution_correctionbool, optional

If True, correct the mean critical surface density for photo-z biases. Not used if shear is True. This should be consistent with what is used for calculating the total excess surface density. Default is False.

shearbool, optional

If True, return bias of the mean tangential shear. Otherwise, return an estimate for the bias of the excess surface density. Default is False.

Returns:
ds_lmnumpy.ndarray

The lens magnification bias in each radial bin.

dsigma.stacking.matrix_shear_response_factor(table_l)[source]

Compute the mean tangential response.

The tangential shear response factor \(R_t\) is defined such that \(\gamma_{\mathrm obs} = R_t \gamma_{\mathrm intrinsic}\).

Parameters:
table_lastropy.table.Table

Precompute results for the lenses.

Returns:
r_tnumpy.ndarray

Tangential shear response factor in each radial bin.

dsigma.stacking.mean_critical_surface_density(table_l, photo_z_dilution_correction=False)[source]

Compute the weighted-average (effective) critical surface density.

Parameters:
table_lastropy.table.Table

Precompute results for the lenses.

photo_z_dilution_correctionbool, optional

If True, correct for photo-z biases. This can only be done if a calibration catalog has been provided in the precomputation phase. Default is False.

Returns:
sigma_critnumpy.ndarray

Mean (effective) critical surface density.

dsigma.stacking.mean_lens_redshift(table_l)[source]

Compute the weighted-average lens redshift.

Parameters:
table_lastropy.table.Table

Precompute results for the lenses.

Returns:
z_lnumpy.ndarray

Mean lens redshift in each bin.

dsigma.stacking.mean_source_redshift(table_l)[source]

Compute the weighted-average source redshift.

Parameters:
table_lastropy.table.Table

Precompute results for the lenses.

Returns:
z_snumpy.ndarray

Mean source redshift in each bin.

dsigma.stacking.number_of_pairs(table_l)[source]

Compute the number of lens-source pairs per bin.

Parameters:
table_lastropy.table.Table

Precompute results for the lenses.

Returns:
n_pairsnumpy.ndarray

The number of lens-source pairs in each radial bin.

dsigma.stacking.photo_z_dilution_factor(table_l)[source]

Compute the photometric redshift bias averaged over the entire catalog.

Parameters:
table_lastropy.table.Table

Precompute results for the lenses.

Returns:
f_biasfloat

Photometric redshift bias \(f_{\mathrm{bias}}\).

dsigma.stacking.raw_excess_surface_density(table_l)[source]

Compute the raw, uncorrected excess surface density for a catalog.

Parameters:
table_lastropy.table.Table

Precompute results for the lenses.

Returns:
dsnumpy.ndarray

The raw, uncorrected excess surface density in each radial bin.

dsigma.stacking.raw_tangential_shear(table_l)[source]

Compute the average tangential shear for a catalog.

Parameters:
table_lastropy.table.Table

Precompute results for the lenses.

Returns:
gtnumpy.ndarray

The raw, uncorrected tangential shear in each radial bin.

dsigma.stacking.scalar_shear_response_factor(table_l, selection_bias=False)[source]

Compute the mean shear response.

The shear response factor \(m\) is defined such that \(\gamma_{\mathrm obs} = (1 + m) \gamma_{\mathrm intrinsic}\).

Parameters:
table_lastropy.table.Table

Precompute results for the lenses.

selection_biasbool

If True, calculate the selection bias \(m_\mathrm{sel}\), instead. Default is False.

Returns:
mnumpy.ndarray

Multiplicative shear bias in each radial bin.

dsigma.stacking.shear_responsivity_factor(table_l)[source]

Compute the shear responsivity factor.

Parameters:
table_lastropy.table.Table

Precompute results for the lenses.

Returns:
rnumpy.ndarray

Shear responsivity factor in each radial bin.

dsigma.stacking.tangential_shear(table_l, table_r=None, boost_correction=False, scalar_shear_response_correction=False, matrix_shear_response_correction=False, shear_responsivity_correction=False, selection_bias_correction=False, random_subtraction=False, return_table=False)[source]

Compute the mean tangential shear with corrections, if applicable.

Parameters:
table_lastropy.table.Table

Precompute results for the lenses.

table_rastropy.table.Table, optional

Precompute results for random lenses. Default is None.

boost_correctionbool, optional

If True, calculate and apply a boost factor correction. This can only be done if a random catalog is provided. Default is False.

scalar_shear_response_correctionbool, optional

Whether to correct for the multiplicative shear bias (scalar form). Default is False.

matrix_shear_response_correctionbool, optional

Whether to correct for the multiplicative shear bias (tensor form). Default is False.

shear_responsivity_correctionbool, optional

If True, correct for the shear responsivity. Default is False.

selection_bias_correctionbool, optional

If True, correct for the multiplicative selection bias in, e.g., HSC. Default is False.

random_subtractionbool, optional

If True, subtract the signal around randoms. This can only be done if a random catalog is provided. Default is False.

return_tablebool, optional

If True, return a table with many intermediate steps of the computation. Otherwise, a simple array with just the final tangential shear is returned. Default is False.

Returns:
gtnumpy.ndarray or astropy.table.Table

The tangential shear in each radial bin specified in the precomputation phase. If return_table is True, will return a table with detailed information for each radial bin. The final result is in the column gt.

Raises:
ValueError

If boost or random subtraction correction are requested but no random catalog is provided.