pyklip.kpp.metrics package


pyklip.kpp.metrics.crossCorr module

pyklip.kpp.metrics.crossCorr.calculate_cc(image, PSF, spectrum=None, nans2zero=False)[source]

Perform a cross correlation on the current loaded file.

  • image – image to get the cross correlation from.
  • PSF – Template for the cross correlation
  • spectrum – If not None, combine the 3D cube into a 2D image using a weighted mean with spectrum.
  • nans2zero – If True, temporarily replace all nans values with zeros for the cross correlation

Return: cross correlated image.

pyklip.kpp.metrics.matchedfilter module

pyklip.kpp.metrics.matchedfilter.calculate_matchedfilter(row_indices, col_indices, image, PSF, stamp_PSF_sky_mask, stamp_PSF_aper_mask, mute=True)[source]

Calculate the matched filter, cross correlation and flux map on a given image or datacube for the pixels targeted by row_indices and col_indices. These lists of indices can basically be given from the numpy.where function following the example:

import numpy as np row_indices,col_indices = np.where(np.finite(np.mean(cube,axis=0)))

By truncating the given lists in small pieces it is then easy to parallelized.

  • row_indices – Row indices list of the pixels where to calculate the metric in cube. Indices should be given from a 2d image.
  • col_indices – Column indices list of the pixels where to calculate the metric in cube. Indices should be given from a 2d image.
  • image – 2D or 3D image from which one wants the metric map. PSF_cube should be norm-2 normalized. PSF_cube /= np.sqrt(np.sum(PSF_cube**2))
  • PSF – 2D or 3D PSF template used for calculated the metric. If nl,ny_PSF,nx_PSF = PSF_cube.shape, nl is the number of wavelength samples, ny_PSF and nx_PSF are the spatial dimensions of the PSF_cube.
  • stamp_PSF_sky_mask – 2d mask of size (ny_PSF,nx_PSF) used to mask the central part of a stamp slice. It is used as a type of a high pass filter. Before calculating the metric value of a stamp cube around a given pixel the average value of the surroundings of each slice of that stamp cube will be removed. The pixel used for calculating the average are the one equal to one in the mask.
  • stamp_PSF_aper_mask – 3d mask for the aperture.
  • mute – If True prevent printed log outputs.

Return: Vector of length row_indices.size with the value of the metric for the corresponding pixels.


Convert f([1,2]) to f(1,2) call. It allows one to call calculate_shape3D_metric() with a tuple of parameters.

pyklip.kpp.metrics.matchedfilter.run_matchedfilter(image, PSF, N_threads=None, maskedge=True)[source]

Perform a matched filter on the current loaded file.

  • image – image for which to get the matched filter.
  • PSF – Template for the matched filter. It should include any kind of spectrum you which to use of the data is 3d.
  • maskedge – If True (default), mask the edges of the image to prevent partial projection of the PSF. If False, does not mask the edges.

Return: Processed images (matched filter,cross correlation,estimated flux).

Module contents