redshift_tools package

Submodules

redshift_tools.base module

redshift_tools.base.lensing_kernel(nz, nz_tot=None, cosmo=None)[source]

Compute the lensing kernel for a given redshift distribution.

Parameters:
  • nz – list of redshift distributions

  • nz_tot – total redshift distribution

  • cosmo – PyCosmo cosmology instance

Returns:

list of lensing kernels for each redshift distribution and total lensing kernel

redshift_tools.base.load_bins(path)[source]

Load the redshift bins from a given path.

Parameters:

path – path to the redshift bins

Returns:

list of redshift bins and total redshift distribution

redshift_tools.catalog module

redshift_tools.catalog.find_bin_thresholds(x, n_bins=4, lower_cut=None, upper_cut=None)[source]

Find the bin threshold when splitting the data into equally populated bins. Lower and upper cuts can be defined which are then used as an additional bin between -inf and lower cut and upper cut and inf. This can e.g. be used to have a bin which you exclude from the analysis.

Parameters:
  • x – data to bin

  • n_bins – number of bins

  • lower_cut – lower cut

  • upper_cut – upper cut

Returns:

bin thresholds

redshift_tools.create module

redshift_tools.create.create_bins(n_bins, sigma_z, max_z=5, min_z=0, num_z=1000, redshift_dep=False, z_t=None, normalize_bins=True, distribution='smail', **distribution_parameters)[source]

Creates redshift bins following an overall Smail-type distribution

Parameters:
  • bins – number of bins

  • sigma_z – array with the photometric_scatter per bin

  • max_z – maximum redshift

  • min_z – minimum redshift

  • num_z – size of the returned redshift array

  • redshift_dep – boolean if the photometric scatter has a redshift dependence sigma_z*(1+z)

  • z_t – thresholds for the different bins. If None, the thresholds are computed

  • normalize_bins – If returned bins should be normalized

  • distribution – type of the overall redshift distribution, options are “smail” or “fu”

  • distribution_parameters – paramters that specify the Smail-type or Fu-type distribution

Return nz:

list with num_zx2 arrays with redshift on [:,0] and n(z) on [:,1]

Raises:

ValueError – if distribution is not “smail” or “fu”

redshift_tools.create.find_z_threshold(distribution, n_bins, z_max=5, num_z=10000, **dist_params)[source]

find redshift thresholds given the overall redshift distribution to split the redshift distribution in equally populated bins

Parameters:
  • distribution – function of redshift for the overall redshift distribution

  • n_bins – number of bins in which the overall redshift distribution is cut

  • z_max – maximum redshift

  • num_z – number of points used for the interpolation

  • dist_params – parameters of the distribution

Returns:

list with the threshold values starting including start value (0) and final value (z_max)

redshift_tools.create.fixed_width_convolution(n, z, sigma)[source]

Convolve a redshift distribution with a Gaussian kernel with no redshift dependence.

Parameters:
  • n – redshift distribution

  • z – redshift array

  • sigma – width of the Gaussian kernel

Returns:

convolved redshift distribution

redshift_tools.create.fu(z, a=0.612, b=8.125, c=0.62, A=None)[source]

Fu-type function for the overall redshift distribution. (z**a + a**(a*b)) / (z**b + c) * A Default values are taken from Fu et al. arXiv:0712.0884

Parameters:
  • z – redshift

  • a – parameter of the Fu-type distribution

  • b – parameter of the Fu-type distribution

  • c – parameter of the Fu-type distribution

  • A – normalization of the Fu-type distribution

Returns:

Fu-type redshift distribution

redshift_tools.create.normalize(y, x)[source]

Normalize a function to 1

Parameters:
  • y – function values

  • x – x values

Returns:

normalized function

redshift_tools.create.save_bins(nz, path, nz_tot=None)[source]

Saves redshift bins separetely in .txt files

Parameters:
  • nz – list of redshift bins with z and n(z)

  • path – path where to save the file

redshift_tools.create.smail(z, alpha=2.0, beta=2.0, z0=1.13, normalization=1)[source]

Smail-type function for the overall redshift distribution z**alpha * np.exp( -(z/z0)**beta) * normalization

Parameters:
  • z – redshift

  • alpha – parameter of the Smail-type distribution

  • beta – parameter of the Smail-type distribution

  • z0 – parameter of the Smail-type distribution

  • normalization – normalization of the Smail-type distribution

Returns:

Smail-type redshift distribution

redshift_tools.create.z_dep_width_convolution(n, z, sigma)[source]

Convolve a redshift distribution with a Gaussian kernel with a redshift dependent width.

Parameters:
  • n – redshift distribution

  • z – redshift array

  • sigma – width of the Gaussian kernel

Returns:

convolved redshift distribution

redshift_tools.manipulate module

redshift_tools.manipulate.compute_n_tot(nz)[source]

