fpfs.imgutil#

fpfs.imgutil.convolve2gausspsf(img_data, psf_data, sigmaf, klim)[source]#

This function convolves an image to transform the PSF to a Gaussian

Parameters:
  • img_data (ndarray) – image data

  • psf_data (ndarray) – psf data

  • sigmaf (float) – sigma of Gaussian

  • klim (float) – radius for masking in Fourier space

Returns:

img_conv (ndarray) – the reconvolved image

fpfs.imgutil.cut_img(img, rcut)[source]#

Cuts img into postage stamp with width=2rcut

Parameters:
  • img (ndarray) – input image

  • rcut (int) – cutout radius

Returns:

out (ndarray) – image in a stamp

fpfs.imgutil.detlets2d(ngrid, sigma, klim)[source]#

Generates shapelets function in Fourier space, chi00 are normalized to 1. This function only supports square stamps: ny=nx=ngrid.

Parameters:
  • ngrid (int) – number of pixels in x and y direction

  • sigma (float) – scale of shapelets in Fourier space

  • klim (float) – upper limit of |k|

Returns:

psi (ndarray) – 2d detlets basis in shape of [8,3,ngrid,ngrid]

fpfs.imgutil.find_peaks(img_conv, img_conv_det, thres, thres2=0.0, bound=20.0)[source]#

Detects peaks and returns the coordinates (y,x) This function does the pre-selection in Li & Mandelbaum (2023)

Parameters:
  • img_conv (ndarray) – convolved image

  • img_conv_det (ndarray) – convolved image

  • thres (float) – detection threshold

  • thres2 (float) – peak identification difference threshold

  • bound (float) – minimum distance to the image boundary

Returns:

coord_array (ndarray) – ndarray of coordinates [y,x]

fpfs.imgutil.fit_noise_pf(ngrid, gal_pow, noise_mod, rlim)[source]#

Fit the noise power from observed galaxy power

Parameters:
  • ngrid (int) – number of pixels in x and y direction

  • gal_pow (ndarray) – galaxy Fourier power function

Returns:

out (ndarray) – noise power to be subtracted

fpfs.imgutil.fpfs_bases(ngrid, nord, sigma, sigma_det=None, klim=3.15)[source]#

Returns the FPFS bases (shapelets and detectlets)

Parameters:
  • ngrid (int) – stamp size

  • nnord (int) – the highest order of Shapelets radial components [default: 4]

  • sigma (float) – shapelet kernel scale in Fourier space

  • sigma_det (float) – detectlet kernel scale in Fourier space

  • klim (float) – upper limit of |k| [default 3.15]

fpfs.imgutil.get_fourier_pow_fft(input_data)[source]#

Gets Fourier power function

Parameters:

input_data (ndarray) – image array, centroid does not matter.

Returns:

out (ndarray) – Fourier Power

fpfs.imgutil.get_fourier_pow_rfft(input_data)[source]#

Gets Fourier power function

Parameters:

input_data (ndarray) – image array. The centroid does not matter.

Returns:

galpow (ndarray) – Fourier Power

fpfs.imgutil.get_klim(psf_array, sigma, thres=1e-20)[source]#

Gets klim, the region outside klim is supressed by the shaplet Gaussian kernel in FPFS shear estimation method; therefore we set values in this region to zeros

Parameters:
  • psf_array (ndarray) – PSF’s Fourier power or Fourier transform

  • sigma (float) – one sigma of Gaussian Fourier power

  • thres (float) – the threshold for a tuncation on Gaussian [default: 1e-20]

Returns:

klim (float) – the limit radius

fpfs.imgutil.get_pixel_detect_mask(sel, img, thres2)[source]#
fpfs.imgutil.pcaimages(xdata, nmodes)[source]#

Estimates the principal components of array list xdata

Parameters:
  • xdata (ndarray) – input data array

  • nmodes (int) – number of pcs to keep

Returns:
  • out (ndarray) – pc images,

  • stds (ndarray) – stds on the axis

  • coeffs (ndarray) – projection coefficient

fpfs.imgutil.shapelets2d(ngrid, nord, sigma, klim)[source]#

Generates complex shapelets function in Fourier space, chi00 are normalized to 1 [only support square stamps: ny=nx=ngrid]

Parameters:
  • ngrid (int) – number of pixels in x and y direction

  • nord (int) – radial order of the shaplets

  • sigma (float) – scale of shapelets in Fourier space

  • klim (float) – upper limit of |k|

Returns:

chi (ndarray) – 2d shapelet basis

fpfs.imgutil.shapelets2d_real(ngrid, nord, sigma, klim)[source]#

Generates real shapelets function in Fourier space, chi00 are normalized to 1 [only support square stamps: ny=nx=ngrid]

Parameters:
  • ngrid (int) – number of pixels in x and y direction

  • nord (int) – radial order of the shaplets

  • sigma (float) – scale of shapelets in Fourier space

  • klim (float) – upper limit of |k|

Returns:
  • chi_2 (ndarray) – 2d shapelet basis w/ shape [n,ngrid,ngrid]

  • name_s (list) – A list of shaplet names w/ shape [n]

fpfs.imgutil.truncate_circle(arr, rcut)[source]#
fpfs.imgutil.truncate_square(arr, rcut)[source]#