dsigma.jackknife module¶
Module containing jackknife resampling functions.
- dsigma.jackknife.compress_jackknife_fields(table)[source]¶
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:
- table
astropy.table.Table Catalog containing objects. The catalog needs to have been assigned jackknife fields.
- table
- Returns:
- table_jk
astropy.table.Table Catalog containing the information for each jackknife field. It has exactly as many rows as there are jackknife fields.
- table_jk
- dsigma.jackknife.compute_jackknife_fields(table, centers, distance_threshold=1, weights=None, seed=None)[source]¶
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:
- table
astropy.table.Table Catalog containing objects. The catalog needs to have coordinates and field IDs. The jackknife field for each galaxy will be added in the field_jk column.
- centers
intornumpy.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_threshold
float,optional The angular separation in degrees used to link points and calculate continous fields before running KMeans. Default is 1.
- weights
Noneornumpy.ndarray,optional Per-lens weights for clustering. If None, assume the same weight for all points. Default is None.
- seed
intorNone,optional Random seed to iniatialize the random number generator.
- table
- Returns:
- centers
numpy.ndarray The coordinates of the centers of the jackknife regions.
- centers
- dsigma.jackknife.jackknife_resampling(f, table_l, table_r=None, table_l_2=None, table_r_2=None, **kwargs)[source]¶
Compute the covariance of a function from jackknife re-sampling.
- Parameters:
- f
function 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_l
astropy.table.Table Precompute results for the lenses. The catalog must have jackknife regions assigned to it.
- table_r
optional,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_2
optional,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_2
optional,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.
- kwargs
dict,optional Additional keyword arguments to be passed to the function.
- f
- Returns:
- cov
numpy.ndarray Covariance matrix of the result derived from jackknife re-sampling.
- cov
- dsigma.jackknife.smooth_correlation_matrix(cor, sigma, exclude_diagonal=True)[source]¶
Apply a simple gaussian filter on a correlation matrix.
- Parameters:
- cor
numpy.ndarray Correlation matrix.
- sigma
int Scale of the gaussian filter.
- exclude_diagonalbool,
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.
- cor
- Returns:
- cor_new
numpy.ndarray Smoothed correlation matrix.
- cor_new