Compute the total redshift distribution from a set of redshift distributions.

Parameters:

nz – list of redshift distributions

Returns:

total redshift distribution

redshift_tools.manipulate.normalize_bins(nz)[source]

Normalize a set of redshift distributions.

Parameters:

nz – list of redshift distributions

Returns:

list of normalized redshift distributions

redshift_tools.manipulate.overlap(bin1, bin2)[source]

Compute the overlap between two redshift distributions.

Parameters:
  • bin1 – first redshift distribution

  • bin2 – second redshift distribution

Returns:

overlap

redshift_tools.manipulate.overlap_all_bins(nz)[source]

Compute the overlap between all redshift distributions.

Parameters:

nz – list of redshift distributions

Returns:

overlap matrix

redshift_tools.manipulate.resample(xp, x, y, interp_kind='linear')[source]

Resample a distribution with a given set of bins.

Parameters:
  • xp – new bins

  • x – old bins

  • y – old distribution

  • interp_kind – interpolation method

Returns:

resampled distribution

redshift_tools.manipulate.shift(nz_fid, delta_z)[source]

Shift a set of redshift distributions by a given set of shift factors.

Parameters:
  • nz_fid – list of redshift distributions

  • delta_z – list of shift factors

Returns:

list of shifted redshift distributions

redshift_tools.manipulate.shift_and_stretch(nz, z_bias, z_sigma, normalize=True)[source]

Shift and stretch a set of redshift distributions.

Parameters:
  • nz – list of redshift distributions

  • z_bias – list of shift factors

  • z_sigma – list of stretch factors

Returns:

list of shifted and stretched redshift distributions

redshift_tools.manipulate.stretch(NZ, sigma_z, normalize=True)[source]

Stretch a set of redshift distributions by a given set of stretch factors.

Parameters:
  • NZ – list of redshift distributions

  • sigma_z – list of stretch factors

  • normalize – normalize the stretched distributions

Returns:

list of stretched redshift distributions

redshift_tools.manipulate.stretch_bin(z, nz, s)[source]

Stretch a redshift distribution by a given factor.

Parameters:
  • z – redshift array

  • nz – redshift distribution n(z)

  • s – stretch factor

Returns:

stretched redshift distribution n_s(z)

redshift_tools.plot module

redshift_tools.plot.get_max_number_of_bins(nz)[source]

Get the maximum number of bins.

Parameters:

nz – list of redshift distributions

Returns:

maximum number of bins

redshift_tools.plot.plot_bins(nz, nz_tot=None, nz_is_path=False, colors=['#0063B9', '#BA1A13', '#34BA09', '#ED6018', '#6E13BA', '#6E2C0B', '#808080', '#BA13A0', '#B0BA13', '#09BAAF', '#1994FF', '#FF3D33', '#5CFF26', '#FFA547', '#A333FF', '#FFA541', '#BEBEBE', '#FF33E0', '#F1FF33', '#33FFE7'], linestyle=['-', ':', '--', '-.'], figsize=(6, 3), subplots_args={}, plot_args={})[source]

Plot the redshift bins.

Parameters:
  • nz – list of redshift distributions

  • nz_tot – total redshift distribution

  • nz_is_path – if True, the redshift distributions are loaded from the given paths

  • colors – list of colors

  • linestyle – list of linestyles

  • figsize – figure size

  • subplots_args – arguments for the subplots (dict)

  • plot_args – arguments for the plot (dict)

redshift_tools.plot.plot_bins_2panels(nz_up, nz_down, nz_tot_up=None, nz_tot_down=None, nz_up_is_path=False, nz_down_is_path=False, y_labels=['$n(z)$', '$g(z)$'], colors=['#0063B9', '#BA1A13', '#34BA09', '#ED6018', '#6E13BA', '#6E2C0B', '#808080', '#BA13A0', '#B0BA13', '#09BAAF', '#1994FF', '#FF3D33', '#5CFF26', '#FFA547', '#A333FF', '#FFA541', '#BEBEBE', '#FF33E0', '#F1FF33', '#33FFE7'], linestyle=['-', ':', '--', '-.'], figsize=(6, 3))[source]

Plot the redshift bins in two panels.

Parameters:
  • nz_up – list of redshift distributions for the upper panel

  • nz_down – list of redshift distributions for the lower panel

  • nz_tot_up – total redshift distribution for the upper panel

  • nz_tot_down – total redshift distribution for the lower panel

  • nz_up_is_path – if True, the redshift distributions are loaded from the given paths

  • nz_down_is_path – if True, the redshift distributions are loaded from the given paths

  • y_labels – list of y labels

  • colors – list of colors for the different bins of the redshift distributions

  • linestyle – list of linestyles for the different bins of the redshift distributions

  • figsize – figure size

Module contents