PURIFY
Next-generation radio interferometric imaging
Enumerations | Functions | Variables
purify::kernels Namespace Reference

Enumerations

enum class  kernel {
  kb , gauss , box , pswf ,
  kbmin , gauss_alt , kb_presample
}
 

Functions

t_real kaiser_bessel (const t_real x, const t_real J)
 Kaiser-Bessel kernel. More...
 
t_real kaiser_bessel_general (const t_real x, const t_real J, const t_real alpha)
 More general Kaiser-Bessel kernel. More...
 
t_real ft_kaiser_bessel_general (const t_real x, const t_real J, const t_real alpha)
 Fourier transform of more general Kaiser-Bessel kernel. More...
 
t_real ft_kaiser_bessel (const t_real x, const t_real J)
 Fourier transform of kaiser bessel kernel. More...
 
t_real gaussian (const t_real x, const t_real J)
 Gaussian kernel. More...
 
t_real ft_gaussian (const t_real x, const t_real J)
 Fourier transform of Gaussian kernel. More...
 
t_real calc_for_pswf (const t_real x, const t_real J, const t_real alpha)
 Calculates Horner's Rule the standard PSWF for radio astronomy, with a support of J = 6 and alpha = 1. More...
 
t_real pswf (const t_real x, const t_real J)
 PSWF kernel. More...
 
t_real ft_pswf (const t_real x, const t_real J)
 Fourier transform of PSWF kernel. More...
 
std::vector< t_real > kernel_samples (const t_int total_samples, const std::function< t_real(t_real)> kernelu)
 Calculates samples of a kernel. More...
 
t_real kernel_zero_interp (const std::vector< t_real > &samples, const t_real x, const t_real J)
 zeroth order interpolates from samples of kernel More...
 
t_real kernel_linear_interp (const Vector< t_real > &samples, const t_real x, const t_real J)
 linearly interpolates from samples of kernel More...
 
t_real pill_box (const t_real x, const t_real J)
 Box car function for kernel. More...
 
t_real ft_pill_box (const t_real x, const t_real J)
 Fourier transform of box car function, a Sinc function. More...
 
t_real gaussian_general (const t_real x, const t_real J, const t_real sigma)
 Fourier transform of general Gaussian kernel. More...
 
t_real ft_gaussian_general (const t_real x, const t_real J, const t_real sigma)
 Fourier transform of general Gaussian kernel. More...
 

Variables

const std::map< std::string, kernelkernel_from_string
 

Enumeration Type Documentation

◆ kernel

Enumerator
kb 
gauss 
box 
pswf 
kbmin 
gauss_alt 
kb_presample 

Definition at line 15 of file kernels.h.

Function Documentation

◆ calc_for_pswf()

t_real purify::kernels::calc_for_pswf ( const t_real  x,
const t_real  J,
const t_real  alpha 
)

Calculates Horner's Rule the standard PSWF for radio astronomy, with a support of J = 6 and alpha = 1.

Parameters
[in]eta0value to evaluate
[in]Jsupport size of gridding kernel
[in]alphatype of special PSWF to calculate

The tailored prolate spheroidal wave functions for gridding radio astronomy. Details are explained in Optimal Gridding of Visibility Data in Radio Astronomy, F. R. Schwab 1983.

Definition at line 71 of file kernels.cc.

71  {
72  // polynomial coefficients for prolate spheriodal wave function rational approximation
73  const std::array<t_real, 6> p1 = {
74  {8.203343e-2, -3.644705e-1, 6.278660e-1, -5.335581e-1, 2.312756e-1, 2 * 0.0}};
75  const std::array<t_real, 6> p2 = {
76  {4.028559e-3, -3.697768e-2, 1.021332e-1, -1.201436e-1, 6.412774e-2, 2 * 0.0}};
77  const std::array<t_real, 3> q1 = {{1., 8.212018e-1, 2.078043e-1}};
78  const std::array<t_real, 3> q2 = {{1., 9.599102e-1, 2.918724e-1}};
79 
80  if (J != 6 or alpha != 1) {
81  return 0;
82  }
83  // Calculating numerator and denominator using Horner's rule.
84  // PSWF = numerator / denominator
85 
86  auto fraction = [](t_real eta, std::array<t_real, 6> const &p, std::array<t_real, 3> const &q) {
87  auto const p_size = sizeof(p) / sizeof(p[0]) - 1;
88  auto const q_size = sizeof(q) / sizeof(q[0]) - 1;
89 
90  auto numerator = p[p_size];
91  for (auto i = decltype(p_size){1}; i <= p_size; ++i)
92  numerator = eta * numerator + p[p_size - i];
93 
94  auto denominator = q[q_size];
95  for (auto i = decltype(q_size){1}; i <= q_size; ++i)
96  denominator = eta * denominator + q[q_size - i];
97 
98  return numerator / denominator;
99  };
100  if (0 <= std::abs(eta0) and std::abs(eta0) <= 0.75)
101  return fraction(eta0 * eta0 - 0.75 * 0.75, p1, q1);
102  if (0.75 < std::abs(eta0) and std::abs(eta0) <= 1) return fraction(eta0 * eta0 - 1 * 1, p2, q2);
103 
104  return 0;
105 }

