PURIFY
Next-generation radio interferometric imaging
Functions
wkernel.cc File Reference
#include "purify/config.h"
#include "catch2/catch_all.hpp"
#include "purify/logging.h"
#include "purify/types.h"
#include "purify/directories.h"
#include "purify/kernels.h"
#include "purify/wide_field_utilities.h"
#include "purify/wkernel_integration.h"
+ Include dependency graph for wkernel.cc:

Go to the source code of this file.

Functions

 TEST_CASE ("test transform kernels")
 
 TEST_CASE ("calculating zero")
 

Function Documentation

◆ TEST_CASE() [1/2]

TEST_CASE ( "calculating zero"  )

Definition at line 23 of file wkernel.cc.

23  {
24  const t_real cell = 30;
25  const t_int imsize = 1024;
26  const t_real absolute_error = 1e-9;
27  t_uint const J = 4;
28  const t_real oversample_ratio = 2;
29  const t_real du = widefield::pixel_to_lambda(cell, imsize, oversample_ratio);
30  auto const normu = [=](const t_real l) -> t_real { return kernels::ft_kaiser_bessel(l, J); };
31 
32  const t_uint max_evaluations = 1e9;
33  const t_real relative_error = 0;
34  t_uint e;
35  const t_real norm2d = std::sqrt(std::abs(projection_kernels::exact_w_projection_integration(
36  0, 0, 0, du, du, oversample_ratio, normu, normu, 1e9, 0, 1e-12, integration::method::h, e)));
37  const t_real norm1d = std::abs(projection_kernels::exact_w_projection_integration_1d(
38  0, 0, 0, du, oversample_ratio, normu, 1e9, 0, 1e-12, integration::method::h, e));
39  auto const ftkernelu = [=](const t_real l) -> t_real {
40  return kernels::ft_kaiser_bessel(l, J) / norm2d;
41  };
42  auto const ftkernelv = [=](const t_real l) -> t_real {
43  return kernels::ft_kaiser_bessel(l, J) / norm1d;
44  };
45  t_uint total = 0;
46  t_uint rtotal = 0;
47  t_int const Ju = J;
48  t_real const upsample = 2;
49  const t_int Ju_max = std::floor(Ju * upsample * 0.5);
50  SECTION("+u") {
51  for (int j = 0; j < Ju_max; j++) {
52  t_uint evaluations = 0;
53  t_uint revaluations = 0;
54  t_uint e;
55  const t_real u = j / upsample;
56  CAPTURE(u);
57  const t_complex kernel2d = projection_kernels::exact_w_projection_integration(
58  u, 0, 0, du, du, oversample_ratio, ftkernelu, ftkernelu, max_evaluations, absolute_error,
59  absolute_error, integration::method::h, evaluations);
61  u, 0, 0, du, oversample_ratio, ftkernelv, max_evaluations, absolute_error, absolute_error,
62  integration::method::h, evaluations);
63  CHECK(kernel2d.real() ==
64  Approx(kernels::kaiser_bessel(0, J) * kernels::kaiser_bessel(u, J)).margin(1e-4));
65  CHECK(kernel2d.imag() == Approx(0.).margin(1e-5));
66  CHECK(kernel1d.imag() == Approx(0.).margin(1e-5));
67  }
68  }
69  SECTION("-u") {
70  for (int j = 0; j < Ju_max; j++) {
71  t_uint evaluations = 0;
72  t_uint revaluations = 0;
73  t_uint e;
74  const t_real u = j / upsample;
75  CAPTURE(u);
76  const t_complex kernel2d = projection_kernels::exact_w_projection_integration(
77  -u, 0, 0, du, du, oversample_ratio, ftkernelu, ftkernelu, max_evaluations, absolute_error,
78  absolute_error, integration::method::h, evaluations);
79  CHECK(kernel2d.real() ==
80  Approx(kernels::kaiser_bessel(0, J) * kernels::kaiser_bessel(-u, J)).margin(1e-4));
81  CHECK(kernel2d.imag() == Approx(0.).margin(1e-5));
82  }
83  }
84  SECTION("+/-w relation") {
85  const t_real w = 100.;
86  for (int j = 0; j < Ju_max; j++) {
87  t_uint evaluations = 0;
88  t_uint revaluations = 0;
89  t_uint e;
90  const t_real u = j / upsample;
91  CAPTURE(u);
92  const t_complex kernel2d = projection_kernels::exact_w_projection_integration(
93  u, 0, w, du, du, oversample_ratio, ftkernelu, ftkernelu, max_evaluations, absolute_error,
94  absolute_error, integration::method::h, evaluations);
96  u, 0, w, du, oversample_ratio, ftkernelv, max_evaluations, absolute_error, absolute_error,
97  integration::method::h, evaluations);
98  const t_complex kernel2d_conj = projection_kernels::exact_w_projection_integration(
99  u, 0, -w, du, du, oversample_ratio, ftkernelu, ftkernelu, max_evaluations, absolute_error,
100  absolute_error, integration::method::h, evaluations);
101  const t_complex kernel1d_conj = projection_kernels::exact_w_projection_integration_1d(
102  u, 0, -w, du, oversample_ratio, ftkernelv, max_evaluations, absolute_error,
103  absolute_error, integration::method::h, evaluations);
104  CHECK(kernel2d.real() == Approx(kernel2d_conj.real()).margin(1e-4));
105  CHECK(kernel2d.imag() == Approx(-kernel2d_conj.imag()).margin(1e-4));
106  CHECK(kernel1d.real() == Approx(kernel1d_conj.real()).margin(1e-4));
107  CHECK(kernel1d.imag() == Approx(-kernel1d_conj.imag()).margin(1e-4));
108  }
109  }
110  SECTION("window function") {
111  for (int j = 0; j < Ju_max; j++) {
112  t_uint evaluations = 0;
113  t_uint revaluations = 0;
114  t_uint e;
115  const t_real u = j / upsample;
116  CAPTURE(u);
117  const t_complex kernel2d = projection_kernels::exact_w_projection_integration(
118  u, 0, 0, du, du, oversample_ratio, [](t_real) { return 1.; }, [](t_real) { return 1.; },
119  max_evaluations, 1e-5, 1e-5, integration::method::h, evaluations);
121  u + 1e-4, 0, 0, du, oversample_ratio, [](t_real) { return 1.; }, max_evaluations, 1e-5,
122  1e-5, integration::method::h, evaluations);
123  // analytical results from theory
124  const t_real expected2d = boost::math::sinc_pi(2 * constant::pi * u * 2. / oversample_ratio);
125  const t_real expected1d =
126  boost::math::cyl_bessel_j(1, 2 * constant::pi * (u + 1e-4) * 2. / oversample_ratio) /
127  ((u + 1e-4) * 2. / oversample_ratio);
128  CAPTURE(du);
129  CAPTURE(kernel2d / expected2d);
130  CAPTURE(kernel1d / expected1d);
131  CHECK(kernel2d.real() == Approx(expected2d).margin(1e-6));
132  CHECK(kernel2d.imag() == Approx(0).margin(1e-6));
133  CHECK(kernel1d.real() == Approx(expected1d).margin(1e-6));
134  CHECK(kernel1d.imag() == Approx(0).margin(1e-6));
135  }
136  }
137 }
#define CHECK(CONDITION, ERROR)
Definition: casa.cc:6
const std::vector< t_real > u
data for u coordinate
Definition: operators.cc:18
const t_real pi
mathematical constant
Definition: types.h:70
t_real ft_kaiser_bessel(const t_real x, const t_real J)
Fourier transform of kaiser bessel kernel.
Definition: kernels.cc:40
t_real kaiser_bessel(const t_real x, const t_real J)
Kaiser-Bessel kernel.
Definition: kernels.cc:7
t_complex exact_w_projection_integration_1d(const t_real u, const t_real v, const t_real w, const t_real du, const t_real oversample_ratio, const std::function< t_complex(t_real)> &ftkerneluv, const t_uint &max_evaluations, const t_real &absolute_error, const t_real &relative_error, const integration::method method, t_uint &evaluations)
t_complex exact_w_projection_integration(const t_real u, const t_real v, const t_real w, const t_real du, const t_real dv, const t_real oversample_ratio, const std::function< t_complex(t_real)> &ftkernelu, const std::function< t_complex(t_real)> &ftkernelv, const t_uint &max_evaluations, const t_real &absolute_error, const t_real &relative_error, const integration::method method, t_uint &evaluations)
numerical integration of chirp and kernel in image domain
t_real pixel_to_lambda(const t_real cell, const t_uint imsize, const t_real oversample_ratio)
return factors to convert between arcsecond pixel size image space and lambda for uv space

