lenspack.image.filters module

lenspack.image.filters.aperture_mass(image, theta, filter='s98', method='fourier', border='constant')[source]

Filter an image (convergence map) using an aperture mass kernel.

Parameters
  • image (array_like) – 2D convergence map.

  • theta (float) – Aperture radial size in pixels.

  • filter ({'s98', 'vw98', 'jbj04', 'starlet'}) – Radial filter function. Default is ‘s98’.

  • method (str, optional) –

    Computation technique. Options are

    1. ’direct’ for angular-space convolution using scipy.ndimage.convolve with an approximate (truncated) kernel

    2. ’fourier’ for Fourier-space convolution using scipy.signal.fftconvolve

    3. ’brute’ for brute force pixel-by-pixel computation in direct space. Gives exactly the same result as (1) when ‘constant’ is used in convolve function.

    Default is ‘fourier’.

  • border (str, optional) – If method is ‘direct’, border determines how the border is treated via the scipy.ndimage.convolve option. Options are {‘reflect’, ‘constant’, ‘nearest’, ‘mirror’, ‘wrap’}. Defaults is ‘constant’ with zero-filling.

Returns

aperture_mass – Aperture mass map, i.e. a filtered version of image.

Return type

2D numpy array

Raises

ValueError – For invalid input options.

Notes

The different methods have vastly different computation times. Fourier-space convolution is by far the fastest and the only usable option for large images and large apertures. It gives very nearly the same results as direct-space convolution when the convolution border is ‘constant’ with zero-padding. The latter also gives the same result as the brute-force approach.

When using the starlet filter, the result is closest to the mr_transform (ISAP binary) output when the border is ‘constant’.

Examples

lenspack.image.filters.gen_apmass_kernel(theta, filter, size=None)[source]

Generate a convolution kernel for aperture mass filtering.

Parameters
  • theta (float) – Aperture radial size in pixels.

  • filter ({'s98', 'vw98', 'jbj04', 'starlet'}) – Radial filter function.

  • size (int, optional) – Side length N of the output (N, N) kernel matrix. If not given, the output shape is determined by the minimum radius at which the filter function becomes effectively negligible.

Returns

Aperture mass kernel matrix of shape (N, N). N is always odd when size is not specified.

Return type

2D numpy array

lenspack.image.filters.u_function(x, xs, filter, l=1)[source]

Aperture mass isotropic filter function U(theta).

Parameters
  • x (array_like) – Radial distances.

  • xs (float) – Scale radius.

  • filter (str) –

    Functional form - one of {‘s98’, ‘vw98’, ‘jbj04’, ‘starlet’} from the following references.

    • s98 : Schneider, van Waerbeke, Jain, Kruse (1998), MNRAS 296, 873

    • vw98 : Van Waerbeke (1998), A&A 334, 1

    • jbj04 : Jarvis, Bernstein, Jain (2004), MNRAS 352, 338

    • starlet : Leonard, Pires, Starck (2012), MNRAS 423, 3045

    See also Zhang, Pen, Zhang et al. (2003), ApJ 598, 818, and Schirmer et al. (2007), A&A 462, 875.

  • l (int, optional) – Parameter of the ‘s98’ filter. Default is 1.

Returns

Function value at each x.

Return type

numpy array

Notes

For the starlet, a factor of 1 / xs^2 was added to the normalization in order to give consistent results with mr_transform (ISAP binary).