Referenced by ft_pswf(), and pswf().

◆ ft_gaussian()

t_real purify::kernels::ft_gaussian ( const t_real  x,
const t_real  J 
)

Fourier transform of Gaussian kernel.

Definition at line 60 of file kernels.cc.

60  {
61  /*
62  Fourier transform of guassian gridding kernel
63 
64  x:: value to evaluate
65  J:: support size of gridding kernel
66  */
67  t_real sigma = 0.31 * std::pow(J, 0.52);
68  return ft_gaussian_general(x, J, sigma);
69 }
t_real ft_gaussian_general(const t_real x, const t_real J, const t_real sigma)
Fourier transform of general Gaussian kernel.
Definition: kernels.cc:233

References ft_gaussian_general().

Referenced by purify::create_kernels(), and purify::create_radial_ftkernel().

◆ ft_gaussian_general()

t_real purify::kernels::ft_gaussian_general ( const t_real  x,
const t_real  J,
const t_real  sigma 
)

Fourier transform of general Gaussian kernel.

Definition at line 233 of file kernels.cc.

233  {
234  /*
235  Fourier transform of Gaussian gridding kernel
236 
237  x:: value to evaluate
238  J:: support size of gridding kernel
239  sigma:: standard deviation of Gaussian kernel (in pixels)
240  */
241 
242  t_real a = x * sigma;
243  return std::exp(a * a * 2);
244 }

Referenced by purify::create_kernels(), and ft_gaussian().

◆ ft_kaiser_bessel()

t_real purify::kernels::ft_kaiser_bessel ( const t_real  x,
const t_real  J 
)

Fourier transform of kaiser bessel kernel.

Definition at line 40 of file kernels.cc.

40  {
41  /*
42  Fourier transform of kaiser bessel gridding kernel
43  */
44 
45  t_real alpha = 2.34 * J; // value said to be optimal in Fessler et. al. 2003
46  return ft_kaiser_bessel_general(x, J, alpha);
47 }
t_real ft_kaiser_bessel_general(const t_real x, const t_real J, const t_real alpha)
Fourier transform of more general Kaiser-Bessel kernel.
Definition: kernels.cc:25

References ft_kaiser_bessel_general().

Referenced by purify::create_kernels(), purify::create_radial_ftkernel(), main(), and TEST_CASE().

◆ ft_kaiser_bessel_general()

t_real purify::kernels::ft_kaiser_bessel_general ( const t_real  x,
const t_real  J,
const t_real  alpha 
)

Fourier transform of more general Kaiser-Bessel kernel.

Definition at line 25 of file kernels.cc.

25  {
26  /*
27  Fourier transform of kaiser bessel gridding kernel
28  */
29 
30  t_complex eta = std::sqrt(
31  static_cast<t_complex>((constant::pi * x * J) * (constant::pi * x * J) - alpha * alpha));
32  const t_real normalisation = J / boost::math::cyl_bessel_i(0, alpha);
33 
34  return std::real(std::sin(eta) / eta) *
35  normalisation; // simple way of doing the calculation, the
36  // boost bessel funtions do not support
37  // complex valued arguments
38 }
const t_real pi
mathematical constant
Definition: types.h:70

References purify::constant::pi.

Referenced by purify::create_kernels(), purify::create_radial_ftkernel(), and ft_kaiser_bessel().

◆ ft_pill_box()

t_real purify::kernels::ft_pill_box ( const t_real  x,
const t_real  J 
)

Fourier transform of box car function, a Sinc function.

Definition at line 211 of file kernels.cc.

211  {
212  /*
213  Gaussian gridding kernel
214 
215  x:: value to evaluate
216  J:: support size
217  */
218  return boost::math::sinc_pi(J * x * constant::pi);
219 }

References purify::constant::pi.

Referenced by purify::create_kernels(), and purify::create_radial_ftkernel().

