dsigma.jackknife module

Module containing jackknife resampling functions.

dsigma.jackknife.compress_jackknife_fields(table)

Sum together all lenses in each jackknife field.

After assigning jackknife fields, for most applications, we do not need information on individual objects anymore. Compress the information in each jackknife field by taking weighted averages. The only exception is the weight column where the sum is taken.

Parameters
tableastropy.table.Table

Catalog containing objects. The catalog needs to have been assigned jackknife fields.

Returns
table_jkastropy.table.Table

Catalog containing the information for each jackknife field. It has exactly as many rows as there are jackknife fields.

dsigma.jackknife.compute_jackknife_fields(table, centers, distance_threshold=1, weights=None)

Compute the centers for jackknife regions using DBSCAN and KMeans.

The function first runs DBSCAN to identify continous fields of points. Afterwards, KMeans clustering is run. The initial cluster centers are random points from each continous field. The number of initial cluster centers per field is determined according to the total weight of each continous field. The centers are defined in cartesian coordinates on a unit sphere.

Parameters
tableastropy.table.Table

Catalog containing objects. The catalog needs to have coordinates and field IDs.

centersint or numpy.ndarray

If int, total number of jackknife fields. Otherwise, the centers returned from a previous call to that function. This allows for different samples to have the same jackknife fields.

distance_thresholdfloat, optional

The angular separation in degrees used to link points and calculate continous fields before running KMeans. Default is 1.

weightsNone or numpy.ndarray

Per-lens weights for clustering. If None, assume the same weight for all points. Default is None.

Returns
centersnumpy.ndarray

The coordinates of the centers of the jackknife regions.

dsigma.jackknife.jackknife_resampling(f, table_l, table_r=None, table_l_2=None, table_r_2=None, **kwargs)

Compute the covariance of a function from jackknife re-sampling.

Parameters
ffunction

Function that returns a result for which we want to have uncertainties. The function must take exactly one positional argument, the lens table. Additionally, it can have several additional keyword arguments.

table_lastropy.table.Table

Precompute results for the lenses. The catalog must have jackknife regions assigned to it.

table_roptional, astropy.table.Table, optional

Precompute results for random lenses. The input function must accept the random lens table via the table_r keyword argument. Default is None.

table_l_2optional, astropy.table.Table

Precompute results for a second set of lenses.The input function must accept the second lens table via the table_l_2 keyword argument. Default is None.

table_r_2optional, astropy.table.Table, optional

Precompute results for a second set of random lenses. The input function must accept the second random lens table via the table_r_2 keyword argument. Default is None.

kwargsdict, optional

Additional keyword arguments to be passed to the function.

Returns
covnumpy.ndarray

Covariance matrix of the result derived from jackknife re-sampling.

dsigma.jackknife.smooth_correlation_matrix(cor, sigma, exclude_diagonal=True)

Apply a simple gaussian filter on a correlation matrix.

Parameters
cornumpy.ndarray

Correlation matrix.

sigmaint

Scale of the gaussian filter.

exclude_diagonalboolean, optional

Whether to exclude the diagonal from the smoothing. That is what should be done generally because the diagonal is 1 by definition. Default is True.

Returns
cor_newnumpy.ndarray

Smoothed correlation matrix.