sp_validation.calibration

CALIBRATION.

Name:

calibration.py

Description:

This script contains methods for shear calibration.

Author:

Martin Kilbinger

get_calibrated_quantities(gal_metacal, shape_method='ngmix')[source]

Get Calibrated Quantities.

Return catalogue quantities for objects calibrated for multiplicative bias.

Parameters:
  • gal_metacal (dict) – galaxy metacalibration catalogue

  • shape_method (string, optional, default='ngmix') – shape measurement method, one in ‘ngmix’, ‘galsim’

Returns:

  • g_corr (array(2, ngal) of float) – shear estimates calibrated for multiplicative bias

  • g_uncorr (array(2, ngal) of float) – uncalibrated shear estimates

  • w (array of float) – weights

  • mask (array of bool) – mask to indicate valid objects in “no-shear” sample

get_calibrated_m_c(gal_metacal, shape_method='ngmix')[source]

Get Calibrated C.

Return catalogue quantities for objects calibrated for multiplicative and additive bias.

Parameters:
  • gal_metacal (dict) – galaxy metacalibration catalogue

  • shape_method (string, optional, default='ngmix') – shape measurement method, one in ‘ngmix’, ‘galsim’

Returns:

  • numpy.ndarray – shear estimates calibrated for multiplicative and additive bias; array(2, ngal) of float

  • numpy.ndarray – uncalibrated shear estimates; array(2, ngal) of float

  • numpy.ndarray – weights; array of float

  • numpy.ndarray – mask to indicate valid objects in “no-shear” sample; array of bool

  • numpy.ndarray – additive bias for both components;

  • numpy.ndarray – error on the additive bias for both components

create_bins(x, num_bins, type='log', x_min=None, x_max=None)[source]

Create Bins. Create bins for a given array. The bins are logarithmic by default.

Parameters:
  • x (array) – Array to bin

  • num_bins (int) – Number of bins

  • type (str, optional) – Type of binning. Options are ‘log’ (defaults)

  • x_min (float, optional) – Minimum value of the bins. If None, the minimum value of x is used.

  • x_max (float, optional) – Maximum value of the bins. If None, the maximum value of x is used.

cut_to_bins(df, key, num_bins, type='log', x_min=None, x_max=None)[source]

Cut To Bins.

Cut a given array into bins. Create a new column in the DataFrame with the binning.

Parameters:
  • df (pandas.DataFrame) – DataFrame to cut

  • key (str) – Key to cut

  • num_bins (int) – Number of bins

  • type (str, optional) – Type of binning. Options are ‘log’ (default)

  • x_min (float, optional) – Minimum value of the bins. If None, the minimum value of x is used.

  • x_max (float, optional) – Maximum value of the bins. If None, the maximum value of x is used.

Returns:

bin edges

Return type:

numpy.ndarray

fill_cat_gal(cat_gal, dat, g_uncorr, gal_metacal, mask1, mask2, purpose='weights')[source]
build_df(cat_gal)[source]

Build DF.

Build pandas dataframe.

Parameters:

cat_gal (dict) – input data

Returns:

collected data

Return type:

pd.DataFrame

get_w_des(cat_gal, num_bins, snr_min=None, snr_max=None, size_ratio_min=None, size_ratio_max=None)[source]

Get DES weights. (Gatti et al. 2021) Return an array of DES weights obtained by binning in SNR and size and computing the ratio between the shear response and the shape noise.

Parameters:
  • cat_gal (dict) – A catalog of galaxies containing the response matrix and the uncalibrated ellipticities

  • num_bins (int) – Number of bins to use for the binning of the SNR and size.

  • snr_min (float, optional) – Minimum SNR, default (None): determined by the data

  • snr_max (float, optional) – Maximum SNR, default (None): determined by the data

  • size_ratio_min (float, optional) – Minimum size ratio, default (None): determined by the data

  • size_ratio_max (float, optional) – Maximum size ratio, default (None): determined by the data

Returns:

w – DES weights

Return type:

array of float

get_alpha_leakage_per_object(cat_gal, num_bins, weight_type='des')[source]

Compute the leakage per object (Li et al. 2024) Return an array of leakage coefficients obtained by binning in SNR and size.

Parameters:
  • cat_gal (dict) – A catalog of galaxies containing galaxy ellipticity, PSF ellipticity, SNR and size of the galaxy and the PSF.

  • num_bins (int) – Number of bins

Returns:

  • alpha_1 (np.array) – Array containing the correction coefficient for the PSF leakage per object for the first component.

  • alpha_2 (np.array) – Array containing the correction coefficient for the PSF leakage per object for the second component.

get_quantities_binned(cat_gal, num_bins_x, num_bins_y=None, which=['response', 'number', 'leakage'], verbose=True)[source]
get_calibrate_e_from_cat(path_cat_gal, weight_type='des', verbose=False)[source]

Calibrates ellipticities from a galaxy catalog with a certain weight type.

Parameters:
  • path_cat_gal (str) – Path to the galaxy catalog

  • weight_type (str, optional, default='des') – Type of weight to use. Options are ‘des’ (DES weight) or ‘iv’ (inverse variance)

  • verbose (bool, optional, default=False) – If True, print intermediate results

Returns:

g_cal – Calibrated ellipticities

Return type:

np.array

get_calibrate_no_leakage_e_from_cat(path_cat_gal, weight_type='des', verbose=False)[source]

Calibrate ellipticities and removes leakage from a galaxy catalog with a certain weight type.

Parameters:
  • path_cat_gal (str) – Path to the galaxy catalog

  • weight_type (str, optional, default='des') – Type of weight to use. Options are ‘des’ (DES weight) or ‘iv’ (inverse variance)

  • verbose (bool, optional, default=False) – If True, print intermediate results

Returns:

  • e1_noleak (np.array) – Calibrated ellipticities without leakage for the first component

  • e2_noleak (np.array) – Calibrated ellipticities without leakage for the second component