◆ ft_pswf()

t_real purify::kernels::ft_pswf ( const t_real  x,
const t_real  J 
)

Fourier transform of PSWF kernel.

Definition at line 124 of file kernels.cc.

124  {
125  /*
126  Calculates the fourier transform of the standard PSWF for radio astronomy, with a support of J
127  = 6 and alpha = 1.
128 
129  x:: value to evaluate
130  J:: support size of gridding kernel
131 
132  The tailored prolate spheroidal wave functions for gridding radio astronomy.
133  Details are explained in Optimal Gridding of Visibility Data in Radio
134  Astronomy, F. R. Schwab 1983.
135 
136 */
137 
138  const t_real alpha = 1;
139  const t_real eta0 = 2 * x;
140 
141  return calc_for_pswf(eta0, J, alpha) * std::sqrt(5.343);
142 }
t_real calc_for_pswf(const t_real eta0, const t_real J, const t_real alpha)
Calculates Horner's Rule the standard PSWF for radio astronomy, with a support of J = 6 and alpha = 1...
Definition: kernels.cc:71

References calc_for_pswf().

Referenced by purify::create_kernels(), and purify::create_radial_ftkernel().

◆ gaussian()

t_real purify::kernels::gaussian ( const t_real  x,
const t_real  J 
)

Gaussian kernel.

Definition at line 49 of file kernels.cc.

49  {
50  /*
51  Guassian gridding kernel
52 
53  x:: value to evaluate
54  J:: support size
55  */
56  t_real sigma = 0.31 * std::pow(J, 0.52); // Optimal sigma according to fessler et al.
57  return gaussian_general(x, J, sigma);
58 }
t_real gaussian_general(const t_real x, const t_real J, const t_real sigma)
Fourier transform of general Gaussian kernel.
Definition: kernels.cc:220

References gaussian_general().

Referenced by purify::create_kernels(), and purify::create_radial_ftkernel().

◆ gaussian_general()

t_real purify::kernels::gaussian_general ( const t_real  x,
const t_real  J,
const t_real  sigma 
)

Fourier transform of general Gaussian kernel.

Definition at line 220 of file kernels.cc.

220  {
221  /*
222  Gaussian gridding kernel
223 
224  x:: value to evaluate
225  J:: support size
226  sigma:: standard deviation of Gaussian kernel (in pixels)
227  */
228 
229  t_real a = x / sigma;
230  return std::exp(-a * a * 0.5) / (sigma * std::sqrt(2 * constant::pi));
231 }

References purify::constant::pi.

Referenced by purify::create_kernels(), and gaussian().

◆ kaiser_bessel()

t_real purify::kernels::kaiser_bessel ( const t_real  x,
const t_real  J 
)

Kaiser-Bessel kernel.

Definition at line 7 of file kernels.cc.

7  {
8  /*
9  kaiser bessel gridding kernel
10  */
11  t_real alpha = 2.34 * J; // value said to be optimal in Fessler et. al. 2003
12  return kaiser_bessel_general(x, J, alpha);
13 }
t_real kaiser_bessel_general(const t_real x, const t_real J, const t_real alpha)
More general Kaiser-Bessel kernel.
Definition: kernels.cc:15

References kaiser_bessel_general().

Referenced by purify::create_kernels(), purify::create_radial_ftkernel(), and TEST_CASE().

◆ kaiser_bessel_general()

t_real purify::kernels::kaiser_bessel_general ( const t_real  x,
const t_real  J,
const t_real  alpha 
)

More general Kaiser-Bessel kernel.

Definition at line 15 of file kernels.cc.

15  {
16  /*
17  kaiser bessel gridding kernel
18  */
19  if (2 * x > J) return 0;
20  t_real a = 2 * x / J;
21  return boost::math::cyl_bessel_i(0, std::real(alpha * std::sqrt(1 - a * a))) /
22  boost::math::cyl_bessel_i(0, alpha);
23 }

Referenced by purify::create_kernels(), purify::create_radial_ftkernel(), and kaiser_bessel().

◆ kernel_linear_interp()

t_real purify::kernels::kernel_linear_interp ( const Vector< t_real > &  samples,
const t_real  x,
const t_real  J 
)

linearly interpolates from samples of kernel

Definition at line 171 of file kernels.cc.