References CHECK, purify::projection_kernels::exact_w_projection_integration(), purify::projection_kernels::exact_w_projection_integration_1d(), purify::kernels::ft_kaiser_bessel(), purify::integration::h, purify::kernels::kaiser_bessel(), purify::constant::pi, purify::widefield::pixel_to_lambda(), and operators_test::u.

◆ TEST_CASE() [2/2]

TEST_CASE ( "test transform kernels"  )

Definition at line 15 of file wkernel.cc.

15  {
16  SECTION("horizon bound check for 2d transform") {
17  REQUIRE(projection_kernels::fourier_wproj_kernel(0, 0, 0, 0, 0, 1, 1).real() == Approx(1));
18  REQUIRE(std::abs(projection_kernels::fourier_wproj_kernel(2, 2, 0, 0, 0, 1, 1)) == Approx(0));
19  REQUIRE(std::abs(projection_kernels::fourier_wproj_kernel(0.4, 0, 0, 0, 0, 0.3, 0.3)) ==
20  Approx(0));
21  }
22 }
t_complex fourier_wproj_kernel(const t_real x, const t_real y, const t_real w, const t_real u, const t_real v, const t_real du, const t_real dv)
integration kernel for 2d fourier transform of chirp, bounded to a circle of radius x/du < 1

References purify::projection_kernels::fourier_wproj_kernel().