1 #include "purify/config.h"
2 #include "catch2/catch_all.hpp"
7 #include "purify/directories.h"
16 SECTION(
"horizon bound check for 2d transform") {
24 const t_real cell = 30;
25 const t_int imsize = 1024;
26 const t_real absolute_error = 1e-9;
28 const t_real oversample_ratio = 2;
32 const t_uint max_evaluations = 1e9;
33 const t_real relative_error = 0;
36 0, 0, 0, du, du, oversample_ratio, normu, normu, 1e9, 0, 1e-12,
integration::method::h, e)));
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 {
42 auto const ftkernelv = [=](
const t_real l) -> t_real {
48 t_real
const upsample = 2;
49 const t_int Ju_max = std::floor(Ju * upsample * 0.5);
51 for (
int j = 0; j < Ju_max; j++) {
52 t_uint evaluations = 0;
53 t_uint revaluations = 0;
55 const t_real
u = j / upsample;
58 u, 0, 0, du, du, oversample_ratio, ftkernelu, ftkernelu, max_evaluations, absolute_error,
61 u, 0, 0, du, oversample_ratio, ftkernelv, max_evaluations, absolute_error, absolute_error,
63 CHECK(kernel2d.real() ==
65 CHECK(kernel2d.imag() == Approx(0.).margin(1e-5));
66 CHECK(kernel1d.imag() == Approx(0.).margin(1e-5));
70 for (
int j = 0; j < Ju_max; j++) {
71 t_uint evaluations = 0;
72 t_uint revaluations = 0;
74 const t_real
u = j / upsample;
77 -
u, 0, 0, du, du, oversample_ratio, ftkernelu, ftkernelu, max_evaluations, absolute_error,
79 CHECK(kernel2d.real() ==
81 CHECK(kernel2d.imag() == Approx(0.).margin(1e-5));
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;
90 const t_real
u = j / upsample;
93 u, 0, w, du, du, oversample_ratio, ftkernelu, ftkernelu, max_evaluations, absolute_error,
96 u, 0, w, du, oversample_ratio, ftkernelv, max_evaluations, absolute_error, absolute_error,
99 u, 0, -w, du, du, oversample_ratio, ftkernelu, ftkernelu, max_evaluations, absolute_error,
102 u, 0, -w, du, oversample_ratio, ftkernelv, max_evaluations, absolute_error,
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));
110 SECTION(
"window function") {
111 for (
int j = 0; j < Ju_max; j++) {
112 t_uint evaluations = 0;
113 t_uint revaluations = 0;
115 const t_real
u = j / upsample;
118 u, 0, 0, du, du, oversample_ratio, [](t_real) {
return 1.; }, [](t_real) {
return 1.; },
121 u + 1e-4, 0, 0, du, oversample_ratio, [](t_real) {
return 1.; }, max_evaluations, 1e-5,
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);
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));
#define CHECK(CONDITION, ERROR)
const std::vector< t_real > u
data for u coordinate
const t_real pi
mathematical constant
t_real ft_kaiser_bessel(const t_real x, const t_real J)
Fourier transform of kaiser bessel kernel.
t_real kaiser_bessel(const t_real x, const t_real J)
Kaiser-Bessel kernel.
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_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
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
TEST_CASE("test transform kernels")