171  {
172  /*
173  Calculates kernel using linear interpolation between pre-calculated samples. (see Rapid
174  gridding reconstruction with a minimal oversampling ratio, Beatty et. al. 2005)
175  */
176  t_int total_samples = samples.size();
177 
178  t_real i_effective = (x + J / 2) * total_samples / J;
179 
180  t_int i_0 = floor(i_effective);
181  t_int i_1 = ceil(i_effective);
182  // case where i_effective is a sample point
183  if (std::abs(i_0 - i_1) == 0) {
184  return samples(i_0);
185  }
186  // linearly interpolate from nearest neighbour
187  t_real y_0;
188  t_real y_1;
189  if (i_0 < 0 or i_0 >= total_samples) {
190  y_0 = 0;
191  } else {
192  y_0 = samples(i_0);
193  }
194  if (i_1 < 0 or i_1 >= total_samples) {
195  y_1 = 0;
196  } else {
197  y_1 = samples(i_1);
198  }
199  t_real output = y_0 + (y_1 - y_0) / (i_1 - i_0) * (i_effective - i_0);
200  return output;
201 }

◆ kernel_samples()

std::vector< t_real > purify::kernels::kernel_samples ( const t_int  total_samples,
const std::function< t_real(t_real)>  kernelu 
)

Calculates samples of a kernel.

Definition at line 144 of file kernels.cc.

145  {
146  /*
147  Pre-calculates samples of a kernel, that can be used with linear interpolation (see Rapid
148  gridding reconstruction with a minimal oversampling ratio, Beatty et. al. 2005)
149  */
150  std::vector<t_real> samples(total_samples);
151  for (Vector<t_real>::Index i = 0; i < static_cast<t_int>(total_samples); ++i) {
152  samples[i] = kernelu(static_cast<t_real>(i) / total_samples);
153  }
154  return samples;
155 }

Referenced by purify::create_kernels(), and purify::operators::init_on_the_fly_gridding_matrix_2d().

◆ kernel_zero_interp()

t_real purify::kernels::kernel_zero_interp ( const std::vector< t_real > &  samples,
const t_real  x,
const t_real  J 
)

zeroth order interpolates from samples of kernel

Definition at line 156 of file kernels.cc.

156  {
157  /*
158  Calculates kernel using linear interpolation between pre-calculated samples. (see Rapid
159  gridding reconstruction with a minimal oversampling ratio, Beatty et. al. 2005)
160  */
161  const t_int total_samples = samples.size();
162 
163  const t_real i_effective = 2 * std::abs(x) * total_samples / J;
164 
165  const t_real i_0 = std::floor(i_effective);
166  if (i_0 < 0 or i_0 >= total_samples) return 0.;
167 
168  return samples[static_cast<t_int>(i_0)];
169 }

Referenced by purify::create_kernels().

◆ pill_box()

t_real purify::kernels::pill_box ( const t_real  x,
const t_real  J 
)

Box car function for kernel.

Definition at line 202 of file kernels.cc.

202  {
203  /*
204  Gaussian gridding kernel
205 
206  x:: value to evaluate
207  J:: support size
208  */
209  return 1. / static_cast<t_real>(J);
210 }

Referenced by purify::create_kernels(), and purify::create_radial_ftkernel().

◆ pswf()

t_real purify::kernels::pswf ( const t_real  x,
const t_real  J 
)

PSWF kernel.

Definition at line 107 of file kernels.cc.

107  {
108  /*
109  Calculates the standard PSWF for radio astronomy, with a support of J = 6 and alpha = 1.
110 
111  x:: value to evaluate
112  J:: support size of gridding kernel
113 
114  The tailored prolate spheroidal wave functions for gridding radio astronomy.
115  Details are explained in Optimal Gridding of Visibility Data in Radio
116  Astronomy, F. R. Schwab 1983.
117 
118 */
119  const t_real eta0 = 2 * x / J;
120  const t_real alpha = 1;
121  return calc_for_pswf(eta0, J, alpha) * std::pow(1 - eta0 * eta0, alpha);
122 }

References calc_for_pswf().

Referenced by purify::create_kernels(), and purify::create_radial_ftkernel().

Variable Documentation

◆ kernel_from_string

const std::map<std::string, kernel> purify::kernels::kernel_from_string
Initial value:
= {{"kb", kernel::kb},
{"gauss", kernel::gauss},
{"box", kernel::box},
{"pswf", kernel::pswf},
{"kbmin", kernel::kbmin},
{"kb_presample", kernel::kb_presample},
{"gauss_alt", kernel::gauss_alt}}

Definition at line 16 of file kernels.h.

Referenced by BENCHMARK_DEFINE_F(), createMeasurementOperator(), getInputData(), main(), padmm(), and TEST_CASE().